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(compiler-cli): readConfiguration existing options should override options in tsconfig #40694

Closed
wants to merge 6 commits into from
Closed

fix(compiler-cli): readConfiguration existing options should override options in tsconfig #40694

wants to merge 6 commits into from

Conversation

alan-agius4
Copy link
Contributor

@alan-agius4 alan-agius4 commented Feb 3, 2021

fix(compiler-cli): extend angularCompilerOptions in tsconfig from node
TypeScript supports non rooted extends, we should do the same

https://github.com/microsoft/TypeScript/blob/b346f5764e4d500ebdeff7086e43690ea533a305/src/compiler/commandLineParser.ts#L2603-L2628

Closes: #36715

refactor(bazel): use readConfiguration to read config file
With this change we clean up the parsing of tsconfig files.

fix(compiler-cli): readConfiguration existing options should override options in tsconfig
At the moment, when passing an Angular Compiler option
in the existingOptions it doesn't override the defined in the TSConfig.

@alan-agius4 alan-agius4 added area: compiler Issues related to `ngc`, Angular's template compiler target: patch This PR is targeted for the next patch release labels Feb 3, 2021
@ngbot ngbot bot added this to the Backlog milestone Feb 3, 2021
@google-cla google-cla bot added the cla: yes label Feb 3, 2021
@alan-agius4 alan-agius4 marked this pull request as ready for review February 4, 2021 11:06
@pullapprove pullapprove bot requested a review from JoostK February 4, 2021 11:07
@alan-agius4 alan-agius4 requested review from petebacondarwin and removed request for petebacondarwin February 4, 2021 11:07
Copy link
Member

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

Ugh, I hate how convoluted this whole area of code is.
I appreciate that this is not the fault of this PR.
But I wonder if we ought to take this opportunity to clean it up rather than patching it after the fact, which is basically what we are doing in this PR.

As I understand it there are "TypeScript" configurations and "Angular" configurations.
We have to effectively parse the tsconfig.json twice with two different tools to extract each.
On top of this the caller can pass in an object of programmatically defined existingOptions which should override those that appear in the tsconfig.json. But since this existingOptions (despite the typing) can contain Angular options too, we have to do this overriding twice.

So I think that the config object should only contain Angular options and the parsed.options should only contain TypeScript options.

I believe that the call to ts.parseJsonConfigFileContent() should already override the TypeScript options with those from existingOptions but I think that this will not apply the Angular parts of existingOptions over the top of those in config.

So I think that the right thing to do is to fix the config object so that it has the Angular options overridden by those in existingOptions before passing it to createNgCompilerOptions(), which should not have to care about overriding.

Does that sound right?

packages/compiler-cli/src/perform_compile.ts Outdated Show resolved Hide resolved
packages/compiler-cli/src/perform_compile.ts Outdated Show resolved Hide resolved
packages/compiler-cli/test/perform_compile_spec.ts Outdated Show resolved Hide resolved
@alan-agius4 alan-agius4 marked this pull request as draft February 4, 2021 16:49
@alan-agius4 alan-agius4 marked this pull request as ready for review February 4, 2021 18:05
@alan-agius4 alan-agius4 added the action: review The PR is still awaiting reviews from at least one requested reviewer label Feb 4, 2021
Copy link
Member

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

LGTM - just a couple of suggested refactorings.

packages/bazel/src/ngc-wrapped/index.ts Outdated Show resolved Hide resolved
packages/compiler-cli/src/perform_compile.ts Outdated Show resolved Hide resolved
packages/compiler-cli/src/perform_compile.ts Outdated Show resolved Hide resolved
@alan-agius4 alan-agius4 removed the request for review from JoostK February 8, 2021 13:56
@pullapprove pullapprove bot requested a review from JoostK February 8, 2021 13:56
@alan-agius4
Copy link
Contributor Author

@petebacondarwin updated.

Copy link
Member

@josephperrott josephperrott left a comment

Choose a reason for hiding this comment

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

LGTM

Reviewed-For: bazel

packages/compiler-cli/src/perform_compile.ts Outdated Show resolved Hide resolved
packages/compiler-cli/src/perform_compile.ts Outdated Show resolved Hide resolved
packages/compiler-cli/src/perform_compile.ts Outdated Show resolved Hide resolved
packages/bazel/src/ngc-wrapped/index.ts Outdated Show resolved Hide resolved
packages/bazel/src/ngc-wrapped/index.ts Outdated Show resolved Hide resolved
packages/compiler-cli/src/perform_compile.ts Outdated Show resolved Hide resolved
packages/compiler-cli/src/perform_compile.ts Outdated Show resolved Hide resolved
packages/compiler-cli/src/perform_compile.ts Outdated Show resolved Hide resolved
@alan-agius4 alan-agius4 added action: presubmit The PR is in need of a google3 presubmit and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Feb 9, 2021
@AndrewKushnir AndrewKushnir added state: blocked and removed action: merge The PR is ready for merge by the caretaker labels Feb 10, 2021
@alan-agius4
Copy link
Contributor Author

alan-agius4 commented Feb 10, 2021

I can re-add that method although I prefer not to, but if it’s widely used in G3 I will be easier.

@AndrewKushnir
Copy link
Contributor

AndrewKushnir commented Feb 11, 2021

@alan-agius4 FYI I've started a new presubmit (+ TGP) after @kyliau submitted an internal refactoring to avoid using createNgCompilerOptions function (thanks Keen!). Will keep this thread updated.

@AndrewKushnir AndrewKushnir added action: merge The PR is ready for merge by the caretaker and removed action: presubmit The PR is in need of a google3 presubmit labels Feb 11, 2021
@AndrewKushnir
Copy link
Contributor

@alan-agius4 FYI presubmits were successful for the changes in this PR, adding the "merge" label back. Thank you.

@kyliau
Copy link
Contributor

kyliau commented Feb 11, 2021

thanks @AndrewKushnir !

@alan-agius4
Copy link
Contributor Author

Thanks @AndrewKushnir & @kyliau for your help.

josephperrott pushed a commit that referenced this pull request Feb 11, 2021
With this change we clean up the parsing of tsconfig files.

PR Close #40694
@alan-agius4 alan-agius4 deleted the read-config-existing-options branch February 11, 2021 21:31
zarend pushed a commit that referenced this pull request Mar 1, 2021
…de options in tsconfig (#40694) (#41036)

At the moment, when passing an Angular Compiler option
in the `existingOptions` it doesn't override the defined in the TSConfig.

PR Close #40694

(cherry picked from commit b7c4d07)

PR Close #41036
zarend pushed a commit that referenced this pull request Mar 1, 2021
…#41036)

With this change we clean up the parsing of tsconfig files.

PR Close #40694

(cherry picked from commit 719f9ef)

PR Close #41036
zarend pushed a commit that referenced this pull request Mar 1, 2021
@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 Mar 14, 2021
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 area: compiler Issues related to `ngc`, Angular's template compiler cla: yes target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support extend angularCompilerOptions in tsconfig from absolute tsconfig
6 participants