Skip to content
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

moduleResolution: node12 support #45884

Merged
merged 31 commits into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c416aa9
Initial support for module: node12
weswigham Jun 8, 2021
34812f0
Add allowJs and declaration emit enabled tests
weswigham Jun 8, 2021
b447ed7
Fix typos
weswigham Jul 12, 2021
9b83a2e
cts, mts, cjs, mjs, etc extension support
weswigham Jul 6, 2021
44675c9
Merge branch 'main' into module-node
weswigham Aug 26, 2021
55d0728
Merge branch 'module-node' into mjscjs-support
weswigham Aug 26, 2021
e6a386c
Fix watch of files whose intepretation changes due to a package.json …
weswigham Aug 26, 2021
fd2190f
Merge branch 'main' into module-node
weswigham Sep 1, 2021
13e76d7
Merge branch 'module-node' into mjscjs-support
weswigham Sep 1, 2021
b12315f
Minor PR feedback
weswigham Sep 1, 2021
15e1904
Adjust error message
weswigham Sep 1, 2021
093002c
Initial import/export/self-name support
weswigham Sep 14, 2021
4ab3f7e
Merge branch 'main' into module-node
weswigham Sep 15, 2021
a092fd3
Merge branch 'module-node' into mjscjs-support
weswigham Sep 15, 2021
5bf44ac
Accept new error codes
weswigham Sep 15, 2021
859abb6
Merge branch 'mjscjs-support' into imports-exports-selfs
weswigham Sep 15, 2021
c21cb48
TypesVersions support in export/import map conditions
weswigham Sep 15, 2021
9294633
Fix import suggestion and autoimport default extensions under new res…
weswigham Sep 20, 2021
c776453
Add tests for import maps non-relative name lookup feature
weswigham Sep 20, 2021
ae83938
Fix isDeclarationFileName for .d.mts and .d.cts
weswigham Sep 20, 2021
8ab7517
Preserve new extensions when generating module specifiers
weswigham Sep 20, 2021
222ba00
Fix spurious implict any suggestion caused by file ordering bug and o…
weswigham Sep 21, 2021
408ef20
Fix a bunch of incremental bugs that dont repro under fourslash for s…
weswigham Sep 21, 2021
6aaa681
Merge branch 'main' into module-node
weswigham Sep 21, 2021
21b73e8
Accept updated baseline
weswigham Sep 21, 2021
c160805
Merge branch 'module-node' into mjscjs-support
weswigham Sep 21, 2021
44b81b2
Merge branch 'mjscjs-support' into imports-exports-selfs
weswigham Sep 21, 2021
4a33975
Always include extensions on completions for cjs/mjs style imports
weswigham Sep 21, 2021
76afb79
String completion relative import suggestions respect the mode of the…
weswigham Sep 21, 2021
0891db4
Style feedback
weswigham Sep 23, 2021
a2e799a
Change diagnostic case
weswigham Sep 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2374,7 +2374,7 @@ namespace ts {

function checkStrictModeLabeledStatement(node: LabeledStatement) {
// Grammar checking for labeledStatement
if (inStrictMode && options.target! >= ScriptTarget.ES2015) {
if (inStrictMode && getEmitScriptTarget(options) >= ScriptTarget.ES2015) {
if (isDeclarationStatement(node.statement) || isVariableStatement(node.statement)) {
errorOnFirstToken(node.label, Diagnostics.A_label_is_not_allowed_here);
}
Expand Down
18 changes: 13 additions & 5 deletions src/compiler/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,14 @@ namespace ts {
Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
state.seenAffectedFiles = state.seenAffectedFiles || new Set();
}
if (useOldState) {
// Any time the interpretation of a source file changes, mark it as changed
forEachEntry(oldState!.fileInfos, (info, sourceFilePath) => {
if (state.fileInfos.has(sourceFilePath) && state.fileInfos.get(sourceFilePath)!.impliedFormat !== info.impliedFormat) {
state.changedFilesSet.add(sourceFilePath);
}
});
}

state.buildInfoEmitPending = !!state.changedFilesSet.size;
return state;
Expand Down Expand Up @@ -744,13 +752,13 @@ namespace ts {
const actualSignature = signature ?? value.signature;
return value.version === actualSignature ?
value.affectsGlobalScope ?
{ version: value.version, signature: undefined, affectsGlobalScope: true } :
{ version: value.version, signature: undefined, affectsGlobalScope: true, impliedFormat: value.impliedFormat } :
value.version :
actualSignature !== undefined ?
signature === undefined ?
value :
{ version: value.version, signature, affectsGlobalScope: value.affectsGlobalScope } :
{ version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope };
{ version: value.version, signature, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat } :
{ version: value.version, signature: false, affectsGlobalScope: value.affectsGlobalScope, impliedFormat: value.impliedFormat };
});

let referencedMap: ProgramBuildInfoReferencedMap | undefined;
Expand Down Expand Up @@ -1243,10 +1251,10 @@ namespace ts {

export function toBuilderStateFileInfo(fileInfo: ProgramBuildInfoFileInfo): BuilderState.FileInfo {
return isString(fileInfo) ?
{ version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined } :
{ version: fileInfo, signature: fileInfo, affectsGlobalScope: undefined, impliedFormat: undefined } :
isString(fileInfo.signature) ?
fileInfo as BuilderState.FileInfo :
{ version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope };
{ version: fileInfo.version, signature: fileInfo.signature === false ? undefined : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
}

export function createBuildProgramUsingProgramBuildInfo(program: ProgramBuildInfo, buildInfoPath: string, host: ReadBuildProgramHost): EmitAndSemanticDiagnosticsBuilderProgram {
Expand Down
5 changes: 3 additions & 2 deletions src/compiler/builderState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ namespace ts {
readonly version: string;
signature: string | undefined;
affectsGlobalScope: boolean | undefined;
impliedFormat: number | undefined;
}

export interface ReadonlyManyToManyPathMap {
Expand Down Expand Up @@ -332,7 +333,7 @@ namespace ts {
}
}
}
fileInfos.set(sourceFile.resolvedPath, { version, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined });
fileInfos.set(sourceFile.resolvedPath, { version, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) || undefined, impliedFormat: sourceFile.impliedNodeFormat });
}

return {
Expand Down Expand Up @@ -433,7 +434,7 @@ namespace ts {
);
const firstDts = firstOrUndefined(emitOutput.outputFiles);
if (firstDts) {
Debug.assert(fileExtensionIs(firstDts.name, Extension.Dts), "File extension for signature expected to be dts", () => `Found: ${getAnyExtensionFromPath(firstDts.name)} for ${firstDts.name}:: All output files: ${JSON.stringify(emitOutput.outputFiles.map(f => f.name))}`);
Debug.assert(fileExtensionIsOneOf(firstDts.name, [Extension.Dts, Extension.Dmts, Extension.Dcts]), "File extension for signature expected to be dts", () => `Found: ${getAnyExtensionFromPath(firstDts.name)} for ${firstDts.name}:: All output files: ${JSON.stringify(emitOutput.outputFiles.map(f => f.name))}`);
latestSignature = (computeHash || generateDjb2Hash)(firstDts.text);
if (exportedModulesMapCache && latestSignature !== prevSignature) {
updateExportedModules(sourceFile, emitOutput.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
Expand Down
Loading