Skip to content

Commit 0f640a7

Browse files
committed
fix(wasm): use .mjs extension for ES modules compatibility
- Rename generated .js to .mjs to avoid needing type:module in pkg/package.json - Update imports to use .mjs extension - Add LICENSE file to wasm directory - Simplifies the build process and removes complex post-build scripts
1 parent 1600931 commit 0f640a7

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

wasm/LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
(The MIT License)
2+
3+
Copyright (c) 2022 Titus Wormer <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining
6+
a copy of this software and associated documentation files (the
7+
'Software'), to deal in the Software without restriction, including
8+
without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to
10+
permit persons to whom the Software is furnished to do so, subject to
11+
the following conditions:
12+
13+
The above copyright notice and this permission notice shall be
14+
included in all copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

wasm/lib/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let wasmModule = null;
77

88
async function loadWasmModule() {
99
if (!wasmModule) {
10-
wasmModule = await import('../pkg/markdown_rs_wasm.js');
10+
wasmModule = await import('../pkg/markdown_rs_wasm.mjs');
1111
}
1212
return wasmModule;
1313
}

wasm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"README.md"
1111
],
1212
"scripts": {
13-
"build": "wasm-pack build --target web --out-dir pkg",
13+
"build": "wasm-pack build --target web --out-dir pkg && mv pkg/markdown_rs_wasm.js pkg/markdown_rs_wasm.mjs",
1414
"test": "node --test test/index.test.mjs",
1515
"example:basic": "node examples/basic.mjs",
1616
"example:options": "node examples/with-options.mjs"

0 commit comments

Comments
 (0)