Skip to content

Commit

Permalink
Revert "web: Simplify .wasm loading"
Browse files Browse the repository at this point in the history
This reverts commit 66bfff7.
  • Loading branch information
relrelb committed Jul 27, 2021
1 parent 66bfff7 commit 508f541
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
8 changes: 7 additions & 1 deletion web/packages/core/src/load-ruffle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ async function fetchRuffle(): Promise<typeof Ruffle> {
// libraries, if needed.
setPolyfillsOnLoad();

await init();
// 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);

return Ruffle;
}
Expand Down
4 changes: 4 additions & 0 deletions web/packages/demo/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ module.exports = (_env, _argv) => {
test: /\.css$/i,
use: ["style-loader", "css-loader"],
},
{
test: /\.wasm$/i,
type: "asset/resource",
},
],
},
devtool: "source-map",
Expand Down
4 changes: 4 additions & 0 deletions web/packages/extension/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ module.exports = (env, _argv) => {
test: /\.ts$/i,
use: "ts-loader",
},
{
test: /\.wasm$/i,
type: "asset/resource",
},
],
},
resolve: {
Expand Down
8 changes: 8 additions & 0 deletions web/packages/selfhosted/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ 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({
Expand Down

0 comments on commit 508f541

Please sign in to comment.