Skip to content

Commit

Permalink
feat: add internalWasmUrl option (#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaubee committed Jul 19, 2023
1 parent e44d964 commit 45c5006
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
3 changes: 3 additions & 0 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ export interface BuildOptions {
filterDiagnostic?: (diagnostic: ts.Diagnostic) => boolean;
/** Action to do after emitting and before running tests. */
postBuild?: () => void | Promise<void>;
/** Custom Wasm URL for the internal Wasm module used by dnt. */
internalWasmUrl?: string;
}

/** Builds the specified Deno module to an npm package using the TypeScript compiler. */
Expand Down Expand Up @@ -539,6 +541,7 @@ export async function build(options: BuildOptions): Promise<void> {
mappings: options.mappings,
target: scriptTarget,
importMap: options.importMap,
internalWasmUrl: options.internalWasmUrl,
});
}

Expand Down
5 changes: 4 additions & 1 deletion transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export interface TransformOptions {
target: ScriptTarget;
/// Path or url to the import map.
importMap?: string;
internalWasmUrl?: string;
}

/** Dependency in a package.json file. */
Expand Down Expand Up @@ -122,7 +123,9 @@ export async function transform(
? undefined
: valueToUrl(options.importMap),
};
const wasmFuncs = await instantiate();
const wasmFuncs = await instantiate({
url: options.internalWasmUrl ? new URL(options.internalWasmUrl) : undefined,
});
return wasmFuncs.transform(newOptions);
}

Expand Down

0 comments on commit 45c5006

Please sign in to comment.