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
feat(wasm): allow WebAssembly module filenames to use more path templates (e.g. [file], [base]) #10202
base: main
Are you sure you want to change the base?
Conversation
For maintainers only:
|
Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon. |
let found = false; | ||
stats.assets.forEach((asset) => { | ||
found = found || !!asset.name.match( | ||
/^\w{20}\.\w{20}\.\w{16}\.wasm\.wat\.wat\.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.
const found = stats.assets.every((asset) => {
!!asset.name.match(
/^\w{20}\.\w{20}\.\w{16}\.wasm\.wat\.wat\.wasm$/
);
});
What about this approach?
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.
@jamesgeorge007 Good idea, I did this with the slight change that it should be .some
rather than .every
(I'm looking for only one outputted file that matches this reg exp).
let found = false; | ||
stats.assets.forEach((asset) => { | ||
found = found || !!asset.name.match( | ||
/^\w{20}\.\w{20}\.\w{16}\.wasm\.wat\.wat\.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.
Solves #9517 (I used this to dive into the webpack source a bit since this issue looked inactive)
The problem is that currently you can only use
[hash]
to set a wasm output filename:More options would be useful, such as:
[base].wasm
, etc.Changes were needed in
TemplatedPathPlugin.js
because the wasm path templates were not being set correctly. For example, in the output, I would get the path string:but, I wanted the output:
I adjusted the
TemplatedPathPlugin
so that it could be easier to handle the many templates that stem from thefilename
property (e.g.base
,ext
,file
) in this situation.I added tests using configs that encompass many of the template cases:
webassemblyModuleFilename: "[fullhash].[hash].[hash:16].[base][ext].wasm"
What kind of change does this PR introduce?
feature
Did you add tests for your changes?
Yes
Does this PR introduce a breaking change?
No, there should be no breaking changes.
What needs to be documented once your changes are merged?
wasm in general seems to not be documented well, so that in addition to the new path templates for
webassemblyModuleFilename
.