Skip to content

Repository files navigation

assemblyscript-loader-loader

Loader for webpack to compile typescript with AssemblyScript and bundle it to wasm or bytes string

Install

$ yarn add assemblyscript-loader-loader --dev

Usage

webpack.config.js

{test: /\.tsx?$/,loader: 'assemblyscript-loader-loader',include: /assemblyscript/,exclude: /node_modules/,options: {limit: 1000,optimize: true,noAssert: true,importMemory: true,runtime: 'none',useInWorker: true,}}

file.js

importasmPromisefrom"./assemblyscript/test.ts";constimports={env: {}};asmPromise(imports).then(function(asmModule){// you can use the wasm exports})

Ths usage of imports can refer to @assemblyscript/loader

Options

The loader supports some of the assemblyscript options here

custom options

NameTypeDefaultDescription
limitstring | number1000Byte limit of the wasm file. If the size is smaller then limit value, the wasm will bundled into js, or the wasm file will build into dist.
namestring[name].[hash:7].wasmConfigure a custom filename template for your file.
publicPathstring__webpack_public_path__Configure a custom public path for your file.
useInWorkerbooleanundefinedIf the wasm is used in web worker, you should set useInWorker to true. Loader will set publicPath to current origin. If production mode and development mode are different, you need set publicPath at production mode.

Thanks to the authors of assemblyscript-typescript-loader and assemblyscript-wasm-loader for their contributions.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages