feat: add support for including the babel partial config to cache key#1638
feat: add support for including the babel partial config to cache key#1638EvanBacon wants to merge 1 commit intofacebook:mainfrom
Conversation
Update the Metro Babel transformer to generate cache keys that include the contents of user Babel configuration files, ensuring cache invalidation when Babel configs change.
de0439b to
4f84860
Compare
| cwd: options.projectRoot, | ||
| root: options.projectRoot, | ||
| // Use a dummy filename in the project root to trigger config resolution | ||
| filename: options.projectRoot + '/index.js', |
| // babel.config.js or similar project-wide config | ||
| if (partialConfig.config != null) { | ||
| configFiles.push(partialConfig.config); | ||
| } | ||
|
|
||
| // .babelrc or .babelrc.js file-relative config | ||
| if (partialConfig.babelrc != null) { | ||
| configFiles.push(partialConfig.babelrc); | ||
| } |
There was a problem hiding this comment.
It looks like we can use partialConfig.files (which was missing from Flow types) instead of checking these two props here, which also includes extends files, ignore files, etc.
From the docs:
A
Setof file paths that were read to build the resulting config, including project wide config files, local config files,
extended config files, ignore files, etc. Useful for implementing watch mode or cache invalidation.
...which seems perfect
|
Also, re previous discussion about perf impact - IIRC we both thought this was called for each worker - it's actually only called once by the main thread, so no concerns. |
| export const getCacheKey = (config: JsTransformerConfig): string => { | ||
| export const getCacheKey = ( | ||
| config: JsTransformerConfig, | ||
| projectRoot: string, |
There was a problem hiding this comment.
Just a heads up that I'm going to make this arg optional (so it's non breaking) and wrap it in an object (for future extension)
Summary: Update the Metro Babel transformer to generate cache keys that include the contents of user Babel configuration files, ensuring cache invalidation when Babel configs change. This is similar to what Jest does and it seems to work really well for them. Metro changelog: [Fix] Include user-defined babel config in transformer cache key to ensure correctness Changelog: [Internal] bypass-github-export-checks X-link: facebook/metro#1638 Reviewed By: vzaidman Differential Revision: D90469997 Pulled By: robhogan fbshipit-source-id: 44d06e7ec873988bcd0dff61ec13318d20f7223b
Summary: Update the Metro Babel transformer to generate cache keys that include the contents of user Babel configuration files, ensuring cache invalidation when Babel configs change. This is similar to what Jest does and it seems to work really well for them. Metro changelog: [Fix] Include user-defined babel config in transformer cache key to ensure correctness Changelog: [Internal] bypass-github-export-checks X-link: facebook/metro#1638 Reviewed By: vzaidman Differential Revision: D90469997 Pulled By: robhogan fbshipit-source-id: 44d06e7ec873988bcd0dff61ec13318d20f7223b
…#1638) Summary: Update the Metro Babel transformer to generate cache keys that include the contents of user Babel configuration files, ensuring cache invalidation when Babel configs change. This is similar to what Jest does and it seems to work really well for them. Metro changelog: [Fix] Include user-defined babel config in transformer cache key to ensure correctness Changelog: [Internal] bypass-github-export-checks Pull Request resolved: #1638 Reviewed By: vzaidman Differential Revision: D90469997 Pulled By: robhogan fbshipit-source-id: 44d06e7ec873988bcd0dff61ec13318d20f7223b
…#1638) Summary: Update the Metro Babel transformer to generate cache keys that include the contents of user Babel configuration files, ensuring cache invalidation when Babel configs change. This is similar to what Jest does and it seems to work really well for them. Metro changelog: [Fix] Include user-defined babel config in transformer cache key to ensure correctness Changelog: [Internal] bypass-github-export-checks Pull Request resolved: #1638 Reviewed By: vzaidman Differential Revision: D90469997 Pulled By: robhogan fbshipit-source-id: 44d06e7ec873988bcd0dff61ec13318d20f7223b

Summary
Update the Metro Babel transformer to generate cache keys that include the contents of user Babel configuration files, ensuring cache invalidation when Babel configs change. This is similar to what Jest does and it seems to work really well for them.
Changelog: [Fix] Include user-defined babel config in transformer cache key to ensure correctness
Test plan