Skip to content

Commit

Permalink
Do not memoize, since only one is executed
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Aug 17, 2023
1 parent 8409749 commit 8fce167
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
Expand Up @@ -9,23 +9,12 @@ export default declare(({ assertVersion, types: t, template }) => {
function buildFetch(
path: NodePath<t.ImportDeclaration | t.ImportExpression>,
) {
let specifier = path.node.source;
let specifierRef: t.Expression;
if (t.isStringLiteral(specifier)) {
specifierRef = specifier;
} else {
specifierRef = path.scope.generateDeclaredUidIdentifier("specifier");
specifier = t.assignmentExpression(
"=",
t.cloneNode(specifierRef),
specifier,
);
}
const specifier = path.node.source;

return template.expression.ast`
WebAssembly.compileStreaming(fetch(
import.meta.resolve?.(${specifier}) ??
new URL(${t.cloneNode(specifierRef)}, import.meta.url)
new URL(${t.cloneNode(specifier)}, import.meta.url)
))
`;
}
Expand Down
@@ -1,2 +1 @@
var _specifier;
let promise = WebAssembly.compileStreaming(fetch(import.meta.resolve?.(_specifier = getSpecifier()) ?? new URL(_specifier, import.meta.url)));
let promise = WebAssembly.compileStreaming(fetch(import.meta.resolve?.(getSpecifier()) ?? new URL(getSpecifier(), import.meta.url)));

0 comments on commit 8fce167

Please sign in to comment.