Skip to content

yiwen03/wasm-module-webpack-plugin

 
 

Repository files navigation

WASM Module Webpack Plugin

npm Build Status

NPM

中文文档

Load module which have wasm file into javascript with a zero bloat.

Installation

1 Run npm i wasm-module-webpack-plugin --save-dev.

2 Require method from wasm-module-webpack-plugin

const WasmModuleWebpackPlugin = require('wasm-module-webpack-plugin');

3 Add this object to the rules section of your webpack build:

{
  test: /\.m?js$/,
  exclude: /(node_modules|bower_components)/,
  include: [ path.join(process.cwd(), './node_modules/{wasm_module_name}') ],
  use: {
    loader: 'babel-loader',
    options: {
      presets: ['@babel/preset-env'],
      plugins: [ '@babel/plugin-syntax-dynamic-import', WasmModuleWebpackPlugin.BabelPlugin ]
    }
  }
}

4 Add this object to the plugins section of your webpack build:

plugins: [
  new WasmModuleWebpackPlugin.WebpackPlugin()
]

Example

You can also view a complete working example on github here.

MIT License

Copyright 2018 zhi.zhou

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 79.6%
  • HTML 20.4%