Skip to content

Commit

Permalink
feat: allow specifying wasm plugin options (nitrojs#450)
Browse files Browse the repository at this point in the history
  • Loading branch information
sisou authored and WinterYukky committed Nov 1, 2022
1 parent 6fa05eb commit 1f47081
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/rollup/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { dirname, join, normalize, relative, resolve } from 'pathe'
import type { InputOptions, OutputOptions } from 'rollup'
import { defu } from 'defu'
import { terser } from 'rollup-plugin-terser'
import type { RollupWasmOptions } from '@rollup/plugin-wasm'
import commonjs from '@rollup/plugin-commonjs'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import alias from '@rollup/plugin-alias'
Expand Down Expand Up @@ -130,7 +131,8 @@ export const getRollupConfig = (nitro: Nitro) => {

// WASM import support
if (nitro.options.experimental.wasm) {
rollupConfig.plugins.push(wasmPlugin())
const options = { ...nitro.options.experimental.wasm as RollupWasmOptions }
rollupConfig.plugins.push(wasmPlugin(options))
}

// Build-time environment variables
Expand Down
3 changes: 2 additions & 1 deletion src/types/nitro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { NestedHooks, Hookable } from 'hookable'
import type { Consola, LogLevel } from 'consola'
import type { WatchOptions } from 'chokidar'
import type { RollupCommonJSOptions } from '@rollup/plugin-commonjs'
import type { RollupWasmOptions } from '@rollup/plugin-wasm'
import type { Storage, BuiltinDriverName } from 'unstorage'
import type { NodeExternalsOptions } from '../rollup/plugins/externals'
import type { RollupConfig } from '../rollup/config'
Expand Down Expand Up @@ -123,7 +124,7 @@ export interface NitroOptions {
renderer: string
serveStatic: boolean
experimental?: {
wasm?: boolean
wasm?: boolean | RollupWasmOptions
}
serverAssets: ServerAssetDir[]
publicAssets: PublicAssetDir[]
Expand Down

0 comments on commit 1f47081

Please sign in to comment.