Repository navigation
fix(ivy): reuse compilation scope for incremental template changes. - #31932
petebacondarwin wants to merge 1 commit into
Conversation
277e9d6 to
96062e9
Compare
96062e9 to
2dc3172
Compare
There was a problem hiding this comment.
Use .has for map key presence and not || null
There was a problem hiding this comment.
Honestly, I think that this results in more verbose, ugly and less clear code:
getScopeForComponent(clazz: ClassDeclaration): LocalModuleScope|null {
const metadata = this.metadata.has(clazz.getSourceFile()) ?
this.metadata.get(clazz.getSourceFile()) ! :
null;
return metadata && metadata.componentScope.has(clazz) ? metadata.componentScope.get(clazz) ! :
null;
}Notice the repetition and the need to use the ! operator.
I think it is fair to use has() when the type of the stored object could be falsy. But where a falsy return from get() can only mean the value was not there, then I think it is better to avoid the extra call to has().
There was a problem hiding this comment.
Slightly cleaner version, which I can accept:
getScopeForComponent(clazz: ClassDeclaration): LocalModuleScope|null {
if (!this.metadata.has(clazz.getSourceFile())) {
return null;
}
const metadata = this.metadata.get(clazz.getSourceFile()) !;
if (!metadata.componentScope.has(clazz)) {
return null;
}
return metadata.componentScope.get(clazz) !;
}There was a problem hiding this comment.
I live for the day .has() will narrow the type of a subsequent .get() 😁
There was a problem hiding this comment.
OOC wouldn't doing just a get be more performant anyway if you need the value? I see has for the use case of just testing whether or not a key exists without needing the actual value.
There was a problem hiding this comment.
Can you file a JIRA and add a TODO here...
Remote scoping is gonna be tricky. If a component requires remote scoping, it means that the component's template changing requires the module to be re-emitted. Also, we need to make sure the cycle detector works well across rebuilds. Incremental compilation is ugly.
There was a problem hiding this comment.
Previously if only a component template changed then we would know to rebuild its component source file. But the compilation was incorrect if the component was part of an NgModule, since we were not capturing the compilation scope information that had a been acquired from the NgModule and was not being regenerated since we were not needing to recompile the NgModule. Now we register compilation scope information for each component, via the `ComponentScopeRegistry` interface, so that it is available for incremental compilation. The `ComponentDecoratorHandler` now reads the compilation scope from a `ComponentScopeReader` interface which is implemented as a compound reader composed of the original `LocalModuleScopeRegistry` and the `IncrementalState`. Fixes angular#31654
55ae1cf to
d643043
Compare
…ngular#31932) Previously if only a component template changed then we would know to rebuild its component source file. But the compilation was incorrect if the component was part of an NgModule, since we were not capturing the compilation scope information that had a been acquired from the NgModule and was not being regenerated since we were not needing to recompile the NgModule. Now we register compilation scope information for each component, via the `ComponentScopeRegistry` interface, so that it is available for incremental compilation. The `ComponentDecoratorHandler` now reads the compilation scope from a `ComponentScopeReader` interface which is implemented as a compound reader composed of the original `LocalModuleScopeRegistry` and the `IncrementalState`. Fixes angular#31654 PR Close angular#31932
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Previously if only a component template changed then we would know to
rebuild its component source file. But the compilation was incorrect if the
component was part of an NgModule, since we were not capturing the
compilation scope information that had a been acquired from the NgModule
and was not being regenerated since we were not needing to recompile
the NgModule.
Now we register compilation scope information for each component, via the
ComponentScopeRegistryinterface, so that it is available for incrementalcompilation.
The
ComponentDecoratorHandlernow reads the compilation scope from aComponentScopeReaderinterface which is implemented as a compoundreader composed of the original
LocalModuleScopeRegistryand theIncrementalState.Fixes #31654