1.0.8 • Published 4 years ago

asc-loader v1.0.8

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

npm node deps tests

ASC Loader

AssemblyScript loader for Webpack.

Installation

# npm
npm i -D asc-loader
npm i -D @assemblyscript/loader
npm i -D assemblyscript

# yarn
yarn add -D asc-loader
yarn add -D @assemblyscript/loader
yarn add -D assemblyscript

Configuration

webpack.config.js

module.exports = {
  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

module.exports = {
  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 SimpleHTTPServer
import SocketServer

PORT = 8000

class Handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
  pass

Handler.extensions_map['.wasm'] = 'application/wasm'

httpd = SocketServer.TCPServer(("", PORT), Handler)
httpd.serve_forever()
1.0.8

4 years ago

1.0.7

4 years ago

1.0.2

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.1

4 years ago