Skip to content

Commit a014b8e

Browse files
author
Barthélémy Ledoux
committed
feat: add wasm file to file exports
1 parent 39964f1 commit a014b8e

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

scripts/build-wasm.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,23 @@ wasmPkg.type = 'module';
5454
wasmPkg.main = 'index.mjs';
5555
wasmPkg.module = 'index.mjs';
5656
wasmPkg.exports = {
57-
types: './index.d.ts',
58-
node: {
59-
import: './wasm-node.mjs',
60-
require: './wasm-node.cjs',
57+
'.': {
58+
types: './index.d.ts',
59+
node: {
60+
import: './wasm-node.mjs',
61+
require: './wasm-node.cjs'
62+
},
63+
default: {
64+
import: './index.mjs',
65+
require: './index.cjs'
66+
}
6167
},
62-
default: {
63-
import: './index.mjs',
64-
require: './index.cjs',
68+
// Allow esbuild to import the wasm file
69+
// without copying it in the src directory.
70+
// Simplifies loading it in the browser when used in a library.
71+
'./lightningcss_node.wasm': {
72+
import: './lightningcss_node.wasm',
73+
require: './lightningcss_node.wasm'
6574
}
6675
};
6776
wasmPkg.types = 'index.d.ts';

0 commit comments

Comments
 (0)