-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
module: support Wasm without file extension within module
scope
#49540
Conversation
Review requested:
|
fd = openSync(url); | ||
readSync(fd, magic); | ||
if (magic[0] === 0x00 && magic[1] === 0x61 && magic[2] === 0x73 && magic[3] === 0x6d) { | ||
return 'wasm'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get that we’re just reading the first four bytes here (I think?) but doesn’t doing this here mean that we open and read the file twice? Once to detect format and again later to actually run it?
Especially since this happens for every ESM entry point, even JavaScript ones, this feels like a performance regression that we should avoid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This happens only for extensionless files, right? If that's the case, that seems absolutely OK as a tradeoff, the workaround is to use the .mjs
extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct, the check is only for local extensionless files in module
scope.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need a tradeoff? Can’t we keep the file contents in memory once we have them, so that later on when the load
hook runs it uses the contents from memory rather than refetching them from disk?
export function jsInitFn () { | ||
strictEqual(state, 'JS Function Executed'); | ||
state = 'WASM Start Executed'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | |
} | |
Closing now that #49974 has landed. |
d78a9da blocked on #49531