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 doesn't work for globally installed nested dependencies #18098

Closed
1 of 15 tasks
bmayen opened this issue Jul 1, 2020 · 4 comments
Closed
1 of 15 tasks
Labels
area: devkit/schematics freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix
Milestone

Comments

@bmayen
Copy link

bmayen commented Jul 1, 2020

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, this previously worked in v8

Description

Using "externalSchematic" on a collection defined in a dependency of a custom schematic, does not work when the custom schematic is installed globally. Globally installed npm packages are not flattened/deduped and the nested collection dependency is not found by "externalSchematic".

🔬 Minimal Reproduction

Running ng new -c schematic-1.

"schematic-1" is installed globally (npm i schematic-1 -g) and has an npm dependency on "schematic-2".

Under the global node_modules folder, "schematic-1" has a nested node_modules folder containing "schematic-2". If installed locally, npm will flatten the dependencies and "schematic-1" and "schematic-2" will be siblings, but a global install will nest "schematic-2" under "schematic-1".

"schematic-1" calls externalSchematic('schematic-2', 'ng-add', options), from ng new.

When installed globally, this fails with "Collection schematic-2 cannot be resolved" When installed locally, and dependencies are flatted, this succeeds.

🔥 Exception or Error

Collection schematic-2 cannot be resolved

🌍 Your Environment

Angular CLI: 9.1.9
Node: 10.21.0
OS: darwin x64

Angular:
...
Ivy Workspace:

Package Version

@angular-devkit/architect 0.901.9
@angular-devkit/core 9.1.9
@angular-devkit/schematics 9.1.9
@schematics/angular 9.1.9
@schematics/update 0.901.9
rxjs 6.5.4

@alan-agius4 alan-agius4 added area: devkit/schematics freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix labels Jul 1, 2020
@ngbot ngbot bot modified the milestone: Backlog Jul 1, 2020
@bmayen
Copy link
Author

bmayen commented Jul 2, 2020

@alan-agius4, if someone can point me in the right direction, I can look into submitting a PR for this.

Where is the code that loads up the available collections under node_modules? Guessing the issue is that it doesn't look under the nested node_modules folder.

@bmayen
Copy link
Author

bmayen commented Sep 17, 2020

With v11 on the horizon, are there any plans to address this regression? Or perhaps a suggestion for a better workaround? Currently, we have Schematics shared across multiple teams and external contractors and all are forced to install these Schematics locally in a parent folder whenever they need to run ng new.

clydin added a commit to clydin/angular-cli that referenced this issue Sep 17, 2020
…uesting collection

This change first attempts to resolve a schematic referenced via the external schematic rule from the requesting schematic collection.  This allows schematic packages that are direct dependencies of another schematic package to be used with the external schematic rule without manual package resolution code within the schematic.

Closes angular#18098
Closes angular#11026
@bmayen
Copy link
Author

bmayen commented Sep 18, 2020

🎉 Thank you!

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: devkit/schematics freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix
Projects
None yet
Development

No branches or pull requests

2 participants