Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add internalWasmUrl option #323

Merged
merged 3 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading