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

fix(ngcc): report a warning if ngcc tries to use a solution-style tsconfig #38003

Conversation

petebacondarwin
Copy link
Member

In CLI v10 there was a move to use the new solution-style tsconfig
which became available in TS 3.9. The result of this is that the standard
tsconfig.json, which ngcc (and ngc and tsc) infer if not given a explicit
tsconfig file path no longer contains important information such as
"paths" mappings, which ngcc might need to correctly compute
dependencies.

This commit logs a warning in this case to inform the developer
that they might not have meant to load this tsconfig and offer
alternative options.

Fixes #36386

@petebacondarwin petebacondarwin added type: bug/fix action: review The PR is still awaiting reviews from at least one requested reviewer severity1: confusing target: patch This PR is targeted for the next patch release labels Jul 10, 2020
@ngbot ngbot bot modified the milestone: needsTriage Jul 10, 2020
@pullapprove pullapprove bot requested a review from JoostK July 10, 2020 15:45
@petebacondarwin petebacondarwin force-pushed the ngcc-solution-style-tsconfig-handling branch from 0cd55d6 to bcbb39f Compare July 10, 2020 15:51
Copy link
Member

@JoostK JoostK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type in commit message: "a explicit" -> "an explicit"

packages/compiler-cli/ngcc/src/ngcc_options.ts Outdated Show resolved Hide resolved
packages/compiler-cli/ngcc/src/ngcc_options.ts Outdated Show resolved Hide resolved
packages/compiler-cli/ngcc/src/ngcc_options.ts Outdated Show resolved Hide resolved
@JoostK JoostK added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jul 10, 2020
packages/compiler-cli/ngcc/src/ngcc_options.ts Outdated Show resolved Hide resolved
@@ -112,6 +112,7 @@ export interface ParsedConfiguration {
project: string;
options: api.CompilerOptions;
rootNames: string[];
projectReferences?: readonly ts.ProjectReference[]|undefined;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't come up with a cleaner way for ngcc to work out whether this tsconfig was solution-style. I didn't want to do the computation here and have a flag (like isSolutionStyleConfig).

But if ngc wanted to do something similar there might be value with moving the test from ngcc to here...

…onfig

In CLI v10 there was a move to use the new solution-style tsconfig
which became available in TS 3.9.

The result of this is that the standard tsconfig.json no longer contains
important information such as "paths" mappings, which ngcc might need to
correctly compute dependencies.

ngcc (and ngc and tsc) infer the path to tsconfig.json if not given an
explicit tsconfig file-path. But now that means it infers the solution
tsconfig rather than one that contains the useful information it used to
get.

This commit logs a warning in this case to inform the developer
that they might not have meant to load this tsconfig and offer
alternative options.

Fixes angular#36386
@petebacondarwin petebacondarwin force-pushed the ngcc-solution-style-tsconfig-handling branch from bcbb39f to 98d03ff Compare July 10, 2020 17:46
@petebacondarwin petebacondarwin force-pushed the ngcc-solution-style-tsconfig-handling branch from 9ba3331 to 6670b17 Compare July 10, 2020 17:51
@petebacondarwin petebacondarwin added action: merge The PR is ready for merge by the caretaker action: presubmit The PR is in need of a google3 presubmit and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Jul 10, 2020
@alxhub
Copy link
Member

alxhub commented Jul 10, 2020

Presubmit

Copy link
Contributor

@alan-agius4 alan-agius4 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@atscott atscott removed action: presubmit The PR is in need of a google3 presubmit cla: yes labels Jul 14, 2020
atscott pushed a commit that referenced this pull request Jul 14, 2020
…onfig (#38003)

In CLI v10 there was a move to use the new solution-style tsconfig
which became available in TS 3.9.

The result of this is that the standard tsconfig.json no longer contains
important information such as "paths" mappings, which ngcc might need to
correctly compute dependencies.

ngcc (and ngc and tsc) infer the path to tsconfig.json if not given an
explicit tsconfig file-path. But now that means it infers the solution
tsconfig rather than one that contains the useful information it used to
get.

This commit logs a warning in this case to inform the developer
that they might not have meant to load this tsconfig and offer
alternative options.

Fixes #36386

PR Close #38003
@atscott atscott closed this in b358495 Jul 14, 2020
@petebacondarwin petebacondarwin deleted the ngcc-solution-style-tsconfig-handling branch July 15, 2020 15:39
@rhysowen9
Copy link

I think it would be beneficial to update the Angular Ivy guide to explain which tsconfig file to specify.
The current docs explain that ngcc is beneficial, but as soon as I add it, I start getting this ⬆️ new warning.

@petebacondarwin
Copy link
Member Author

@rhysowen9 - how are you running ngcc? What is the content of the warning that you get? It should be listing the paths to the possible tsconfigs that you can choose. It would be normal to run ngcc against the "app" config (possibly tsconfig.app.json) but exactly which file would depend upon your set up. If you are using Angular CLI then you should not need to run ngcc yourself, since it takes care of that (including passing the appropriate tsconfig path).

@rhysowen9
Copy link

rhysowen9 commented Jul 20, 2020

@petebacondarwin ,

I believe that ngcc was added to our package.json file when upgrading from Angular 8 to Angular 9 back in February (would have been done using ng update).

It is a postinstall script which specifies --properties es2015 browser module main --first-only --create-ivy-entry-points.

Now that we have upgraded to Angular 10, and updated to the latest patch, we are getting the warning introduced by this PR.

We've stripped --create-ivy-entry-points and set --tsconfig ./src/tsconfig.app.json which seems to be working fine, but I can't say I fully understand this side of Angular, so this is nothing more than a best guess as the docs don't seem to offer much clarity.

@petebacondarwin
Copy link
Member Author

Please feel free to remove this postinstall hook, as long as you are using CLI for building your app.

@maxisam
Copy link
Contributor

maxisam commented Jul 22, 2020

Please feel free to remove this postinstall hook, as long as you are using CLI for building your app.

Could you explain why we can remove that postinstall hook? It is still in the document

https://update.angular.io/#9.0:10.0l3

If you depend on many Angular libraries you may consider speeding up your build by invoking the ngcc (Angular Compatibility Compiler) in an npm postinstall script via small change to your package.json.

@bhanna1693
Copy link

Please feel free to remove this postinstall hook, as long as you are using CLI for building your app.

I agree with @maxisam. The postinstall script is "recommended" in both the angular documentation and the angular update guides. Can we get clarification?

@petebacondarwin
Copy link
Member Author

Currently our docs do not recommend running ngcc as a postinstall hook, except for a particular scenario related to Angular Universal: https://angular.io/guide/ivy#ivy-and-universalapp-shell.
I agree that we should fix the update site. I have already created an issue there for it: angular/angular-update-guide#76

@bhanna1693
Copy link

@petebacondarwin ah you're right, I misread that page i guess. Thank you for the help!

@petebacondarwin
Copy link
Member Author

No problem. Sorry for the confusion

@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 Aug 23, 2020
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
…onfig (angular#38003)

In CLI v10 there was a move to use the new solution-style tsconfig
which became available in TS 3.9.

The result of this is that the standard tsconfig.json no longer contains
important information such as "paths" mappings, which ngcc might need to
correctly compute dependencies.

ngcc (and ngc and tsc) infer the path to tsconfig.json if not given an
explicit tsconfig file-path. But now that means it infers the solution
tsconfig rather than one that contains the useful information it used to
get.

This commit logs a warning in this case to inform the developer
that they might not have meant to load this tsconfig and offer
alternative options.

Fixes angular#36386

PR Close angular#38003
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes target: patch This PR is targeted for the next patch release type: bug/fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Angular 9 (Ivy) App build with local library (mono-repo) failing
9 participants