react-doctor 0.9.13-dev.ff7dd67 → 0.9.14-dev.499a020

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/_react-doctor_require-typescript-DXQDYeWK.js +16 -0
  2. package/dist/{active-run-trace-dlIZeEvb.js → active-run-trace-Dewycxda.js} +3 -3
  3. package/dist/{active-scan-abort-registry-DwG6tSPy.js → active-scan-abort-registry-CCTgal0O.js} +3 -3
  4. package/dist/build-section-divider-BsKw6rbA.js +81 -0
  5. package/dist/{ci-ByM_SFTq.js → ci-Y7ntr_X7.js} +14 -13
  6. package/dist/cli.js +31 -30
  7. package/dist/constants-CW_854PH.js +1035 -0
  8. package/dist/constants-DNh19qg9.js +23 -0
  9. package/dist/{design-2hjOmtV1.js → design-CZbXwzWh.js} +4 -4
  10. package/dist/{devtools-CC2PAZ85.js → devtools-D20sefkm.js} +3 -3
  11. package/dist/duplicate-jsx-worker.d.ts +1 -0
  12. package/dist/duplicate-jsx-worker.js +636 -0
  13. package/dist/{exit-gracefully-niPFXq9Y.js → exit-gracefully-Bq8kCmar.js} +7 -7
  14. package/dist/fs-utils-C88IbqFa.js +45 -0
  15. package/dist/{get-east-asian-width-Bv2TD3Xj.js → get-east-asian-width-DRPy7dqz.js} +4 -4
  16. package/dist/{handle-error-D-4lexec.js → handle-error-DkZtH4y1.js} +6 -5
  17. package/dist/index.d.ts +8511 -8509
  18. package/dist/index.js +61693 -60580
  19. package/dist/{inspect-BrctG7ql.js → inspect-4R70DaBp.js} +38 -27
  20. package/dist/{install-CcFc56OK.js → install-DSOkcCn6.js} +10 -9
  21. package/dist/{install-doctor-script-Coa2ErCg.js → install-doctor-script-k5jxcUWB.js} +17 -8
  22. package/dist/{install-github-workflow-DlfdrYkQ.js → install-github-workflow-Dh3nS6ms.js} +10 -10
  23. package/dist/{install-react-doctor-BWxqZMX-.js → install-react-doctor-NmiRJQtp.js} +15 -11
  24. package/dist/is-cache-globally-disabled-CoHiYz2i.js +10 -0
  25. package/dist/{jsx-runtime-Njm7vAoN.js → jsx-runtime-B1PPqZBs.js} +11 -10
  26. package/dist/oxlint-worker.d.ts +1 -0
  27. package/dist/oxlint-worker.js +225 -0
  28. package/dist/{path-format-DnHpmJwG.js → path-format-By20mo8A.js} +3 -3
  29. package/dist/{print-branded-header-DFkeG4BS.js → print-branded-header-ydu9MCpt.js} +4 -4
  30. package/dist/project-analysis-worker.js +461 -480
  31. package/dist/{prompt-runtime-scan-url-BenBNq25.js → prompt-runtime-scan-url-BEFbrKze.js} +6 -6
  32. package/dist/react-compiler-detection-worker.d.ts +1 -0
  33. package/dist/react-compiler-detection-worker.js +1029 -0
  34. package/dist/{read-object-file-CqMtxcfF.js → read-object-file-f9AWbDOo.js} +4 -4
  35. package/dist/{record-metric-Bkorhx43.js → record-metric-BeiisdDK.js} +12998 -12770
  36. package/dist/{report-error-DPjmfRi9.js → report-error-CwReeGgL.js} +9 -8
  37. package/dist/{report-workflow-result-CBL6CrLY.js → report-workflow-result-CRhHHcHp.js} +24 -11
  38. package/dist/{resolve-scope-BFloAClV.js → resolve-scope-DsrT6gaf.js} +7 -7
  39. package/dist/{rules-BKNy9YIl.js → rules-Bhk46JNb.js} +8 -7
  40. package/dist/{run-scan-app-Bc70ozp-.js → run-scan-app-B_r_jHg-.js} +30 -23
  41. package/dist/{runtime-scan-ODrdp5mV.js → runtime-scan-B6v3G55b.js} +13 -12
  42. package/dist/{sanitize-runtime-url-BYOmPSdm.js → sanitize-runtime-url-CVRMHksi.js} +4 -4
  43. package/dist/{scan-BfcGHHkI.js → scan-BJsk-x4c.js} +10 -9
  44. package/dist/{semver-DFtnEmN-.js → semver-BZIuy1gP.js} +3 -3
  45. package/dist/{should-fail-scan-gate-CCPDoHaM.js → should-fail-scan-gate-B8cvpr6W.js} +1339 -1283
  46. package/dist/{should-skip-prompts-D-ClPHHR.js → should-skip-prompts-CupUff2k.js} +4 -4
  47. package/dist/{should-use-tui-BaCVIPPN.js → should-use-tui-t0DIGfJ0.js} +4 -4
  48. package/dist/start-scan-preamble-D0QepYZ_.js +68 -0
  49. package/dist/start-scan-preamble-DVhXIPc0.d.ts +1 -0
  50. package/dist/start-scan-preamble.d.ts +1 -0
  51. package/dist/start-scan-preamble.js +4 -0
  52. package/dist/{telemetry-runtime-BGWa_GB9.js → telemetry-runtime-DfK-XYFO.js} +154 -5
  53. package/dist/{unref-stdin-SK3WfwxS.js → unref-stdin-D-NZBFpg.js} +3 -3
  54. package/dist/unwrap-typescript-expression-CrEPQUWz.js +14 -0
  55. package/dist/{version-DN1N-oZy.js → version-DpQFTCI_.js} +5 -4
  56. package/dist/{why-CyioXUF2.js → why-DA3u09OY.js} +4 -4
  57. package/dist/{with-run-span-GsCWW2_X.js → with-run-span-DP84SJbD.js} +7 -6
  58. package/package.json +9 -7
  59. package/dist/build-section-divider-BRuN44fL.js +0 -216
