https://github.com/angular/angular
Revision b66e479cdb1e474a29ff676f10a5fcc3d7eae799 authored by JoostK on 09 January 2022, 20:23:33 UTC, committed by Dylan Hunn on 15 January 2022, 01:43:59 UTC
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
1 parent 6e04815
History
Tip revision: b66e479cdb1e474a29ff676f10a5fcc3d7eae799 authored by JoostK on 09 January 2022, 20:23:33 UTC
fix(ngcc): support element accesses for export declarations (#44669)
Tip revision: b66e479
File Mode Size
.circleci
.devcontainer
.github
.husky
.ng-dev
.vscode
.yarn
aio
docs
goldens
integration
modules
packages
scripts
third_party
tools
.bazelignore -rw-r--r-- 2.8 KB
.bazelrc -rw-r--r-- 6.7 KB
.bazelversion -rw-r--r-- 6 bytes
.clang-format -rw-r--r-- 73 bytes
.editorconfig -rw-r--r-- 245 bytes
.gitattributes -rw-r--r-- 240 bytes
.gitignore -rw-r--r-- 797 bytes
.gitmessage -rw-r--r-- 7.2 KB
.mailmap -rw-r--r-- 51 bytes
.npmrc -rw-r--r-- 21 bytes
.nvmrc -rw-r--r-- 8 bytes
.prettierrc -rw-r--r-- 157 bytes
.pullapprove.yml -rw-r--r-- 47.7 KB
.yarnrc -rw-r--r-- 130 bytes
BUILD.bazel -rw-r--r-- 2.0 KB
CHANGELOG.md -rw-r--r-- 978.7 KB
CODE_OF_CONDUCT.md -rw-r--r-- 1.1 KB
CONTRIBUTING.md -rw-r--r-- 15.8 KB
LICENSE -rw-r--r-- 1.1 KB
README.md -rw-r--r-- 4.7 KB
WORKSPACE -rw-r--r-- 2.8 KB
browser-providers.conf.js -rw-r--r-- 1.8 KB
gulpfile.js -rw-r--r-- 631 bytes
karma-js.conf.js -rw-r--r-- 6.0 KB
package.json -rw-r--r-- 8.5 KB
renovate.json -rw-r--r-- 2.5 KB
test-events.js -rw-r--r-- 259 bytes
tsconfig-tslint.json -rw-r--r-- 149 bytes
tslint.json -rw-r--r-- 4.9 KB
yarn.lock -rw-r--r-- 649.0 KB
yarn.lock.readme.md -rw-r--r-- 1.3 KB

README.md

back to top