mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
feat: auto fallback to legacy build for node@6 support
This commit is contained in:
parent
35ee689473
commit
412ffd4c06
11
bin/nuxt
11
bin/nuxt
@ -1,8 +1,7 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
const { join } = require('path')
|
const { join } = require('path')
|
||||||
const semver = require('semver')
|
|
||||||
const consola = require('consola')
|
const consola = require('consola')
|
||||||
const { name, engines } = require('../package.json')
|
|
||||||
|
|
||||||
// Global error handler
|
// Global error handler
|
||||||
process.on('unhandledRejection', _error => {
|
process.on('unhandledRejection', _error => {
|
||||||
@ -19,14 +18,6 @@ consola.add({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!semver.satisfies(process.version, engines.node)) {
|
|
||||||
consola.fatal(
|
|
||||||
`The engine "node" is incompatible with ${name}. Expected version "${
|
|
||||||
engines.node
|
|
||||||
}".`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
const defaultCommand = 'dev'
|
const defaultCommand = 'dev'
|
||||||
const commands = new Set([defaultCommand, 'init', 'build', 'start', 'generate'])
|
const commands = new Set([defaultCommand, 'init', 'build', 'start', 'generate'])
|
||||||
|
|
||||||
|
10
index.js
10
index.js
@ -7,9 +7,17 @@
|
|||||||
|
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
|
const semver = require('semver')
|
||||||
|
|
||||||
if (fs.existsSync(path.resolve(__dirname, '.babelrc'))) {
|
const { engines } = require('./package.json')
|
||||||
|
|
||||||
|
if (!semver.satisfies(process.version, engines.node)) {
|
||||||
|
// Auto fallback to legacy build on older node versions
|
||||||
|
module.exports = require('./dist/nuxt-legacy.js')
|
||||||
|
} else if (fs.existsSync(path.resolve(__dirname, '.babelrc'))) {
|
||||||
|
// Use esm version when using linked repository to prevent builds
|
||||||
module.exports = require('./lib/index.js')
|
module.exports = require('./lib/index.js')
|
||||||
} else {
|
} else {
|
||||||
|
// Use production bundle by default
|
||||||
module.exports = require('./dist/nuxt.js')
|
module.exports = require('./dist/nuxt.js')
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
import 'babel-polyfill'
|
import 'babel-polyfill'
|
||||||
|
|
||||||
|
import consola from 'consola'
|
||||||
|
|
||||||
import core from './core'
|
import core from './core'
|
||||||
import builder from './builder'
|
import builder from './builder'
|
||||||
import * as Utils from './common/utils'
|
import * as Utils from './common/utils'
|
||||||
|
|
||||||
|
consola.warn('You are using legacy build of Nuxt. Please consider upgrading your Node.js version to 8.x or later.')
|
||||||
|
|
||||||
export default Object.assign({ Utils }, core, builder)
|
export default Object.assign({ Utils }, core, builder)
|
||||||
|
Loading…
Reference in New Issue
Block a user