mirror of
https://github.com/remko/waforth
synced 2024-12-25 09:59:07 +01:00
build: Resolve waforth import from examples
This commit is contained in:
parent
75c6490dc5
commit
01fcb9e2a8
13 changed files with 27 additions and 12 deletions
|
@ -1,3 +1,4 @@
|
|||
public/waforth/dist
|
||||
build/
|
||||
dist/
|
||||
src/web/benchmarks/sieve/sieve-c.js
|
||||
|
|
|
@ -36,7 +36,7 @@ document](doc/Design.md).
|
|||
|
||||
You can embed WAForth in any JavaScript application.
|
||||
|
||||
A simple example to illustrate starting WAForth, and binding JavaScript functions:
|
||||
A [simple example](https://github.com/remko/waforth/blob/master/src/web/examples/prompt/prompt.ts) to illustrate starting WAForth, and binding JavaScript functions:
|
||||
|
||||
```typescript
|
||||
import WAForth from "waforth";
|
||||
|
|
|
@ -9,7 +9,7 @@ const { wasmTextPlugin } = require("./scripts/esbuild/wasm-text");
|
|||
let buildConfig = {
|
||||
bundle: true,
|
||||
logLevel: "info",
|
||||
entryPoints: [path.join(__dirname, "src", "web", "WAForth")],
|
||||
entryPoints: [path.join(__dirname, "src", "web", "waforth")],
|
||||
outfile: path.join(__dirname, "dist", "index.js"),
|
||||
minify: true,
|
||||
format: "cjs",
|
||||
|
|
15
build-web.js
15
build-web.js
|
@ -81,7 +81,20 @@ let buildConfig = {
|
|||
},
|
||||
sourcemap: true,
|
||||
metafile: true,
|
||||
plugins: [wasmTextPlugin({ debug: true }), forthPlugin()],
|
||||
plugins: [
|
||||
wasmTextPlugin({ debug: true }),
|
||||
forthPlugin(),
|
||||
|
||||
// Resolve 'waforth' to the main entrypoint (for examples)
|
||||
{
|
||||
name: "waforth",
|
||||
setup: (build) => {
|
||||
build.onResolve({ filter: /^waforth$/ }, () => {
|
||||
return { path: path.join(__dirname, "src", "web", "waforth.ts") };
|
||||
});
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const INDEX_TEMPLATE = `<!doctype html>
|
||||
|
|
|
@ -59,7 +59,7 @@ shared function table is large enough for the module to register itself.
|
|||
## The Shell
|
||||
|
||||
The shell is [a JavaScript
|
||||
class](https://github.com/remko/waforth/blob/master/src/shell/WAForth.js) that
|
||||
class](https://github.com/remko/waforth/blob/master/src/web/waforth.ts) that
|
||||
wraps the WebAssembly module, and loads it in the browser. It provides the I/O
|
||||
primitives to the WebAssembly module to read and write characters to a
|
||||
terminal, and externally provides a `interpret()` function to execute a fragment of
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
"react-dom": "^18.0.0",
|
||||
"typescript": "^4.6.4"
|
||||
},
|
||||
"types": "dist/WAForth.d.ts",
|
||||
"types": "dist/waforth.d.ts",
|
||||
"main": "dist/index.js",
|
||||
"files": [
|
||||
"dist"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import React from "react";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import WAForth from "../WAForth";
|
||||
import WAForth from "../waforth";
|
||||
import sieve from "../../examples/sieve.f";
|
||||
import sieveWasmModule from "./sieve/sieve.wat";
|
||||
import sieveJS from "./sieve/sieve.js";
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
|
||||
import "./prompt.css";
|
||||
import WAForth from "../../WAForth";
|
||||
import WAForth from "waforth";
|
||||
|
||||
(async () => {
|
||||
// Create the UI
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* global WAFORTH_VERSION */
|
||||
|
||||
import WAForth from "../WAForth";
|
||||
import WAForth from "../waforth";
|
||||
import sieve from "../../examples/sieve.f";
|
||||
import "./shell.css";
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import WAForth from "../WAForth";
|
||||
import WAForth from "../waforth";
|
||||
import sieve from "../../examples/sieve.f";
|
||||
import standardTestSuiteTester from "../../standard-testsuite/tester.f";
|
||||
import standardCoreWordsTestSuite from "../../standard-testsuite/core.f";
|
||||
|
|
|
@ -5,8 +5,9 @@
|
|||
"strict": true,
|
||||
"target": "es2015",
|
||||
"typeRoots": ["./src/web/types"],
|
||||
"types": ["node"]
|
||||
"types": ["node"],
|
||||
"baseUrl": "./src/web"
|
||||
},
|
||||
"include": ["src/web"],
|
||||
"include": ["./src/web"],
|
||||
"exclude": ["node_modules", "dist", "build"]
|
||||
}
|
||||
|
|
|
@ -9,6 +9,6 @@
|
|||
"declaration": true,
|
||||
"emitDeclarationOnly": true
|
||||
},
|
||||
"include": ["src/web/WAForth.ts", "src/web/types"],
|
||||
"include": ["src/web/waforth.ts", "src/web/types"],
|
||||
"exclude": ["node_modules", "dist", "build"]
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue