Repository navigation
feat(core): add @oxc-node/core/importer, a jiti-shaped TypeScript importer - #870
Conversation
…orter (#173) `createImporter(parentId, { moduleCache, interopDefault })` with `.import(id, { default, parentURL, conditions, try })` and `.resolve()`, the same shape and behaviour as jiti v2. It runs modules itself instead of through Node's loader: files are resolved with the oxc-node resolver, transformed by the new `transformModuleRunner` binding (the load hook's transform followed by oxc's module runner transform) and evaluated with `vm`. Nothing global is installed, so the host's own import() and require() stay as they are. Fixes #173 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aacc617079
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…rted `reexport-oxc-runtime.mjs` rewrites `exports` from a fixed list on CI and before publish, which dropped `./importer`. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ith the import conditions - An ES module with top-level await in its static graph, loaded by import() first, now fails require() with ERR_REQUIRE_ASYNC_MODULE, as Node.js does, instead of handing back the cached namespace. - A package path exported only under `require` (or other conditions than the ones in use) now fails import with ERR_PACKAGE_PATH_NOT_EXPORTED and Node's message, instead of ERR_MODULE_NOT_FOUND. - Docs: `default: true` is `mod.default ?? mod`, as in jiti. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
… literal On Windows the folder path has backslashes, which read as escapes inside the quoted key, so the module counted under another key and the cache checks saw no runs. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 57c49d80e0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…-level await A static import that Node.js loads itself made no record, so a module importing a node_modules package with top-level await was not marked async and a later require() of it got the cached namespace. Node.js' own require() of the loaded package now tells, as it throws ERR_REQUIRE_ASYNC_MODULE. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4eb07efb4f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…rter oxc's module runner transform pops the namespace specifier and drops the default one, so `a` was left unbound (ReferenceError). Split the declaration into `import a from "x"; import * as b from "x";` before the transform. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 50445537d2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
They sat in one process-wide map, so a `moduleCache: false` importer that loads new files every time kept every file's map forever. Each module map now has its own, which goes when the graph goes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4115642d08
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
The mark came only after the dependency finished, so a require() of the module while it still waited on the dependency's top-level await got the partly filled namespace. The dependency's record knows about its own await as soon as the import starts, so the mark is set then. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A module that throws leaves the cache so that it is tried again, but its source map, decoded to map the error's stack, stayed. Maps of modules no longer in the cache are dropped once the error has used them. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 304dd9ea59
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Dropping the maps of failed modules only when an error left import() missed failures caught inside a runner file. A failed module's map now moves from the module map to its error, for the stack, and goes when the error does. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 93297308f6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
`require.resolve.paths()` in a CommonJS runner file threw a TypeError. It now returns the folders Node.js would look in, as Node's own does. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 41d2cc2dc2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
`memory-failed-new-files` decoded 220 source maps of 1200 lines to map each error's stack, which ran past the 5 s probe limit on a macOS runner. The failure probes now load 120 files of 600 lines, and the memory probes get 30 s. Each still fails on the code before its fix. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
…, as jiti does - An import inside a runner file of CommonJS marked `__esModule` (Babel and tsc output) gets `exports.default` as its default, as jiti's transformed files do. The module `import()` returns stays as Node.js gives it, and `default: true` reads through the interop, so a function default is unwrapped, as in jiti. - `__dirname`, `__filename` and `require` exist in ES module files, as in jiti, from an outer function so that a module declaring its own still works. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e9f0e4e8e3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Babel and tsc define `__esModule` hidden, so it was left out of the namespace of a CommonJS file the runner evaluates, and jiti's interop never unwrapped its function default. Node.js' own CommonJS import exports it, so the runner does too. Seen with OXC_TRANSFORM_ALL, where node_modules files run in the runner. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…resolve options
- The `__esModule` interop also unwrapped the default of a real ES module
Node.js loaded. Node.js' CommonJS sits in `require.cache` with its own
exports, which tells the two apart on every supported version.
- `require.resolve(id, { paths })` in a runner file dropped the options; with
them it is Node.js' own lookup.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 862951b8c0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- A named export defined with `Object.defineProperty(exports, "a", { value })`
is hidden from Object.keys(), so `import { a }` of a runner CommonJS file
got undefined. An exports object's hidden properties now count, as Node.js'
CommonJS import finds them; a function's or an array's still do not.
- The runner's `require` has `main`, as Node.js' own does.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a29d075176
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A `file:` specifier that names no file kept no URL on its not-found error, so `import.meta.resolve()` threw where Node.js returns the URL. The error also names the path now, as Node's does. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cf02f91df3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…URLs - A `data:` URL (or another non-file URL) resolved to nothing and failed as not found; it is now Node.js' to load, as `import()` and `import.meta.resolve()` do natively. - `file:///a` has no path on Windows, where fileURLToPath() throws. Such a URL now fails as not found, and `import.meta.resolve()` returns it. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 318eb9fc60
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Where Node.js has `import.meta.main`, an imported module sees `false`; the runner's `import.meta` left it out. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b341a8efe2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…resolve specifiers Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: acec2ba181
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 61c82e3890
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1b4020ce74
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Fixes #173
A tool can import a user's TypeScript file (e.g.
eslint.config.ts) without registering hooks for the whole process. Same API shape and behaviour as jiti v2:How it works
require.extensions, nothing inrequire.cache,process.sourceMapsEnableduntouched.moduleCache: falsere-runs user files perimport();interopDefaultand{ default: true }match jiti.retainLines, which jiti uses), and errors escapingimport()get columns mapped through the source map, with no global switch.Rust
transformModuleRunner(path, source, sync?) -> { code, map, esm, topLevelAwait }. The runner flag is a real argument throughoxc_transform/transform_program; existing callers passNone, so their output is unchanged.Tests
.ctsrequiring ESM.ts, cycles (including parallel ones), live bindings,export *conflicts, retry after failure, memory bound withmoduleCache: false, no global leaks.vp run test: 546 passed, 7 skipped.Differences from jiti
import()only (no syncjiti(),alias,fsCache,transformOptions).import()insideeval/new Functionfalls back to Node's loader (no TS), and Node may print an experimental warning once.🤖 Generated with Claude Code