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