transform_wasm

command
v0.0.0-...-a20b76d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2019 License: Apache-2.0 Imports: 9 Imported by: 0

README

WebAssembly local transformer

This is a proof of concept for running the local transformer in a JS environment, using WebAssembly. It depends on Go 1.12 (currently available in beta).

Running

To run the test:

git clone https://github.com/ampproject/amppackager.git
cd amppackager/cmd/transform_wasm
GOROOT=~/sdk/go1.12beta2 node main.js main.wasm testfile

For a bigger testfile, pass node something like --max-old-space-size=4000.

lib.js can be reused for other purposes. See main.js for an example use.

Building

Go's current wasm backend allocates a lot of memory and never frees it. To conserve memory usage, build a patched Go compiler:

git clone https://github.com/twifkak/go.git
cd go
git checkout small
src/make.bash

And then use that to build the wasm binary:

cd amppackager/cmd/transform_wasm
GOOS=js GOARCH=wasm path/to/go/bin/go build -o main.wasm .

Documentation

Rendered for js/wasm

Overview

Binary wrapper for the transformer lib, to be run via main.js.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL