ASC Loader
AssemblyScript loader for Webpack.
Installation
# npm npm i -D asc-loadernpm i -D @assemblyscript/loadernpm i -D assemblyscript # yarn yarn add -D asc-loaderyarn add -D @assemblyscript/loaderyarn add -D assemblyscript
Configuration
webpack.config.js
moduleexports = module: rules: test: /\.ts$/ include: /src\/assembly/ use: loader: 'asc-loader' options: name: 'static/wasm/[name].[hash:8].wasm' build: false /* enable in production */ optimize: '-O' importMemory: true use: 'Math=JSMath'
Alternative Configuration
webpack.config.js
moduleexports = module: rules: test: /\.ts$/ use: 'asc-loader' include: /src\/assembly/ options: name: 'static/wasm/[name].[hash:8].wasm' build: false /* enable in production */ optimize: '-O' importMemory: true use: 'Math=JSMath'
Examples
Create React App
This also works on Create React App, just make sure that the loader is placed in the right place in the configuration file.
Python SimpleHTTPServer
If you're using SimpleHTTPServer on Python to run production builds, please make sure that your Python version supports WASM MIME type detection.
If not, you can simply use this script to specify the MIME Type.
import SimpleHTTPServerimport SocketServer PORT = 8000 pass = 'application/wasm' httpd =