angular-cn/packages
Alex Rickabaugh e039075a28 fix(compiler-cli): better detect classes that are indirectly exported (#42207)
The compiler flag `compileNonExportedClasses` allows the Angular compiler to
process classes which are not exported at the top level of a source file.
This is often used to allow for AOT compilation of test classes inside
`it()` test blocks, for example.

Previously, the compiler would identify exported classes by looking for an
`export` modifier on the class declaration itself. This works for the
trivial case, but fails for indirectly exported classes:

```typescript
// Component is declared unexported.
@Component({...})
class FooCmp {...}

// Indirect export of FooCmp
export {FooCmp};
```

This is not an immediate problem for most application builds, since the
default value for `compileNonExportedClasses` is `true` and therefore such
classes get compiled regardless.

However, in the Angular Language Service now, `compileNonExportedClasses` is
forcibly overridden to `false`. That's because the tsconfig used by the IDE
and Language Service is often far broader than the application build's
configuration, and pulls in test files that can contain unexported classes
not designed with AOT compilation in mind.

Therefore, the Language Service has trouble working with such structures.

In this commit, the `ReflectionHost` gains a new API for detecting whether a
class is exported. The implementation of this method now not only considers
the `export` modifier, but also scans the `ts.SourceFile` for indirect
exports like the example above. This ensures the above case will be
processed directly in the Language Service.

This new operation is cached using an expando symbol on the `ts.SourceFile`,
ensuring good performance even when scanning large source files with lots of
exports (e.g. a FESM file under `ngcc`).

Fixes #42184.

PR Close #42207
2021-06-01 12:16:46 -07:00
..
animations fix(platform-browser): update started state on reset (#41608) 2021-05-25 20:28:41 +00:00
bazel build(bazel): update supported range of node versions to be less restrictive (#42205) 2021-05-25 17:48:45 +00:00
benchpress test: clean up internal testing utilities (#42177) 2021-05-26 20:07:25 +00:00
common test: clean up internal testing utilities (#42177) 2021-05-26 20:07:25 +00:00
compiler test: clean up internal testing utilities (#42177) 2021-05-26 20:07:25 +00:00
compiler-cli fix(compiler-cli): better detect classes that are indirectly exported (#42207) 2021-06-01 12:16:46 -07:00
core docs: list supported values for `read` in decorator metadata (#42370) 2021-06-01 10:12:23 -07:00
docs docs: remove/update broken links in resources appearing on aio (#42232) 2021-05-26 14:21:12 -07:00
elements build(elements): update supported range of node versions to be less restrictive (#42205) 2021-05-25 17:48:45 +00:00
examples build: fix linting against jasmine focus functions (#42415) 2021-06-01 10:16:55 -07:00
forms test: clean up internal testing utilities (#42177) 2021-05-26 20:07:25 +00:00
language-service build(language-service): update supported range of node versions to be less restrictive (#42205) 2021-05-25 17:48:46 +00:00
localize build(localize): update supported range of node versions to be less restrictive (#42205) 2021-05-25 17:48:46 +00:00
misc/angular-in-memory-web-api build: remove `core-js` in favor of `core-js-bundle` (#41739) 2021-04-26 09:29:58 -07:00
platform-browser test: clean up internal testing utilities (#42177) 2021-05-26 20:07:25 +00:00
platform-browser-dynamic test: clean up internal testing utilities (#42177) 2021-05-26 20:07:25 +00:00
platform-server build(platform-server): update supported range of node versions to be less restrictive (#42205) 2021-05-25 17:48:46 +00:00
private/testing docs: convert the last `my-app` components to `app-root` (#42256) 2021-05-25 22:13:36 +00:00
router docs: expand documentation for ROUTES (#42398) 2021-05-27 16:47:39 -07:00
service-worker build(service-worker): update supported range of node versions to be less restrictive (#42205) 2021-05-25 17:48:46 +00:00
upgrade build(upgrade): update supported range of node versions to be less restrictive (#42205) 2021-05-25 17:48:46 +00:00
zone.js build: lock file maintenance (#42120) 2021-05-19 09:20:53 -07:00
BUILD.bazel build: replace @types/trusted-types dep with minimal type defs (#39211) 2020-10-15 09:08:00 -07:00
README.md
circular-deps-test.conf.js fix(platform-webworker): remove platform-webworker and platform-webworker-dynamic (#38846) 2020-09-30 09:13:59 -04:00
empty.ts
goog.d.ts
license-banner.txt docs: update year (#40925) 2021-02-22 12:37:40 -08:00
system.d.ts
tsconfig-build-no-strict.json
tsconfig-build.json
tsconfig-test.json
tsconfig.json build: exclude compiler compliance tests from Saucelabs tests (#41866) 2021-04-30 14:15:10 -07:00
types.d.ts build: replace @types/trusted-types dep with minimal type defs (#39211) 2020-10-15 09:08:00 -07:00

README.md

Angular

The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.

Usage information and reference details can be found in Angular documentation.

License: MIT