-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Make module
control impliedNodeFormat
and moduleResolution
control just module resolution
#54788
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
660bf60
Make module, not moduleResolution, the trigger for setting impliedNod…
andrewbranch 77a931b
Update baselines
andrewbranch 081a381
Reset target for less baseline change
andrewbranch d3c08b2
Set lib file content instead of changing target
andrewbranch 34cf76c
Replace lib file instead of changing target
andrewbranch 46572b0
Apply suggestions from code review
andrewbranch f346be4
Update node10Result baselines
andrewbranch 4e35976
Update src/testRunner/unittests/helpers/node10Result.ts
andrewbranch 4d47e76
Fix node10Result baselines
andrewbranch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...lines/reference/conditionalExportsResolutionFallback(moduleresolution=bundler).errors.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
[ | ||
"File '/node_modules/dep/dist/package.json' does not exist.", | ||
"Found 'package.json' at '/node_modules/dep/package.json'.", | ||
"======== Resolving module 'dep' from '/index.mts'. ========", | ||
"Explicitly specified module resolution kind: 'Bundler'.", | ||
"Resolving in CJS mode with conditions 'import', 'types'.", | ||
"File '/package.json' does not exist.", | ||
"Loading module 'dep' from 'node_modules' folder, target file types: TypeScript, JavaScript, Declaration, JSON.", | ||
"Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", | ||
"Found 'package.json' at '/node_modules/dep/package.json'.", | ||
"File '/node_modules/dep/package.json' exists according to earlier cached lookups.", | ||
"Entering conditional exports.", | ||
"Matched 'exports' condition 'import'.", | ||
"Using 'exports' subpath '.' with target './dist/index.mjs'.", | ||
|
@@ -21,6 +23,8 @@ | |
"Exiting conditional exports.", | ||
"Resolving real path for '/node_modules/dep/dist/index.d.ts', result '/node_modules/dep/dist/index.d.ts'.", | ||
"======== Module name 'dep' was successfully resolved to '/node_modules/dep/dist/index.d.ts' with Package ID 'dep/dist/[email protected]'. ========", | ||
"File '/.ts/package.json' does not exist.", | ||
"File '/package.json' does not exist according to earlier cached lookups.", | ||
"======== Resolving module '@typescript/lib-es5' from '/.src/__lib_node_modules_lookup_lib.es5.d.ts__.ts'. ========", | ||
"Explicitly specified module resolution kind: 'Node10'.", | ||
"Loading module '@typescript/lib-es5' from 'node_modules' folder, target file types: TypeScript, Declaration.", | ||
|
@@ -33,6 +37,8 @@ | |
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.", | ||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.", | ||
"======== Module name '@typescript/lib-es5' was not resolved. ========", | ||
"File '/.ts/package.json' does not exist according to earlier cached lookups.", | ||
"File '/package.json' does not exist according to earlier cached lookups.", | ||
"======== Resolving module '@typescript/lib-decorators' from '/.src/__lib_node_modules_lookup_lib.decorators.d.ts__.ts'. ========", | ||
"Explicitly specified module resolution kind: 'Node10'.", | ||
"Loading module '@typescript/lib-decorators' from 'node_modules' folder, target file types: TypeScript, Declaration.", | ||
|
@@ -45,6 +51,8 @@ | |
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.", | ||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.", | ||
"======== Module name '@typescript/lib-decorators' was not resolved. ========", | ||
"File '/.ts/package.json' does not exist according to earlier cached lookups.", | ||
"File '/package.json' does not exist according to earlier cached lookups.", | ||
"======== Resolving module '@typescript/lib-decorators/legacy' from '/.src/__lib_node_modules_lookup_lib.decorators.legacy.d.ts__.ts'. ========", | ||
"Explicitly specified module resolution kind: 'Node10'.", | ||
"Loading module '@typescript/lib-decorators/legacy' from 'node_modules' folder, target file types: TypeScript, Declaration.", | ||
|
@@ -57,6 +65,8 @@ | |
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.", | ||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.", | ||
"======== Module name '@typescript/lib-decorators/legacy' was not resolved. ========", | ||
"File '/.ts/package.json' does not exist according to earlier cached lookups.", | ||
"File '/package.json' does not exist according to earlier cached lookups.", | ||
"======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", | ||
"Explicitly specified module resolution kind: 'Node10'.", | ||
"Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", | ||
|
@@ -69,6 +79,8 @@ | |
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.", | ||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.", | ||
"======== Module name '@typescript/lib-dom' was not resolved. ========", | ||
"File '/.ts/package.json' does not exist according to earlier cached lookups.", | ||
"File '/package.json' does not exist according to earlier cached lookups.", | ||
"======== Resolving module '@typescript/lib-webworker/importscripts' from '/.src/__lib_node_modules_lookup_lib.webworker.importscripts.d.ts__.ts'. ========", | ||
"Explicitly specified module resolution kind: 'Node10'.", | ||
"Loading module '@typescript/lib-webworker/importscripts' from 'node_modules' folder, target file types: TypeScript, Declaration.", | ||
|
@@ -81,6 +93,8 @@ | |
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.", | ||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.", | ||
"======== Module name '@typescript/lib-webworker/importscripts' was not resolved. ========", | ||
"File '/.ts/package.json' does not exist according to earlier cached lookups.", | ||
"File '/package.json' does not exist according to earlier cached lookups.", | ||
"======== Resolving module '@typescript/lib-scripthost' from '/.src/__lib_node_modules_lookup_lib.scripthost.d.ts__.ts'. ========", | ||
"Explicitly specified module resolution kind: 'Node10'.", | ||
"Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: TypeScript, Declaration.", | ||
|
@@ -92,5 +106,7 @@ | |
"Loading module '@typescript/lib-scripthost' from 'node_modules' folder, target file types: JavaScript.", | ||
"Searching all ancestor node_modules directories for fallback extensions: JavaScript.", | ||
"Directory '/.src/node_modules' does not exist, skipping all lookups in it.", | ||
"======== Module name '@typescript/lib-scripthost' was not resolved. ========" | ||
"======== Module name '@typescript/lib-scripthost' was not resolved. ========", | ||
"File '/.ts/package.json' does not exist according to earlier cached lookups.", | ||
"File '/package.json' does not exist according to earlier cached lookups." | ||
] |
31 changes: 0 additions & 31 deletions
31
...elines/reference/conditionalExportsResolutionFallback(moduleresolution=node16).errors.txt
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
...ines/reference/conditionalExportsResolutionFallback(moduleresolution=nodenext).errors.txt
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait... so
module
now controls weather we interpret files as cjs/esm, but you still can't combine that withbundler
? I thought the point of this was basically to make it sobundler
could assimilate the mode-swapping interpretation? So you could mimic bundlers that more closely mimiced node?Isn't allowing
module: nodenext
+moduleResultion: bundler
for modern-node-like bundler environments kinda the goal here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Since this format data directly controls, eg, how we interpret
default
imports, the distinction may be material)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's the linked issue #54102 - shouldn't we just fix that, while we're here? It should be removing this error, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that is the ultimate goal, but I don’t think
--module nodenext
is the right thing to combine with--moduleResolution bundler
.--module nodenext
implies that CJS-mode files actually get emitted as CJS, which doesn’t make sense in the context of most bundlers. In bundlers, the choice is not between CJS and ESM; the default is ESM with Babel-like interop and.mjs
files just disable the Babel-like interop in favor of Node’s always-synthesize-a-default interop. It can be hard to tell the difference between “ESM with Babel-like interop” and “it’s actually just CJS withesModuleInterop
under the hood,” but we can tell there’s a difference because"imports"
/"exports"
conditions used in module resolution—import statements always have"import"
; they’re not secretly transformed torequire
first in CJS-mode filesrequire
calls outside of node_modules at allAdditionally, the transform for
import foo = require(...)
to acreateRequire
call under--module nodenext
is highly Node-specific and would fail under I think every bundler (maybe Webpack has compat for that; they do the most complete job at imitating Node).So, my thinking for addressing #54102 is that either there needs to be a different
module
mode for these bundlers that have Node-like interop behavior (in which case this PR is necessary but not sufficient), or the thing that makes us setimpliedNodeFormat
in the first place needs to be decoupled frommodule
(in which case this PR is not necessary, but doesn’t hurt anything as an interim step toward the eventual goal). Either way, we’ll need to move it off ofmoduleResolution
in order to resolve #54102, andmodule
will imply animpliedNodeFormat
-setting behavior if it doesn’t directly control it.