-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Making it possible to import the project as an NPM package using a Gi…
…t URL
- Loading branch information
Showing
20 changed files
with
119 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
.nyc_output | ||
coverage | ||
node_modules | ||
out | ||
lib | ||
tsconfig.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import * as routines from "./routines.js" | ||
|
||
routines.compileRuntime() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
#!/usr/bin/bash | ||
|
||
echo "Making sure runtime output directory exists ..." | ||
mkdir -p ./out | ||
rm -fR ./out/wa | ||
mkdir ./out/wa || exit 1 | ||
mkdir -p ./lib | ||
rm -fR ./lib/wa | ||
mkdir ./lib/wa || exit 1 | ||
|
||
echo "Building runtime modules ..." | ||
ls ./src/wa/*.wat \ | ||
| xargs -I {} basename {} ".wat" \ | ||
| xargs -I {} wat2wasm --output=./out/wa/{}.wasm ./src/wa/{}.wat || exit 1 | ||
| xargs -I {} wat2wasm --output=./lib/wa/{}.wasm ./src/wa/{}.wat || exit 1 | ||
|
||
echo "Success!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import * as routines from "./routines.js" | ||
|
||
routines.clean() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import * as routines from "./routines.js" | ||
|
||
routines.finalize() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import fs from 'fs' | ||
import binaryen from "binaryen" | ||
|
||
const src = "./src" | ||
const lib = "./lib" | ||
const waSrc = `${src}/wa` | ||
const waLib = `${lib}/wa` | ||
const jsLib = `${lib}/js` | ||
const prodLib = `${lib}/prod` | ||
|
||
export function compileRuntime() { | ||
console.log("Making sure runtime output directory exists ...") | ||
if (!fs.existsSync(lib)) { | ||
fs.mkdirSync(lib) | ||
} | ||
if (!fs.existsSync(waLib)) { | ||
fs.mkdirSync(waLib) | ||
} | ||
|
||
console.log("Building runtime modules ...") | ||
const watFiles = fs.readdirSync(waSrc).filter(f => f.endsWith(".wat")) | ||
for (const watFile of watFiles) { | ||
console.log(`Compiling ${watFile} ...`) | ||
const buffer = fs.readFileSync(`${waSrc}/${watFile}`) | ||
const code = buffer.toString("utf-8") | ||
const module = binaryen.parseText(code) | ||
module.setFeatures(binaryen.Features.BulkMemory) | ||
module.optimize() | ||
const binary = module.emitBinary() | ||
fs.writeFileSync(`${waLib}/${watFile.replace(".wat", ".wasm")}`, binary) | ||
} | ||
console.log("Success!") | ||
} | ||
|
||
export function clean() { | ||
fs.rmSync(lib, { force: true, recursive: true }) | ||
} | ||
|
||
export function finalize() { | ||
fs.renameSync(prodLib, jsLib) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"sourceMap": false, | ||
"declarationMap": false | ||
}, | ||
"exclude": ["./src/test"] | ||
} |