mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-26 23:52:06 +00:00
refactor(config): rename devModules
to buildModules
(#6203)
This commit is contained in:
parent
c436839a17
commit
560cb57443
@ -23,7 +23,7 @@ export default () => ({
|
||||
css: [],
|
||||
|
||||
modules: [],
|
||||
devModules: [],
|
||||
buildModules: [],
|
||||
|
||||
layouts: {},
|
||||
|
||||
|
@ -336,6 +336,13 @@ export function getNuxtConfig (_options) {
|
||||
consola.warn('build.extractCSS.allChunks has no effect from v2.0.0. Please use build.optimization.splitChunks settings instead.')
|
||||
}
|
||||
|
||||
// devModules has been renamed to buildModules
|
||||
if (typeof options.devModules !== 'undefined') {
|
||||
consola.warn('`devModules` has been renamed to `buildModules` and will be removed in Nuxt 3.')
|
||||
options.buildModules.push(...options.devModules)
|
||||
delete options.devModules
|
||||
}
|
||||
|
||||
// Enable minimize for production builds
|
||||
if (options.build.optimization.minimize === undefined) {
|
||||
options.build.optimization.minimize = !options.dev
|
||||
@ -376,7 +383,7 @@ export function getNuxtConfig (_options) {
|
||||
|
||||
// Add loading screen
|
||||
if (options.dev) {
|
||||
options.devModules.push('@nuxt/loading-screen')
|
||||
options.buildModules.push('@nuxt/loading-screen')
|
||||
// Disable build indicator for programmatic users
|
||||
if (!options._cli) {
|
||||
options.build.indicator = false
|
||||
|
@ -143,13 +143,13 @@ Object {
|
||||
"watch": Array [],
|
||||
},
|
||||
"buildDir": "/var/nuxt/test/.nuxt",
|
||||
"buildModules": Array [],
|
||||
"cli": Object {
|
||||
"badgeMessages": Array [],
|
||||
},
|
||||
"css": Array [],
|
||||
"debug": false,
|
||||
"dev": false,
|
||||
"devModules": Array [],
|
||||
"dir": Object {
|
||||
"app": "app",
|
||||
"assets": "assets",
|
||||
|
@ -123,13 +123,13 @@ Object {
|
||||
"watch": Array [],
|
||||
},
|
||||
"buildDir": ".nuxt",
|
||||
"buildModules": Array [],
|
||||
"cli": Object {
|
||||
"badgeMessages": Array [],
|
||||
},
|
||||
"css": Array [],
|
||||
"debug": undefined,
|
||||
"dev": false,
|
||||
"devModules": Array [],
|
||||
"dir": Object {
|
||||
"app": "app",
|
||||
"assets": "assets",
|
||||
@ -450,13 +450,13 @@ Object {
|
||||
"watch": Array [],
|
||||
},
|
||||
"buildDir": ".nuxt",
|
||||
"buildModules": Array [],
|
||||
"cli": Object {
|
||||
"badgeMessages": Array [],
|
||||
},
|
||||
"css": Array [],
|
||||
"debug": undefined,
|
||||
"dev": false,
|
||||
"devModules": Array [],
|
||||
"dir": Object {
|
||||
"app": "app",
|
||||
"assets": "assets",
|
||||
|
@ -232,6 +232,13 @@ describe('config: options', () => {
|
||||
expect(consola.warn).toHaveBeenCalledWith('vendor has been deprecated due to webpack4 optimization')
|
||||
})
|
||||
|
||||
test('should deprecate devModules', () => {
|
||||
const config = getNuxtConfig({ devModules: ['foo'], buildModules: ['bar'] })
|
||||
expect(consola.warn).toHaveBeenCalledWith('`devModules` has been renamed to `buildModules` and will be removed in Nuxt 3.')
|
||||
expect(config.devModules).toBe(undefined)
|
||||
expect(config.buildModules).toEqual(['bar', 'foo'])
|
||||
})
|
||||
|
||||
test('should deprecate build.extractCSS.allChunks', () => {
|
||||
getNuxtConfig({ build: { extractCSS: { allChunks: true } } })
|
||||
expect(consola.warn).toHaveBeenCalledWith('build.extractCSS.allChunks has no effect from v2.0.0. Please use build.optimization.splitChunks settings instead.')
|
||||
|
@ -16,9 +16,9 @@ export default class ModuleContainer {
|
||||
// Call before hook
|
||||
await this.nuxt.callHook('modules:before', this, this.options.modules)
|
||||
|
||||
if (this.options.devModules && !this.options._start) {
|
||||
if (this.options.buildModules && !this.options._start) {
|
||||
// Load every devModule in sequence
|
||||
await sequence(this.options.devModules, this.addModule.bind(this))
|
||||
await sequence(this.options.buildModules, this.addModule.bind(this))
|
||||
}
|
||||
|
||||
// Load every module in sequence
|
||||
@ -136,8 +136,8 @@ export default class ModuleContainer {
|
||||
handler = src
|
||||
}
|
||||
|
||||
// Prevent adding devModules-listed entries in production
|
||||
if (this.options.devModules.includes(handler) && this.options._start) {
|
||||
// Prevent adding buildModules-listed entries in production
|
||||
if (this.options.buildModules.includes(handler) && this.options._start) {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ jest.mock('@nuxt/utils', () => ({
|
||||
|
||||
const defaultOptions = {
|
||||
modules: [],
|
||||
devModules: []
|
||||
buildModules: []
|
||||
}
|
||||
|
||||
describe('core: module', () => {
|
||||
|
Loading…
Reference in New Issue
Block a user