fix(jco): use the node:path adapters during componentization - #1977
Merged
vados-cosmonic merged 1 commit intoAug 27, 2026
Merged
Conversation
The `node:path` adapters shipped in cd106b7 were never reachable: - `componentize()` called `bundleComponentSource()` without passing the adapter plugin, so `node:path` imports were left for StarlingMonkey to resolve, failing with `Error loading module "node:path"`. - `src/node-builtins.js` was a `.js` file in a `tsconfig` that includes `src/**/*` without `allowJs`, so it was never emitted to `dist` either. The hand-written `types/node-builtins.d.ts` hid that from type-checkers. - `jco` had no dependency on `@bytecodealliance/jco-std`, so resolving the path factory would have thrown even once the plugin was wired in. Convert the module to TypeScript so it is built like the rest of `src`, pass the plugin into bundling, and depend on the published jco-std, whose `node/path` export has been available since v0.2.1. The existing unit tests passed throughout, because they call the plugin's hooks directly and never go through `componentize()`. Add `test/node-path.js`, which componentizes and runs the new `node-path` fixture, covering both the lexical behavior (including the win32 namespace and `matchesGlob`) and `resolve()` reading the host cwd through `wasi:cli/environment`. Add a `componentizeFixture()` test helper for building fixture components through the CLI, and move the existing componentize tests onto it and onto `setupAsyncTest()`. `setupAsyncTest()` now defaults its import object to the WASI shim, which a component transpiled for explicit instantiation needs. Tests that cover Node builtins live under test/node/, one file per builtin.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
NodeJS builtins were in in place in Jco but couldn't be used due to lack of passing thorugh the impl from
jco-std-- this PR fixes that, and makes the tests a bit easier to run.Now, tests actually run through the componentize route so we can make sure that works e2e in a sense.