mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-14 09:39:15 +00:00
Use native Wasm+Webpack support for Rust codecs
This delegates loading of Wasm modules to Webpack itself, making wrapper code simpler. Emscripten-generated modules are still using custom loading glue as they're not compatible with Webpack.
This commit is contained in:
@@ -147,8 +147,9 @@ module.exports = async function (_, env) {
|
||||
loader: 'exports-loader'
|
||||
},
|
||||
{
|
||||
// For some reason using `include` here breaks the build.
|
||||
test: /[/\\]codecs[/\\].*\.wasm$/,
|
||||
// Emscripten modules don't work with Webpack's Wasm loader.
|
||||
test: /\.wasm$/,
|
||||
exclude: /_bg\.wasm$/,
|
||||
// This is needed to make webpack NOT process wasm files.
|
||||
// See https://github.com/webpack/webpack/issues/6725
|
||||
type: 'javascript/auto',
|
||||
@@ -157,6 +158,11 @@ module.exports = async function (_, env) {
|
||||
name: '[name].[hash:5].[ext]',
|
||||
},
|
||||
},
|
||||
{
|
||||
// Wasm modules generated by Rust + wasm-pack work great with Webpack.
|
||||
test: /_bg\.wasm$/,
|
||||
type: 'webassembly/experimental',
|
||||
},
|
||||
{
|
||||
test: /\.(png|svg|jpg|gif)$/,
|
||||
loader: 'file-loader',
|
||||
|
||||
Reference in New Issue
Block a user