Skip to content

Commit cd038f5

Browse files
devversionzarend
authored andcommitted
build: remove view engine workarounds for old APF output
Removes all View Engine workarounds that we previously needed to generate the APF package output with View Engine.
1 parent 119716e commit cd038f5

File tree

7 files changed

+6
-278
lines changed

7 files changed

+6
-278
lines changed

WORKSPACE

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,10 @@ node_repositories(
4949

5050
yarn_install(
5151
name = "npm",
52-
# We add the postinstall patches file, and ngcc main fields update script here so
53-
# that Yarn will rerun whenever one of these files has been modified.
52+
# We add the postinstall patches file here so that Yarn will rerun whenever
53+
# the file is modified.
5454
data = [
5555
"//:tools/postinstall/apply-patches.js",
56-
"//:tools/postinstall/update-ngcc-main-fields.js",
5756
],
5857
package_json = "//:package.json",
5958
quiet = False,

angular-tsconfig.json

Lines changed: 0 additions & 44 deletions
This file was deleted.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"npm": "Please use Yarn instead of NPM to install dependencies. See: https://yarnpkg.com/lang/en/docs/install/"
1515
},
1616
"scripts": {
17-
"postinstall": "node tools/postinstall/apply-patches.js && ngcc --properties module main --create-ivy-entry-points && node tools/postinstall/update-ngcc-main-fields.js",
17+
"postinstall": "node tools/postinstall/apply-patches.js",
1818
"build": "ts-node --project scripts/tsconfig.json ./scripts/build-packages-dist.ts",
1919
"build-and-check-release-output": "ts-node --project scripts/tsconfig.json scripts/build-and-check-release-output.ts",
2020
"build-docs-content": "node ./scripts/build-docs-content.js",

tools/postinstall/apply-patches.js

Lines changed: 3 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -52,69 +52,13 @@ async function main() {
5252
}
5353

5454
function applyPatches() {
55-
// Workaround for https://github.com/angular/angular/issues/18810.
56-
shelljs.exec('ngc -p angular-tsconfig.json');
57-
58-
// Workaround for: https://github.com/angular/angular/issues/32651. We just do not
59-
// generate re-exports for secondary entry-points. Similar to what "ng-packagr" does.
60-
searchAndReplace(
61-
/(?!function\s+)createMetadataReexportFile\([^)]+\);/, '',
62-
'node_modules/@angular/bazel/src/ng_package/packager.js');
63-
searchAndReplace(
64-
/(?!function\s+)createTypingsReexportFile\([^)]+\);/, '',
65-
'node_modules/@angular/bazel/src/ng_package/packager.js');
66-
6755
// Workaround for: https://github.com/angular/angular/pull/32650
6856
searchAndReplace(
69-
'var indexFile;', `
70-
var indexFile = files.find(f => f.endsWith('/public-api.ts'));
57+
'let resolvedEntryPoint = null;', `
58+
let resolvedEntryPoint = tsFiles.find(f => f.endsWith('/public-api.ts')) || null;
7159
`,
72-
'node_modules/@angular/compiler-cli/src/metadata/bundle_index_host.js');
73-
searchAndReplace(
74-
'var resolvedEntryPoint = null;', `
75-
var resolvedEntryPoint = tsFiles.find(f => f.endsWith('/public-api.ts')) || null;
76-
`,
77-
'node_modules/@angular/compiler-cli/src/ngtsc/entry_point/src/logic.js');
78-
79-
// Workaround for: https://hackmd.io/MlqFp-yrSx-0mw4rD7dnQQ?both. We only want to discard
80-
// the metadata of files in the bazel managed node modules. That way we keep the default
81-
// behavior of ngc-wrapped except for dependencies between sources of the library. This makes
82-
// the "generateCodeForLibraries" flag more accurate in the Bazel environment where previous
83-
// compilations should not be treated as external libraries. Read more about this in the document.
84-
searchAndReplace(
85-
/if \((this\.options\.generateCodeForLibraries === false)/, `
86-
const fs = require('fs');
87-
const hasFlatModuleBundle = fs.existsSync(filePath.replace('.d.ts', '.metadata.json'));
88-
if ((filePath.includes('node_modules/') || !hasFlatModuleBundle) && $1`,
89-
'node_modules/@angular/compiler-cli/src/transformers/compiler_host.js');
90-
applyPatch(path.join(__dirname, './flat_module_factory_resolution.patch'));
91-
// The three replacements below ensure that metadata files can be read by NGC and
92-
// that metadata files are collected as Bazel action inputs.
93-
searchAndReplace(
94-
/(const NGC_ASSETS = \/[^(]+\()([^)]*)(\).*\/;)/, '$1$2|metadata.json$3',
95-
'node_modules/@angular/bazel/src/ngc-wrapped/index.js');
96-
searchAndReplace(
97-
/^((\s*)results = depset\(dep.angular.summaries, transitive = \[results]\))$/m,
98-
`$1#\n$2results = depset(dep.angular.metadata, transitive = [results])`,
99-
'node_modules/@angular/bazel/src/ng_module.bzl');
100-
searchAndReplace(
101-
/^((\s*)results = depset\(target.angular\.summaries if _has_target_angular_summaries\(target\) else \[]\))$/m,
102-
`$1#\n$2results = depset(target.angular.metadata if _has_target_angular_summaries(target) else [], transitive = [results])`,
103-
'node_modules/@angular/bazel/src/ng_module.bzl');
104-
// Ensure that "metadata" of transitive dependencies can be collected.
105-
searchAndReplace(
106-
/providers\["angular"]\["metadata"] = outs\.metadata/,
107-
`$& + [m for dep in ctx.attr.deps if (hasattr(dep, "angular") and hasattr(dep.angular, "metadata")) for m in dep.angular.metadata]`,
108-
'node_modules/@angular/bazel/src/ng_module.bzl');
109-
110-
// Workaround for: https://github.com/bazelbuild/rules_nodejs/issues/1208.
111-
applyPatch(path.join(__dirname, './manifest_externs_hermeticity.patch'));
60+
'node_modules/@angular/compiler-cli/bundles/index.js');
11261

113-
// Workaround for https://github.com/angular/angular/issues/33452:
114-
searchAndReplace(
115-
/angular_compiler_options = {/, `$&
116-
"strictTemplates": True,`,
117-
'node_modules/@angular/bazel/src/ng_module.bzl');
11862

11963
// More info in https://github.com/angular/angular/pull/33786
12064
shelljs.rm('-rf', [

tools/postinstall/flat_module_factory_resolution.patch

Lines changed: 0 additions & 36 deletions
This file was deleted.

tools/postinstall/manifest_externs_hermeticity.patch

Lines changed: 0 additions & 97 deletions
This file was deleted.

tools/postinstall/update-ngcc-main-fields.js

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)