Skip to content

Commit b20fd92

Browse files
authored
fix: should not transform [name]/[file] in wasm filename template (#12184)
fix: should not transform in wasm template
1 parent 6631901 commit b20fd92

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

crates/rspack_plugin_wasm/src/parser_and_generator.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@ async fn render_wasm_name(
340340
.map(|s| PathData::prepare_id(s.as_str()))
341341
.as_deref(),
342342
)
343-
.filename(normal_module.resource_resolved_data().resource())
344343
.content_hash(hash)
345344
.hash(hash),
346345
)
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { _Z4facti } from './factorial.wasm';
2+
3+
const factorial = _Z4facti;
4+
5+
it("should compile wasm", () => {
6+
expect(factorial(3)).toBe(6);
7+
});
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const path = require('path');
2+
const fs = require('fs');
3+
module.exports = (_, { testPath }) => ({
4+
output: {
5+
webassemblyModuleFilename: "[name].wasm",
6+
},
7+
module: {
8+
rules: [
9+
{
10+
test: /\.wasm$/,
11+
type: "webassembly/async"
12+
}
13+
]
14+
},
15+
experiments: {
16+
asyncWebAssembly: true
17+
},
18+
plugins: [{
19+
apply(compiler) {
20+
compiler.hooks.done.tap("Test", (_) => {
21+
const main = fs.readFileSync(path.join(testPath, "bundle0.js"), "utf8");
22+
expect(main).toContain("[name].wasm");
23+
const assets = fs.readdirSync(path.join(testPath));
24+
expect(assets).toContain("[name].wasm");
25+
});
26+
}
27+
}]
28+
});

0 commit comments

Comments
 (0)