Environment
@oxc-node/cli: v0.1.0
- Node.js:
v24.19.0
- OS: Windows 11
Reproduction
src/index.ts
import configs from "#/configs/cfg.json" with { type: "json" };
console.log(configs);
tsconfig.json
{
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext",
"paths": {
"#/*": ["./src/*"]
}
}
}
Project structure
src/
├── index.ts
└── configs/
└── cfg.json
Expected behavior
oxnode should resolve #/configs/cfg.json using the tsconfig.json compilerOptions.paths configuration, just as it does for TypeScript imports without the JSON import attribute.
Actual behavior
Running:
fails with:
node:internal/modules/run_main:107
triggerUncaughtException(
^
TypeError [ERR_PACKAGE_IMPORT_NOT_DEFINED]: Package import specifier "#/configs/cfg.json" is not defined in package D:\Repositories\synchronous-chat\package.json imported from D:\Repositories\synchronous-chat\src\app.ts
This suggests that the #/configs/cfg.json specifier is reaching Node's native ESM resolver without being resolved through the tsconfig.paths configuration first.
Comparison
The same import works with:
tsx src/index.ts → works
tsc -b → works
tsc-alias → works
node dist/... → works
oxnode src/index.ts → fails
The JSON file itself does not appear to be the issue.
Additional observations
Removing the import attribute:
import configs from "#/configs/cfg.json";
makes the alias work with oxnode.
Alternatively, adding a corresponding imports mapping to package.json also makes it work.
For example:
{
"imports": {
"#/*": "./src/*"
}
}
This suggests that when with { type: "json" } is present, the tsconfig.paths resolver may be bypassed and the specifier is instead passed directly to Node's native package-import resolution.
Expected
This should work without requiring a corresponding package.json#imports entry:
import configs from "#/configs/cfg.json" with { type: "json" };
when the alias is defined through:
{
"compilerOptions": {
"paths": {
"#/*": ["./src/*"]
}
}
}
Could this be related to the handling of import attributes in the resolver hook?
Environment
@oxc-node/cli:v0.1.0v24.19.0Reproduction
src/index.tstsconfig.json{ "compilerOptions": { "module": "NodeNext", "moduleResolution": "NodeNext", "paths": { "#/*": ["./src/*"] } } }Project structure
Expected behavior
oxnodeshould resolve#/configs/cfg.jsonusing thetsconfig.jsoncompilerOptions.pathsconfiguration, just as it does for TypeScript imports without the JSON import attribute.Actual behavior
Running:
fails with:
This suggests that the
#/configs/cfg.jsonspecifier is reaching Node's native ESM resolver without being resolved through thetsconfig.pathsconfiguration first.Comparison
The same import works with:
The JSON file itself does not appear to be the issue.
Additional observations
Removing the import attribute:
makes the alias work with
oxnode.Alternatively, adding a corresponding
importsmapping topackage.jsonalso makes it work.For example:
{ "imports": { "#/*": "./src/*" } }This suggests that when
with { type: "json" }is present, thetsconfig.pathsresolver may be bypassed and the specifier is instead passed directly to Node's native package-import resolution.Expected
This should work without requiring a corresponding
package.json#importsentry:when the alias is defined through:
{ "compilerOptions": { "paths": { "#/*": ["./src/*"] } } }Could this be related to the handling of import attributes in the resolver hook?