Skip to content

Commit a4e66bc

Browse files
author
Guy Bedford
committed
fix: specifier mappings in componentizeJS
1 parent 303024d commit a4e66bc

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/componentize.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const isWindows = platform === 'win32';
2525
const DEBUG_BINDINGS = false;
2626
const DEBUG_CALLS = false;
2727
const DEBUG_BUILD = false;
28+
const DEBUG_BINARY = false;
2829

2930
function maybeWindowsPath(path) {
3031
if (!path) return path;
@@ -61,13 +62,13 @@ export async function componentize(jsSource, witWorld, opts) {
6162
}
6263

6364
let guestImports = [];
64-
jsImports.map((k) => {
65-
guestImports.push(k.n);
65+
jsImports.map(({ t, n }) => {
66+
if (typeof n === 'string' && (t === 1 || t === 2)) guestImports.push(n);
6667
});
6768

6869
let guestExports = [];
6970
jsExports.map((k) => {
70-
guestExports.push(k.n);
71+
if (k.n) guestExports.push(k.n);
7172
});
7273

7374
// we never disable a feature that is already in the target world usage
@@ -132,6 +133,7 @@ export async function componentize(jsSource, witWorld, opts) {
132133
let source = '',
133134
curIdx = 0;
134135
for (const jsImpt of jsImports) {
136+
if (jsImpt.t !== 1 && jsImpt.t !== 2) continue;
135137
const specifier = jsSource.slice(jsImpt.s, jsImpt.e);
136138
source += jsSource.slice(curIdx, jsImpt.s);
137139
source += `./${specifier.replace(':', '__').replace('/', '$')}.js`;
@@ -384,6 +386,10 @@ export async function componentize(jsSource, witWorld, opts) {
384386
worldName
385387
);
386388

389+
if (DEBUG_BINARY) {
390+
await writeFile('binary.wasm', finalBin);
391+
}
392+
387393
const component = await metadataAdd(
388394
await componentNew(
389395
finalBin,

0 commit comments

Comments
 (0)