-
-
Notifications
You must be signed in to change notification settings - Fork 532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module nodenext is resolving to cjs build incorrectly #1778
Module nodenext is resolving to cjs build incorrectly #1778
Comments
Thank you for the excellent reproduction. As a workaround until a proper fix is made, you can add I tried adding TSC output
ts-node output
|
I think I found the issue. To support the new NodeNext mode, TypeScript's resolver needs to pass around new information about the type of the module making the import request: either cjs or esm. That info is passed in new, optional arguments in some of the compiler APIs, so it wasn't flagged as an error when we moved to the new TS version. Should be a straightforward fix that I can do soon. |
Note to self, how to fix this bug: Update the signatures of these two functions to include the new, optional arguments in TS4.7 ts-node/src/resolver-functions.ts Lines 87 to 131 in b3dd3f2
|
thank you so much for the quick response @cspotcode! |
… cjs or esm -- into account when resolving package.json "exports" (#1782) * Add failing test * fix typo in failing test * fix bug * fix test runIf filter * fix * fix * lint
@cspotcode Thank you so much for the fix! Was just wondering if by any chance you could cut a |
Yeah, absolutely. I can do that tomorrow morning. |
@perrin4869 v10.8.1 is published, thanks for your patience, and please let me know if you hit any other issues. https://github.com/TypeStrong/ts-node/releases/tag/v10.8.1 |
This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [ts-node](https://typestrong.org/ts-node) ([source](https://github.com/TypeStrong/ts-node)) | devDependencies | patch | [`10.8.0` -> `10.8.1`](https://renovatebot.com/diffs/npm/ts-node/10.8.0/10.8.1) | --- ### Release Notes <details> <summary>TypeStrong/ts-node</summary> ### [`v10.8.1`](https://github.com/TypeStrong/ts-node/releases/tag/v10.8.1) [Compare Source](TypeStrong/ts-node@v10.8.0...v10.8.1) **Fixed** - Fixed [#​1769](TypeStrong/ts-node#1769): source URLs in source map cache were malformed on Windows, affecting code coverage reports ([#​1769](TypeStrong/ts-node#1769), [#​1771](TypeStrong/ts-node#1771)) [@​cspotcode](https://github.com/cspotcode) - Fixed [#​1778](TypeStrong/ts-node#1778): typechecker was erronously resolving imports from ESM files as if they were from CJS files ([#​1778](TypeStrong/ts-node#1778), [#​1782](TypeStrong/ts-node#1782)) [@​cspotcode](https://github.com/cspotcode) https://github.com/TypeStrong/ts-node/milestone/14 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). Co-authored-by: cabr2-bot <[email protected]> Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1393 Co-authored-by: Calciumdibromid Bot <[email protected]> Co-committed-by: Calciumdibromid Bot <[email protected]>
Search Terms
nodenext
Expected Behavior
tsc
andts-node
resolve to the same modules when usingnodenext
.Actual Behavior
ts-node
is resolving to thecommonjs
build of a dependency, even thoughtsc
resolves to theesm
build.Steps to reproduce the problem
Using the reproduction below, notice:
I think this has to do with the fact that
foo
is usingpackage.json
with"type": "commonjs"
to specify thecommonjs
build.If this is changed to a
cjs
file, the problem does not occurMinimal reproduction
https://github.com/perrin4869/ts-node-nodenext-bug
The text was updated successfully, but these errors were encountered: