Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Configurable opts for babel-preset-env + babel-plugin-transform-runti…
…me (#2991) * Configurable opts for babel-preset-env + babel-plugin-transform-runtime This adds `preset-env` and `transform-runtime` options to the `next/babel` Babel preset, which are then passed through to those presets and transforms. This allows configuration to keep next.js from the default 'maximum' transform, and instead use built-in implementations of globals, classes, async, and other commonly-supported features. Fixes #2989 * Use spread notation instead of Object.assign
- Loading branch information
1 parent
a761aa5
commit 559c25253ea4a50fbc04ef37f466d9e9b616512a
Showing
4 changed files
with
65 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,26 @@ | ||
{ | ||
"env": { | ||
"production": { | ||
"presets": [ | ||
"next/babel" | ||
] | ||
}, | ||
"development": { | ||
"presets": [ | ||
["next/babel", { | ||
"preset-env": { | ||
"targets": { | ||
"browsers": "last 1 Chrome version", | ||
"node": true | ||
} | ||
}, | ||
"transform-runtime": { | ||
"regenerator": false, | ||
"useBuiltIns": true, | ||
"polyfill": false | ||
} | ||
}] | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,12 @@ | ||
{ | ||
"scripts": { | ||
"dev": "next", | ||
"build": "next build", | ||
"start": "next start" | ||
}, | ||
"dependencies": { | ||
"next": "latest", | ||
"react": "^15.4.2", | ||
"react-dom": "^15.4.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,21 @@ | ||
import {Component} from 'react' | ||
|
||
function * generatorMethod () { | ||
yield 1 | ||
} | ||
|
||
async function fooBar () { | ||
for (let val of generatorMethod()) { | ||
return val | ||
} | ||
} | ||
|
||
export default class Index extends Component { | ||
async otherMethod () { | ||
await fooBar() | ||
} | ||
render () { | ||
const foo = new Map([['cats', 'dogs']]) | ||
return <h1>Garbage {foo.get('cats')}</h1> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters