@samitouri / QOS-React-2 / commits / d3ce0d3ea9

feat(compiler-healthcheck): Support strict mode check for nextjs apps (#29167)

## Summary Closes #29130 ## How did you test this change? Run the healthcheck in the compiler playground and the nodejs.org repo for the next config with a `.mjs` extension. Sanity with Vite React template. Signed-off-by: abizek <abishekilango@protonmail.com>

Abishek Ilango committed May 20, 2024 at 21:25 UTC d3ce0d3ea9736e1e1bc3e6b6834bc3170b1fa8eb
2 files changed +7 -3
compiler/packages/react-compiler-healthcheck/src/checks/strictMode.ts
+6 -2
@@ -8,16 +8,20 @@
8 import chalk from "chalk";
9
10 const JsFileExtensionRE = /(js|ts|jsx|tsx)$/;
11 +const NextConfigFileRE = /^next\.config\.(js|mjs)$/;
12 const StrictModeRE = /<(React\.StrictMode|StrictMode)>/;
13 +const NextStrictModeRE = /reactStrictMode:\s*true/;
14 let StrictModeUsage = false;
15
16 export default {
17 run(source: string, path: string): void {
16 - if (JsFileExtensionRE.exec(path) === null) {
18 + if (StrictModeUsage) {
19 return;
20 }
21
20 - if (!StrictModeUsage) {
22 + if (NextConfigFileRE.exec(path) !== null) {
23 + StrictModeUsage = NextStrictModeRE.exec(source) !== null;
24 + } else if (JsFileExtensionRE.exec(path) !== null) {
25 StrictModeUsage = StrictModeRE.exec(source) !== null;
26 }
27 },
compiler/packages/react-compiler-healthcheck/src/index.ts
+1 -1
@@ -20,7 +20,7 @@ async function main() {
20 .option("src", {
21 description: "glob expression matching src files to compile",
22 type: "string",
23 - default: "**/+(*.{js,jsx,ts,tsx}|package.json)",
23 + default: "**/+(*.{js,mjs,jsx,ts,tsx}|package.json)",
24 })
25 .parseSync();
26