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

Support cache with external dependencies #1033

Merged
merged 8 commits into from
Sep 2, 2024

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Aug 26, 2024

Please Read the CONTRIBUTING Guidelines
In particular the portion on Commit Message Formatting

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior? (You can also link to an open issue here)
The babel-loader cache is disabled when there are external dependencies registered from the Babel plugin API addExternalDependencies

What is the new behavior?
Still enable the cache if there are external deps. When the external deps are modified, the cache will be disgarded.

Does this PR introduce a breaking change?

  • Yes
  • No

If this PR contains a breaking change, please describe the following...

  • Impact:
  • Migration path for existing applications:
  • Github Issue(s) this is regarding:

Other information:
This PR is reviving #984, it picks the tests from #984 but adopts a slightly different approach.

In #984 we generate timestamps and use that as a cache identifier. As is pointed out in #984 (comment), the cache will not be reused after the first run because of different cache identifiers (One for unknown externalDeps and the other for known externalDepsMtimes).

In this PR we store the timestamps of external deps within the transform result and validate it against the new timestamps returned from the webpack API _compilation.fileSystemInfo.getFileTimestamp, so the first cache will be reused because there is no cache identifier changes as now we determine if the cache should be reused after reading the cache result.

Closes #984, fixes #983.

Copy link
Member

@liuxingbaoyu liuxingbaoyu left a comment

Choose a reason for hiding this comment

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

Sorry I forgot about that one. Looks great, thanks!

src/cache.js Outdated Show resolved Hide resolved
@JLHwung JLHwung mentioned this pull request Aug 27, 2024
11 tasks
@JLHwung JLHwung merged commit d4181b8 into main Sep 2, 2024
16 checks passed
@JLHwung JLHwung deleted the support-cache-with-external-dependencies branch September 2, 2024 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refresh time is too slow in expo react-native project after upgrade
2 participants