angular-cn/packages/compiler-cli/test/ngtsc
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
..
fake_core feat(ivy): use the schema registry to check DOM bindings (#32171) 2019-08-22 10:12:45 -07:00
BUILD.bazel build: remove redundant `@types/source-map` dependency (#31468) 2019-07-11 17:18:12 -04:00
component_indexing_spec.ts feat(ivy): index template references, variables, bound attributes/events (#31535) 2019-07-25 13:09:10 -07:00
env.ts fix(ivy): capture template source mapping details during preanalysis (#32544) 2019-09-09 19:10:34 -04:00
incremental_spec.ts fix(ivy): reuse compilation scope for incremental template changes. (#31932) 2019-08-09 10:50:40 -07:00
ngtsc_spec.ts refactor(ivy): generate ngFactoryDef for injectables (#32433) 2019-10-02 13:04:26 -07:00
scope_spec.ts feat(ivy): translate type-check diagnostics to their original source (#30181) 2019-07-25 16:36:32 -07:00
sourcemap_utils.ts refactor(ivy): implement a virtual file-system layer in ngtsc + ngcc (#30921) 2019-06-25 16:25:24 -07:00
template_mapping_spec.ts refactor(ivy): implement a virtual file-system layer in ngtsc + ngcc (#30921) 2019-06-25 16:25:24 -07:00
template_typecheck_spec.ts fix(ivy): capture template source mapping details during preanalysis (#32544) 2019-09-09 19:10:34 -04:00