Go to file
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
.circleci docs: remove/update broken links in resources appearing on aio (#42232) 2021-05-26 14:21:12 -07:00
.devcontainer build: upgrade to node 14 (#41544) 2021-04-14 09:40:17 -07:00
.github ci: update the github feature request process action and run on cron (#42337) 2021-05-26 14:22:36 -07:00
.husky build: update to husky@5 (#39739) 2020-11-18 11:11:41 -08:00
.ng-dev build: properly handle whether builds should be stamped for release (#42319) 2021-05-25 22:11:03 +00:00
.vscode build: use "outFiles" in .vscode/launch.json to speed up debugging sessions (#39848) 2020-12-17 11:23:13 -08:00
.yarn build: update to yarn v1.22.10 (#40562) 2021-01-26 10:52:27 -08:00
aio docs: clarify how declaration files can be installed (#42417) 2021-06-01 10:17:32 -07:00
dev-infra refactor(dev-infra): update to later version of @octokit/rest and remove class extenstion of Octokit (#42395) 2021-06-01 10:14:48 -07:00
docs docs: update contributor instructions for installing java (#42294) 2021-05-25 22:12:38 +00:00
goldens feat(docs-infra): implement dark mode (#41129) 2021-05-27 11:24:53 -07:00
integration build: update dependency io_bazel_rules_sass to v1.33.0 (#42210) 2021-05-21 18:05:58 +00:00
modules fix(dev-infra): update build tooling for latest changes in rules_nodejs (#40710) 2021-02-09 10:48:43 -08:00
packages fix(compiler-cli): better detect classes that are indirectly exported (#42207) 2021-06-01 12:16:46 -07:00
scripts build: use wombat-dressing-room proxy for publishing releases (#42357) 2021-05-26 17:51:12 +00:00
third_party test(core): fix `Function#name` shim used in IE11 (#41439) 2021-04-05 08:56:17 -07:00
tools build: update release configuration to use new release notes system (#41905) 2021-05-06 09:40:29 -04:00
.bazelignore test: delete integration test for language service plugin (#41740) 2021-04-23 11:00:40 -07:00
.bazelrc build: use platform from shared dev-infra package for remote execution (#41767) 2021-04-23 11:01:40 -07:00
.bazelversion build: update .bazelversion (#40579) 2021-01-26 11:35:54 -08:00
.clang-format
.editorconfig
.gitattributes test: fix ts api guardian and public guard tests on windows (#30105) 2019-04-26 16:32:22 -07:00
.gitignore fix(dev-infra): add vim .swp files to gitignore (#40094) 2020-12-14 11:39:41 -08:00
.gitmessage fix(platform-webworker): remove platform-webworker and platform-webworker-dynamic (#38846) 2020-09-30 09:13:59 -04:00
.mailmap
.npmrc build: rely on engines to prevent using npm for dependency install (#41477) 2021-04-07 12:05:01 -07:00
.nvmrc build: upgrade to node 14 (#41544) 2021-04-14 09:40:17 -07:00
.prettierrc ci: use prettier to format yml files (#42136) 2021-05-19 11:20:20 -07:00
.pullapprove.yml docs: remove VS 2015 guide (#42253) 2021-05-25 22:14:02 +00:00
.yarnrc build: update to yarn v1.22.10 (#40562) 2021-01-26 10:52:27 -08:00
BUILD.bazel build: remove `core-js` in favor of `core-js-bundle` (#41739) 2021-04-26 09:29:58 -07:00
CHANGELOG.md docs: cherry pick release notes for 12.0.2 to main (#42390) 2021-05-27 09:31:53 -07:00
CODE_OF_CONDUCT.md docs: add Discord as an official communication channel (#39149) 2020-10-14 10:23:15 -07:00
CONTRIBUTING.md docs: add link to fork repo how-to (#41266) 2021-03-23 11:22:31 -07:00
LICENSE docs: update the copyright notice date (#40707) 2021-02-16 10:04:23 -08:00
README.md docs: update tagline (#41922) 2021-05-03 10:04:05 -07:00
WORKSPACE build: update all non-major dependencies (#42077) 2021-05-18 11:08:13 -07:00
browser-providers.conf.js ci: remove IE 9 and IE 10 from CI (#38931) 2020-09-25 14:31:10 -04:00
gulpfile.js build: update release configuration to use new release notes system (#41905) 2021-05-06 09:40:29 -04:00
karma-js.conf.js build: remove `core-js` in favor of `core-js-bundle` (#41739) 2021-04-26 09:29:58 -07:00
package.json refactor(dev-infra): update to later version of @octokit/rest and remove class extenstion of Octokit (#42395) 2021-06-01 10:14:48 -07:00
renovate.json build(docs-infra): revert `watchr` to v3.0.1 to restore `docs-watch` performance (#41903) 2021-05-03 10:05:31 -07:00
test-events.js build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
test-main.js test: clean up internal testing utilities (#42177) 2021-05-26 20:07:25 +00:00
tslint.json build: fix linting against jasmine focus functions (#42415) 2021-06-01 10:16:55 -07:00
yarn.lock refactor(dev-infra): update to later version of @octokit/rest and remove class extenstion of Octokit (#42395) 2021-06-01 10:14:48 -07:00
yarn.lock.readme.md

README.md

Angular - The modern web developer's platform.

angular-logo
Angular is a development platform for building mobile and desktop web applications
using Typescript/JavaScript and other languages.

www.angular.io

Contributing Guidelines · Submit an Issue · Blog

CI status   Angular on npm   Discord conversation


Documentation

Get started with Angular, learn the fundamentals and explore advanced topics on our documentation website.

Advanced

Development Setup

Prerequisites

Setting Up a Project

Install the Angular CLI globally:

npm install -g @angular/cli

Create workspace:

ng new [PROJECT NAME]

Run the application:

cd [PROJECT NAME]
ng serve

Angular is cross-platform, fast, scalable, has incredible tooling, and is loved by millions.

Quickstart

Get started in 5 minutes.

Ecosystem

angular ecosystem logos

Changelog

Learn about the latest improvements.

Upgrading

Check out our upgrade guide to find out the best way to upgrade your project.

Contributing

Contributing Guidelines

Read through our contributing guidelines to learn about our submission process, coding rules and more.

Want to Help?

Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues labeled as help wanted or good first issue.

Code of Conduct

Help us keep Angular open and inclusive. Please read and follow our Code of Conduct.

Community

Join the conversation and help the community.

Love Angular badge

Love Angular? Give our repo a star ⬆️.