mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Add hash of Babel plugin to Jest transform
Jest caches based on the hash of the babel config. This caused us to not break that cache when the we made changes to the plugin. Fixes #643
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
"src"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"build": "tsc && scripts/hash-dist.sh",
|
||||
"bundle:meta": "scripts/bundle-meta.sh",
|
||||
"dev": "concurrently \"yarn:build --watch\" \"yarn:playground\"",
|
||||
"playground": "cd packages/playground && yarn && yarn dev",
|
||||
|
||||
Executable
+6
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
|
||||
# Hashes JS files in the dist directory to create a cache-breaker
|
||||
|
||||
find dist -name '*.js' | sort | xargs shasum | shasum | awk '{ print $1 }' > dist/HASH
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
const ReactForgetBabelPlugin = require("../../dist").default;
|
||||
const babelJest = require("babel-jest");
|
||||
const { readFileSync } = require("fs");
|
||||
|
||||
module.exports = (useForget) => {
|
||||
function createTransformer() {
|
||||
@@ -17,7 +18,17 @@ module.exports = (useForget) => {
|
||||
{
|
||||
plugins: [
|
||||
"@babel/plugin-syntax-jsx",
|
||||
...(useForget ? [ReactForgetBabelPlugin, {}] : []),
|
||||
...(useForget
|
||||
? [
|
||||
[
|
||||
ReactForgetBabelPlugin,
|
||||
{
|
||||
// Jest hashes the babel config as a cache breaker.
|
||||
cacheBreaker: readFileSync("dist/HASH", "utf8"),
|
||||
},
|
||||
],
|
||||
]
|
||||
: []),
|
||||
],
|
||||
},
|
||||
"@babel/preset-react",
|
||||
|
||||
Reference in New Issue
Block a user