Skip to content

Commit

Permalink
feat: support core-js 3 (#5291)
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkdo authored and pi0 committed Mar 20, 2019
1 parent cf02e82 commit d094c4a
Show file tree
Hide file tree
Showing 8 changed files with 11,754 additions and 11,857 deletions.
3 changes: 2 additions & 1 deletion distributions/nuxt-legacy/bin/nuxt-legacy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env node

require('@babel/polyfill')
require('core-js/stable')
require('renegerator-runtime/runtime')

require('@babel/register')({
presets: [
Expand Down
5 changes: 3 additions & 2 deletions distributions/nuxt-legacy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,16 @@
"bin": "bin/nuxt-legacy.js",
"dependencies": {
"@babel/core": "^7.4.0",
"@babel/polyfill": "^7.4.0",
"@babel/preset-env": "^7.4.1",
"@babel/register": "^7.4.0",
"@nuxt/builder": "2.4.5",
"@nuxt/cli": "2.4.5",
"@nuxt/core": "2.4.5",
"@nuxt/generator": "2.4.5",
"@nuxt/opencollective": "^0.2.1",
"@nuxt/webpack": "2.4.5"
"@nuxt/webpack": "2.4.5",
"core-js": "3",
"regenerator-runtime": "^0.13.1"
},
"engines": {
"node": ">=6.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-preset-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Below is a list of all available parameters:
* **loose**, default `false` - '[@babel/preset-env](https://babeljs.io/docs/en/babel-preset-env#loose)' parameter and also sets `loose=true` for `@babel/plugin-proposal-class-properties`
* **modern** passed by builder, either `true` or `false`
* **modules**, default `false` - '[@babel/preset-env](https://babeljs.io/docs/en/babel-preset-env#modules)' parameter
* **polyfills**, default `['es6.array.iterator','es6.promise','es6.object.assign','es7.promise.finally']`, more [in the corresponding repository](https://github.com/zloirock/core-js)
* **polyfills**, default `['es.array.iterator','es.promise','es.object.assign','es.promise.finally']`, more [in the corresponding repository](https://github.com/zloirock/core-js)
* **shippedProposals** - '[@babel/preset-env](https://babeljs.io/docs/en/babel-preset-env#shippedproposals)' parameter
* **spec** - '[@babel/preset-env](https://babeljs.io/docs/en/babel-preset-env#spec)' parameter
* **targets** - '[@babel/preset-env](https://babeljs.io/docs/en/babel-preset-env#targets)' parameter
Expand Down
4 changes: 3 additions & 1 deletion packages/babel-preset-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
"@babel/plugin-transform-runtime": "^7.4.0",
"@babel/preset-env": "^7.4.1",
"@babel/runtime": "^7.4.0",
"@vue/babel-preset-jsx": "^1.0.0-beta.2"
"@babel/runtime-corejs3": "^7.4.0",
"@vue/babel-preset-jsx": "^1.0.0-beta.2",
"core-js": "3"
},
"publishConfig": {
"access": "public"
Expand Down
17 changes: 10 additions & 7 deletions packages/babel-preset-app/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ const path = require('path')
const defaultPolyfills = [
// Promise polyfill alone doesn't work in IE,
// Needs this as well. see: #1642
'es6.array.iterator',
'es.array.iterator',
// This is required for webpack code splitting, vuex etc.
'es6.promise',
'es.promise',
// this is needed for object rest spread support in templates
// as vue-template-es2015-compiler 1.8+ compiles it to Object.assign() calls.
'es6.object.assign',
// #2012 es6.promise replaces native Promise in FF and causes missing finally
'es7.promise.finally'
'es.object.assign',
// #2012 es.promise replaces native Promise in FF and causes missing finally
'es.promise.finally'
]

function getPolyfills(targets, includes, { ignoreBrowserslistConfig, configPath }) {
const { isPluginRequired } = require('@babel/preset-env')
const builtInsList = require('@babel/preset-env/data/built-ins.json')
const builtInsList = require('core-js-compat/data')
const getTargets = require('@babel/preset-env/lib/targets-parser').default
const builtInTargets = getTargets(targets, {
ignoreBrowserslistConfig,
Expand Down Expand Up @@ -67,6 +67,8 @@ module.exports = (context, options = {}) => {
polyfills = []
}

const corejs = { version: 3 }

// Pass options along to babel-preset-env
presets.push([
require('@babel/preset-env'), {
Expand All @@ -76,6 +78,7 @@ module.exports = (context, options = {}) => {
modules,
targets,
useBuiltIns,
corejs,
ignoreBrowserslistConfig,
configPath,
include,
Expand All @@ -102,7 +105,7 @@ module.exports = (context, options = {}) => {
// Transform runtime, but only for helpers
plugins.push([require('@babel/plugin-transform-runtime'), {
regenerator: useBuiltIns !== 'usage',
corejs: useBuiltIns !== false ? false : 2,
corejs: useBuiltIns !== false ? false : corejs,
helpers: useBuiltIns === 'usage',
useESModules: true,
absoluteRuntime: path.dirname(require.resolve('@babel/runtime/package.json'))
Expand Down
1 change: 0 additions & 1 deletion packages/webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"main": "dist/webpack.js",
"dependencies": {
"@babel/core": "^7.4.0",
"@babel/polyfill": "^7.4.0",
"@nuxt/babel-preset-app": "2.4.5",
"@nuxt/friendly-errors-webpack-plugin": "^2.4.0",
"@nuxt/utils": "2.4.5",
Expand Down
2 changes: 1 addition & 1 deletion test/unit/async-config.size-limit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ describe('size-limit test', () => {
const responseSizeBytes = responseSizes.reduce((bytes, responseLength) => bytes + responseLength, 0)
const responseSizeKilobytes = Math.ceil(responseSizeBytes / 1024)
// Without gzip!
expect(responseSizeKilobytes).toBeLessThanOrEqual(185)
expect(responseSizeKilobytes).toBeLessThanOrEqual(191)
})
})

0 comments on commit d094c4a

Please sign in to comment.