Skip to content

build: remove devmode tsickle decorator processing workaround #19405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
6 changes: 0 additions & 6 deletions src/bazel-tsconfig-build.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@
// Note: We can remove this once we fully switched away from Gulp. Currently we still set
// some options here just in favor of the standard tsconfig's which extending this one.
"suppressTsconfigOverrideWarnings": true,

// Enable tsickle so that decorators are processed by tsickle. This is necessary because
// we don't want to ship JavaScript files that contain references to DOM elements. This
// breaks server-side rendering for non-CLI projects: see: angular#30586.
"tsickle": true,

// See https://github.com/angular/angular/issues/29107
"devmodeTargetOverride": "es5"
}
Expand Down
5 changes: 0 additions & 5 deletions src/bazel-tsconfig-test.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
},
"bazelOptions": {
"suppressTsconfigOverrideWarnings": true,

// Disable tsickle. Tsickle is only needed for building library code that will be
// shipped through npm packages. This should speed up compilation for tests.
"tsickle": false,

// See https://github.com/angular/angular/issues/29107
"devmodeTargetOverride": "es5"
}
Expand Down
9 changes: 9 additions & 0 deletions src/universal-app/prerender.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import 'reflect-metadata';
import 'zone.js';

// We need to mock a few native DOM globals as those are not present on the server, but they
// are required for decorator metadata. The View Engine compiler preserves Angular decorator
// metadata in the JS output. This could mean for example that inputs which are typed to
// `HTMLElement` break on the server, as the `__decorate` call requires the `HTMLElement`
// global to be present. More details: https://github.com/angular/angular/issues/30586.
(global as any).HTMLElement = {};
(global as any).Event = {};
(global as any).TransitionEvent = {};

import {renderModuleFactory} from '@angular/platform-server';
import {readFileSync, writeFileSync} from 'fs';
import {join} from 'path';
Expand Down
15 changes: 0 additions & 15 deletions tools/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,25 +1,10 @@
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")

package(default_visibility = ["//visibility:public"])

exports_files([
"system-config-tmpl.js",
"system-rxjs-operators.js",
])

# Custom "tsc_wrapped" binary that has "tsickle" available as runtime dependency.
# This is needed as the default compiler for a "ts_library" does not have a dependency
# on "tsickle" by default.
nodejs_binary(
name = "tsc_wrapped_with_tsickle",
data = [
"@npm//@bazel/typescript",
"@npm//tsickle",
],
entry_point = "@npm//:node_modules/@bazel/typescript/internal/tsc_wrapped/tsc_wrapped.js",
install_source_map_support = False,
)

# Workaround for https://github.com/bazelbuild/bazel-toolchains/issues/356. We need the
# "SYS_ADMIN" capability in order to run browsers with sandbox enabled.
platform(
Expand Down
4 changes: 0 additions & 4 deletions tools/defaults.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ def ts_library(tsconfig = None, deps = [], testonly = False, **kwargs):
_ts_library(
tsconfig = tsconfig,
testonly = testonly,
# The default "ts_library" compiler does not come with "tsickle" available. Since
# we have targets that use "tsickle" decorator processing, we need to ensure that
# the compiler could load "tsickle" if needed.
compiler = "//tools:tsc_wrapped_with_tsickle",
deps = local_deps,
**kwargs
)
Expand Down
14 changes: 0 additions & 14 deletions tools/postinstall/apply-patches.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,6 @@ shelljs.cd(projectDir);
// Workaround for https://github.com/angular/angular/issues/18810.
shelljs.exec('ngc -p angular-tsconfig.json');

// Workaround for https://github.com/angular/angular/issues/30586. It's not possible to
// enable tsickle decorator processing without enabling import rewriting to closure.
// This replacement allows us to enable decorator processing without rewriting imports.
searchAndReplace(
/(this\.transformTypesToClosure) = bazelOpts\.tsickle;/, '$1 = false;',
'node_modules/@bazel/typescript/internal/tsc_wrapped/compiler_host.js');

// Workaround for https://github.com/angular/angular/issues/32389. We need to ensure
// that tsickle is available for esm5 output re-compilations.
searchAndReplace(
'@npm//@bazel/typescript/bin:tsc_wrapped',
'@angular_material//tools:tsc_wrapped_with_tsickle',
'node_modules/@angular/bazel/src/esm5.bzl');

// Workaround for: https://github.com/angular/angular/issues/32651. We just do not
// generate re-exports for secondary entry-points. Similar to what "ng-packagr" does.
searchAndReplace(
Expand Down