angular-docs-cn/packages/platform-browser-dynamic
Alex Rickabaugh 235a235fab feat: change @Injectable() to support tree-shakeable tokens (#22005)
This commit bundles 3 important changes, with the goal of enabling tree-shaking
of services which are never injected. Ordinarily, this tree-shaking is prevented
by the existence of a hard dependency on the service by the module in which it
is declared.

Firstly, @Injectable() is modified to accept a 'scope' parameter, which points
to an @NgModule(). This reverses the dependency edge, permitting the module to
not depend on the service which it "provides".

Secondly, the runtime is modified to understand the new relationship created
above. When a module receives a request to inject a token, and cannot find that
token in its list of providers, it will then look at the token for a special
ngInjectableDef field which indicates which module the token is scoped to. If
that module happens to be in the injector, it will behave as if the token
itself was in the injector to begin with.

Thirdly, the compiler is modified to read the @Injectable() metadata and to
generate the special ngInjectableDef field as part of TS compilation, using the
PartialModules system.

Additionally, this commit adds several unit and integration tests of various
flavors to test this change.

PR Close #22005
2018-02-12 14:34:59 -08:00
..
src feat: change @Injectable() to support tree-shakeable tokens (#22005) 2018-02-12 14:34:59 -08:00
test build: Remove angular_src nested workspace (#21096) 2018-01-19 10:17:37 -08:00
testing build: move repeated tsconfig attributes to a macro (#20964) 2018-01-10 12:30:19 -08:00
BUILD.bazel build: move repeated tsconfig attributes to a macro (#20964) 2018-01-10 12:30:19 -08:00
index.ts build: publish tree of files rather than FESMs (#18541) 2017-08-31 15:34:50 -07:00
package.json build: roll up to named .js files rather than 'index.js' (#19190) 2017-09-19 16:59:18 -07:00
public_api.ts build: publish tree of files rather than FESMs (#18541) 2017-08-31 15:34:50 -07:00
rollup.config.js refactor: make all rollup config ES5 compatible (#20028) 2017-10-30 23:09:17 -04:00
tsconfig-build.json build: remove references to `tsc-wrapped` (#19298) 2017-09-21 13:55:52 -07:00