externalSchematic('@schematics/update', 'update') doesn't respect order in chain() for migration
See original GitHub issueπ Bug report
Command (mark with an x
)
- new
- build
- serve
- test
- e2e
- generate
- add
- update (schematics)
- lint
- xi18n
- run
- config
- help
- version
- doc
Is this a regression?
Only tested with ^0.900.0
Description
For given snippet:
export function migrate(): Rule {
return chain([
externalSchematic('@schematics/update', 'update', {
packages: ['@nguniversal/express-engine'],
from: '8.0.0',
to: '9.0.0',
}),
removeImportsInMainServerFile(),
]);
}
Both functions are invoked almost immediately, as provided in the screenshot below. If I understand correctly, chain() method containing externalSchematics with @schematics/update should respect the order and finish migration and then invoke another function in order. Tried approach with translating tree to observable in the second function, however, the outcome is the same. Looks like @schematics/update performs this asynchronously, causing the next functions to be invoked immediately. I havenβt noticed this behavior for other migrations or schematics from Angular collections (like creating an app, component, service etc.).
π¬ Minimal Reproduction
Create simple migration containing externalSchematic(β@schematics/updateβ, βupdateβ) for any given library.
π₯ Exception or Error
The red highlighted area is separate function that should be invoked after @schematics/update for the library has been completed.
π Your Environment
Angular CLI: 9.0.7
Node: 10.16.0
OS: win32 x64
Angular: 9.0.7
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, localize, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker
Ivy Workspace: Yes
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.900.7
@angular-devkit/build-angular 0.900.7
@angular-devkit/build-ng-packagr 0.900.7
@angular-devkit/build-optimizer 0.900.7
@angular-devkit/build-webpack 0.900.7
@angular-devkit/core 9.0.7
@angular-devkit/schematics 9.0.7
@ngtools/webpack 9.0.7
@nguniversal/builders 9.0.2
@nguniversal/common 9.0.2
@nguniversal/express-engine 9.0.2
@schematics/angular 9.0.7
@schematics/update 0.900.7
ng-packagr 9.0.3
rxjs 6.5.4
typescript 3.7.5
webpack 4.41.2
Anything else relevant?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5
@iKrishnaSahu Appreciate mentioning me to this thread! Sadly we havenβt found another solution, so we decided to do things other way. At least we know we shouldnβt wait for any update in this case.
Potentially I have the same problem with a custom schematic (not a migration). Please let me know if this should be a separate issue.
In my example I have the following code:
With
overwriteLibraryTSConfigPaths
we modify the tsconfig.jsonpaths
, but itβs always empty, even tho thelibrary
schematic should itβs own paths there already.