web: Simplify .wasm loading
Use wasm-bindgen's built-in loader instead of relying on Webpack. This allows to no longer declare .wasm files as resource assets in each webpack.config.js. Also the bundled JS is a bit smaller (e.g. demo is now ~88KB vs. ~90KB before).
This commit is contained in:
parent
6b91239e28
commit
66bfff7687
|
@ -20,13 +20,7 @@ async function fetchRuffle(): Promise<typeof Ruffle> {
|
|||
// libraries, if needed.
|
||||
setPolyfillsOnLoad();
|
||||
|
||||
// wasm files are set to be resource assets,
|
||||
// so this import will resolve to the URL of the wasm file.
|
||||
const ruffleWasm = await import(
|
||||
/* webpackMode: "eager" */
|
||||
"../pkg/ruffle_web_bg.wasm"
|
||||
);
|
||||
await init(ruffleWasm.default);
|
||||
await init();
|
||||
|
||||
return Ruffle;
|
||||
}
|
||||
|
|
|
@ -22,10 +22,6 @@ module.exports = (_env, _argv) => {
|
|||
test: /\.css$/i,
|
||||
use: ["style-loader", "css-loader"],
|
||||
},
|
||||
{
|
||||
test: /\.wasm$/i,
|
||||
type: "asset/resource",
|
||||
},
|
||||
],
|
||||
},
|
||||
devtool: "source-map",
|
||||
|
|
|
@ -62,10 +62,6 @@ module.exports = (env, _argv) => {
|
|||
test: /\.ts$/i,
|
||||
use: "ts-loader",
|
||||
},
|
||||
{
|
||||
test: /\.wasm$/i,
|
||||
type: "asset/resource",
|
||||
},
|
||||
],
|
||||
},
|
||||
resolve: {
|
||||
|
|
|
@ -17,14 +17,6 @@ module.exports = (_env, _argv) => {
|
|||
chunkFilename: "core.ruffle.[contenthash].js",
|
||||
clean: true,
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.wasm$/i,
|
||||
type: "asset/resource",
|
||||
},
|
||||
],
|
||||
},
|
||||
devtool: "source-map",
|
||||
plugins: [
|
||||
new CopyPlugin({
|
||||
|
|
Loading…
Reference in New Issue