Skip to content

Commit 512175d

Browse files
authored
update to componentizeJS 0.17 (#347)
* update to componentizeJS 0.17 Signed-off-by: karthik2804 <[email protected]> * fix webpack externals Signed-off-by: karthik2804 <[email protected]> --------- Signed-off-by: karthik2804 <[email protected]>
1 parent f379208 commit 512175d

File tree

7 files changed

+50
-38
lines changed

7 files changed

+50
-38
lines changed

bin/j2w.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,20 @@ const args = yargs(hideBin(process.argv))
3737
describe: "Spin trigger to target",
3838
demandOption: true
3939
})
40+
.option('debug-build', {
41+
describe: "Use debug build of the runtime",
42+
type: 'boolean',
43+
})
4044
.option('aot', {
4145
describe: "Enable Ahead of Time compilation",
4246
type: 'boolean',
4347
})
48+
.check((argv) => {
49+
if (argv['debug-build'] && argv['runtime-path']) {
50+
throw new Error("The --runtime-path option cannot be used when --debug-build is enabled.");
51+
}
52+
return true;
53+
})
4454
.argv;
4555

4656
const src = args.input;
@@ -123,6 +133,7 @@ async function saveBuildData(buildDataPath, checksum, version) {
123133
worldName: args.triggerType,
124134
disableFeatures: [],
125135
enableFeatures: ["http"],
136+
debugBuild: args.debugBuild ?? false,
126137
enableAot: args.aot
127138
});
128139

bin/wit/deps/[email protected]/spin.wit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package fermyon:spin@2.0.0;
22

33
world spin-imports {
4+
import wasi:cli/environment@0.2.3;
45
import wasi:http/outgoing-handler@0.2.3;
56
import llm;
67
import redis;

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@fermyon/spin-sdk",
3-
"version": "3.1.0",
3+
"version": "3.2.0",
44
"description": "",
55
"main": "lib/index.js",
66
"typings": "lib/index.d.ts",
@@ -26,7 +26,7 @@
2626
"typescript": "^5.4.3"
2727
},
2828
"dependencies": {
29-
"@bytecodealliance/componentize-js": "^0.16.0",
29+
"@bytecodealliance/componentize-js": "^0.17.0",
3030
"@fermyon/knitwit": "^0.3.0",
3131
"acorn-walk": "^8.3.4",
3232
"acron": "^1.0.5",
@@ -45,4 +45,4 @@
4545
"world": "spin-imports"
4646
}
4747
}
48-
}
48+
}

plugins/webpack/index.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
class SpinSdkPlugin {
22
constructor() {
3-
this.externals = {
4-
"wasi:http/[email protected]": "wasi:http/[email protected]",
5-
"wasi:cli/[email protected]": "wasi:cli/[email protected]",
6-
"wasi:filesystem/[email protected]": "wasi:filesystem/[email protected]",
7-
"fermyon:spin/[email protected]": "fermyon:spin/[email protected]",
8-
"fermyon:spin/[email protected]": "fermyon:spin/[email protected]",
9-
"fermyon:spin/[email protected]": "fermyon:spin/[email protected]",
10-
"fermyon:spin/[email protected]": "fermyon:spin/[email protected]",
11-
"fermyon:spin/[email protected]": "fermyon:spin/[email protected]",
12-
"fermyon:spin/[email protected]": "fermyon:spin/[email protected]",
13-
"fermyon:spin/[email protected]": "fermyon:spin/[email protected]",
14-
"fermyon:spin/[email protected]": "fermyon:spin/[email protected]",
15-
"wasi:config/[email protected]": "wasi:config/[email protected]",
16-
"spin:postgres/[email protected]": "spin:postgres/[email protected]",
17-
};
3+
this.externals = [
4+
/^wasi:.*/,
5+
/^fermyon:.*/,
6+
/^spin:.*/,
7+
];
188
}
199

2010
apply(compiler) {
2111
// If externals are already defined, merge them with new externals
22-
if (compiler.options.externals && typeof compiler.options.externals === 'object') {
23-
this.externals = Object.assign({}, compiler.options.externals, this.externals);
12+
const userExternals = compiler.options.externals;
13+
14+
if (Array.isArray(userExternals)) {
15+
// Append to the existing array
16+
compiler.options.externals = [...userExternals, ...this.externals];
17+
} else if (typeof userExternals === 'object') {
18+
// Wrap in an array and add the object as-is
19+
compiler.options.externals = [userExternals, ...this.externals];
20+
} else {
21+
// Default: Just use our externals
22+
compiler.options.externals = [...this.externals];
2423
}
25-
compiler.options.externals = this.externals;
2624
}
2725
}
2826

test/test-app/package-lock.json

Lines changed: 9 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/test-app/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7-
"build": "npx webpack --mode=production && npx mkdirp dist && npx j2w -i build/bundle.js -d build/wit/knitwit -n combined -o dist/test-app.wasm --aot",
8-
"test": "echo \"Error: no test specified\" && exit 1",
9-
"postinstall": "knitwit --out-dir build/wit/knitwit"
7+
"build": "knitwit --out-dir build/wit/knitwit && npx webpack --mode=production && npx mkdirp dist && npx j2w --debug-build -i build/bundle.js -d build/wit/knitwit -n combined -o dist/test-app.wasm --aot",
8+
"test": "echo \"Error: no test specified\" && exit 1"
109
},
1110
"keywords": [],
1211
"author": "",
@@ -22,4 +21,4 @@
2221
"@fermyon/spin-sdk": "file:../../",
2322
"itty-router": "^5.0.18"
2423
}
25-
}
24+
}

0 commit comments

Comments
 (0)