Skip to content

Commit 2b9f838

Browse files
vouillonhhugo
authored andcommitted
Enable imported string constants
Allow to import JavaScript using the mechanism described by: https://github.com/WebAssembly/js-string-builtins/blob/main/proposals/js-string-builtins/Overview.md#string-constants A polyfill is provided for Wasm engines which do not support this feature.
1 parent decdb30 commit 2b9f838

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

runtime/wasm/runtime.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,11 +572,22 @@
572572
"wasm:js-string": string_ops,
573573
"wasm:text-decoder": string_ops,
574574
"wasm:text-encoder": string_ops,
575+
"": new globalThis.Proxy(
576+
{},
577+
{
578+
get(_, prop) {
579+
return prop;
580+
},
581+
},
582+
),
575583
env: {},
576584
},
577585
generated,
578586
);
579-
const options = { builtins: ["js-string", "text-decoder", "text-encoder"] };
587+
const options = {
588+
builtins: ["js-string", "text-decoder", "text-encoder"],
589+
importedStringConstants: "",
590+
};
580591

581592
function loadRelative(src) {
582593
const path = require("node:path");

0 commit comments

Comments
 (0)