Skip to content

Commit ce50327

Browse files
authored
chore: Compile the type information from wit-bindgen into components directly (#588)
1 parent 52947a6 commit ce50327

File tree

5 files changed

+5
-18
lines changed

5 files changed

+5
-18
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,6 @@ jobs:
365365
uses: actions/download-artifact@v3
366366
with:
367367
name: engine-release
368-
- name: Locate component resources
369-
run: |
370-
cp runtime/js-compute-runtime/fastly.wit .
371368
- run: yarn
372369
shell: bash
373370
- run: npm test

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ node_modules/
1515
/js-compute-runtime-component.wasm
1616
/runtime/js-compute-runtime/obj
1717
tests/wpt-harness/wpt-test-runner.js
18-
/fastly.wit
1918
wpt-runtime.wasm
2019
docs-app/bin/main.wasm
2120
docs-app/pkg/*.tar.gz

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"types",
2121
"js-compute-runtime-cli.js",
2222
"*.wasm",
23-
"fastly.wit",
2423
"src",
2524
"index.d.ts",
2625
"package.json",
@@ -31,8 +30,8 @@
3130
"test": "npm run test:types && npm run test:cli",
3231
"test:cli": "brittle --bail integration-tests/cli/**.test.js",
3332
"test:types": "tsd",
34-
"build": "make -j8 -C runtime/js-compute-runtime && cp runtime/js-compute-runtime/*.wasm runtime/js-compute-runtime/fastly.wit .",
35-
"build:debug": "DEBUG=true make -j8 -C runtime/js-compute-runtime && cp runtime/js-compute-runtime/*.wasm runtime/js-compute-runtime/fastly.wit .",
33+
"build": "make -j8 -C runtime/js-compute-runtime && cp runtime/js-compute-runtime/*.wasm .",
34+
"build:debug": "DEBUG=true make -j8 -C runtime/js-compute-runtime && cp runtime/js-compute-runtime/*.wasm .",
3635
"check-changelog": "cae-release-notes-format-checker CHANGELOG.md"
3736
},
3837
"devDependencies": {

runtime/js-compute-runtime/Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,7 @@ $(eval $(call compile_c,$(FSM_SRC)/fastly-world/fastly_world.c))
326326
# that script for more information about why we do this.
327327
$(OBJ_DIR)/js-compute-runtime-component.wasm: $(FSM_OBJ) $(SM_OBJ) $(RUST_URL_LIB) $(RUST_ENCODING_LIB)
328328
$(OBJ_DIR)/js-compute-runtime-component.wasm: $(OBJ_DIR)/impl/main_component.o
329-
# NOTE: we don't currently link in the component type object because we
330-
# explicitly reference fastly.wit when building the component. If this changes,
331-
# uncommenting this line will link the component type object in.
332-
# $(OBJ_DIR)/js-compute-runtime-component.wasm: $(FSM_SRC)/fastly-world/fastly_world_component_type.o
329+
$(OBJ_DIR)/js-compute-runtime-component.wasm: $(FSM_SRC)/fastly-world/fastly_world_component_type.o
333330
$(OBJ_DIR)/js-compute-runtime-component.wasm: $(OBJ_DIR)/fastly-world/fastly_world.o
334331
$(call cmd_format,WASI_LD,$@) PATH="$(FSM_SRC)/scripts:$$PATH" \
335332
$(WASI_CXX) $(LD_FLAGS) $(OPENSSL_LIBS) -o $@ $^

src/component.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
import { componentEmbed, componentNew, preview1AdapterReactorPath } from '@bytecodealliance/jco';
1+
import { componentNew, preview1AdapterReactorPath } from '@bytecodealliance/jco';
22
import { readFile, writeFile } from 'node:fs/promises';
33

44
export async function compileComponent (path) {
55
const coreComponent = await readFile(path);
6-
const wit = await readFile(new URL('../fastly.wit', import.meta.url), 'utf8');
7-
const coreComponentEmbedded = await componentEmbed({
8-
binary: coreComponent,
9-
witSource: wit,
10-
});
11-
const generatedComponent = await componentNew(coreComponentEmbedded, [['wasi_snapshot_preview1', await readFile(preview1AdapterReactorPath())]]);
6+
const generatedComponent = await componentNew(coreComponent, [['wasi_snapshot_preview1', await readFile(preview1AdapterReactorPath())]]);
127
await writeFile(path, generatedComponent);
138
}

0 commit comments

Comments
 (0)