Skip to content

Commit 8127185

Browse files
authored
build: remove devmode tsickle decorator processing workaround (#19405)
In the past, we added a workaround for angular/angular#30586, so that tsickle actually runs on the devmode output. We can remove this since there is a more simpler workaround until View Engine is completely gone. Ivy is supposed to fix this unless the output format is modified to preserve TS decorator calls. If that would be the case (it's not at time of writing), then we can still use the global mocking (which is not that unreasonable), or wire up build optimizer (which would be quite complicated in Bazel).
1 parent 5506d0f commit 8127185

File tree

6 files changed

+9
-44
lines changed

6 files changed

+9
-44
lines changed

src/bazel-tsconfig-build.json

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,6 @@
3535
// Note: We can remove this once we fully switched away from Gulp. Currently we still set
3636
// some options here just in favor of the standard tsconfig's which extending this one.
3737
"suppressTsconfigOverrideWarnings": true,
38-
39-
// Enable tsickle so that decorators are processed by tsickle. This is necessary because
40-
// we don't want to ship JavaScript files that contain references to DOM elements. This
41-
// breaks server-side rendering for non-CLI projects: see: angular#30586.
42-
"tsickle": true,
43-
4438
// See https://github.com/angular/angular/issues/29107
4539
"devmodeTargetOverride": "es5"
4640
}

src/bazel-tsconfig-test.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@
99
},
1010
"bazelOptions": {
1111
"suppressTsconfigOverrideWarnings": true,
12-
13-
// Disable tsickle. Tsickle is only needed for building library code that will be
14-
// shipped through npm packages. This should speed up compilation for tests.
15-
"tsickle": false,
16-
1712
// See https://github.com/angular/angular/issues/29107
1813
"devmodeTargetOverride": "es5"
1914
}

src/universal-app/prerender.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
import 'reflect-metadata';
22
import 'zone.js';
33

4+
// We need to mock a few native DOM globals as those are not present on the server, but they
5+
// are required for decorator metadata. The View Engine compiler preserves Angular decorator
6+
// metadata in the JS output. This could mean for example that inputs which are typed to
7+
// `HTMLElement` break on the server, as the `__decorate` call requires the `HTMLElement`
8+
// global to be present. More details: https://github.com/angular/angular/issues/30586.
9+
(global as any).HTMLElement = {};
10+
(global as any).Event = {};
11+
(global as any).TransitionEvent = {};
12+
413
import {renderModuleFactory} from '@angular/platform-server';
514
import {readFileSync, writeFileSync} from 'fs';
615
import {join} from 'path';

tools/BUILD.bazel

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,10 @@
1-
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
2-
31
package(default_visibility = ["//visibility:public"])
42

53
exports_files([
64
"system-config-tmpl.js",
75
"system-rxjs-operators.js",
86
])
97

10-
# Custom "tsc_wrapped" binary that has "tsickle" available as runtime dependency.
11-
# This is needed as the default compiler for a "ts_library" does not have a dependency
12-
# on "tsickle" by default.
13-
nodejs_binary(
14-
name = "tsc_wrapped_with_tsickle",
15-
data = [
16-
"@npm//@bazel/typescript",
17-
"@npm//tsickle",
18-
],
19-
entry_point = "@npm//:node_modules/@bazel/typescript/internal/tsc_wrapped/tsc_wrapped.js",
20-
install_source_map_support = False,
21-
)
22-
238
# Workaround for https://github.com/bazelbuild/bazel-toolchains/issues/356. We need the
249
# "SYS_ADMIN" capability in order to run browsers with sandbox enabled.
2510
platform(

tools/defaults.bzl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,6 @@ def ts_library(tsconfig = None, deps = [], testonly = False, **kwargs):
4141
_ts_library(
4242
tsconfig = tsconfig,
4343
testonly = testonly,
44-
# The default "ts_library" compiler does not come with "tsickle" available. Since
45-
# we have targets that use "tsickle" decorator processing, we need to ensure that
46-
# the compiler could load "tsickle" if needed.
47-
compiler = "//tools:tsc_wrapped_with_tsickle",
4844
deps = local_deps,
4945
**kwargs
5046
)

tools/postinstall/apply-patches.js

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,6 @@ shelljs.cd(projectDir);
2929
// Workaround for https://github.com/angular/angular/issues/18810.
3030
shelljs.exec('ngc -p angular-tsconfig.json');
3131

32-
// Workaround for https://github.com/angular/angular/issues/30586. It's not possible to
33-
// enable tsickle decorator processing without enabling import rewriting to closure.
34-
// This replacement allows us to enable decorator processing without rewriting imports.
35-
searchAndReplace(
36-
/(this\.transformTypesToClosure) = bazelOpts\.tsickle;/, '$1 = false;',
37-
'node_modules/@bazel/typescript/internal/tsc_wrapped/compiler_host.js');
38-
39-
// Workaround for https://github.com/angular/angular/issues/32389. We need to ensure
40-
// that tsickle is available for esm5 output re-compilations.
41-
searchAndReplace(
42-
'@npm//@bazel/typescript/bin:tsc_wrapped',
43-
'@angular_material//tools:tsc_wrapped_with_tsickle',
44-
'node_modules/@angular/bazel/src/esm5.bzl');
45-
4632
// Workaround for: https://github.com/angular/angular/issues/32651. We just do not
4733
// generate re-exports for secondary entry-points. Similar to what "ng-packagr" does.
4834
searchAndReplace(

0 commit comments

Comments
 (0)