refactor(config): rename devModules to buildModules (#6203)

This commit is contained in:
Pooya Parsa 2019-08-09 15:02:53 +04:30 committed by GitHub
parent c436839a17
commit 560cb57443
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 24 additions and 10 deletions

View File

@ -23,7 +23,7 @@ export default () => ({
css: [], css: [],
modules: [], modules: [],
devModules: [], buildModules: [],
layouts: {}, layouts: {},

View File

@ -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.') 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 // Enable minimize for production builds
if (options.build.optimization.minimize === undefined) { if (options.build.optimization.minimize === undefined) {
options.build.optimization.minimize = !options.dev options.build.optimization.minimize = !options.dev
@ -376,7 +383,7 @@ export function getNuxtConfig (_options) {
// Add loading screen // Add loading screen
if (options.dev) { if (options.dev) {
options.devModules.push('@nuxt/loading-screen') options.buildModules.push('@nuxt/loading-screen')
// Disable build indicator for programmatic users // Disable build indicator for programmatic users
if (!options._cli) { if (!options._cli) {
options.build.indicator = false options.build.indicator = false

View File

@ -143,13 +143,13 @@ Object {
"watch": Array [], "watch": Array [],
}, },
"buildDir": "/var/nuxt/test/.nuxt", "buildDir": "/var/nuxt/test/.nuxt",
"buildModules": Array [],
"cli": Object { "cli": Object {
"badgeMessages": Array [], "badgeMessages": Array [],
}, },
"css": Array [], "css": Array [],
"debug": false, "debug": false,
"dev": false, "dev": false,
"devModules": Array [],
"dir": Object { "dir": Object {
"app": "app", "app": "app",
"assets": "assets", "assets": "assets",

View File

@ -123,13 +123,13 @@ Object {
"watch": Array [], "watch": Array [],
}, },
"buildDir": ".nuxt", "buildDir": ".nuxt",
"buildModules": Array [],
"cli": Object { "cli": Object {
"badgeMessages": Array [], "badgeMessages": Array [],
}, },
"css": Array [], "css": Array [],
"debug": undefined, "debug": undefined,
"dev": false, "dev": false,
"devModules": Array [],
"dir": Object { "dir": Object {
"app": "app", "app": "app",
"assets": "assets", "assets": "assets",
@ -450,13 +450,13 @@ Object {
"watch": Array [], "watch": Array [],
}, },
"buildDir": ".nuxt", "buildDir": ".nuxt",
"buildModules": Array [],
"cli": Object { "cli": Object {
"badgeMessages": Array [], "badgeMessages": Array [],
}, },
"css": Array [], "css": Array [],
"debug": undefined, "debug": undefined,
"dev": false, "dev": false,
"devModules": Array [],
"dir": Object { "dir": Object {
"app": "app", "app": "app",
"assets": "assets", "assets": "assets",

View File

@ -232,6 +232,13 @@ describe('config: options', () => {
expect(consola.warn).toHaveBeenCalledWith('vendor has been deprecated due to webpack4 optimization') 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', () => { test('should deprecate build.extractCSS.allChunks', () => {
getNuxtConfig({ build: { extractCSS: { allChunks: true } } }) 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.') expect(consola.warn).toHaveBeenCalledWith('build.extractCSS.allChunks has no effect from v2.0.0. Please use build.optimization.splitChunks settings instead.')

View File

@ -16,9 +16,9 @@ export default class ModuleContainer {
// Call before hook // Call before hook
await this.nuxt.callHook('modules:before', this, this.options.modules) 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 // 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 // Load every module in sequence
@ -136,8 +136,8 @@ export default class ModuleContainer {
handler = src handler = src
} }
// Prevent adding devModules-listed entries in production // Prevent adding buildModules-listed entries in production
if (this.options.devModules.includes(handler) && this.options._start) { if (this.options.buildModules.includes(handler) && this.options._start) {
return return
} }

View File

@ -19,7 +19,7 @@ jest.mock('@nuxt/utils', () => ({
const defaultOptions = { const defaultOptions = {
modules: [], modules: [],
devModules: [] buildModules: []
} }
describe('core: module', () => { describe('core: module', () => {