Skip to content

Commit abfef99

Browse files
committed
build: update dev-infra build tooling and properly handle builtin node: imports (angular#48521)
* Updates build-tooling to benefit from the latest `spec_bundle` improvements. * Updates the ESM extension loader to not attempt adding extensions to builtin `node:` specifiers. This seems to be disallowed and cannot be handled gracefully (the attempts are part of a try/catch). ``` Use --sandbox_debug to see verbose messages from the sandbox Error [ERR_UNKNOWN_BUILTIN_MODULE]: No such built-in module: node:fs.mjs at new NodeError (node:internal/errors:371:5) at ESMLoader.builtinStrategy (node:internal/modules/esm/translators:276:11) at ESMLoader.moduleProvider (node:internal/modules/esm/loader:236:14) ``` PR Close angular#48521
1 parent 13d3039 commit abfef99

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
},
180180
"// 2": "devDependencies are not used under Bazel. Many can be removed after test.sh is deleted.",
181181
"devDependencies": {
182-
"@angular/build-tooling": "https://github.com/angular/dev-infra-private-build-tooling-builds.git#e1aec534818208328b29a76cfe9892c2a031ed94",
182+
"@angular/build-tooling": "https://github.com/angular/dev-infra-private-build-tooling-builds.git#700b36f4887bdd4c82332f7ce0e407d19cd9a644",
183183
"@angular/ng-dev": "https://github.com/angular/dev-infra-private-ng-dev-builds.git#05278122c48e06eff8e5398d59c49ed6688c949b",
184184
"@bazel/bazelisk": "^1.7.5",
185185
"@bazel/buildifier": "^5.0.0",

tools/esm-interop/esm-extension-loader.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
const explicitExtensionRe = /\.[mc]?js$/;
1010
const explicitJsExtensionRe = /\.js$/;
11+
const builtinNamespaceImportRe = /^node:/;
1112

1213
/*
1314
* NodeJS resolver that enables the interop with the current Bazel setup.
@@ -34,7 +35,9 @@ export async function resolve(specifier, context, nextResolve) {
3435
interopAttempts.push(specifier.replace(explicitJsExtensionRe, '.mjs'));
3536
}
3637

37-
if (!explicitExtensionRe.test(specifier)) {
38+
// If there is no explicit extension and we are not dealing with a
39+
// builtin namespace module, attempt various subpaths to prioritize ESM.
40+
if (!explicitExtensionRe.test(specifier) && !builtinNamespaceImportRe.test(specifier)) {
3841
interopAttempts.push(`${specifier}.mjs`);
3942
interopAttempts.push(`${specifier}/index.mjs`);
4043
// Last attempts are normal `.js` extensions. These could still

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@
149149
"@angular/core" "^13.0.0 || ^14.0.0-0"
150150
reflect-metadata "^0.1.13"
151151

152-
"@angular/build-tooling@https://github.com/angular/dev-infra-private-build-tooling-builds.git#e1aec534818208328b29a76cfe9892c2a031ed94":
153-
version "0.0.0-30acfb31077ddc552b6be501516833ec234ce5c1"
154-
resolved "https://github.com/angular/dev-infra-private-build-tooling-builds.git#e1aec534818208328b29a76cfe9892c2a031ed94"
152+
"@angular/build-tooling@https://github.com/angular/dev-infra-private-build-tooling-builds.git#700b36f4887bdd4c82332f7ce0e407d19cd9a644":
153+
version "0.0.0-bc7bf8bfc84492f04d18dc1cbf4b7547e51c3786"
154+
resolved "https://github.com/angular/dev-infra-private-build-tooling-builds.git#700b36f4887bdd4c82332f7ce0e407d19cd9a644"
155155
dependencies:
156156
"@angular-devkit/build-angular" "15.1.0-next.2"
157157
"@angular/benchpress" "0.3.0"

0 commit comments

Comments
 (0)