Skip to content

Commit 8985833

Browse files
Update rspack/react-compiler-babel-ts/rspack.config.js
Co-authored-by: Copilot <[email protected]>
1 parent be86d66 commit 8985833

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

rspack/react-compiler-babel-ts/rspack.config.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,19 @@ const config = {
5757
],
5858
},
5959
{
60-
test: (resouce) =>
61-
/\.(jsx|tsx)$/.test(resouce) && isReactCompilerRequiredSync(fs.readFileSync(resouce)),
60+
test: (() => {
61+
const fileCache = new Map();
62+
return (resource) => {
63+
if (!/\.jsx|tsx$/.test(resource)) {
64+
return false;
65+
}
66+
if (!fileCache.has(resource)) {
67+
const fileContent = fs.readFileSync(resource, 'utf-8'); // Cache file content synchronously
68+
fileCache.set(resource, fileContent);
69+
}
70+
return isReactCompilerRequiredSync(fileCache.get(resource));
71+
};
72+
})(),
6273
loader: 'babel-loader',
6374
},
6475
{

0 commit comments

Comments
 (0)