refactor(nitro): move wasm support behind a flag (`nitro.experiments.wasm`) (#1045)

This commit is contained in:
Daniel Roe 2021-10-14 19:57:23 +01:00 committed by GitHub
parent 6e787c20ec
commit 6acfdcd0f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -35,6 +35,9 @@ export interface NitroContext {
esbuild?: { esbuild?: {
options?: EsbuildOptions options?: EsbuildOptions
} }
experiments?: {
wasm?: boolean
}
moduleSideEffects: string[] moduleSideEffects: string[]
renderer: string renderer: string
serveStatic: boolean serveStatic: boolean
@ -94,6 +97,7 @@ export function getNitroContext (nuxtOptions: NuxtOptions, input: NitroInput): N
node: undefined, node: undefined,
preset: undefined, preset: undefined,
rollupConfig: undefined, rollupConfig: undefined,
experiments: {},
moduleSideEffects: ['unenv/runtime/polyfill/'], moduleSideEffects: ['unenv/runtime/polyfill/'],
renderer: undefined, renderer: undefined,
serveStatic: undefined, serveStatic: undefined,

View File

@ -143,7 +143,9 @@ export const getRollupConfig = (nitroContext: NitroContext) => {
rollupConfig.plugins.push(raw()) rollupConfig.plugins.push(raw())
// WASM import support // WASM import support
rollupConfig.plugins.push(wasmPlugin()) if (nitroContext.experiments.wasm) {
rollupConfig.plugins.push(wasmPlugin())
}
// https://github.com/rollup/plugins/tree/master/packages/replace // https://github.com/rollup/plugins/tree/master/packages/replace
rollupConfig.plugins.push(replace({ rollupConfig.plugins.push(replace({