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 node: boolean
preset: string preset: string
rollupConfig?: RollupConfig rollupConfig?: RollupConfig
moduleSideEffects: string[]
renderer: string renderer: string
serveStatic: boolean serveStatic: boolean
middleware: ServerMiddleware[] middleware: ServerMiddleware[]
@ -79,6 +80,7 @@ export function getNitroContext (nuxtOptions: NuxtOptions, input: NitroInput): N
node: undefined, node: undefined,
preset: undefined, preset: undefined,
rollupConfig: undefined, rollupConfig: undefined,
moduleSideEffects: ['unenv/runtime/polyfill/'],
renderer: undefined, renderer: undefined,
serveStatic: undefined, serveStatic: undefined,
middleware: [], middleware: [],

View File

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