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:
Jan Kassens
2022-10-06 16:59:12 -04:00
parent b605fc1ab3
commit e575e22925
3 changed files with 19 additions and 2 deletions
+1 -1
View File
@@ -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",
+6
View File
@@ -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
+12 -1
View File
@@ -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",