Skip to content

fix(jco): use the node:path adapters during componentization - #1977

Merged
vados-cosmonic merged 1 commit into
bytecodealliance:mainfrom
vados-cosmonic:fix(jco)=node-builtins-path-usage
Aug 27, 2026
Merged

fix(jco): use the node:path adapters during componentization#1977
vados-cosmonic merged 1 commit into
bytecodealliance:mainfrom
vados-cosmonic:fix(jco)=node-builtins-path-usage

Conversation

@vados-cosmonic

Copy link
Copy Markdown
Collaborator

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.

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.
@vados-cosmonic
vados-cosmonic added this pull request to the merge queue Aug 27, 2026
Merged via the queue into bytecodealliance:main with commit a22a3ec Aug 27, 2026
56 checks passed
@vados-cosmonic
vados-cosmonic deleted the fix(jco)=node-builtins-path-usage branch August 27, 2026 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant