mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 00:20:04 +01:00
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>
This commit is contained in:
parent
57fbe3ba37
commit
d3ce0d3ea9
|
|
@ -8,16 +8,20 @@
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
|
|
||||||
const JsFileExtensionRE = /(js|ts|jsx|tsx)$/;
|
const JsFileExtensionRE = /(js|ts|jsx|tsx)$/;
|
||||||
|
const NextConfigFileRE = /^next\.config\.(js|mjs)$/;
|
||||||
const StrictModeRE = /<(React\.StrictMode|StrictMode)>/;
|
const StrictModeRE = /<(React\.StrictMode|StrictMode)>/;
|
||||||
|
const NextStrictModeRE = /reactStrictMode:\s*true/;
|
||||||
let StrictModeUsage = false;
|
let StrictModeUsage = false;
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
run(source: string, path: string): void {
|
run(source: string, path: string): void {
|
||||||
if (JsFileExtensionRE.exec(path) === null) {
|
if (StrictModeUsage) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!StrictModeUsage) {
|
if (NextConfigFileRE.exec(path) !== null) {
|
||||||
|
StrictModeUsage = NextStrictModeRE.exec(source) !== null;
|
||||||
|
} else if (JsFileExtensionRE.exec(path) !== null) {
|
||||||
StrictModeUsage = StrictModeRE.exec(source) !== null;
|
StrictModeUsage = StrictModeRE.exec(source) !== null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ async function main() {
|
||||||
.option("src", {
|
.option("src", {
|
||||||
description: "glob expression matching src files to compile",
|
description: "glob expression matching src files to compile",
|
||||||
type: "string",
|
type: "string",
|
||||||
default: "**/+(*.{js,jsx,ts,tsx}|package.json)",
|
default: "**/+(*.{js,mjs,jsx,ts,tsx}|package.json)",
|
||||||
})
|
})
|
||||||
.parseSync();
|
.parseSync();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user