From b65cd7862a829df4de6cc356037499765683b42f Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Fri, 13 Nov 2020 17:18:27 +0100 Subject: [PATCH] fix: always mock generic dependencies also inject after json --- packages/nitro/src/rollup/config.ts | 44 ++++++++++++++--------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/packages/nitro/src/rollup/config.ts b/packages/nitro/src/rollup/config.ts index 9251f1ce32..b9f6b0a9d9 100644 --- a/packages/nitro/src/rollup/config.ts +++ b/packages/nitro/src/rollup/config.ts @@ -33,7 +33,25 @@ export const getRollupConfig = (config: SLSOptions) => { const injects:{ [key: string]: string| string[] } = {} - const aliases: {[key: string]: string} = {} + const aliases: { [key: string]: string } = {} + + Object.assign(aliases, mapArrToVal('~mocks/generic', [ + // @nuxt/devalue + 'consola', + // vue2 + 'encoding', + 'stream', + 'he', + 'resolve', + 'source-map', + 'lodash.template', + 'serialize-javascript', + // vue3 + '@babel/parser', + '@vue/compiler-core', + '@vue/compiler-dom', + '@vue/compiler-ssr' + ])) if (config.node === false) { // Globals @@ -41,24 +59,6 @@ export const getRollupConfig = (config: SLSOptions) => { // Aliases Object.assign(aliases, { - ...mapArrToVal('~mocks/generic', [ - // @nuxt/devalue - 'consola', - // vue2 - 'encoding', - 'stream', - 'he', - 'resolve', - 'source-map', - 'lodash.template', - 'serialize-javascript', - // vue3 - '@babel/parser', - '@vue/compiler-core', - '@vue/compiler-dom', - '@vue/compiler-ssr' - ]), - // Node ...mapArrToVal('~mocks/generic', Module.builtinModules), http: '~mocks/node/http', @@ -169,12 +169,12 @@ export const getRollupConfig = (config: SLSOptions) => { extensions: extensions.filter(ext => ext !== '.json') })) - // https://github.com/rollup/plugins/tree/master/packages/inject - options.plugins.push(inject(injects)) - // https://github.com/rollup/plugins/tree/master/packages/json options.plugins.push(json()) + // https://github.com/rollup/plugins/tree/master/packages/inject + options.plugins.push(inject(injects)) + if (config.analyze) { // https://github.com/doesdev/rollup-plugin-analyzer options.plugins.push(analyze())