提交 fa5be497 编写于 作者: J Jason Miller 提交者: Tim Neutkens

Bugfix: Babel targets value can be a String (#8268)

* Fix modern SSR build when Babel configuration uses a String value for "targets". Fixes #8255.

* Add custom babelrc integration tests
上级 484f988a
......@@ -73,7 +73,11 @@ module.exports = (
// if not explicitly specified:
if (
(isServer || isTest) &&
(!presetEnvConfig.targets || !('node' in presetEnvConfig.targets))
(!presetEnvConfig.targets ||
!(
typeof presetEnvConfig.targets === 'object' &&
'node' in presetEnvConfig.targets
))
) {
presetEnvConfig.targets = {
// Targets the current process' version of Node. This requires apps be
......
{
"presets": [
[
"next/babel",
{
"preset-env": {
"targets": {
"browsers": "chrome>71"
}
}
}
]
]
}
\ No newline at end of file
{
"presets": [
[
"next/babel",
{
"preset-env": {
"targets": "chrome>71"
}
}
]
]
}
\ No newline at end of file
{
"presets": [
["next/babel", {
"preset-env": {
"modules": "commonjs"
}
}]
]
}
\ No newline at end of file
/* eslint-env jest */
/* global jasmine */
import { join } from 'path'
import { nextBuild } from 'next-test-utils'
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 60 * 5
describe('Babel', () => {
it('should allow setting targets.browsers', async () => {
await nextBuild(join(__dirname, '../fixtures/targets-browsers'))
})
it('should allow setting targets to a string', async () => {
await nextBuild(join(__dirname, '../fixtures/targets-string'))
})
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册