Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

externalSchematic('@schematics/update', 'update') doesn't respect order in chain() for migration #17317

Open
psmul opened this issue Mar 26, 2020 · 1 comment

Comments

@psmul
Copy link

@psmul psmul commented Mar 26, 2020

🐞 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

image

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?

@psmul psmul changed the title externalSchematic('@schematics/update', 'update') doesn't respect order for passed functions in chain() for migration Mar 26, 2020
@ngbot ngbot bot added this to the needsTriage milestone Mar 30, 2020
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Mar 30, 2020
@klemenoslaj
Copy link

@klemenoslaj klemenoslaj commented Sep 3, 2020 •

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:

return chain([
  externalSchematic('@schematics/angular', 'library', { ...options, lintFix: false }),
  !options.skipTsConfig ? overwriteLibraryTSConfigPaths(options) : noop(),
]);

With overwriteLibraryTSConfigPaths we modify the tsconfig.json paths, but it's always empty, even tho the library schematic should it's own paths there already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.