Repository navigation
fix(import-elision): keep an @Inject token's import the file also uses as a value elsewhere - #606
Conversation
…as a value elsewhere An import used in @Inject(TOKEN) was elided as decorator-only unless the walk of other value uses saw it, and that walk skipped exported consts, functions and other statements: `export const providers = [{ provide: TOKEN }]` lost its import. A name is now decorator-only when every value reference to it is inside a decorator compilation removes.
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Brooooooklyn
left a comment
There was a problem hiding this comment.
Thanks! A small follow-up (aliased @Inject) is coming right after this merges.
|
Follow-up for aliased |
With
advancedOptimizations(no class metadata), an import used in a constructor's@Inject(TOKEN)is elided as decorator-only, since compilation removes the decorator. But it was elided even when the file also usesTOKENas a value elsewhere:The factory gets
i1.SSR_RENDER_STATEthrough a namespace import, but the named import was removed, soprovidersreferenced an undefinedSSR_RENDER_STATEand the bundle threw when loaded. The other value uses were collected by a walk that only looked at classes, plain top-levelconsts and expression statements; an exportedconst, a function, a block orexport defaultwere missed.Now a name is decorator-only when every value reference to it (from the semantic model) is inside a decorator compilation removes: the reference ids within Angular's constructor parameter decorators and
declareproperties' decorators. The walk still proposes the candidates; the references confirm them.test_inject_token_used_elsewhere_in_the_file_is_keptcovers an exported const, an exported and a local function,export default, a block and another class's static property; each kept the import only with the change. The existing elision tests pass unchanged.