question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

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?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
psmulcommented, Dec 21, 2021

@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.

1reaction
klemenoslajcommented, Sep 12, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ng update not running migration.json schematic - Stack Overflow
I have an ng-update folder with index.ts : import { Rule, SchematicContext, SchematicsException, Tree } from "@angular-devkit/schematics";Β ...
Read more >
The Website Migration Guide: SEO Strategy, Process ... - Moz
A site migration is a term broadly used by SEO professionals to describe any event whereby a website undergoes substantial changes in areas...
Read more >
Angular Schematics – The Solution to All Your Problems
Updates and breaking changes. @ErinJZimmer ... npm install -g @angular-devkit/schematics-cli ... package.json - provide path to schematic collection.
Read more >
Troubleshooting the GitLab chart
This is to ensure that the application does not malfunction to the schema ... After migrating a Helm 2 release to Helm 3,...
Read more >
A guide to international refugee protection and building state ...
Promote Respect for International Humanitarian Law, in particular Senator ... to maintain a clear distinction between refugees and migrants,Β ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found