mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-27 08:02:01 +00:00
feat: support core-js 3 (#5291)
This commit is contained in:
parent
cf02e8226a
commit
d094c4a974
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
require('@babel/polyfill')
|
||||
require('core-js/stable')
|
||||
require('renegerator-runtime/runtime')
|
||||
|
||||
require('@babel/register')({
|
||||
presets: [
|
||||
|
@ -51,7 +51,6 @@
|
||||
"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",
|
||||
@ -59,7 +58,9 @@
|
||||
"@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",
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
|
@ -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,
|
||||
@ -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'), {
|
||||
@ -76,6 +78,7 @@ module.exports = (context, options = {}) => {
|
||||
modules,
|
||||
targets,
|
||||
useBuiltIns,
|
||||
corejs,
|
||||
ignoreBrowserslistConfig,
|
||||
configPath,
|
||||
include,
|
||||
@ -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'))
|
||||
|
@ -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",
|
||||
|
@ -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)
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user