Skip to content

Commit

Permalink
Fix broken npm start
Browse files Browse the repository at this point in the history
- Use production mode for wasm-pack
Development mode results in 'Unexpected section' error,
possibly due to unstripped sections in wasm.

- Ignore "Critical dependency" warning
The problem and the workaround are described in
rust-random/getrandom#224
  • Loading branch information
mosmeh committed Feb 10, 2022
1 parent 5b023bb commit 301f22b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ module.exports = {
new WasmPackPlugin({
crateDirectory: path.resolve(__dirname, '.'),
outDir: path.resolve(__dirname, 'web', 'pkg'),

// development mode results in 'Unexpected section' error,
// possibly due to unstripped sections in wasm
forceMode: 'production',
}),
new webpack.ProvidePlugin({
TextDecoder: ['text-encoding', 'TextDecoder'],
Expand All @@ -45,4 +49,10 @@ module.exports = {
experiments: {
asyncWebAssembly: true,
},

// https://github.com/rust-random/getrandom/issues/224#issuecomment-944329336
ignoreWarnings: [
(warning) => warning.message ===
'Critical dependency: the request of a dependency is an expression',
],
};

0 comments on commit 301f22b

Please sign in to comment.