angular-cn/packages/common
crisbeto 4e35e348af refactor(ivy): generate ngFactoryDef for injectables (#32433)
With #31953 we moved the factories for components, directives and pipes into a new field called `ngFactoryDef`, however I decided not to do it for injectables, because they needed some extra logic. These changes set up the `ngFactoryDef` for injectables as well.

For reference, the extra logic mentioned above is that for injectables we have two code paths:

1. For injectables that don't configure how they should be instantiated, we create a `factory` that proxies to `ngFactoryDef`:

```
// Source
@Injectable()
class Service {}

// Output
class Service {
  static ngInjectableDef = defineInjectable({
    factory: () => Service.ngFactoryFn(),
  });

  static ngFactoryFn: (t) => new (t || Service)();
}
```

2. For injectables that do configure how they're created, we keep the `ngFactoryDef` and generate the factory based on the metadata:

```
// Source
@Injectable({
  useValue: DEFAULT_IMPL,
})
class Service {}

// Output
export class Service {
  static ngInjectableDef = defineInjectable({
    factory: () => DEFAULT_IMPL,
  });

  static ngFactoryFn: (t) => new (t || Service)();
}
```

PR Close #32433
2019-10-02 13:04:26 -07:00
..
http docs: clarify http response type (#32817) 2019-10-01 11:00:36 -07:00
locales build: remove unreferenced tsconfig-build.json files (#30858) 2019-06-05 09:03:36 -07:00
src refactor(ivy): generate ngFactoryDef for injectables (#32433) 2019-10-02 13:04:26 -07:00
test refactor(core): Migrate TestBed.get to TestBed.inject (#32382) 2019-09-09 19:10:54 -04:00
testing build: TypeScript 3.5 upgrade (#31615) 2019-07-25 17:05:23 -07:00
upgrade fix(upgrade): fix AngularJsUrlCodec to support Safari (#32959) 2019-10-02 10:00:47 -07:00
BUILD.bazel build: convert entry_point to label (#30627) 2019-06-11 00:03:11 +00:00
PACKAGE.md docs: add package doc files (#26047) 2018-10-05 15:42:14 -07:00
index.ts refactor: move angular source to /packages rather than modules/@angular 2017-03-08 16:29:27 -08:00
package.json feat: update rxjs peerDependencies minimum requirment to 6.5.3 (#32812) 2019-10-01 14:56:45 -07:00
public_api.ts build: add bazel test rules for more packages (#21053) 2017-12-22 13:10:51 -08:00