@@ -0,0 +1,1029 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="538f795a-ce66-5950-bf7f-048038bff5f8")}catch(e){}}();
3
+ import { t as typescriptBinding } from "./_react-doctor_require-typescript-DXQDYeWK.js";
4
+ import { t as unwrapTypescriptExpression } from "./unwrap-typescript-expression-CrEPQUWz.js";
5
+ import { i as isErrnoException, n as isPlainObject, r as readDirectoryEntries, t as isFile } from "./fs-utils-C88IbqFa.js";
6
+ import { createRequire } from "node:module";
7
+ import * as fs$1 from "node:fs";
8
+ import * as path$1 from "node:path";
9
+ import { parentPort } from "node:worker_threads";
10
+ import { ResolverFactory } from "oxc-resolver";
11
+ //#region ../core/src/utils/strip-utf8-bom.ts
12
+ const UTF8_BOM_CHARACTER = "";
13
+ const stripUtf8Bom = (content) => content.startsWith(UTF8_BOM_CHARACTER) ? content.slice(1) : content;
14
+ //#endregion
15
+ //#region ../core/src/project-info/package-json.ts
16
+ const cachedPackageJsons = /* @__PURE__ */ new Map();
17
+ const readPackageJsonUncached = (packageJsonPath) => {
18
+ try {
19
+ return JSON.parse(stripUtf8Bom(fs$1.readFileSync(packageJsonPath, "utf-8")));
20
+ } catch (error) {
21
+ if (error instanceof SyntaxError) return {};
22
+ if (isErrnoException(error)) {
23
+ const { code } = error;
24
+ if (code === "EISDIR" || code === "EACCES" || code === "EPERM" || code === "ENOENT") return {};
25
+ }
26
+ throw error;
27
+ }
28
+ };
29
+ const readPackageJson = (packageJsonPath) => {
30
+ const absolutePath = path$1.resolve(packageJsonPath);
31
+ const cached = cachedPackageJsons.get(absolutePath);
32
+ if (cached !== void 0) return cached;
33
+ const result = readPackageJsonUncached(absolutePath);
34
+ cachedPackageJsons.set(absolutePath, result);
35
+ return result;
36
+ };
37
+ //#endregion
38
+ //#region ../core/src/project-info/monorepo-root.ts
39
+ const isMonorepoRoot = (directory) => {
40
+ if (isFile(path$1.join(directory, "pnpm-workspace.yaml"))) return true;
41
+ if (isFile(path$1.join(directory, "nx.json"))) return true;
42
+ const packageJsonPath = path$1.join(directory, "package.json");
43
+ if (!isFile(packageJsonPath)) return false;
44
+ const packageJson = readPackageJson(packageJsonPath);
45
+ return Array.isArray(packageJson.workspaces) || Boolean(packageJson.workspaces?.packages);
46
+ };
47
+ //#endregion
48
+ //#region ../core/src/utils/is-project-boundary.ts
49
+ /**
50
+ * True when `directory` looks like a project root we shouldn't walk
51
+ * past — either the working tree's git root (a `.git` entry sits
52
+ * here) or an npm/pnpm/yarn/bun monorepo root.
53
+ *
54
+ * Used as the stop-condition for the ancestor walks performed by
55
+ * `detectUserLintConfigPaths`, `loadConfigWithSource`, and
56
+ * `detectReactCompiler`. All three previously inlined their own
57
+ * byte-equivalent copy.
58
+ */
59
+ const isProjectBoundary = (directory) => fs$1.existsSync(path$1.join(directory, ".git")) || isMonorepoRoot(directory);
60
+ //#endregion
61
+ //#region ../core/src/project-info/is-local-module-specifier.ts
62
+ const isLocalModuleSpecifier = (moduleSpecifier) => moduleSpecifier === "." || moduleSpecifier === ".." || moduleSpecifier.startsWith("./") || moduleSpecifier.startsWith("../") || path$1.isAbsolute(moduleSpecifier);
63
+ //#endregion
64
+ //#region ../core/src/project-info/detect-nextjs-static-export.ts
65
+ const NEXT_CONFIG_FILENAMES = [
66
+ "next.config.js",
67
+ "next.config.mjs",
68
+ "next.config.ts",
69
+ "next.config.cjs"
70
+ ];
71
+ //#endregion
72
+ //#region ../core/src/project-info/react-compiler-config-evaluator.ts
73
+ const BABEL_CONFIG_FILENAMES = [
74
+ ".babelrc",
75
+ ".babelrc.js",
76
+ ".babelrc.json",
77
+ ".babelrc.cjs",
78
+ ".babelrc.mjs",
79
+ ".babelrc.cts",
80
+ "babel.config.js",
81
+ "babel.config.json",
82
+ "babel.config.cjs",
83
+ "babel.config.mjs",
84
+ "babel.config.ts",
85
+ "babel.config.cts"
86
+ ];
87
+ const VITE_CONFIG_FILENAMES = [
88
+ "vite.config.js",
89
+ "vite.config.ts",
90
+ "vite.config.mjs",
91
+ "vite.config.mts",
92
+ "vite.config.cjs",
93
+ "vite.config.cts",
94
+ "vitest.config.ts",
95
+ "vitest.config.js"
96
+ ];
97
+ const RSBUILD_CONFIG_FILENAMES = [
98
+ "rsbuild.config.ts",
99
+ "rsbuild.config.js",
100
+ "rsbuild.config.mts",
101
+ "rsbuild.config.mjs",
102
+ "rsbuild.config.cts",
103
+ "rsbuild.config.cjs"
104
+ ];
105
+ const RSPACK_CONFIG_FILENAMES = [
106
+ "rspack.config.ts",
107
+ "rspack.config.js",
108
+ "rspack.config.mts",
109
+ "rspack.config.mjs",
110
+ "rspack.config.cts",
111
+ "rspack.config.cjs"
112
+ ];
113
+ const EXPO_APP_CONFIG_FILENAMES = [
114
+ "app.json",
115
+ "app.config.js",
116
+ "app.config.ts"
117
+ ];
118
+ const REACT_COMPILER_CONFIG_FILENAMES = [
119
+ ...NEXT_CONFIG_FILENAMES,
120
+ ...BABEL_CONFIG_FILENAMES,
121
+ ...VITE_CONFIG_FILENAMES,
122
+ ...RSBUILD_CONFIG_FILENAMES,
123
+ ...RSPACK_CONFIG_FILENAMES,
124
+ ...EXPO_APP_CONFIG_FILENAMES
125
+ ];
126
+ const REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS = [
127
+ ".js",
128
+ ".jsx",
129
+ ".ts",
130
+ ".tsx",
131
+ ".mjs",
132
+ ".mts",
133
+ ".cjs",
134
+ ".cts",
135
+ ".json"
136
+ ];
137
+ const REACT_COMPILER_CONFIG_RESOLVER = new ResolverFactory({
138
+ conditionNames: [
139
+ "import",
140
+ "require",
141
+ "node",
142
+ "default"
143
+ ],
144
+ extensions: REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS
145
+ });
146
+ const resolveImportedConfigFile = (fromFilePath, moduleSpecifier) => {
147
+ if (!isLocalModuleSpecifier(moduleSpecifier)) {
148
+ try {
149
+ const resolvedPath = REACT_COMPILER_CONFIG_RESOLVER.resolveFileSync(fromFilePath, moduleSpecifier).path;
150
+ if (resolvedPath && isFile(resolvedPath)) return resolvedPath;
151
+ } catch {}
152
+ try {
153
+ const resolvedPath = createRequire(fromFilePath).resolve(moduleSpecifier);
154
+ return isFile(resolvedPath) ? resolvedPath : null;
155
+ } catch {
156
+ return null;
157
+ }
158
+ }
159
+ const unresolvedPath = path$1.resolve(path$1.dirname(fromFilePath), moduleSpecifier);
160
+ const extension = path$1.extname(unresolvedPath);
161
+ return (extension ? [unresolvedPath, ...REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS.map((sourceExtension) => `${unresolvedPath.slice(0, -extension.length)}${sourceExtension}`)] : [
162
+ unresolvedPath,
163
+ ...REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS.map((sourceExtension) => `${unresolvedPath}${sourceExtension}`),
164
+ ...REACT_COMPILER_CONFIG_SOURCE_EXTENSIONS.map((sourceExtension) => path$1.join(unresolvedPath, `index${sourceExtension}`))
165
+ ]).find(isFile) ?? null;
166
+ };
167
+ const parseConfigSourceFile = (filePath, content) => filePath.endsWith(".json") || path$1.basename(filePath) === ".babelrc" ? typescriptBinding.parseJsonText(filePath, content) : typescriptBinding.createSourceFile(filePath, content, typescriptBinding.ScriptTarget.Latest, true);
168
+ const getStaticPropertyName = (propertyName) => typescriptBinding.isIdentifier(propertyName) || typescriptBinding.isStringLiteralLike(propertyName) ? propertyName.text : typescriptBinding.isComputedPropertyName(propertyName) && typescriptBinding.isStringLiteralLike(propertyName.expression) ? propertyName.expression.text : null;
169
+ const getAccessedPropertyName = (expression) => typescriptBinding.isPropertyAccessExpression(expression) ? expression.name.text : expression.argumentExpression && typescriptBinding.isStringLiteralLike(expression.argumentExpression) ? expression.argumentExpression.text : null;
170
+ const isCommonJsConfigExportAssignment = (node, sourceFile) => typescriptBinding.isBinaryExpression(node) && node.operatorToken.kind === typescriptBinding.SyntaxKind.EqualsToken && (node.left.getText(sourceFile) === "module.exports" || node.left.getText(sourceFile) === "exports.default");
171
+ const hasExportModifier = (node) => typescriptBinding.canHaveModifiers(node) && Boolean(typescriptBinding.getModifiers(node)?.some((modifier) => modifier.kind === typescriptBinding.SyntaxKind.ExportKeyword));
172
+ const getRequireModuleSpecifier = (expression) => {
173
+ if (!typescriptBinding.isCallExpression(expression) || !typescriptBinding.isIdentifier(expression.expression) || expression.expression.text !== "require" || expression.arguments.length !== 1) return null;
174
+ const moduleSpecifier = expression.arguments[0];
175
+ return moduleSpecifier && typescriptBinding.isStringLiteralLike(moduleSpecifier) ? moduleSpecifier.text : null;
176
+ };
177
+ const bindingNameContainsIdentifier = (bindingName, identifierName) => typescriptBinding.isIdentifier(bindingName) ? bindingName.text === identifierName : bindingName.elements.some((element) => !typescriptBinding.isOmittedExpression(element) && bindingNameContainsIdentifier(element.name, identifierName));
178
+ const hasTopLevelValueBinding = (sourceFile, bindingName) => sourceFile.statements.some((statement) => {
179
+ if (typescriptBinding.isImportDeclaration(statement)) {
180
+ const importClause = statement.importClause;
181
+ if (importClause?.name?.text === bindingName) return true;
182
+ const namedBindings = importClause?.namedBindings;
183
+ return namedBindings ? typescriptBinding.isNamespaceImport(namedBindings) ? namedBindings.name.text === bindingName : namedBindings.elements.some((element) => element.name.text === bindingName) : false;
184
+ }
185
+ if (typescriptBinding.isVariableStatement(statement)) return statement.declarationList.declarations.some((declaration) => bindingNameContainsIdentifier(declaration.name, bindingName));
186
+ return (typescriptBinding.isFunctionDeclaration(statement) || typescriptBinding.isClassDeclaration(statement)) && statement.name?.text === bindingName;
187
+ });
188
+ const getImportBinding = (sourceFile, bindingName) => {
189
+ const hasShadowedRequire = hasTopLevelValueBinding(sourceFile, "require");
190
+ for (const statement of sourceFile.statements) {
191
+ if (typescriptBinding.isImportDeclaration(statement) && statement.importClause && !statement.importClause.isTypeOnly && typescriptBinding.isStringLiteralLike(statement.moduleSpecifier)) {
192
+ if (statement.importClause.name?.text === bindingName) return {
193
+ moduleSpecifier: statement.moduleSpecifier.text,
194
+ exportName: "default",
195
+ isNamespace: false
196
+ };
197
+ const { namedBindings } = statement.importClause;
198
+ if (namedBindings && typescriptBinding.isNamespaceImport(namedBindings) && namedBindings.name.text === bindingName) return {
199
+ moduleSpecifier: statement.moduleSpecifier.text,
200
+ exportName: "*",
201
+ isNamespace: true
202
+ };
203
+ if (namedBindings && typescriptBinding.isNamedImports(namedBindings)) {
204
+ const importSpecifier = namedBindings.elements.find((element) => !element.isTypeOnly && element.name.text === bindingName);
205
+ if (importSpecifier) return {
206
+ moduleSpecifier: statement.moduleSpecifier.text,
207
+ exportName: (importSpecifier.propertyName ?? importSpecifier.name).text,
208
+ isNamespace: false
209
+ };
210
+ }
211
+ }
212
+ if (!typescriptBinding.isVariableStatement(statement) || hasShadowedRequire) continue;
213
+ for (const declaration of statement.declarationList.declarations) {
214
+ if (!declaration.initializer) continue;
215
+ if (typescriptBinding.isIdentifier(declaration.name) && declaration.name.text === bindingName) {
216
+ const directModuleSpecifier = getRequireModuleSpecifier(declaration.initializer);
217
+ if (directModuleSpecifier) return {
218
+ moduleSpecifier: directModuleSpecifier,
219
+ exportName: "default",
220
+ isNamespace: true
221
+ };
222
+ if (typescriptBinding.isPropertyAccessExpression(declaration.initializer) && getRequireModuleSpecifier(declaration.initializer.expression) !== null) return {
223
+ moduleSpecifier: getRequireModuleSpecifier(declaration.initializer.expression) ?? "",
224
+ exportName: declaration.initializer.name.text,
225
+ isNamespace: false
226
+ };
227
+ }
228
+ if (!typescriptBinding.isObjectBindingPattern(declaration.name)) continue;
229
+ const bindingElement = declaration.name.elements.find((element) => typescriptBinding.isIdentifier(element.name) && element.name.text === bindingName);
230
+ const moduleSpecifier = getRequireModuleSpecifier(declaration.initializer);
231
+ if (bindingElement && moduleSpecifier) return {
232
+ moduleSpecifier,
233
+ exportName: bindingElement.propertyName ? getStaticPropertyName(bindingElement.propertyName) ?? bindingElement.propertyName.getText(sourceFile) : bindingElement.name.getText(sourceFile),
234
+ isNamespace: false
235
+ };
236
+ }
237
+ }
238
+ return null;
239
+ };
240
+ const getTopLevelBinding = (sourceFile, bindingName) => {
241
+ for (const statement of sourceFile.statements) {
242
+ if (typescriptBinding.isVariableStatement(statement)) {
243
+ const declaration = statement.declarationList.declarations.find((candidate) => typescriptBinding.isIdentifier(candidate.name) && candidate.name.text === bindingName);
244
+ if (declaration?.initializer) return declaration.initializer;
245
+ }
246
+ if (typescriptBinding.isFunctionDeclaration(statement) && statement.name?.text === bindingName) return statement;
247
+ }
248
+ return null;
249
+ };
250
+ const getFunctionLocalBindings = (functionNode, argumentsList, argumentAnalysis, functionAnalysis) => {
251
+ const localBindings = /* @__PURE__ */ new Map();
252
+ functionNode.parameters.forEach((parameter, parameterIndex) => {
253
+ if (typescriptBinding.isIdentifier(parameter.name)) {
254
+ const argument = argumentsList[parameterIndex];
255
+ localBindings.set(parameter.name.text, {
256
+ expression: argument ?? parameter.initializer ?? null,
257
+ analysis: argument ? argumentAnalysis : functionAnalysis
258
+ });
259
+ }
260
+ });
261
+ return localBindings;
262
+ };
263
+ const getScopedConfigBinding = (identifier) => {
264
+ let childNode = identifier;
265
+ let currentNode = identifier.parent;
266
+ while (currentNode && !typescriptBinding.isSourceFile(currentNode)) {
267
+ if (typescriptBinding.isBlock(currentNode)) for (const statement of currentNode.statements) {
268
+ if (typescriptBinding.isVariableStatement(statement)) {
269
+ for (const declaration of statement.declarationList.declarations) if (bindingNameContainsIdentifier(declaration.name, identifier.text)) return {
270
+ wasFound: true,
271
+ initializer: statement.pos < childNode.pos && typescriptBinding.isIdentifier(declaration.name) ? declaration.initializer ?? null : null
272
+ };
273
+ }
274
+ if ((typescriptBinding.isFunctionDeclaration(statement) || typescriptBinding.isClassDeclaration(statement)) && statement.name?.text === identifier.text) return {
275
+ wasFound: true,
276
+ initializer: null
277
+ };
278
+ }
279
+ if (typescriptBinding.isCatchClause(currentNode) && currentNode.variableDeclaration && bindingNameContainsIdentifier(currentNode.variableDeclaration.name, identifier.text)) return {
280
+ wasFound: true,
281
+ initializer: typescriptBinding.isIdentifier(currentNode.variableDeclaration.name) ? currentNode.variableDeclaration.initializer ?? null : null
282
+ };
283
+ childNode = currentNode;
284
+ currentNode = currentNode.parent;
285
+ }
286
+ return {
287
+ wasFound: false,
288
+ initializer: null
289
+ };
290
+ };
291
+ const isCompilerTransformModule = (moduleSpecifier, exportName) => moduleSpecifier === "babel-plugin-react-compiler" && exportName === "default" || moduleSpecifier === "@vitejs/plugin-react" && exportName === "reactCompilerPreset";
292
+ const NODE_MODULE_SPECIFIERS = new Set(["module", "node:module"]);
293
+ const isConstantVariableInitializer = (node) => typescriptBinding.isExpression(node) && typescriptBinding.isVariableDeclaration(node.parent) && typescriptBinding.isVariableDeclarationList(node.parent.parent) && Boolean(node.parent.parent.flags & typescriptBinding.NodeFlags.Const);
294
+ const isTransparentConfigExpression = (node) => typescriptBinding.isParenthesizedExpression(node) || typescriptBinding.isAsExpression(node) || typescriptBinding.isTypeAssertionExpression(node) || typescriptBinding.isSatisfiesExpression(node) || typescriptBinding.isNonNullExpression(node) || typescriptBinding.isAwaitExpression(node);
295
+ const isNodeCreateRequireCall = (node, analysis) => {
296
+ if (isTransparentConfigExpression(node)) return isNodeCreateRequireCall(node.expression, analysis);
297
+ if (!typescriptBinding.isCallExpression(node)) return false;
298
+ const target = node.expression;
299
+ if (typescriptBinding.isIdentifier(target)) {
300
+ if (analysis.localBindings.has(target.text) || getScopedConfigBinding(target).wasFound) return false;
301
+ const importBinding = getImportBinding(analysis.sourceFile, target.text);
302
+ return Boolean(importBinding && NODE_MODULE_SPECIFIERS.has(importBinding.moduleSpecifier) && importBinding.exportName === "createRequire");
303
+ }
304
+ if (!typescriptBinding.isPropertyAccessExpression(target) && !typescriptBinding.isElementAccessExpression(target)) return false;
305
+ if (getAccessedPropertyName(target) !== "createRequire") return false;
306
+ const createRequireReceiver = target.expression;
307
+ if (typescriptBinding.isCallExpression(createRequireReceiver)) {
308
+ const requiredModuleSpecifier = getRequireModuleSpecifier(createRequireReceiver);
309
+ if (requiredModuleSpecifier === null || !NODE_MODULE_SPECIFIERS.has(requiredModuleSpecifier) || !typescriptBinding.isIdentifier(createRequireReceiver.expression)) return false;
310
+ const requireIdentifier = createRequireReceiver.expression;
311
+ return !analysis.localBindings.has(requireIdentifier.text) && !getScopedConfigBinding(requireIdentifier).wasFound && !hasTopLevelValueBinding(analysis.sourceFile, requireIdentifier.text);
312
+ }
313
+ if (!typescriptBinding.isIdentifier(createRequireReceiver)) return false;
314
+ if (analysis.localBindings.has(createRequireReceiver.text) || getScopedConfigBinding(createRequireReceiver).wasFound) return false;
315
+ const importBinding = getImportBinding(analysis.sourceFile, createRequireReceiver.text);
316
+ return Boolean(importBinding?.isNamespace && NODE_MODULE_SPECIFIERS.has(importBinding.moduleSpecifier));
317
+ };
318
+ const isUnshadowedGlobalRequireIdentifier = (identifier, analysis) => identifier.text === "require" && !hasTopLevelValueBinding(analysis.sourceFile, identifier.text) && getImportBinding(analysis.sourceFile, identifier.text) === null;
319
+ const isNodeRequireResolverIdentifier = (identifier, analysis) => {
320
+ if (analysis.localBindings.has(identifier.text)) return false;
321
+ const scopedBinding = getScopedConfigBinding(identifier);
322
+ const resolverInitializer = scopedBinding.wasFound ? scopedBinding.initializer : getTopLevelBinding(analysis.sourceFile, identifier.text);
323
+ if (!scopedBinding.wasFound && resolverInitializer === null) return isUnshadowedGlobalRequireIdentifier(identifier, analysis);
324
+ return Boolean(resolverInitializer && isConstantVariableInitializer(resolverInitializer) && isNodeCreateRequireCall(resolverInitializer, analysis));
325
+ };
326
+ const getNodeRequireResolveModuleSpecifier = (callExpression, analysis) => {
327
+ const [moduleSpecifierNode] = callExpression.arguments;
328
+ if (!moduleSpecifierNode || !typescriptBinding.isStringLiteralLike(moduleSpecifierNode)) return null;
329
+ const target = callExpression.expression;
330
+ if (!typescriptBinding.isPropertyAccessExpression(target) && !typescriptBinding.isElementAccessExpression(target)) return null;
331
+ if (getAccessedPropertyName(target) !== "resolve") return null;
332
+ if (isNodeCreateRequireCall(target.expression, analysis)) return moduleSpecifierNode.text;
333
+ if (!typescriptBinding.isIdentifier(target.expression)) return null;
334
+ return isNodeRequireResolverIdentifier(target.expression, analysis) ? moduleSpecifierNode.text : null;
335
+ };
336
+ const getAssignedPropertyInitializer = (identifier, propertyName) => {
337
+ let bindingScope = null;
338
+ let currentNode = identifier;
339
+ while (currentNode) {
340
+ if (typescriptBinding.isBlock(currentNode) || typescriptBinding.isSourceFile(currentNode)) {
341
+ const statementScope = currentNode;
342
+ const hasBinding = statementScope.statements.some((statement) => {
343
+ if (typescriptBinding.isVariableStatement(statement)) return statement.declarationList.declarations.some((declaration) => bindingNameContainsIdentifier(declaration.name, identifier.text));
344
+ if ((typescriptBinding.isFunctionDeclaration(statement) || typescriptBinding.isClassDeclaration(statement)) && statement.name?.text === identifier.text) return true;
345
+ if (!typescriptBinding.isSourceFile(statementScope) || !typescriptBinding.isImportDeclaration(statement)) return false;
346
+ const importClause = statement.importClause;
347
+ if (importClause?.name?.text === identifier.text) return true;
348
+ const namedBindings = importClause?.namedBindings;
349
+ return namedBindings ? typescriptBinding.isNamespaceImport(namedBindings) ? namedBindings.name.text === identifier.text : namedBindings.elements.some((element) => element.name.text === identifier.text) : false;
350
+ });
351
+ const isFunctionParameter = typescriptBinding.isBlock(currentNode) && typescriptBinding.isFunctionLike(currentNode.parent) && currentNode.parent.parameters.some((parameter) => typescriptBinding.isIdentifier(parameter.name) && parameter.name.text === identifier.text);
352
+ if (hasBinding || isFunctionParameter) {
353
+ bindingScope = currentNode;
354
+ break;
355
+ }
356
+ }
357
+ currentNode = currentNode.parent;
358
+ }
359
+ if (!bindingScope) bindingScope = identifier.getSourceFile();
360
+ let assignedInitializer = null;
361
+ let wasFound = false;
362
+ for (const statement of bindingScope.statements) {
363
+ if (statement.end > identifier.pos) break;
364
+ if (!typescriptBinding.isExpressionStatement(statement) || !typescriptBinding.isBinaryExpression(statement.expression) || statement.expression.operatorToken.kind !== typescriptBinding.SyntaxKind.EqualsToken) continue;
365
+ const { left } = statement.expression;
366
+ const assignedObject = typescriptBinding.isPropertyAccessExpression(left) || typescriptBinding.isElementAccessExpression(left) ? left.expression : null;
367
+ const assignedPropertyName = typescriptBinding.isPropertyAccessExpression(left) ? left.name.text : typescriptBinding.isElementAccessExpression(left) && left.argumentExpression && typescriptBinding.isStringLiteralLike(left.argumentExpression) ? left.argumentExpression.text : null;
368
+ if (assignedObject && typescriptBinding.isIdentifier(assignedObject) && assignedObject.text === identifier.text && assignedPropertyName === propertyName) {
369
+ wasFound = true;
370
+ assignedInitializer = statement.expression.right;
371
+ }
372
+ }
373
+ return {
374
+ wasFound,
375
+ initializer: assignedInitializer
376
+ };
377
+ };
378
+ const getStaticConfigValueState = (expression, analysis, visitedExpressions = /* @__PURE__ */ new Set()) => {
379
+ const unwrappedExpression = unwrapTypescriptExpression(expression);
380
+ if (visitedExpressions.has(unwrappedExpression)) return null;
381
+ const nextVisitedExpressions = new Set(visitedExpressions);
382
+ nextVisitedExpressions.add(unwrappedExpression);
383
+ if (unwrappedExpression.kind === typescriptBinding.SyntaxKind.NullKeyword || typescriptBinding.isIdentifier(unwrappedExpression) && unwrappedExpression.text === "undefined") return {
384
+ isNullish: true,
385
+ isTruthy: false
386
+ };
387
+ if (unwrappedExpression.kind === typescriptBinding.SyntaxKind.FalseKeyword || typescriptBinding.isStringLiteralLike(unwrappedExpression) && unwrappedExpression.text.length === 0 || typescriptBinding.isNumericLiteral(unwrappedExpression) && Number(unwrappedExpression.text) === 0) return {
388
+ isNullish: false,
389
+ isTruthy: false
390
+ };
391
+ if (unwrappedExpression.kind === typescriptBinding.SyntaxKind.TrueKeyword || typescriptBinding.isStringLiteralLike(unwrappedExpression) && unwrappedExpression.text.length > 0 || typescriptBinding.isNumericLiteral(unwrappedExpression) && Number(unwrappedExpression.text) !== 0 || typescriptBinding.isObjectLiteralExpression(unwrappedExpression) || typescriptBinding.isArrayLiteralExpression(unwrappedExpression) || typescriptBinding.isArrowFunction(unwrappedExpression) || typescriptBinding.isFunctionExpression(unwrappedExpression)) return {
392
+ isNullish: false,
393
+ isTruthy: true
394
+ };
395
+ if (typescriptBinding.isIdentifier(unwrappedExpression)) {
396
+ if (analysis.localBindings.has(unwrappedExpression.text)) {
397
+ const localReference = analysis.localBindings.get(unwrappedExpression.text);
398
+ return localReference?.expression ? getStaticConfigValueState(localReference.expression, localReference.analysis, nextVisitedExpressions) : null;
399
+ }
400
+ const topLevelBinding = getTopLevelBinding(analysis.sourceFile, unwrappedExpression.text);
401
+ return topLevelBinding && typescriptBinding.isExpression(topLevelBinding) ? getStaticConfigValueState(topLevelBinding, analysis, nextVisitedExpressions) : null;
402
+ }
403
+ if (typescriptBinding.isConditionalExpression(unwrappedExpression)) {
404
+ const conditionState = getStaticConfigValueState(unwrappedExpression.condition, analysis, nextVisitedExpressions);
405
+ if (conditionState !== null) return getStaticConfigValueState(conditionState.isTruthy ? unwrappedExpression.whenTrue : unwrappedExpression.whenFalse, analysis, nextVisitedExpressions);
406
+ const whenTrueState = getStaticConfigValueState(unwrappedExpression.whenTrue, analysis, nextVisitedExpressions);
407
+ const whenFalseState = getStaticConfigValueState(unwrappedExpression.whenFalse, analysis, nextVisitedExpressions);
408
+ return whenTrueState !== null && whenFalseState !== null && whenTrueState.isNullish === whenFalseState.isNullish && whenTrueState.isTruthy === whenFalseState.isTruthy ? whenTrueState : null;
409
+ }
410
+ if (typescriptBinding.isBinaryExpression(unwrappedExpression)) {
411
+ const leftState = getStaticConfigValueState(unwrappedExpression.left, analysis, nextVisitedExpressions);
412
+ if (unwrappedExpression.operatorToken.kind === typescriptBinding.SyntaxKind.AmpersandAmpersandToken) {
413
+ if (leftState === null) return null;
414
+ return leftState.isTruthy ? getStaticConfigValueState(unwrappedExpression.right, analysis, nextVisitedExpressions) : leftState;
415
+ }
416
+ if (unwrappedExpression.operatorToken.kind === typescriptBinding.SyntaxKind.BarBarToken) {
417
+ if (leftState === null) return null;
418
+ return leftState.isTruthy ? leftState : getStaticConfigValueState(unwrappedExpression.right, analysis, nextVisitedExpressions);
419
+ }
420
+ if (unwrappedExpression.operatorToken.kind === typescriptBinding.SyntaxKind.QuestionQuestionToken) {
421
+ if (leftState === null) return null;
422
+ return leftState.isNullish ? getStaticConfigValueState(unwrappedExpression.right, analysis, nextVisitedExpressions) : leftState;
423
+ }
424
+ }
425
+ return null;
426
+ };
427
+ const isStaticallyDisabledConfigExpression = (expression, analysis) => getStaticConfigValueState(expression, analysis)?.isTruthy === false;
428
+ const isStaticallyTruthyConfigExpression = (expression, analysis) => getStaticConfigValueState(expression, analysis)?.isTruthy === true;
429
+ const isStaticallyNullishConfigExpression = (expression, analysis) => getStaticConfigValueState(expression, analysis)?.isNullish === true;
430
+ const isStaticallyNonNullishConfigExpression = (expression, analysis) => getStaticConfigValueState(expression, analysis)?.isNullish === false;
431
+ const getReactCompilerFlagState = (expression, analysis, visitedExpressions = /* @__PURE__ */ new Set()) => {
432
+ const unwrappedExpression = unwrapTypescriptExpression(expression);
433
+ if (visitedExpressions.has(unwrappedExpression)) return null;
434
+ const nextVisitedExpressions = new Set(visitedExpressions);
435
+ nextVisitedExpressions.add(unwrappedExpression);
436
+ if (typescriptBinding.isIdentifier(unwrappedExpression)) {
437
+ const assignedBinding = getAssignedPropertyInitializer(unwrappedExpression, "reactCompiler");
438
+ if (assignedBinding.wasFound && assignedBinding.initializer) return { isEnabled: !isStaticallyDisabledConfigExpression(assignedBinding.initializer, analysis) };
439
+ if (analysis.localBindings.has(unwrappedExpression.text)) {
440
+ const localReference = analysis.localBindings.get(unwrappedExpression.text);
441
+ return localReference?.expression ? getReactCompilerFlagState(localReference.expression, localReference.analysis, nextVisitedExpressions) : null;
442
+ }
443
+ const topLevelBinding = getTopLevelBinding(analysis.sourceFile, unwrappedExpression.text);
444
+ return topLevelBinding && typescriptBinding.isExpression(topLevelBinding) ? getReactCompilerFlagState(topLevelBinding, analysis, nextVisitedExpressions) : null;
445
+ }
446
+ if (!typescriptBinding.isObjectLiteralExpression(unwrappedExpression)) return null;
447
+ for (const property of [...unwrappedExpression.properties].reverse()) {
448
+ if (typescriptBinding.isPropertyAssignment(property) && getStaticPropertyName(property.name) === "reactCompiler") return { isEnabled: !isStaticallyDisabledConfigExpression(property.initializer, analysis) };
449
+ if (typescriptBinding.isShorthandPropertyAssignment(property) && property.name.text === "reactCompiler") return { isEnabled: !isStaticallyDisabledConfigExpression(property.name, analysis) };
450
+ if (typescriptBinding.isSpreadAssignment(property)) {
451
+ const spreadState = getReactCompilerFlagState(property.expression, analysis, nextVisitedExpressions);
452
+ if (spreadState) return spreadState;
453
+ }
454
+ }
455
+ return null;
456
+ };
457
+ const getSelectedIdentifierObjectProperty = (identifier, propertyName, analysis, visitedExpressions) => {
458
+ if (analysis.localBindings.has(identifier.text)) {
459
+ const localReference = analysis.localBindings.get(identifier.text);
460
+ return localReference?.expression ? getSelectedObjectProperty(localReference.expression, propertyName, localReference.analysis, visitedExpressions) : null;
461
+ }
462
+ const scopedBinding = getScopedConfigBinding(identifier);
463
+ if (scopedBinding.wasFound) return scopedBinding.initializer ? getSelectedObjectProperty(scopedBinding.initializer, propertyName, analysis, visitedExpressions) : null;
464
+ const topLevelBinding = getTopLevelBinding(analysis.sourceFile, identifier.text);
465
+ return topLevelBinding && typescriptBinding.isExpression(topLevelBinding) ? getSelectedObjectProperty(topLevelBinding, propertyName, analysis, visitedExpressions) : null;
466
+ };
467
+ const getDirectObjectPropertyReference = (property, propertyName, analysis) => {
468
+ if (typescriptBinding.isPropertyAssignment(property) && getStaticPropertyName(property.name) === propertyName) return {
469
+ node: property.initializer,
470
+ analysis
471
+ };
472
+ if (typescriptBinding.isMethodDeclaration(property) && getStaticPropertyName(property.name) === propertyName) return {
473
+ node: property,
474
+ analysis
475
+ };
476
+ if (typescriptBinding.isShorthandPropertyAssignment(property) && property.name.text === propertyName) return {
477
+ node: property.name,
478
+ analysis
479
+ };
480
+ return null;
481
+ };
482
+ const getSelectedObjectLiteralProperty = (objectLiteral, propertyName, analysis, visitedExpressions) => {
483
+ for (const property of [...objectLiteral.properties].reverse()) {
484
+ const directProperty = getDirectObjectPropertyReference(property, propertyName, analysis);
485
+ if (directProperty) return directProperty;
486
+ if (!typescriptBinding.isSpreadAssignment(property)) continue;
487
+ const spreadProperty = getSelectedObjectProperty(property.expression, propertyName, analysis, visitedExpressions);
488
+ if (spreadProperty) return spreadProperty;
489
+ }
490
+ return null;
491
+ };
492
+ const getSelectedObjectProperty = (expression, propertyName, analysis, visitedExpressions = /* @__PURE__ */ new Set()) => {
493
+ const resolvedExpression = unwrapTypescriptExpression(expression);
494
+ if (visitedExpressions.has(resolvedExpression)) return null;
495
+ visitedExpressions.add(resolvedExpression);
496
+ if (typescriptBinding.isIdentifier(resolvedExpression)) return getSelectedIdentifierObjectProperty(resolvedExpression, propertyName, analysis, visitedExpressions);
497
+ return typescriptBinding.isObjectLiteralExpression(resolvedExpression) ? getSelectedObjectLiteralProperty(resolvedExpression, propertyName, analysis, visitedExpressions) : null;
498
+ };
499
+ const configExpressionMayDefineProperty = (expression, propertyName, analysis, visitedExpressions = /* @__PURE__ */ new Set()) => {
500
+ const resolvedExpression = unwrapTypescriptExpression(expression);
501
+ if (visitedExpressions.has(resolvedExpression)) return true;
502
+ const nextVisitedExpressions = new Set(visitedExpressions);
503
+ nextVisitedExpressions.add(resolvedExpression);
504
+ if (typescriptBinding.isIdentifier(resolvedExpression)) {
505
+ if (analysis.localBindings.has(resolvedExpression.text)) {
506
+ const localReference = analysis.localBindings.get(resolvedExpression.text);
507
+ return localReference?.expression ? configExpressionMayDefineProperty(localReference.expression, propertyName, localReference.analysis, nextVisitedExpressions) : true;
508
+ }
509
+ const scopedBinding = getScopedConfigBinding(resolvedExpression);
510
+ if (scopedBinding.wasFound) return scopedBinding.initializer ? configExpressionMayDefineProperty(scopedBinding.initializer, propertyName, analysis, nextVisitedExpressions) : true;
511
+ const topLevelBinding = getTopLevelBinding(analysis.sourceFile, resolvedExpression.text);
512
+ return topLevelBinding && typescriptBinding.isExpression(topLevelBinding) ? configExpressionMayDefineProperty(topLevelBinding, propertyName, analysis, nextVisitedExpressions) : true;
513
+ }
514
+ if (typescriptBinding.isConditionalExpression(resolvedExpression)) {
515
+ if (isStaticallyTruthyConfigExpression(resolvedExpression.condition, analysis)) return configExpressionMayDefineProperty(resolvedExpression.whenTrue, propertyName, analysis, nextVisitedExpressions);
516
+ if (isStaticallyDisabledConfigExpression(resolvedExpression.condition, analysis)) return configExpressionMayDefineProperty(resolvedExpression.whenFalse, propertyName, analysis, nextVisitedExpressions);
517
+ return configExpressionMayDefineProperty(resolvedExpression.whenTrue, propertyName, analysis, nextVisitedExpressions) || configExpressionMayDefineProperty(resolvedExpression.whenFalse, propertyName, analysis, nextVisitedExpressions);
518
+ }
519
+ if (!typescriptBinding.isObjectLiteralExpression(resolvedExpression)) return true;
520
+ return resolvedExpression.properties.some((property) => {
521
+ if (typescriptBinding.isSpreadAssignment(property)) return configExpressionMayDefineProperty(property.expression, propertyName, analysis, nextVisitedExpressions);
522
+ if (typescriptBinding.isPropertyAssignment(property) || typescriptBinding.isShorthandPropertyAssignment(property) || typescriptBinding.isMethodDeclaration(property) || typescriptBinding.isGetAccessorDeclaration(property) || typescriptBinding.isSetAccessorDeclaration(property)) {
523
+ const staticPropertyName = getStaticPropertyName(property.name);
524
+ return staticPropertyName === null || staticPropertyName === propertyName;
525
+ }
526
+ return false;
527
+ });
528
+ };
529
+ const getNamedObjectLiteralExportNode = (objectLiteral, exportName) => {
530
+ for (const property of [...objectLiteral.properties].reverse()) {
531
+ if (typescriptBinding.isPropertyAssignment(property) && getStaticPropertyName(property.name) === exportName) return property.initializer;
532
+ if (typescriptBinding.isShorthandPropertyAssignment(property) && property.name.text === exportName) return property.name;
533
+ }
534
+ return null;
535
+ };
536
+ const getCommonJsRootConfigExportMatch = (assignment, sourceFile, exportName) => {
537
+ if (!isCommonJsConfigExportAssignment(assignment, sourceFile)) return null;
538
+ if (exportName === "default") return {
539
+ node: assignment.right,
540
+ strategy: "replace-mutation"
541
+ };
542
+ if (!typescriptBinding.isObjectLiteralExpression(assignment.right)) return null;
543
+ const exportedNode = getNamedObjectLiteralExportNode(assignment.right, exportName);
544
+ return exportedNode ? {
545
+ node: exportedNode,
546
+ strategy: "source-order"
547
+ } : null;
548
+ };
549
+ const getCommonJsPropertyConfigExportMatch = (assignment, sourceFile, exportName) => {
550
+ if (assignment.left.getText(sourceFile) === `exports.${exportName}`) return {
551
+ node: assignment.right,
552
+ strategy: "source-order"
553
+ };
554
+ if (exportName !== "default" || !typescriptBinding.isPropertyAccessExpression(assignment.left) && !typescriptBinding.isElementAccessExpression(assignment.left)) return null;
555
+ const assignmentObjectText = assignment.left.expression.getText(sourceFile);
556
+ if (!getAccessedPropertyName(assignment.left) || assignmentObjectText !== "module.exports" && assignmentObjectText !== "exports" && assignmentObjectText !== "exports.default") return null;
557
+ return {
558
+ node: assignment,
559
+ strategy: "append-mutation"
560
+ };
561
+ };
562
+ const getCommonJsConfigExportMatch = (statement, sourceFile, exportName) => {
563
+ if (!typescriptBinding.isExpressionStatement(statement) || !typescriptBinding.isBinaryExpression(statement.expression) || statement.expression.operatorToken.kind !== typescriptBinding.SyntaxKind.EqualsToken) return null;
564
+ return getCommonJsRootConfigExportMatch(statement.expression, sourceFile, exportName) ?? getCommonJsPropertyConfigExportMatch(statement.expression, sourceFile, exportName);
565
+ };
566
+ const getExportedVariableInitializerNodes = (statement, exportName) => {
567
+ if (!typescriptBinding.isVariableStatement(statement) || !hasExportModifier(statement)) return [];
568
+ const exportedNodes = [];
569
+ for (const declaration of statement.declarationList.declarations) if (typescriptBinding.isIdentifier(declaration.name) && declaration.name.text === exportName && declaration.initializer) exportedNodes.push(declaration.initializer);
570
+ return exportedNodes;
571
+ };
572
+ const getLocalNamedExportNodes = (statement, exportName) => {
573
+ if (!typescriptBinding.isExportDeclaration(statement) || statement.moduleSpecifier || !statement.exportClause || !typescriptBinding.isNamedExports(statement.exportClause)) return [];
574
+ const exportedNodes = [];
575
+ for (const exportSpecifier of statement.exportClause.elements) if (exportSpecifier.name.text === exportName) exportedNodes.push(exportSpecifier.propertyName ?? exportSpecifier.name);
576
+ return exportedNodes;
577
+ };
578
+ const getDefaultEsmConfigExportNodes = (statement, exportName) => {
579
+ if (exportName !== "default") return [];
580
+ if (typescriptBinding.isExportAssignment(statement)) return [statement.expression];
581
+ if (!typescriptBinding.isFunctionDeclaration(statement) && !typescriptBinding.isClassDeclaration(statement)) return [];
582
+ if (!hasExportModifier(statement)) return [];
583
+ return typescriptBinding.getModifiers(statement)?.some((modifier) => modifier.kind === typescriptBinding.SyntaxKind.DefaultKeyword) ? [statement] : [];
584
+ };
585
+ const getEsmConfigExportNodes = (statement, exportName) => {
586
+ const exportedNodes = getDefaultEsmConfigExportNodes(statement, exportName);
587
+ exportedNodes.push(...getExportedVariableInitializerNodes(statement, exportName));
588
+ if (typescriptBinding.isFunctionDeclaration(statement) && hasExportModifier(statement) && statement.name?.text === exportName) exportedNodes.push(statement);
589
+ exportedNodes.push(...getLocalNamedExportNodes(statement, exportName));
590
+ return exportedNodes;
591
+ };
592
+ const getExportedConfigNodes = (sourceFile, exportName) => {
593
+ if ((sourceFile.fileName.endsWith(".json") || path$1.basename(sourceFile.fileName) === ".babelrc") && exportName === "default") return sourceFile.statements.flatMap((statement) => typescriptBinding.isExpressionStatement(statement) ? [statement.expression] : []);
594
+ const exportedNodes = [];
595
+ const commonJsExportedNodes = [];
596
+ for (const statement of sourceFile.statements) {
597
+ exportedNodes.push(...getEsmConfigExportNodes(statement, exportName));
598
+ const commonJsExportMatch = getCommonJsConfigExportMatch(statement, sourceFile, exportName);
599
+ if (!commonJsExportMatch) continue;
600
+ if (commonJsExportMatch.strategy === "source-order") {
601
+ exportedNodes.push(commonJsExportMatch.node);
602
+ continue;
603
+ }
604
+ if (commonJsExportMatch.strategy === "replace-mutation") commonJsExportedNodes.length = 0;
605
+ commonJsExportedNodes.push(commonJsExportMatch.node);
606
+ }
607
+ return [...exportedNodes, ...commonJsExportedNodes];
608
+ };
609
+ const getReExportedConfigModules = (sourceFile, exportName) => {
610
+ const bindings = [];
611
+ for (const statement of sourceFile.statements) {
612
+ if (!typescriptBinding.isExportDeclaration(statement) || statement.isTypeOnly || !statement.moduleSpecifier || !typescriptBinding.isStringLiteralLike(statement.moduleSpecifier)) continue;
613
+ if (!statement.exportClause && exportName !== "default") {
614
+ bindings.push({
615
+ moduleSpecifier: statement.moduleSpecifier.text,
616
+ exportName,
617
+ isNamespace: true
618
+ });
619
+ continue;
620
+ }
621
+ if (!statement.exportClause || !typescriptBinding.isNamedExports(statement.exportClause)) continue;
622
+ for (const exportSpecifier of statement.exportClause.elements) if (exportSpecifier.name.text === exportName) bindings.push({
623
+ moduleSpecifier: statement.moduleSpecifier.text,
624
+ exportName: (exportSpecifier.propertyName ?? exportSpecifier.name).text,
625
+ isNamespace: false
626
+ });
627
+ }
628
+ return bindings;
629
+ };
630
+ const analyzeConfigModuleExport = (filePath, exportName, allowCompilerTransform, importDepth, visitedModules, argumentsList = [], argumentAnalysis) => {
631
+ if (!isFile(filePath) || importDepth > 4) return false;
632
+ const moduleVisitKey = `${filePath}:${exportName}:${allowCompilerTransform}`;
633
+ if (visitedModules.has(moduleVisitKey)) return false;
634
+ const nextVisitedModules = new Set(visitedModules);
635
+ nextVisitedModules.add(moduleVisitKey);
636
+ let sourceText;
637
+ try {
638
+ sourceText = fs$1.readFileSync(filePath, "utf-8");
639
+ } catch {
640
+ return false;
641
+ }
642
+ return analyzeConfigSourceFileExport(parseConfigSourceFile(filePath, sourceText), filePath, exportName, allowCompilerTransform, importDepth, nextVisitedModules, argumentsList, argumentAnalysis);
643
+ };
644
+ const analyzeConfigSourceFileExport = (sourceFile, filePath, exportName, allowCompilerTransform, importDepth, visitedModules, argumentsList = [], argumentAnalysis) => {
645
+ const analysis = {
646
+ filePath,
647
+ sourceFile,
648
+ importDepth,
649
+ visitedModules,
650
+ visitedNodes: /* @__PURE__ */ new Set(),
651
+ localBindings: /* @__PURE__ */ new Map(),
652
+ activeFunctions: /* @__PURE__ */ new Set()
653
+ };
654
+ const resolvedArgumentAnalysis = argumentAnalysis ?? analysis;
655
+ const exportedConfigNodes = getExportedConfigNodes(sourceFile, exportName);
656
+ return exportedConfigNodes.some((node) => {
657
+ if (typescriptBinding.isArrowFunction(node) || typescriptBinding.isFunctionExpression(node) || typescriptBinding.isFunctionDeclaration(node)) return analyzeConfigFunction(node, analysis, allowCompilerTransform, argumentsList, resolvedArgumentAnalysis);
658
+ if (argumentsList.length > 0 && typescriptBinding.isIdentifier(node)) {
659
+ const topLevelBinding = getTopLevelBinding(sourceFile, node.text);
660
+ if (topLevelBinding && typescriptBinding.isFunctionLike(topLevelBinding)) return analyzeConfigFunction(topLevelBinding, analysis, allowCompilerTransform, argumentsList, resolvedArgumentAnalysis);
661
+ const importBinding = getImportBinding(sourceFile, node.text);
662
+ if (importBinding) {
663
+ const importedFilePath = resolveImportedConfigFile(filePath, importBinding.moduleSpecifier);
664
+ return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, importBinding.exportName, allowCompilerTransform, importDepth + 1, visitedModules, argumentsList, resolvedArgumentAnalysis));
665
+ }
666
+ }
667
+ return analyzeConfigNode(node, analysis, allowCompilerTransform);
668
+ }) || getReExportedConfigModules(sourceFile, exportName).some((binding) => {
669
+ if (exportedConfigNodes.length > 0 && binding.isNamespace) return false;
670
+ const importedFilePath = resolveImportedConfigFile(filePath, binding.moduleSpecifier);
671
+ return Boolean(importedFilePath && analyzeConfigModuleExport(importedFilePath, binding.exportName, allowCompilerTransform, importDepth + 1, visitedModules, argumentsList, resolvedArgumentAnalysis));
672
+ });
673
+ };
674
+ const analyzeConfigFunction = (functionNode, analysis, allowCompilerTransform, argumentsList = [], argumentAnalysis = analysis) => {
675
+ if (!functionNode.body) return false;
676
+ if (analysis.activeFunctions.has(functionNode.pos)) return false;
677
+ const activeFunctions = new Set(analysis.activeFunctions);
678
+ activeFunctions.add(functionNode.pos);
679
+ const functionAnalysis = {
680
+ ...analysis,
681
+ visitedNodes: /* @__PURE__ */ new Set(),
682
+ localBindings: getFunctionLocalBindings(functionNode, argumentsList, argumentAnalysis, analysis),
683
+ activeFunctions
684
+ };
685
+ if (!typescriptBinding.isBlock(functionNode.body)) return analyzeConfigNode(functionNode.body, functionAnalysis, allowCompilerTransform);
686
+ let hasCompiler = false;
687
+ const visitReturns = (node) => {
688
+ if (hasCompiler || node !== functionNode.body && typescriptBinding.isFunctionLike(node)) return;
689
+ if (typescriptBinding.isReturnStatement(node) && node.expression) {
690
+ hasCompiler = analyzeConfigNode(node.expression, functionAnalysis, allowCompilerTransform);
691
+ return;
692
+ }
693
+ typescriptBinding.forEachChild(node, visitReturns);
694
+ };
695
+ visitReturns(functionNode.body);
696
+ return hasCompiler;
697
+ };
698
+ const analyzeImportedConfig = ({ analysis, moduleSpecifier, exportName, allowCompilerTransform, argumentsList }) => {
699
+ const importedFilePath = resolveImportedConfigFile(analysis.filePath, moduleSpecifier);
700
+ if (!importedFilePath) return null;
701
+ return analyzeConfigModuleExport(importedFilePath, exportName, allowCompilerTransform, analysis.importDepth + 1, analysis.visitedModules, argumentsList, analysis);
702
+ };
703
+ const analyzeConfigIdentifier = (identifier, analysis, allowCompilerTransform, isCompilerTransformCollection, excludedPropertyNames) => {
704
+ const assignedReactCompiler = getAssignedPropertyInitializer(identifier, "reactCompiler");
705
+ if (assignedReactCompiler.initializer && !isStaticallyDisabledConfigExpression(assignedReactCompiler.initializer, analysis)) return true;
706
+ const assignedPlugins = getAssignedPropertyInitializer(identifier, "plugins");
707
+ if (assignedPlugins.initializer && analyzeConfigNode(assignedPlugins.initializer, analysis, true, true)) return true;
708
+ const assignedPresets = getAssignedPropertyInitializer(identifier, "presets");
709
+ if (assignedPresets.initializer && analyzeConfigNode(assignedPresets.initializer, analysis, true, true)) return true;
710
+ const overriddenPropertyNames = new Set(excludedPropertyNames);
711
+ if (assignedReactCompiler.wasFound) overriddenPropertyNames.add("reactCompiler");
712
+ if (assignedPlugins.wasFound) overriddenPropertyNames.add("plugins");
713
+ if (assignedPresets.wasFound) overriddenPropertyNames.add("presets");
714
+ if (analysis.localBindings.has(identifier.text)) {
715
+ const localReference = analysis.localBindings.get(identifier.text);
716
+ return Boolean(localReference?.expression && analyzeConfigNode(localReference.expression, localReference.analysis, allowCompilerTransform, isCompilerTransformCollection, overriddenPropertyNames));
717
+ }
718
+ const scopedBinding = getScopedConfigBinding(identifier);
719
+ if (scopedBinding.wasFound) return Boolean(scopedBinding.initializer && analyzeConfigNode(scopedBinding.initializer, analysis, allowCompilerTransform, isCompilerTransformCollection, overriddenPropertyNames));
720
+ const importBinding = getImportBinding(analysis.sourceFile, identifier.text);
721
+ if (importBinding) {
722
+ if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
723
+ return Boolean(analyzeImportedConfig({
724
+ analysis,
725
+ moduleSpecifier: importBinding.moduleSpecifier,
726
+ exportName: importBinding.exportName,
727
+ allowCompilerTransform
728
+ }));
729
+ }
730
+ const topLevelBinding = getTopLevelBinding(analysis.sourceFile, identifier.text);
731
+ return Boolean(topLevelBinding && analyzeConfigNode(topLevelBinding, analysis, allowCompilerTransform, isCompilerTransformCollection, overriddenPropertyNames));
732
+ };
733
+ const hasReactCompilerConfigInSentryWrapperArgument = (callExpression, analysis, moduleSpecifier, exportName) => {
734
+ if (moduleSpecifier !== "@sentry/nextjs" || exportName !== "withSentryConfig") return false;
735
+ const [configArgument] = callExpression.arguments;
736
+ return Boolean(configArgument && analyzeConfigNode(configArgument, analysis, false));
737
+ };
738
+ const hasEnabledCompilerOptionInVitePluginArgument = (callExpression, analysis, moduleSpecifier, exportName) => {
739
+ if (moduleSpecifier !== "@vitejs/plugin-react" || exportName !== "default") return false;
740
+ const [optionsArgument] = callExpression.arguments;
741
+ if (!optionsArgument) return false;
742
+ const compilerProperty = getSelectedObjectProperty(optionsArgument, "compiler", analysis);
743
+ if (compilerProperty === null) return false;
744
+ return !typescriptBinding.isExpression(compilerProperty.node) || !isStaticallyDisabledConfigExpression(compilerProperty.node, compilerProperty.analysis);
745
+ };
746
+ const hasReactCompilerConfigInCallArguments = (callExpression, analysis, moduleSpecifier, exportName) => hasReactCompilerConfigInSentryWrapperArgument(callExpression, analysis, moduleSpecifier, exportName) || hasEnabledCompilerOptionInVitePluginArgument(callExpression, analysis, moduleSpecifier, exportName);
747
+ const analyzeConfigCallTarget = (callExpression, analysis, allowCompilerTransform) => {
748
+ const target = callExpression.expression;
749
+ const callableRequiredModuleSpecifier = getRequireModuleSpecifier(target);
750
+ if (callableRequiredModuleSpecifier !== null) {
751
+ if (typescriptBinding.isCallExpression(target) && typescriptBinding.isIdentifier(target.expression) && (analysis.localBindings.has(target.expression.text) || getScopedConfigBinding(target.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
752
+ if (allowCompilerTransform && isCompilerTransformModule(callableRequiredModuleSpecifier, "default")) return true;
753
+ if (hasReactCompilerConfigInCallArguments(callExpression, analysis, callableRequiredModuleSpecifier, "default")) return true;
754
+ const hasCompilerTransform = analyzeImportedConfig({
755
+ analysis,
756
+ moduleSpecifier: callableRequiredModuleSpecifier,
757
+ exportName: "default",
758
+ allowCompilerTransform,
759
+ argumentsList: callExpression.arguments
760
+ });
761
+ if (isLocalModuleSpecifier(callableRequiredModuleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
762
+ return null;
763
+ }
764
+ if (!typescriptBinding.isPropertyAccessExpression(target) && !typescriptBinding.isElementAccessExpression(target)) return null;
765
+ const propertyName = getAccessedPropertyName(target);
766
+ if (propertyName === null) return null;
767
+ const requiredModuleSpecifier = getRequireModuleSpecifier(target.expression);
768
+ if (requiredModuleSpecifier !== null) {
769
+ if (typescriptBinding.isCallExpression(target.expression) && typescriptBinding.isIdentifier(target.expression.expression) && (analysis.localBindings.has(target.expression.expression.text) || getScopedConfigBinding(target.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
770
+ if (allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, propertyName)) return true;
771
+ if (hasReactCompilerConfigInCallArguments(callExpression, analysis, requiredModuleSpecifier, propertyName)) return true;
772
+ const hasCompilerTransform = analyzeImportedConfig({
773
+ analysis,
774
+ moduleSpecifier: requiredModuleSpecifier,
775
+ exportName: propertyName,
776
+ allowCompilerTransform,
777
+ argumentsList: callExpression.arguments
778
+ });
779
+ if (isLocalModuleSpecifier(requiredModuleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
780
+ return null;
781
+ }
782
+ if (!typescriptBinding.isIdentifier(target.expression)) return null;
783
+ const importBinding = analysis.localBindings.has(target.expression.text) || getScopedConfigBinding(target.expression).wasFound ? null : getImportBinding(analysis.sourceFile, target.expression.text);
784
+ if (importBinding?.isNamespace) {
785
+ if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, propertyName)) return true;
786
+ if (hasReactCompilerConfigInCallArguments(callExpression, analysis, importBinding.moduleSpecifier, propertyName)) return true;
787
+ const hasCompilerTransform = analyzeImportedConfig({
788
+ analysis,
789
+ moduleSpecifier: importBinding.moduleSpecifier,
790
+ exportName: propertyName,
791
+ allowCompilerTransform,
792
+ argumentsList: callExpression.arguments
793
+ });
794
+ if (isLocalModuleSpecifier(importBinding.moduleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
795
+ return null;
796
+ }
797
+ const selectedProperty = getSelectedObjectProperty(target.expression, propertyName, analysis);
798
+ if (selectedProperty === null) return null;
799
+ return typescriptBinding.isFunctionLike(selectedProperty.node) ? analyzeConfigFunction(selectedProperty.node, selectedProperty.analysis, allowCompilerTransform, callExpression.arguments, analysis) : analyzeConfigNode(selectedProperty.node, selectedProperty.analysis, allowCompilerTransform);
800
+ };
801
+ const analyzeConfigMemberAccess = (expression, propertyName, analysis, allowCompilerTransform) => {
802
+ if (!typescriptBinding.isIdentifier(expression)) return analyzeConfigNode(expression, analysis, allowCompilerTransform);
803
+ if (analysis.localBindings.has(expression.text) || getScopedConfigBinding(expression).wasFound) {
804
+ const selectedProperty = getSelectedObjectProperty(expression, propertyName, analysis);
805
+ return Boolean(selectedProperty && analyzeConfigNode(selectedProperty.node, selectedProperty.analysis, allowCompilerTransform));
806
+ }
807
+ const importBinding = getImportBinding(analysis.sourceFile, expression.text);
808
+ if (importBinding?.isNamespace) {
809
+ if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, propertyName)) return true;
810
+ return Boolean(analyzeImportedConfig({
811
+ analysis,
812
+ moduleSpecifier: importBinding.moduleSpecifier,
813
+ exportName: propertyName,
814
+ allowCompilerTransform
815
+ }));
816
+ }
817
+ const selectedProperty = getSelectedObjectProperty(expression, propertyName, analysis);
818
+ return Boolean(selectedProperty && analyzeConfigNode(selectedProperty.node, selectedProperty.analysis, allowCompilerTransform));
819
+ };
820
+ const analyzeConfigNode = (node, analysis, allowCompilerTransform, isCompilerTransformCollection = false, excludedPropertyNames) => {
821
+ const excludedPropertiesVisitKey = excludedPropertyNames ? [...excludedPropertyNames].sort().join(",") : "";
822
+ const nodeVisitKey = `${node.pos}:${node.end}:${allowCompilerTransform}:${isCompilerTransformCollection}:${excludedPropertiesVisitKey}`;
823
+ if (analysis.visitedNodes.has(nodeVisitKey)) return false;
824
+ analysis.visitedNodes.add(nodeVisitKey);
825
+ if (typescriptBinding.isIdentifier(node)) return analyzeConfigIdentifier(node, analysis, allowCompilerTransform, isCompilerTransformCollection, excludedPropertyNames);
826
+ if (typescriptBinding.isStringLiteralLike(node)) return allowCompilerTransform && (node.text === "babel-plugin-react-compiler" || node.text === "react-compiler");
827
+ if (isTransparentConfigExpression(node)) return analyzeConfigNode(node.expression, analysis, allowCompilerTransform, isCompilerTransformCollection, excludedPropertyNames);
828
+ if (typescriptBinding.isObjectLiteralExpression(node)) {
829
+ const reactCompilerFlagState = excludedPropertyNames?.has("reactCompiler") ? null : getReactCompilerFlagState(node, analysis);
830
+ if (reactCompilerFlagState?.isEnabled) return true;
831
+ for (const [propertyIndex, property] of node.properties.entries()) if (typescriptBinding.isPropertyAssignment(property)) {
832
+ const propertyName = getStaticPropertyName(property.name);
833
+ if (propertyName && excludedPropertyNames?.has(propertyName)) continue;
834
+ if (propertyName === "reactCompiler") continue;
835
+ if ((propertyName === "plugins" || propertyName === "presets") && node.properties.slice(propertyIndex + 1).some((laterProperty) => typescriptBinding.isSpreadAssignment(laterProperty) && configExpressionMayDefineProperty(laterProperty.expression, propertyName, analysis) || (typescriptBinding.isPropertyAssignment(laterProperty) || typescriptBinding.isShorthandPropertyAssignment(laterProperty)) && getStaticPropertyName(laterProperty.name) === propertyName)) continue;
836
+ const propertyAllowsCompilerTransform = propertyName === "plugins" || propertyName === "presets";
837
+ if (propertyName === "extends" && typescriptBinding.isStringLiteralLike(property.initializer)) {
838
+ if (analyzeImportedConfig({
839
+ analysis,
840
+ moduleSpecifier: property.initializer.text,
841
+ exportName: "default",
842
+ allowCompilerTransform: false
843
+ })) return true;
844
+ }
845
+ if (analyzeConfigNode(property.initializer, analysis, propertyAllowsCompilerTransform, propertyAllowsCompilerTransform)) return true;
846
+ } else if (typescriptBinding.isShorthandPropertyAssignment(property)) {
847
+ if (excludedPropertyNames?.has(property.name.text)) continue;
848
+ if (property.name.text === "reactCompiler") continue;
849
+ if ((property.name.text === "plugins" || property.name.text === "presets") && node.properties.slice(propertyIndex + 1).some((laterProperty) => typescriptBinding.isSpreadAssignment(laterProperty) && configExpressionMayDefineProperty(laterProperty.expression, property.name.text, analysis) || (typescriptBinding.isPropertyAssignment(laterProperty) || typescriptBinding.isShorthandPropertyAssignment(laterProperty)) && getStaticPropertyName(laterProperty.name) === property.name.text)) continue;
850
+ const propertyAllowsCompilerTransform = property.name.text === "plugins" || property.name.text === "presets";
851
+ if (analyzeConfigNode(property.name, analysis, propertyAllowsCompilerTransform, propertyAllowsCompilerTransform)) return true;
852
+ } else if (typescriptBinding.isSpreadAssignment(property)) {
853
+ if (reactCompilerFlagState && getReactCompilerFlagState(property.expression, analysis) !== null) continue;
854
+ if (node.properties.slice(propertyIndex + 1).some((laterProperty) => (typescriptBinding.isPropertyAssignment(laterProperty) || typescriptBinding.isShorthandPropertyAssignment(laterProperty)) && (getStaticPropertyName(laterProperty.name) === "plugins" || getStaticPropertyName(laterProperty.name) === "presets"))) continue;
855
+ if (analyzeConfigNode(property.expression, analysis, allowCompilerTransform, false, excludedPropertyNames)) return true;
856
+ }
857
+ return false;
858
+ }
859
+ if (typescriptBinding.isArrayLiteralExpression(node)) {
860
+ if (isCompilerTransformCollection) return node.elements.some((element) => analyzeConfigNode(typescriptBinding.isSpreadElement(element) ? element.expression : element, analysis, allowCompilerTransform, typescriptBinding.isSpreadElement(element)));
861
+ const isTransformTuple = allowCompilerTransform && node.elements.length > 1 && typescriptBinding.isStringLiteralLike(node.elements[0]) && node.elements[0].text !== "babel-plugin-react-compiler" && node.elements[0].text !== "react-compiler";
862
+ return node.elements.some((element, elementIndex) => {
863
+ return analyzeConfigNode(typescriptBinding.isSpreadElement(element) ? element.expression : element, analysis, allowCompilerTransform && (!isTransformTuple || elementIndex === 0));
864
+ });
865
+ }
866
+ if (typescriptBinding.isCallExpression(node)) {
867
+ const resolvedModuleSpecifier = getNodeRequireResolveModuleSpecifier(node, analysis);
868
+ if (resolvedModuleSpecifier !== null) return allowCompilerTransform && isCompilerTransformModule(resolvedModuleSpecifier, "default");
869
+ const callTargetResult = analyzeConfigCallTarget(node, analysis, allowCompilerTransform);
870
+ if (callTargetResult !== null) return callTargetResult;
871
+ const directModuleSpecifier = getRequireModuleSpecifier(node);
872
+ const isRequireShadowed = analysis.localBindings.has("require") || typescriptBinding.isIdentifier(node.expression) && getScopedConfigBinding(node.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require");
873
+ if (directModuleSpecifier && isRequireShadowed) return analyzeConfigNode(node.expression, analysis, allowCompilerTransform);
874
+ if (directModuleSpecifier && !isRequireShadowed) {
875
+ if (allowCompilerTransform && isCompilerTransformModule(directModuleSpecifier, "default")) return true;
876
+ if (analyzeImportedConfig({
877
+ analysis,
878
+ moduleSpecifier: directModuleSpecifier,
879
+ exportName: "default",
880
+ allowCompilerTransform
881
+ })) return true;
882
+ }
883
+ if (typescriptBinding.isIdentifier(node.expression)) {
884
+ if (!analysis.localBindings.has(node.expression.text) && !getScopedConfigBinding(node.expression).wasFound) {
885
+ const importBinding = getImportBinding(analysis.sourceFile, node.expression.text);
886
+ if (importBinding) {
887
+ if (allowCompilerTransform && isCompilerTransformModule(importBinding.moduleSpecifier, importBinding.exportName)) return true;
888
+ if (hasReactCompilerConfigInCallArguments(node, analysis, importBinding.moduleSpecifier, importBinding.exportName)) return true;
889
+ if (allowCompilerTransform && importBinding.moduleSpecifier === "@rolldown/plugin-babel" && importBinding.exportName === "default" && node.arguments.some((argument) => analyzeConfigNode(argument, analysis, false))) return true;
890
+ const hasCompilerTransform = analyzeImportedConfig({
891
+ analysis,
892
+ moduleSpecifier: importBinding.moduleSpecifier,
893
+ exportName: importBinding.exportName,
894
+ allowCompilerTransform,
895
+ argumentsList: node.arguments
896
+ });
897
+ if (isLocalModuleSpecifier(importBinding.moduleSpecifier) || hasCompilerTransform !== null) return Boolean(hasCompilerTransform);
898
+ }
899
+ }
900
+ const topLevelBinding = getTopLevelBinding(analysis.sourceFile, node.expression.text);
901
+ if (topLevelBinding && typescriptBinding.isFunctionLike(topLevelBinding) && analyzeConfigFunction(topLevelBinding, analysis, allowCompilerTransform, node.arguments)) return true;
902
+ }
903
+ return analyzeConfigNode(node.expression, analysis, allowCompilerTransform) || node.arguments.some((argument) => analyzeConfigNode(argument, analysis, false));
904
+ }
905
+ if (typescriptBinding.isPropertyAccessExpression(node)) {
906
+ const requiredModuleSpecifier = getRequireModuleSpecifier(node.expression);
907
+ if (requiredModuleSpecifier) {
908
+ if (typescriptBinding.isCallExpression(node.expression) && typescriptBinding.isIdentifier(node.expression.expression) && (analysis.localBindings.has(node.expression.expression.text) || getScopedConfigBinding(node.expression.expression).wasFound || hasTopLevelValueBinding(analysis.sourceFile, "require"))) return false;
909
+ if (analyzeImportedConfig({
910
+ analysis,
911
+ moduleSpecifier: requiredModuleSpecifier,
912
+ exportName: node.name.text,
913
+ allowCompilerTransform
914
+ })) return true;
915
+ return allowCompilerTransform && isCompilerTransformModule(requiredModuleSpecifier, node.name.text);
916
+ }
917
+ return analyzeConfigMemberAccess(node.expression, node.name.text, analysis, allowCompilerTransform);
918
+ }
919
+ if (typescriptBinding.isElementAccessExpression(node) && node.argumentExpression && typescriptBinding.isStringLiteralLike(node.argumentExpression)) return analyzeConfigMemberAccess(node.expression, node.argumentExpression.text, analysis, allowCompilerTransform);
920
+ if (typescriptBinding.isBinaryExpression(node)) {
921
+ if (node.operatorToken.kind === typescriptBinding.SyntaxKind.AmpersandAmpersandToken) return !isStaticallyDisabledConfigExpression(node.left, analysis) && analyzeConfigNode(node.right, analysis, allowCompilerTransform, isCompilerTransformCollection);
922
+ if (node.operatorToken.kind === typescriptBinding.SyntaxKind.EqualsToken) {
923
+ const leftText = node.left.getText(analysis.sourceFile);
924
+ const assignedPropertyName = typescriptBinding.isPropertyAccessExpression(node.left) ? node.left.name.text : typescriptBinding.isElementAccessExpression(node.left) && node.left.argumentExpression && typescriptBinding.isStringLiteralLike(node.left.argumentExpression) ? node.left.argumentExpression.text : null;
925
+ if (assignedPropertyName === "reactCompiler" || leftText.endsWith(".reactCompiler")) return !isStaticallyDisabledConfigExpression(node.right, analysis);
926
+ if (assignedPropertyName === "plugins" || assignedPropertyName === "presets" || leftText.endsWith(".plugins") || leftText.endsWith(".presets")) return analyzeConfigNode(node.right, analysis, true, true);
927
+ return analyzeConfigNode(node.right, analysis, allowCompilerTransform);
928
+ }
929
+ if (node.operatorToken.kind === typescriptBinding.SyntaxKind.BarBarToken) {
930
+ if (isStaticallyTruthyConfigExpression(node.left, analysis)) return analyzeConfigNode(node.left, analysis, allowCompilerTransform, isCompilerTransformCollection);
931
+ if (isStaticallyDisabledConfigExpression(node.left, analysis)) return analyzeConfigNode(node.right, analysis, allowCompilerTransform, isCompilerTransformCollection);
932
+ return analyzeConfigNode(node.left, analysis, allowCompilerTransform, isCompilerTransformCollection) || analyzeConfigNode(node.right, analysis, allowCompilerTransform, isCompilerTransformCollection);
933
+ }
934
+ if (node.operatorToken.kind === typescriptBinding.SyntaxKind.QuestionQuestionToken) {
935
+ if (isStaticallyNullishConfigExpression(node.left, analysis)) return analyzeConfigNode(node.right, analysis, allowCompilerTransform, isCompilerTransformCollection);
936
+ if (isStaticallyNonNullishConfigExpression(node.left, analysis)) return analyzeConfigNode(node.left, analysis, allowCompilerTransform, isCompilerTransformCollection);
937
+ return analyzeConfigNode(node.left, analysis, allowCompilerTransform, isCompilerTransformCollection) || analyzeConfigNode(node.right, analysis, allowCompilerTransform, isCompilerTransformCollection);
938
+ }
939
+ }
940
+ if (typescriptBinding.isConditionalExpression(node)) {
941
+ if (isStaticallyTruthyConfigExpression(node.condition, analysis)) return analyzeConfigNode(node.whenTrue, analysis, allowCompilerTransform, isCompilerTransformCollection);
942
+ if (isStaticallyDisabledConfigExpression(node.condition, analysis)) return analyzeConfigNode(node.whenFalse, analysis, allowCompilerTransform, isCompilerTransformCollection);
943
+ return analyzeConfigNode(node.whenTrue, analysis, allowCompilerTransform, isCompilerTransformCollection) || analyzeConfigNode(node.whenFalse, analysis, allowCompilerTransform, isCompilerTransformCollection);
944
+ }
945
+ if (typescriptBinding.isArrowFunction(node) || typescriptBinding.isFunctionExpression(node) || typescriptBinding.isFunctionDeclaration(node)) return analyzeConfigFunction(node, analysis, allowCompilerTransform);
946
+ return false;
947
+ };
948
+ const hasCompilerInConfigFile = (filePath) => analyzeConfigModuleExport(filePath, "default", false, 0, /* @__PURE__ */ new Set());
949
+ const hasCompilerInConfigFiles = (directory, filenames) => {
950
+ const presentEntryNames = new Set(readDirectoryEntries(directory).map((entry) => entry.name.toLowerCase()));
951
+ return filenames.some((filename) => presentEntryNames.has(filename.toLowerCase()) && hasCompilerInConfigFile(path$1.join(directory, filename)));
952
+ };
953
+ const hasCompilerInPackageJsonConfig = (directory, packageJson) => {
954
+ if (!isPlainObject(packageJson.babel)) return false;
955
+ const packageJsonPath = path$1.join(directory, "package.json");
956
+ return analyzeConfigSourceFileExport(typescriptBinding.parseJsonText(packageJsonPath, JSON.stringify(packageJson.babel)), packageJsonPath, "default", false, 0, /* @__PURE__ */ new Set());
957
+ };
958
+ const hasReactCompilerConfiguration = (directory, packageJson) => hasCompilerInPackageJsonConfig(directory, packageJson) || hasCompilerInConfigFiles(directory, REACT_COMPILER_CONFIG_FILENAMES);
959
+ const hasReactCompilerConfigurationInAncestors = (directory) => {
960
+ if (isProjectBoundary(directory)) return false;
961
+ let ancestorDirectory = path$1.dirname(directory);
962
+ while (ancestorDirectory !== path$1.dirname(ancestorDirectory)) {
963
+ const ancestorPackagePath = path$1.join(ancestorDirectory, "package.json");
964
+ const ancestorPackageJson = isFile(ancestorPackagePath) ? readPackageJson(ancestorPackagePath) : {};
965
+ if (hasCompilerInPackageJsonConfig(ancestorDirectory, ancestorPackageJson) || hasCompilerInConfigFiles(ancestorDirectory, BABEL_CONFIG_FILENAMES)) return true;
966
+ if (isProjectBoundary(ancestorDirectory)) return false;
967
+ ancestorDirectory = path$1.dirname(ancestorDirectory);
968
+ }
969
+ return false;
970
+ };
971
+ //#endregion
972
+ //#region ../core/src/project-info/detect-react-compiler.ts
973
+ const REACT_COMPILER_RUNTIME_PACKAGES = new Set(["react-compiler-runtime"]);
974
+ const hasCompilerPackage = (packageJson, compilerPackages) => {
975
+ const allDependencies = {
976
+ ...packageJson.peerDependencies,
977
+ ...packageJson.dependencies,
978
+ ...packageJson.devDependencies
979
+ };
980
+ return Object.keys(allDependencies).some((packageName) => compilerPackages.has(packageName));
981
+ };
982
+ const hasCompilerPackageInAncestors = (directory, compilerPackages) => {
983
+ if (isProjectBoundary(directory)) return false;
984
+ let ancestorDirectory = path$1.dirname(directory);
985
+ while (ancestorDirectory !== path$1.dirname(ancestorDirectory)) {
986
+ const ancestorPackagePath = path$1.join(ancestorDirectory, "package.json");
987
+ if (isFile(ancestorPackagePath)) {
988
+ if (hasCompilerPackage(readPackageJson(ancestorPackagePath), compilerPackages)) return true;
989
+ }
990
+ if (isProjectBoundary(ancestorDirectory)) return false;
991
+ ancestorDirectory = path$1.dirname(ancestorDirectory);
992
+ }
993
+ return false;
994
+ };
995
+ const detectReactCompiler = (directory, packageJson) => hasCompilerPackage(packageJson, REACT_COMPILER_RUNTIME_PACKAGES) || hasCompilerPackageInAncestors(directory, REACT_COMPILER_RUNTIME_PACKAGES) || hasReactCompilerConfiguration(directory, packageJson) || hasReactCompilerConfigurationInAncestors(directory);
996
+ //#endregion
997
+ //#region ../core/src/project-info/react-compiler-detection-worker-protocol.ts
998
+ const isReactCompilerDetectionRequest = (value) => typeof value === "object" && value !== null && "id" in value && typeof value.id === "number" && "directory" in value && typeof value.directory === "string";
999
+ //#endregion
1000
+ //#region ../core/src/start-react-compiler-detection-worker.ts
1001
+ const detectForDirectory = (directory) => {
1002
+ const packageJsonPath = path$1.join(directory, "package.json");
1003
+ if (!isFile(packageJsonPath)) return null;
1004
+ try {
1005
+ return detectReactCompiler(directory, readPackageJson(packageJsonPath));
1006
+ } catch {
1007
+ return null;
1008
+ }
1009
+ };
1010
+ const startReactCompilerDetectionWorker = () => {
1011
+ if (parentPort === null) throw new Error("React Compiler detection worker must run as a worker thread.");
1012
+ const port = parentPort;
1013
+ port.on("message", (message) => {
1014
+ if (!isReactCompilerDetectionRequest(message)) return;
1015
+ const reply = {
1016
+ id: message.id,
1017
+ hasReactCompiler: detectForDirectory(message.directory)
1018
+ };
1019
+ port.postMessage(reply);
1020
+ });
1021
+ };
1022
+ //#endregion
1023
+ //#region src/react-compiler-detection-worker.ts
1024
+ startReactCompilerDetectionWorker();
1025
+ //#endregion
1026
+ export {};
1027
+
1028
+ //# sourceMappingURL=react-compiler-detection-worker.js.map
1029
+ //# debugId=538f795a-ce66-5950-bf7f-048038bff5f8