mirror of
https://github.com/openai/codex.git
synced 2026-03-05 21:45:28 +03:00
[js_repl] paths for node module resolution can be specified for js_repl (#11944)
# External (non-OpenAI) Pull Request Requirements
In `js_repl` mode, module resolution currently starts from
`js_repl_kernel.js`, which is written to a per-kernel temp dir. This
effectively means that bare imports will not resolve.
This PR adds a new config option, `js_repl_node_module_dirs`, which is a
list of dirs that are used (in order) to resolve a bare import. If none
of those work, the current working directory of the thread is used.
For example:
```toml
js_repl_node_module_dirs = [
"/path/to/node_modules/",
"/other/path/to/node_modules/",
]
```
This commit is contained in:
@@ -37,6 +37,19 @@ You can configure an explicit runtime path:
|
||||
js_repl_node_path = "/absolute/path/to/node"
|
||||
```
|
||||
|
||||
## Module resolution
|
||||
|
||||
`js_repl` resolves **bare** specifiers (for example `await import("pkg")`) using an ordered
|
||||
search path. Path-style specifiers (`./`, `../`, absolute paths, `file:` URLs) are rejected.
|
||||
|
||||
Module resolution proceeds in the following order:
|
||||
|
||||
1. `CODEX_JS_REPL_NODE_MODULE_DIRS` (PATH-delimited list)
|
||||
2. `js_repl_node_module_dirs` in config/profile (array of absolute paths)
|
||||
3. Thread working directory (cwd, always included as the last fallback)
|
||||
|
||||
For `CODEX_JS_REPL_NODE_MODULE_DIRS` and `js_repl_node_module_dirs`, module resolution is attempted in the order provided with earlier entries taking precedence.
|
||||
|
||||
## Usage
|
||||
|
||||
- `js_repl` is a freeform tool: send raw JavaScript source text.
|
||||
|
||||
Reference in New Issue
Block a user