From 3953eef2719c9f14b0d1edf9a9f0352b9f242469 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Tue, 6 Nov 2018 12:53:15 +0000 Subject: [PATCH] refactor(builder): make plugins in BuildContext update dynamically (#4280) --- packages/builder/src/builder.js | 4 ++-- packages/builder/src/context.js | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/builder/src/builder.js b/packages/builder/src/builder.js index 140790d5a5..b4e0d9442e 100644 --- a/packages/builder/src/builder.js +++ b/packages/builder/src/builder.js @@ -207,8 +207,8 @@ export default class Builder { async generateRoutesAndFiles() { consola.debug(`Generating nuxt files`) - this.plugins.length = 0 - this.plugins.push.apply(this.plugins, this.normalizePlugins()) + // Plugins + this.plugins = Array.from(this.normalizePlugins()) // -- Templates -- let templatesFiles = Array.from(this.template.templatesFiles) diff --git a/packages/builder/src/context.js b/packages/builder/src/context.js index 25178c150b..3b60d116e4 100644 --- a/packages/builder/src/context.js +++ b/packages/builder/src/context.js @@ -1,8 +1,12 @@ export default class BuildContext { constructor(builder) { + this._builder = builder this.nuxt = builder.nuxt this.options = builder.nuxt.options this.isStatic = false - this.plugins = builder.plugins + } + + get plugins() { + return this._builder.plugins } }