diff --git a/packages/build-tools/package-lock.json b/packages/build-tools/package-lock.json index d0482478..589970a6 100644 --- a/packages/build-tools/package-lock.json +++ b/packages/build-tools/package-lock.json @@ -1,16 +1,16 @@ { "name": "@spinframework/build-tools", - "version": "1.0.3", + "version": "1.0.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@spinframework/build-tools", - "version": "1.0.3", + "version": "1.0.4", "license": "Apache-2.0 WITH LLVM-exception", "dependencies": { "@ampproject/remapping": "^2.3.0", - "@bytecodealliance/componentize-js": "^0.19.0", + "@bytecodealliance/componentize-js": "^0.19.2", "@bytecodealliance/jco": "^1.10.2", "acorn-walk": "^8.3.4", "acron": "^1.0.5", @@ -49,9 +49,9 @@ } }, "node_modules/@bytecodealliance/componentize-js": { - "version": "0.19.0", - "resolved": "https://registry.npmjs.org/@bytecodealliance/componentize-js/-/componentize-js-0.19.0.tgz", - "integrity": "sha512-xiwg4rh7JPj9uPTcAdj7axSnMRgyp/f5qKKbPRQn9mafASPytgNyhg7YwjcAtX17HiiZGjgGrZCXh+FmLSBbjA==", + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/@bytecodealliance/componentize-js/-/componentize-js-0.19.2.tgz", + "integrity": "sha512-8gzP4mRNkRF7frCf8NChbx0MHKf13VRiDupVF4B9VeTRNBJsLabRXvwaE71Qwe4dB7ZUsD1Rv09anWF12e3XgQ==", "workspaces": [ "." ], diff --git a/packages/build-tools/package.json b/packages/build-tools/package.json index da87a795..8f95ca69 100644 --- a/packages/build-tools/package.json +++ b/packages/build-tools/package.json @@ -1,6 +1,6 @@ { "name": "@spinframework/build-tools", - "version": "1.0.3", + "version": "1.0.4", "description": "", "main": "index.js", "scripts": { @@ -30,7 +30,7 @@ }, "dependencies": { "@ampproject/remapping": "^2.3.0", - "@bytecodealliance/componentize-js": "^0.19.0", + "@bytecodealliance/componentize-js": "^0.19.2", "@bytecodealliance/jco": "^1.10.2", "acorn-walk": "^8.3.4", "acron": "^1.0.5", diff --git a/packages/build-tools/src/cli.ts b/packages/build-tools/src/cli.ts index e5635ee4..866ef6e1 100644 --- a/packages/build-tools/src/cli.ts +++ b/packages/build-tools/src/cli.ts @@ -6,6 +6,7 @@ export interface CliArgs { output: string; aot?: boolean; debug?: boolean; + initLocation?: string; } export function getCliArgs(): CliArgs { @@ -30,6 +31,10 @@ export function getCliArgs(): CliArgs { describe: 'Enable JavaScript debugging', type: 'boolean', }) + .option('initLocation', { + describe: 'Location during top level initialization', + type: 'string', + }) .argv as CliArgs; return args; diff --git a/packages/build-tools/src/index.ts b/packages/build-tools/src/index.ts index 17885c76..184ff2d5 100644 --- a/packages/build-tools/src/index.ts +++ b/packages/build-tools/src/index.ts @@ -26,7 +26,10 @@ async function main() { let CliArgs = getCliArgs(); let src = CliArgs.input; let outputPath = CliArgs.output; - let runtimeArgs = CliArgs.debug ? '--enable-script-debugging' : ''; + let runtimeArgs = [ + CliArgs.debug && '--enable-script-debugging', + CliArgs.initLocation && `--init-location ${CliArgs.initLocation}` + ].filter(Boolean).join(' '); // generate wit world string let wasiDeps = getPackagesWithWasiDeps(process.cwd(), new Set(), true); diff --git a/test/test-app/package-lock.json b/test/test-app/package-lock.json index f54ea1b9..0f7e1d77 100644 --- a/test/test-app/package-lock.json +++ b/test/test-app/package-lock.json @@ -24,11 +24,11 @@ }, "../../packages/build-tools": { "name": "@spinframework/build-tools", - "version": "1.0.3", + "version": "1.0.4", "license": "Apache-2.0 WITH LLVM-exception", "dependencies": { "@ampproject/remapping": "^2.3.0", - "@bytecodealliance/componentize-js": "^0.19.0", + "@bytecodealliance/componentize-js": "^0.19.2", "@bytecodealliance/jco": "^1.10.2", "acorn-walk": "^8.3.4", "acron": "^1.0.5", diff --git a/test/test-app/package.json b/test/test-app/package.json index e5061f36..96725dde 100644 --- a/test/test-app/package.json +++ b/test/test-app/package.json @@ -7,7 +7,7 @@ "keywords": [], "license": "Apache-2.0", "scripts": { - "build": "node build.mjs && mkdirp dist && j2w -i build/bundle.js -o dist/test-app.wasm", + "build": "node build.mjs && mkdirp dist && j2w -i build/bundle.js -o dist/test-app.wasm --initLocation http://foo.bar", "test": "echo \"Error: no test specified\" && exit 1" }, "devDependencies": { diff --git a/test/test-app/src/index.ts b/test/test-app/src/index.ts index 92929a6d..2fd124ae 100644 --- a/test/test-app/src/index.ts +++ b/test/test-app/src/index.ts @@ -1,6 +1,13 @@ import { AutoRouter } from "itty-router" import { headersTest, health, kvTest, kvTestUint8Array, outboundHttp, statusTest, stream, streamTest, testFunctionality } from "./test"; +// Verify top level init location +if (globalThis.location.href != "http://foo.bar/") { + throw new Error(`Expected top-level init location to be "http://foo.bar/", got "${globalThis.location}"`); +} else { + console.log(`Top-level init location verified:, ${globalThis.location.href}`); +} + let router = AutoRouter() router.get("/health", health)