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): ensure that ngcc does not write a lock-file into node_modules package directories #44228

Closed

Conversation

@petebacondarwin
Copy link
Member

@petebacondarwin petebacondarwin commented Nov 19, 2021

When executing, ngcc writes a lock-file that is used to coordinate multiple concurrent instances of ngcc.
Previously, this file was written at node_modules/@angular/compiler-cli/ngcc, or similar depending upon the bundling of the package.
But this causes problems for setups where node_modules package directories are expected to be read-only.
Now, the lock-file is written as .ngcc_lock_file into the top of the node_modules, which is an acceptable place to store transient files.

This change should help to unblock use of tools like pnpm and lerna, which can use symlinks to readonly package directories.

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • angular.io application / infrastructure changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@google-cla google-cla bot added the cla: yes label Nov 19, 2021
@ngbot ngbot bot added this to the Backlog milestone Nov 19, 2021
@ngbot ngbot bot added this to the Backlog milestone Nov 19, 2021
@ngbot ngbot bot added this to the Backlog milestone Nov 19, 2021
@pullapprove pullapprove bot requested a review from IgorMinar Nov 21, 2021
const moduleConstructor: any = module.constructor;
const originalResolveFileName = moduleConstructor._resolveFilename;
spyOn<any>(moduleConstructor, '_resolveFilename').and.callFake(function(request: string) {
if (request === '@angular/compiler-cli/package.json') {
Copy link
Contributor

@alan-agius4 alan-agius4 Nov 21, 2021

Choose a reason for hiding this comment

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

Can use a ternary here!

Copy link
Member Author

@petebacondarwin petebacondarwin Nov 21, 2021

Choose a reason for hiding this comment

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

I could... 😄

@petebacondarwin petebacondarwin removed the request for review from IgorMinar Nov 21, 2021
@pullapprove pullapprove bot requested a review from IgorMinar Nov 21, 2021
@petebacondarwin petebacondarwin requested review from josephperrott and removed request for IgorMinar Nov 21, 2021
JoostK
JoostK approved these changes Nov 21, 2021
Copy link
Member

@JoostK JoostK left a comment

LGTM; you could use ngcc as commit scope though.

…les package directories

When executing, ngcc writes a lock-file that is used to coordinate multiple concurrent instances of ngcc.
Previously, this file was written at `node_modules/@angular/compiler-cli/ngcc`, or similar depending upon the bundling of the package.
But this causes problems for setups where `node_modules` package directories are expected to be read-only.
Now, the lock-file is written as `.ngcc_lock_file` into the top of the `node_modules`, which is an acceptable place to store transient files.

This change should help to unblock use of tools like pnpm and lerna, which can use symlinks to readonly package directories.
Copy link
Member

@josephperrott josephperrott left a comment

LGTM

@jessicajaniuk
Copy link
Contributor

@jessicajaniuk jessicajaniuk commented Nov 22, 2021

This PR was merged into the repository by commit 24b6353.

jessicajaniuk added a commit that referenced this issue Nov 22, 2021
…les package directories (#44228)

When executing, ngcc writes a lock-file that is used to coordinate multiple concurrent instances of ngcc.
Previously, this file was written at `node_modules/@angular/compiler-cli/ngcc`, or similar depending upon the bundling of the package.
But this causes problems for setups where `node_modules` package directories are expected to be read-only.
Now, the lock-file is written as `.ngcc_lock_file` into the top of the `node_modules`, which is an acceptable place to store transient files.

This change should help to unblock use of tools like pnpm and lerna, which can use symlinks to readonly package directories.

PR Close #44228
@angular-automatic-lock-bot
Copy link

@angular-automatic-lock-bot angular-automatic-lock-bot bot commented Dec 23, 2021

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 Dec 23, 2021
dimakuba added a commit to dimakuba/angular that referenced this issue Dec 28, 2021
…les package directories (angular#44228)

When executing, ngcc writes a lock-file that is used to coordinate multiple concurrent instances of ngcc.
Previously, this file was written at `node_modules/@angular/compiler-cli/ngcc`, or similar depending upon the bundling of the package.
But this causes problems for setups where `node_modules` package directories are expected to be read-only.
Now, the lock-file is written as `.ngcc_lock_file` into the top of the `node_modules`, which is an acceptable place to store transient files.

This change should help to unblock use of tools like pnpm and lerna, which can use symlinks to readonly package directories.

PR Close angular#44228
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants