angular/packages/compiler-cli/ngcc/src
JoostK cfd67c1c81 refactor(compiler-cli): track a dependency on a default import on WrappedNodeExpr (#41586)
Previously, the `DefaultImportRecorder` interface was used as follows:

1. During the analysis phase, the default import declaration of an
   identifier was recorded.

2. During the emit phase each emitted identifier would be recorded.
   The information from step 1 would then be used to determine the
   default import declaration of the identifier which would be
   registered as used.

3. A TypeScript transform would taint all default imports that were
   registered as used in step 2 such that the imports are not elided
   by TypeScript.

In incremental compilations, a file may have to be emitted even if its
analysis data has been reused from the prior compilation. This would
mean that step 1 is not executed, resulting in a mismatch in step 2 and
ultimately in incorrectly eliding the default. This was mitigated by
storing the mapping from identifier to import declaration on the
`ts.SourceFile` instead of a member of `DefaultImportTracker` such that
it would also be visible to the `DefaultImportRecorder` of subsequent
compiles even if step 1 had not been executed.

Ultimately however, the information that is being recorded into the
`DefaultImportRecorder` has a longer lifetime than a single
`DefaultImportRecorder` instance, as that is only valid during a single
compilation whereas the identifier to import declaration mapping
outlives a single compilation. This commit replaces the registration of
this mapping by attaching the default import declaration on the output
AST node that captures the identifier. This enables the removal of
all of the `DefaultImportRecorder` usages throughout the analysis phase
together with the `DefaultImportRecorder` interface itself.

PR Close #41586
2021-04-13 07:37:29 -07:00
..
analysis refactor(compiler-cli): track a dependency on a default import on WrappedNodeExpr (#41586) 2021-04-13 07:37:29 -07:00
dependencies refactor(compiler-cli): update to use new file-system interfaces (#40281) 2021-01-08 09:34:44 -08:00
entry_point_finder fix(compiler-cli): ensure ngcc can handle wildcard base-paths (#41033) 2021-03-01 15:25:44 -08:00
execution fix(ngcc): do not compile JavaScript sources if typings-only processing is repeated (#41209) 2021-03-16 09:33:54 -07:00
host docs: remove duplicated the (#40434) 2021-01-14 11:33:57 -08:00
locking refactor(compiler-cli): update to use new file-system interfaces (#40281) 2021-01-08 09:34:44 -08:00
migrations refactor(compiler-cli): implement DeclarationNode node type (#38959) 2020-10-12 08:32:46 -07:00
packages refactor(ngcc): support processing only the typings files of packages (#40976) 2021-02-24 14:23:14 -08:00
rendering fix(compiler-cli): set TS original node on imported namespace identifiers (#40711) 2021-02-11 15:58:25 -08:00
writing fix(compiler-cli): update type castings for JSON.parse usage (#40710) 2021-02-09 10:48:46 -08:00
command_line_options.ts refactor(ngcc): support processing only the typings files of packages (#40976) 2021-02-24 14:23:14 -08:00
constants.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
main.ts refactor(ngcc): support processing only the typings files of packages (#40976) 2021-02-24 14:23:14 -08:00
ngcc_options.ts refactor(ngcc): support processing only the typings files of packages (#40976) 2021-02-24 14:23:14 -08:00
path_mappings.ts refactor(compiler-cli): update to use new file-system interfaces (#40281) 2021-01-08 09:34:44 -08:00
utils.ts refactor(compiler-cli): update to use new file-system interfaces (#40281) 2021-01-08 09:34:44 -08:00