Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .devcontainer/Dockerfile

This file was deleted.

27 changes: 22 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,26 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node
{
"name": "Node.js",
"build": {
"dockerfile": "Dockerfile",
"args": {
"VARIANT": "18"
}
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/javascript-node:1-22-bookworm",

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/go:1": {}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": {
"Configure Build Tools": "sudo corepack enable npm; sudo npm install -g hereby; npm ci",
"Install pprof": "go install github.com/google/pprof@latest",
"Install Graphviz": "sudo apt install graphviz"
},

// Configure tool-specific properties.
"customizations": {
"vscode": {
"settings": {
Expand All @@ -23,5 +38,7 @@
]
}
},

// More info: https://aka.ms/dev-containers-non-root.
"remoteUser": "node"
}
8 changes: 7 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
Expand All @@ -13,3 +14,8 @@ updates:
github-actions:
patterns:
- '*'

- package-ecosystem: 'devcontainers'
directory: '/'
schedule:
interval: weekly
3 changes: 2 additions & 1 deletion src/compiler/moduleSpecifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ export function getLocalModuleSpecifierBetweenFileNames(
targetFileName: string,
compilerOptions: CompilerOptions,
host: ModuleSpecifierResolutionHost,
preferences: UserPreferences,
options: ModuleSpecifierOptions = {},
): string {
const info = getInfo(importingFile.fileName, host);
Expand All @@ -445,7 +446,7 @@ export function getLocalModuleSpecifierBetweenFileNames(
compilerOptions,
host,
importMode,
getModuleSpecifierPreferences({}, host, compilerOptions, importingFile),
getModuleSpecifierPreferences(preferences, host, compilerOptions, importingFile),
);
}

Expand Down
13 changes: 11 additions & 2 deletions src/compiler/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import {
ensureTrailingDirectorySeparator,
equateStringsCaseInsensitive,
equateStringsCaseSensitive,
exclusivelyPrefixedNodeCoreModules,
explainIfFileIsRedirectAndImpliedFormat,
ExportAssignment,
ExportDeclaration,
Expand Down Expand Up @@ -323,6 +324,7 @@ import {
TypeChecker,
typeDirectiveIsEqualTo,
TypeReferenceDirectiveResolutionCache,
unprefixedNodeCoreModules,
VariableDeclaration,
VariableStatement,
Version,
Expand Down Expand Up @@ -1758,7 +1760,7 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
let sourceFileToPackageName = new Map<Path, string>();
// Key is a file name. Value is the (non-empty, or undefined) list of files that redirect to it.
let redirectTargetsMap = createMultiMap<Path, string>();
let usesUriStyleNodeCoreModules = false;
let usesUriStyleNodeCoreModules: boolean | undefined;

/**
* map with
Expand Down Expand Up @@ -3499,7 +3501,14 @@ export function createProgram(rootNamesOrOptions: readonly string[] | CreateProg
setParentRecursive(node, /*incremental*/ false); // we need parent data on imports before the program is fully bound, so we ensure it's set here
imports = append(imports, moduleNameExpr);
if (!usesUriStyleNodeCoreModules && currentNodeModulesDepth === 0 && !file.isDeclarationFile) {
usesUriStyleNodeCoreModules = startsWith(moduleNameExpr.text, "node:");
if (startsWith(moduleNameExpr.text, "node:") && !exclusivelyPrefixedNodeCoreModules.has(moduleNameExpr.text)) {
// Presence of `node:` prefix takes precedence over unprefixed node core modules
usesUriStyleNodeCoreModules = true;
}
else if (usesUriStyleNodeCoreModules === undefined && unprefixedNodeCoreModules.has(moduleNameExpr.text)) {
// Avoid `unprefixedNodeCoreModules.has` for every import
usesUriStyleNodeCoreModules = false;
}
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4866,11 +4866,14 @@ export interface Program extends ScriptReferenceHost {
*/
redirectTargetsMap: MultiMap<Path, string>;
/**
* Whether any (non-external, non-declaration) source files use `node:`-prefixed module specifiers.
* Whether any (non-external, non-declaration) source files use `node:`-prefixed module specifiers
* (except for those that are not available without the prefix).
* `false` indicates that an unprefixed builtin module was seen; `undefined` indicates that no
* builtin modules (or only modules exclusively available with the prefix) were seen.
*
* @internal
*/
readonly usesUriStyleNodeCoreModules: boolean;
readonly usesUriStyleNodeCoreModules: boolean | undefined;
/**
* Map from libFileName to actual resolved location of the lib
* @internal
Expand Down
80 changes: 80 additions & 0 deletions src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11796,3 +11796,83 @@ export function isSideEffectImport(node: Node): boolean {
const ancestor = findAncestor(node, isImportDeclaration);
return !!ancestor && !ancestor.importClause;
}

// require('module').builtinModules.filter(x => !x.startsWith('_'))
const unprefixedNodeCoreModulesList = [
"assert",
"assert/strict",
"async_hooks",
"buffer",
"child_process",
"cluster",
"console",
"constants",
"crypto",
"dgram",
"diagnostics_channel",
"dns",
"dns/promises",
"domain",
"events",
"fs",
"fs/promises",
"http",
"http2",
"https",
"inspector",
"inspector/promises",
"module",
"net",
"os",
"path",
"path/posix",
"path/win32",
"perf_hooks",
"process",
"punycode",
"querystring",
"readline",
"readline/promises",
"repl",
"stream",
"stream/consumers",
"stream/promises",
"stream/web",
"string_decoder",
"sys",
"test/mock_loader",
"timers",
"timers/promises",
"tls",
"trace_events",
"tty",
"url",
"util",
"util/types",
"v8",
"vm",
"wasi",
"worker_threads",
"zlib",
];

/** @internal */
export const unprefixedNodeCoreModules = new Set(unprefixedNodeCoreModulesList);

// await fetch('https://nodejs.org/docs/latest/api/all.json').then(r => r.text()).then(t =>
// new Set(t.match(/(?<=')node:.+?(?=')/g))
// .difference(new Set(require('module').builtinModules.map(x => `node:${x}`))))
/** @internal */
export const exclusivelyPrefixedNodeCoreModules = new Set([
"node:sea",
"node:sqlite",
"node:test",
"node:test/reporters",
]);

/** @internal */
export const nodeCoreModules = new Set([
...unprefixedNodeCoreModulesList,
...unprefixedNodeCoreModulesList.map(name => `node:${name}`),
...exclusivelyPrefixedNodeCoreModules,
]);
59 changes: 1 addition & 58 deletions src/jsTyping/jsTyping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
hasJSFileExtension,
mapDefined,
MapLike,
nodeCoreModules,
normalizePath,
Path,
readConfigFile,
Expand Down Expand Up @@ -61,64 +62,6 @@ export function isTypingUpToDate(cachedTyping: CachedTyping, availableTypingVers
return availableVersion.compareTo(cachedTyping.version) <= 0;
}

const unprefixedNodeCoreModuleList = [
"assert",
"assert/strict",
"async_hooks",
"buffer",
"child_process",
"cluster",
"console",
"constants",
"crypto",
"dgram",
"diagnostics_channel",
"dns",
"dns/promises",
"domain",
"events",
"fs",
"fs/promises",
"http",
"https",
"http2",
"inspector",
"module",
"net",
"os",
"path",
"perf_hooks",
"process",
"punycode",
"querystring",
"readline",
"repl",
"stream",
"stream/promises",
"string_decoder",
"timers",
"timers/promises",
"tls",
"trace_events",
"tty",
"url",
"util",
"util/types",
"v8",
"vm",
"wasi",
"worker_threads",
"zlib",
];

const prefixedNodeCoreModuleList = unprefixedNodeCoreModuleList.map(name => `node:${name}`);

/** @internal */
export const nodeCoreModuleList: readonly string[] = [...unprefixedNodeCoreModuleList, ...prefixedNodeCoreModuleList];

/** @internal */
export const nodeCoreModules = new Set(nodeCoreModuleList);

/** @internal */
export function nonRelativeModuleNameForTypingCache(moduleName: string) {
return nodeCoreModules.has(moduleName) ? "node" : moduleName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11334,6 +11334,18 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Project_0_can_t_be_built_because_its_dependency_1_has_errors_6363" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Project '{0}' can't be built because its dependency '{1}' has errors]]></Val>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Project_0_can_t_be_built_because_its_dependency_1_was_not_built_6383" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Project '{0}' can't be built because its dependency '{1}' was not built]]></Val>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Project_0_is_being_forcibly_rebuilt_6388" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Project '{0}' is being forcibly rebuilt]]></Val>
Expand Down Expand Up @@ -13236,6 +13248,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Skip_building_downstream_projects_on_error_in_upstream_project_6640" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Skip building downstream projects on error in upstream project.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[跳过在上游项目出错时生成下游项目。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Skip_type_checking_all_d_ts_files_6693" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Skip type checking all .d.ts files.]]></Val>
Expand Down Expand Up @@ -13263,6 +13284,18 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Skipping_build_of_project_0_because_its_dependency_1_has_errors_6362" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Skipping build of project '{0}' because its dependency '{1}' has errors]]></Val>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Skipping_build_of_project_0_because_its_dependency_1_was_not_built_6382" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Skipping build of project '{0}' because its dependency '{1}' was not built]]></Val>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";Skipping_module_0_that_looks_like_an_absolute_URI_target_file_types_Colon_1_6164" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[Skipping module '{0}' that looks like an absolute URI, target file types: {1}.]]></Val>
Expand Down Expand Up @@ -15327,6 +15360,15 @@
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";This_operation_can_be_simplified_This_shift_is_identical_to_0_1_2_6807" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[This operation can be simplified. This shift is identical to `{0} {1} {2}`.]]></Val>
<Tgt Cat="Text" Stat="Loc" Orig="New">
<Val><![CDATA[可以简化此操作。此班次与 `{0} {1} {2}` 相同。]]></Val>
</Tgt>
</Str>
<Disp Icon="Str" />
</Item>
<Item ItemId=";This_overload_implicitly_returns_the_type_0_because_it_lacks_a_return_type_annotation_7012" ItemType="0" PsrId="306" Leaf="true">
<Str Cat="Text">
<Val><![CDATA[This overload implicitly returns the type '{0}' because it lacks a return type annotation.]]></Val>
Expand Down
Loading