You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using Yarn PnP and ESM, directory import without explicit /index[.ts] results in error:
node:internal/process/esm_loader:40
internalBinding('errors').triggerUncaughtException(
^
Error: Qualified path resolution failed: we looked for the following paths, but none could be accessed.
Source path: <project path>/src
Not found: <project path>/src
Reproducible as in the codesandbox
Expected behaviour:
Should run without explicit /index[.ts] in import path
Tried solution:
I fixed this by adding / suffix the import path so it runs loaders.ts#L143. But I don't like the extra /.
So I cloned and linked tsx locally, and found that the error.code in loaders.ts#L202 is ERR_MODULE_NOT_FOUND in Yarn, so it doesn't run the tryDirectory.
Changing tryExtensions to tryDirectoryhere fixes this problem. tryDirectory will also fallback to the tryExtensions` in Line 122, so it shouldn't break anything else?
I'm not sure to open PR because it might cause slight slow down due to the multiple tries in tryDirectory, or this could be just a Yarn issue.
Notes:
No error for Yarn PnP with commonjs
No error for ESM without PnP (nodeLinker: node-modules)
Contributions
I plan to open a pull request for this issue
I plan to make a financial contribution to this project
The text was updated successfully, but these errors were encountered:
No, It's still not fixed in v4.9.3, updated the codesandbox repro.
I was planning to make a pull request to check if yarn is used.
But I think it makes more sense for yarn to add the ERR_UNSUPPORTED_DIR_IMPORT instead.
Acknowledgements
Minimal reproduction URL
https://codesandbox.io/p/devbox/yarn-tsx-62dstm
Version
v4.9.3 (issue opened: v4.6.2)
Node.js version
v20.10.0
Package manager
yarn v4.2.2
Operating system
Windows
Problem & Expected behavior
What Happened:
When using Yarn PnP and ESM, directory import without explicit
/index[.ts]
results in error:Reproducible as in the codesandbox
Expected behaviour:
Should run without explicit
/index[.ts]
in import pathTried solution:
I fixed this by adding
/
suffix the import path so it runs loaders.ts#L143. But I don't like the extra/
.So I cloned and linked tsx locally, and found that the
error.code
in loaders.ts#L202 isERR_MODULE_NOT_FOUND
in Yarn, so it doesn't run thetryDirectory
.Changing
tryExtensions
totryDirectory
here fixes this problem.tryDirectory
will also fallback to the tryExtensions` in Line 122, so it shouldn't break anything else?I'm not sure to open PR because it might cause slight slow down due to the multiple tries in
tryDirectory
, or this could be just a Yarn issue.Notes:
nodeLinker: node-modules
)Contributions
The text was updated successfully, but these errors were encountered: