Skip to content

Commit 0fd321f

Browse files
authored
build: remove flat module bundle workaround from view engine (angular#23826)
Removes a past flat module bundle workaround that was needed when we still shipped release packages with View Engine. The Angular compiler picks the `index.ts` files as entry-point for the flat module bundles (this whole flat module construct could be removed in the future anyway). This was problematic because to avoid conflicts, the flat module out file name was set to something unique that does not conflict with the index file. The metadata JSON files for the `ng_module` targets (within our repo) then did not reside next to the `index` files, but rather next to the auto-generated flat module bundle. This broke the generation of `defineInjectable` (which was used in VE as well) calls. We worked around this in the past by patching the Angular compiler to pick the public API file instead as entry-point; allowing us to let the Angular compiler generate metadata and the bundle as `index.js` and `index.metadata.json` (ensuring the release output worked then). All of this is no longer needed with Ivy, so we can remove the workaround and unblock angular/angular#43932 (which fails due to us patching some files in the compiler-cli package)
1 parent 44ba424 commit 0fd321f

File tree

2 files changed

+1
-31
lines changed

2 files changed

+1
-31
lines changed

tools/defaults.bzl

-21
Original file line numberDiff line numberDiff line change
@@ -108,34 +108,14 @@ def ng_module(
108108
deps = [],
109109
srcs = [],
110110
tsconfig = None,
111-
flat_module_out_file = None,
112111
testonly = False,
113112
**kwargs):
114113
if not tsconfig:
115114
tsconfig = _getDefaultTsConfig(testonly)
116115

117-
# We only generate a flat module if there is a "public-api.ts" file that
118-
# will be picked up by NGC or ngtsc.
119-
needs_flat_module = "public-api.ts" in srcs
120-
121116
# Compute an AMD module name for the target.
122117
module_name = _compute_module_name(testonly)
123118

124-
# Targets which have a module name and are not used for tests, should
125-
# have a default flat module out file named "index". This is necessary
126-
# as imports to that target should go through the flat module bundle.
127-
if needs_flat_module and module_name and not flat_module_out_file and not testonly:
128-
flat_module_out_file = "index"
129-
130-
# Workaround to avoid a lot of changes to the Bazel build rules. Since
131-
# for most targets the flat module out file is "index.js", we cannot
132-
# include "index.ts" (if present) as source-file. This would resolve
133-
# in a conflict in the metadata bundler. Once we switch to Ivy and
134-
# no longer need metadata bundles, we can remove this logic.
135-
if flat_module_out_file == "index":
136-
if "index.ts" in srcs:
137-
srcs.remove("index.ts")
138-
139119
local_deps = [
140120
# Add tslib because we use import helpers for all public packages.
141121
"@npm//tslib",
@@ -155,7 +135,6 @@ def ng_module(
155135
# NodeJS executions, by activating the Bazel NodeJS linker.
156136
# See: https://github.com/bazelbuild/rules_nodejs/pull/2799.
157137
package_name = module_name,
158-
flat_module_out_file = flat_module_out_file,
159138
strict_templates = True,
160139
deps = local_deps,
161140
tsconfig = tsconfig,

tools/postinstall/apply-patches.js

+1-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const chalk = require('chalk');
1414
* Version of the post install patch. Needs to be incremented when
1515
* existing patches or edits have been modified.
1616
*/
17-
const PATCH_VERSION = 13;
17+
const PATCH_VERSION = 14;
1818

1919
/** Path to the project directory. */
2020
const projectDir = path.join(__dirname, '../..');
@@ -52,15 +52,6 @@ async function main() {
5252
}
5353

5454
function applyPatches() {
55-
// Workaround for: https://github.com/angular/angular/pull/32650
56-
searchAndReplace(
57-
'let resolvedEntryPoint = null;',
58-
`
59-
let resolvedEntryPoint = tsFiles.find(f => f.endsWith('/public-api.ts')) || null;
60-
`,
61-
'node_modules/@angular/compiler-cli/bundles/index.js',
62-
);
63-
6455
// Switches the devmode output for Angular Bazel to ES2020 target and module.
6556
applyPatch(path.join(__dirname, './devmode-es2020-bazel.patch'));
6657

0 commit comments

Comments
 (0)