mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
fix: add types for build.corejs
option and use number (#7789)
This commit is contained in:
parent
60f68638cb
commit
e295ae7ffd
@ -75,7 +75,7 @@ exports[`webpack nuxt webpack module.rules 1`] = `
|
|||||||
\\"<nuxtDir>/packages/babel-preset-app/src/index.js\\",
|
\\"<nuxtDir>/packages/babel-preset-app/src/index.js\\",
|
||||||
Object {
|
Object {
|
||||||
\\"corejs\\": Object {
|
\\"corejs\\": Object {
|
||||||
\\"version\\": \\"2\\",
|
\\"version\\": 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
@ -654,7 +654,7 @@ exports[`webpack nuxt webpack module.rules test=.jsx 1`] = `
|
|||||||
\\"<nuxtDir>/packages/babel-preset-app/src/index.js\\",
|
\\"<nuxtDir>/packages/babel-preset-app/src/index.js\\",
|
||||||
Object {
|
Object {
|
||||||
\\"corejs\\": Object {
|
\\"corejs\\": Object {
|
||||||
\\"version\\": \\"2\\",
|
\\"version\\": 2,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
1
packages/types/config/build.d.ts
vendored
1
packages/types/config/build.d.ts
vendored
@ -137,6 +137,7 @@ export interface NuxtOptionsBuild {
|
|||||||
analyze?: BundleAnalyzerPlugin.Options | boolean
|
analyze?: BundleAnalyzerPlugin.Options | boolean
|
||||||
babel?: NuxtBabelOptions
|
babel?: NuxtBabelOptions
|
||||||
cache?: boolean
|
cache?: boolean
|
||||||
|
corejs?: 'auto' | 2 | 3
|
||||||
crossorigin?: string
|
crossorigin?: string
|
||||||
cssSourceMap?: boolean
|
cssSourceMap?: boolean
|
||||||
devMiddleware?: WebpackDevMiddlewareOptions
|
devMiddleware?: WebpackDevMiddlewareOptions
|
||||||
|
@ -120,15 +120,15 @@ export default class WebpackBaseConfig {
|
|||||||
let corejsVersion = corejs
|
let corejsVersion = corejs
|
||||||
if (corejsVersion === 'auto') {
|
if (corejsVersion === 'auto') {
|
||||||
try {
|
try {
|
||||||
corejsVersion = createRequire(rootDir)('core-js/package.json').version.split('.')[0]
|
corejsVersion = Number.parseInt(createRequire(rootDir)('core-js/package.json').version.split('.')[0])
|
||||||
} catch (_err) {
|
} catch (_err) {
|
||||||
corejsVersion = '2'
|
corejsVersion = 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (corejsVersion !== '2' && corejsVersion !== '3') {
|
if (![2, 3].includes(corejsVersion)) {
|
||||||
consola.warn(`Invalid corejs version ${JSON.stringify(corejsVersion)}! Please set "build.corejs" to either "2" or "3".`)
|
consola.warn(`Invalid corejs version ${corejsVersion}! Please set "build.corejs" to either "auto", 2 or 3.`)
|
||||||
corejsVersion = '2'
|
corejsVersion = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultPreset = [require.resolve('@nuxt/babel-preset-app'), {
|
const defaultPreset = [require.resolve('@nuxt/babel-preset-app'), {
|
||||||
|
Loading…
Reference in New Issue
Block a user