Skip to content

Commit b31be6c

Browse files
fix: add wasm browser declarations
1 parent acc42c5 commit b31be6c

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

packages/sourcemap-wasm/__tests__/browser.test.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ it("exposes the browser API as static ESM exports before initialization", () =>
1111
assert.equal(typeof wasmMemory, "function");
1212
});
1313

14+
it("publishes declarations for the browser API", () => {
15+
const packageJson = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
16+
17+
assert.equal(packageJson.exports["./browser"].types, "./browser/index.d.ts");
18+
19+
const declarations = readFileSync(new URL("../browser/index.d.ts", import.meta.url), "utf8");
20+
assert.match(declarations, /export \{ LazySourceMap, SourceMap, resultPtr, wasmMemory \}/);
21+
assert.match(declarations, /Promise<void>/);
22+
});
23+
1424
it("initializes the generated module only once", async () => {
1525
const wasm = readFileSync(new URL("../web/srcmap_sourcemap_wasm_bg.wasm", import.meta.url));
1626

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { InitInput } from "../web/srcmap_sourcemap_wasm.js";
2+
3+
export { LazySourceMap, SourceMap, resultPtr, wasmMemory } from "../web/srcmap_sourcemap_wasm.js";
4+
5+
declare const init: (
6+
input?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>,
7+
) => Promise<void>;
8+
9+
export default init;

packages/sourcemap-wasm/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"default": "./coverage.mjs"
4444
},
4545
"./browser": {
46+
"types": "./browser/index.d.ts",
4647
"default": "./browser/index.mjs"
4748
}
4849
},

0 commit comments

Comments
 (0)