fix(webpack): dont push to compilersWatching in callback (#6448)

This commit is contained in:
Pim 2019-09-25 17:11:39 +02:00 committed by Pooya Parsa
parent 85035a6e12
commit 06a288376a
5 changed files with 18 additions and 7 deletions

View File

@ -157,6 +157,9 @@ export default class Builder {
// Generate routes and interpret the template files
await this.generateRoutesAndFiles()
// Add vue-app template dir to watchers
this.options.build.watch.push(this.globPathWithExtensions(this.template.dir))
await this.resolvePlugins()
// Start bundle build: webpack, rollup, parcel...
@ -244,9 +247,6 @@ export default class Builder {
await this.resolveLoadingIndicator(templateContext)
// Add vue-app template dir to watchers
this.options.build.watch.push(this.globPathWithExtensions(this.template.dir))
await this.compileTemplates(templateContext)
if (this.bundleBuilder) {

View File

@ -2,7 +2,9 @@ export const createNuxt = () => ({
options: {
globalName: 'global_name',
globals: [],
build: {},
build: {
watch: []
},
router: {},
dir: {
app: 'app'

View File

@ -33,6 +33,7 @@ describe('builder: builder build', () => {
nuxt.options.srcDir = '/var/nuxt/src'
nuxt.options.buildDir = '/var/nuxt/build'
nuxt.options.dir = { pages: '/var/nuxt/src/pages' }
nuxt.options.build.template = { dir: '/var/nuxt/src/template' }
nuxt.options.build.createRoutes = jest.fn()
const bundleBuilder = { build: jest.fn() }
@ -70,6 +71,7 @@ describe('builder: builder build', () => {
expect(r).nthCalledWith(3, '/var/nuxt/build', 'dist', 'client')
expect(r).nthCalledWith(4, '/var/nuxt/build', 'dist', 'server')
expect(builder.generateRoutesAndFiles).toBeCalledTimes(1)
expect(nuxt.options.build.watch).toEqual(['/var/nuxt/src/template/**/*.{vue,js}'])
expect(builder.resolvePlugins).toBeCalledTimes(1)
expect(bundleBuilder.build).toBeCalledTimes(1)
expect(builder._buildStatus).toEqual(2)

View File

@ -82,7 +82,7 @@ describe('builder: builder generate', () => {
expect(builder.addOptionalTemplates).toBeCalledTimes(1)
expect(builder.resolveCustomTemplates).toBeCalledTimes(1)
expect(builder.resolveLoadingIndicator).toBeCalledTimes(1)
expect(builder.options.build.watch).toEqual(['/var/nuxt/src/template/**/*.{vue,js}'])
expect(builder.options.build.watch).toEqual([])
expect(builder.compileTemplates).toBeCalledTimes(1)
expect(consola.success).toBeCalledTimes(1)
expect(consola.success).toBeCalledWith('Nuxt files generated')
@ -237,6 +237,7 @@ describe('builder: builder generate', () => {
const nuxt = createNuxt()
nuxt.options.srcDir = '/var/nuxt/src'
nuxt.options.build = {
watch: [],
template: { dir: '/var/nuxt/templates' },
templates: [
'/var/nuxt/templates/foo.js',
@ -275,6 +276,7 @@ describe('builder: builder generate', () => {
name: 'test_loading_indicator'
}
nuxt.options.build = {
watch: [],
template: { dir: '/var/nuxt/templates' }
}
const builder = new Builder(nuxt, BundleBuilder)
@ -301,6 +303,7 @@ describe('builder: builder generate', () => {
name: '@/app/template.vue'
}
nuxt.options.build = {
watch: [],
template: { dir: '/var/nuxt/templates' }
}
const builder = new Builder(nuxt, BundleBuilder)
@ -330,6 +333,7 @@ describe('builder: builder generate', () => {
name: '@/app/empty.vue'
}
nuxt.options.build = {
watch: [],
template: { dir: '/var/nuxt/templates' }
}
const builder = new Builder(nuxt, BundleBuilder)
@ -599,6 +603,7 @@ describe('builder: builder generate', () => {
const nuxt = createNuxt()
nuxt.options.srcDir = '/var/nuxt/src'
nuxt.options.build = {
watch: [],
createRoutes: jest.fn(),
template: { dir: '/var/nuxt/templates' }
}
@ -642,6 +647,7 @@ describe('builder: builder generate', () => {
pages: '/var/nuxt/pages'
}
nuxt.options.build = {
watch: [],
createRoutes: jest.fn()
}
nuxt.options.router = {

View File

@ -136,10 +136,11 @@ export class WebpackBundler {
if (err) {
return reject(err)
}
watching.close = pify(watching.close)
this.compilersWatching.push(watching)
resolve()
})
watching.close = pify(watching.close)
this.compilersWatching.push(watching)
})
}