angular/packages/compiler-cli/src/transformers
JoostK 75afd80ae8 refactor(compiler): add @nocollapse annotation using a synthetic comment (#35932)
In Ivy, Angular decorators are compiled into static fields that are
inserted into a class declaration in a TypeScript transform. When
targeting Closure compiler such fields need to be annotated with
`@nocollapse` to prevent them from being lifted from a static field into
a variable, as that would prevent the Ivy runtime from being able to
find the compiled definitions.

Previously, there was a bug in TypeScript where synthetic comments added
in a transform would not be emitted at all, so as a workaround a global
regex-replace was done in the emit's `writeFile` callback that would add
the `@nocollapse` annotation to all static Ivy definition fields. This
approach is no longer possible when ngtsc is running as TypeScript
plugin, as a plugin cannot control emit behavior.

The workaround is no longer necessary, as synthetic comments are now
properly emitted, likely as of
https://github.com/microsoft/TypeScript/pull/22141 which has been
released with TypeScript 2.8.

This change is required for running ngtsc as TypeScript plugin in
Bazel's `ts_library` rule, to move away from the custom `ngc_wrapped`
approach.

Resolves FW-1952

PR Close #35932
2020-04-01 15:37:06 -07:00
..
api.ts refactor(ivy): introduce the 'core' package and split apart NgtscProgram (#34887) 2020-01-24 08:59:59 -08:00
compiler_host.ts fix(compiler-cli): add sass as a valid css preprocessor extension (#35052) 2020-01-31 13:28:39 -08:00
entry_points.ts Revert "Revert "Revert "perf(compiler): skip type check and emit in bazel in some cases. (#19646)""" 2017-10-12 16:09:49 -07:00
inline_resources.ts build(compiler-cli): enable full TypeScript strictness (#29436) 2019-03-21 12:14:39 -04:00
lower_expressions.ts build: typescript 3.8 support (#35864) 2020-03-10 17:51:20 -04:00
metadata_cache.ts fix(compiler-cli): strictMetadataEmit should not break on non-compliant libraries (#23275) 2018-04-09 15:35:23 -07:00
metadata_reader.ts fix(compiler-cli): propagate ts.SourceFile moduleName into metadata 2017-12-01 14:19:06 -08:00
node_emitter.ts refactor(compiler): add @nocollapse annotation using a synthetic comment (#35932) 2020-04-01 15:37:06 -07:00
node_emitter_transform.ts refactor(compiler): add @nocollapse annotation using a synthetic comment (#35932) 2020-04-01 15:37:06 -07:00
program.ts refactor(compiler): add @nocollapse annotation using a synthetic comment (#35932) 2020-04-01 15:37:06 -07:00
r3_metadata_transform.ts feat(compiler-cli): reflect static methods added to classes in metadata (#21926) 2018-02-01 08:30:58 -08:00
r3_strip_decorators.ts feat(ivy): @NgModule -> ngInjectorDef compilation (#22458) 2018-03-16 12:57:11 -07:00
r3_transform.ts refactor(compiler): add @nocollapse annotation using a synthetic comment (#35932) 2020-04-01 15:37:06 -07:00
util.ts feat: change @Injectable() to support tree-shakeable tokens (#22005) 2018-02-12 14:34:59 -08:00