angular/packages/compiler-cli/ngcc/test
JoostK b66e479cdb fix(ngcc): support element accesses for export declarations (#44669)
Bundlers like Rollup may use an element access expression for an export
declaration, which causes ngcc to ignore those export declarations possibly
resulting in incomplete processing of packages.

Element access syntax may be used when the declared name is not considered
as valid JS identifier, but bundlers may be conservative in determining whether
an identifier can be used (to emit a property access) and opt for a string
literal in an element access instead.

The element access syntax introduces a problem for ngcc, where it wouldn't
consider such export as class declaration, causing them to be skipped. The
ngtsc compiler is implemented with the assumption that all class declarations
use a `ts.Identifier` as name, whereas the element access is using a string
literal for the declared name. This makes it troublesome for ngcc to support
this syntax form in UMD bundles.

To work around the problem, this function transforms these access expressions
into regular property accesses. The source text is parsed to an AST to allow
finding the element accesses in a robust way, after which the affected text
ranges are replaced with property accesses in the original source text.

Closes #44037

PR Close #44669
2022-01-14 17:43:59 -08:00
..
analysis refactor(ngcc): remove Ivy switch marker transform (#43891) 2021-11-24 19:26:25 +00:00
dependencies fix(ngcc): correctly resolve UMD dependencies (#44381) 2021-12-07 08:33:00 -05:00
entry_point_finder fix(compiler-cli): ensure ngcc can handle wildcard base-paths (#41033) 2021-03-01 15:25:44 -08:00
execution feat(core): support TypeScript 4.5 (#44164) 2021-11-30 11:59:02 -05:00
helpers fix(ngcc): support element accesses for export declarations (#44669) 2022-01-14 17:43:59 -08:00
host test(ngcc): run more tests against more supported UMD formats (#44245) 2021-11-29 12:38:05 -05:00
integration fix(ngcc): support element accesses for export declarations (#44669) 2022-01-14 17:43:59 -08:00
locking fix(ngcc): ensure that ngcc does not write a lock-file into node_modules package directories (#44228) 2021-11-22 17:55:13 +00:00
migrations refactor: make all imports compatible with ESM/CJS output. (#43431) 2021-10-01 18:28:45 +00:00
packages fix(ngcc): support element accesses for export declarations (#44669) 2022-01-14 17:43:59 -08:00
rendering fix(ngcc): correctly resolve UMD dependencies (#44381) 2021-12-07 08:33:00 -05:00
writing refactor(ngcc): support processing only the typings files of packages (#40976) 2021-02-24 14:23:14 -08:00
BUILD.bazel build: switch devmode output to es2015 (#44505) 2022-01-05 23:20:20 +00:00
ngcc_options_spec.ts refactor(compiler-cli): do not use __filename or __dirname global for ESM compatibility (#43431) 2021-10-01 18:28:45 +00:00
utils_spec.ts refactor: make all imports compatible with ESM/CJS output. (#43431) 2021-10-01 18:28:45 +00:00