fix: always mock generic dependencies

also inject after json
This commit is contained in:
Pooya Parsa 2020-11-13 17:18:27 +01:00
parent 2384b8269e
commit b65cd7862a

View File

@ -35,13 +35,7 @@ export const getRollupConfig = (config: SLSOptions) => {
const aliases: { [key: string]: string } = {}
if (config.node === false) {
// Globals
injects.Buffer = ['buffer', 'Buffer']
// Aliases
Object.assign(aliases, {
...mapArrToVal('~mocks/generic', [
Object.assign(aliases, mapArrToVal('~mocks/generic', [
// @nuxt/devalue
'consola',
// vue2
@ -57,8 +51,14 @@ export const getRollupConfig = (config: SLSOptions) => {
'@vue/compiler-core',
'@vue/compiler-dom',
'@vue/compiler-ssr'
]),
]))
if (config.node === false) {
// Globals
injects.Buffer = ['buffer', 'Buffer']
// Aliases
Object.assign(aliases, {
// 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())