Skip to content

Conversation

alan-agius4
Copy link
Collaborator

@alan-agius4 alan-agius4 commented May 13, 2021

With this change we enable Webpack's filesystem cache, this important because terser-webpack-plugin, css-minimizer-webpack-plugin and copy-webpack-plugin all use Webpacks' caching API to avoid additional processing during the 2nd build.

This changes causes node_modules to be treated as immutable. Webpack will avoid hashing and timestamping them, assume the version is unique and will use it as a snapshot.

To opt-in using the experimental persistent build cache use theNG_PERSISTENT_BUILD_CACHE environment variable.

NG_PERSISTENT_BUILD_CACHE=1 ng serve

@google-cla google-cla bot added the cla: yes label May 13, 2021
@alan-agius4 alan-agius4 changed the title wip! look away perf(@angular-devkit/build-angular): use file system cache May 17, 2021
@alan-agius4 alan-agius4 marked this pull request as ready for review May 17, 2021 11:17
@alan-agius4 alan-agius4 added the needs: discussion On the agenda for team meeting to determine next steps label May 17, 2021
@alan-agius4 alan-agius4 removed the needs: discussion On the agenda for team meeting to determine next steps label Jun 8, 2021
@alan-agius4 alan-agius4 added the target: minor This PR is targeted for the next minor release label Jun 8, 2021
@alan-agius4 alan-agius4 changed the title perf(@angular-devkit/build-angular): use file system cache perf(@angular-devkit/build-angular): enable opt-in usage of file system cache Jun 8, 2021
@alan-agius4 alan-agius4 requested a review from clydin June 8, 2021 11:37
@alan-agius4 alan-agius4 requested a review from clydin June 11, 2021 14:12
…em cache

With this change we enable Webpack's filesystem cache, this important because `terser-webpack-plugin`, `css-minimizer-webpack-plugin` and `copy-webpack-plugin` all use Webpacks' caching API to avoid additional processing during the 2nd cold build.

This changes causes `node_modules` to be treated as immutable. Webpack will avoid hashing and timestamping them, assume the version is unique and will use it as a snapshot.

To opt-in using the experimental persistent build cache use the`NG_PERSISTENT_BUILD_CACHE` environment variable.

```
NG_PERSISTENT_BUILD_CACHE=1 ng serve
```
@alan-agius4 alan-agius4 added the action: merge The PR is ready for merge by the caretaker label Jun 11, 2021
@clydin clydin merged commit f90a832 into angular:master Jun 11, 2021
@alan-agius4 alan-agius4 deleted the cache-css-optimizations branch June 11, 2021 17:04
@splincode
Copy link

@alan-agius4 hi!, what do you think about support additional property in angularCompilerOptions?

so that caching can be easily configured

tsconfig.json

{
  "angularCompilerOptions": {
     // ...
     persistentBuildCache: true
  }
}

@alan-agius4
Copy link
Collaborator Author

Hi @splincode,

This is not really a compiler option, so angular.json would be a better place. That said, we did discuss this and for the time being we don't want to add this to the API for a number of reasons.

  • Having this in an file will make it harder to opt-in/opt-out in different environments
  • This is a still experimental. We want to understand the impact of this and if in v13 we should abandon, turn it on by default, or leave it as opt-in.

@AFDevMike
Copy link

Can anyone confirm this will (potentially) improve --prod / --configuration production as well?

@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 28, 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 target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants