fix(nitro): disable moduleSideEffects by default (#377)

This commit is contained in:
Matt Kane 2021-07-26 12:32:35 +01:00 committed by GitHub
parent 864d2683ab
commit bad2a74805
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -22,6 +22,7 @@ export interface NitroContext {
node: boolean
preset: string
rollupConfig?: RollupConfig
moduleSideEffects: string[]
renderer: string
serveStatic: boolean
middleware: ServerMiddleware[]
@ -79,6 +80,7 @@ export function getNitroContext (nuxtOptions: NuxtOptions, input: NitroInput): N
node: undefined,
preset: undefined,
rollupConfig: undefined,
moduleSideEffects: ['unenv/runtime/polyfill/'],
renderer: undefined,
serveStatic: undefined,
middleware: [],

View File

@ -114,6 +114,11 @@ export const getRollupConfig = (nitroContext: NitroContext) => {
) {
rollupWarn(warning)
}
},
treeshake: {
moduleSideEffects (id) {
return nitroContext.moduleSideEffects.some(match => id.startsWith(match))
}
}
}