styled-components-to-stylex-codemod 0.0.23 → 0.0.25
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.
- package/dist/{bridge-consumer-patcher-C2mFaVmd.mjs → bridge-consumer-patcher-yD2M8NhV.mjs} +8 -19
- package/dist/{forwarded-as-consumer-patcher-CIOAJ-51.mjs → forwarded-as-consumer-patcher-DobBjqdG.mjs} +2 -11
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +5 -5
- package/dist/{logger-Cml101qs.d.mts → logger-B_bwk2gd.d.mts} +1 -1
- package/dist/path-utils-CTsuWb5f.mjs +22 -0
- package/dist/{run-prepass-DV-4A_Ci.mjs → run-prepass-Dl49r3ug.mjs} +3 -5
- package/dist/transform.d.mts +1 -1
- package/dist/transform.mjs +1236 -503
- package/dist/{transient-prop-consumer-patcher-iofVVX40.mjs → transient-prop-consumer-patcher-DAX9HWDH.mjs} +2 -8
- package/package.json +1 -1
- /package/dist/{resolve-imports-4bFqrkrQ.mjs → resolve-imports-CN7ulI4X.mjs} +0 -0
- /package/dist/{selector-context-heuristic-Cki9_tTH.mjs → selector-context-heuristic-CQgP_0dH.mjs} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { n as escapeRegex } from "./string-utils-J3iaDsXd.mjs";
|
|
2
|
+
import { t as toRealPath } from "./path-utils-CTsuWb5f.mjs";
|
|
3
|
+
import { t as isSelectorContext } from "./selector-context-heuristic-CQgP_0dH.mjs";
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
4
5
|
|
|
5
6
|
//#region src/internal/bridge-consumer-patcher.ts
|
|
6
7
|
/**
|
|
@@ -71,9 +72,9 @@ function patchConsumerFile(filePath, replacements) {
|
|
|
71
72
|
let modified = source;
|
|
72
73
|
for (const [importSource, reps] of bySource) {
|
|
73
74
|
const varNames = reps.map((r) => r.globalSelectorVarName);
|
|
74
|
-
const importRegex = new RegExp(`(import\\s+(?:(?:\\{[^}]*\\}|[^;{]+)\\s+from\\s+['"]${
|
|
75
|
+
const importRegex = new RegExp(`(import\\s+(?:(?:\\{[^}]*\\}|[^;{]+)\\s+from\\s+['"]${escapeRegex(importSource)}['"])\\s*;?)`);
|
|
75
76
|
if (modified.match(importRegex)) {
|
|
76
|
-
const namedImportRegex = new RegExp(`(import\\s+(?:[\\w$]+\\s*,\\s*)?\\{)([^}]*)(\\}\\s+from\\s+['"]${
|
|
77
|
+
const namedImportRegex = new RegExp(`(import\\s+(?:[\\w$]+\\s*,\\s*)?\\{)([^}]*)(\\}\\s+from\\s+['"]${escapeRegex(importSource)}['"]\\s*;?)`);
|
|
77
78
|
const namedMatch = modified.match(namedImportRegex);
|
|
78
79
|
if (namedMatch) {
|
|
79
80
|
const existingNames = namedMatch[2];
|
|
@@ -96,7 +97,7 @@ function patchConsumerFile(filePath, replacements) {
|
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
for (const r of replacements) {
|
|
99
|
-
const templateExprRegex = new RegExp(`(\\$\\{\\s*)${
|
|
100
|
+
const templateExprRegex = new RegExp(`(\\$\\{\\s*)${escapeRegex(r.localName)}(\\s*\\})`, "g");
|
|
100
101
|
modified = modified.replace(templateExprRegex, (match, prefix, suffix, offset) => {
|
|
101
102
|
if (isInStyledTemplateSelectorContext(modified, offset, match.length)) return `${prefix}${r.globalSelectorVarName}${suffix}`;
|
|
102
103
|
return match;
|
|
@@ -117,19 +118,7 @@ function isInStyledTemplateSelectorContext(source, offset, length) {
|
|
|
117
118
|
}
|
|
118
119
|
/** Check if a name appears as a distinct identifier in an import specifier list string. */
|
|
119
120
|
function hasExactImportName(importSpecifiers, name) {
|
|
120
|
-
return new RegExp(`(?:^|[^A-Za-z0-9_$])${
|
|
121
|
-
}
|
|
122
|
-
function escapeRegExp(s) {
|
|
123
|
-
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
124
|
-
}
|
|
125
|
-
/** Resolve symlinks so paths match the keys in transformedFiles (which uses realpathSync). */
|
|
126
|
-
function toRealPath(filePath) {
|
|
127
|
-
const resolved = resolve(filePath);
|
|
128
|
-
try {
|
|
129
|
-
return realpathSync(resolved);
|
|
130
|
-
} catch {
|
|
131
|
-
return resolved;
|
|
132
|
-
}
|
|
121
|
+
return new RegExp(`(?:^|[^A-Za-z0-9_$])${escapeRegex(name)}(?:$|[^A-Za-z0-9_$])`).test(importSpecifiers);
|
|
133
122
|
}
|
|
134
123
|
|
|
135
124
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as escapeRegex } from "./string-utils-J3iaDsXd.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { readFileSync
|
|
2
|
+
import { t as toRealPath } from "./path-utils-CTsuWb5f.mjs";
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
4
4
|
|
|
5
5
|
//#region src/internal/forwarded-as-consumer-patcher.ts
|
|
6
6
|
/**
|
|
@@ -77,15 +77,6 @@ function patchAttrsAsProp(source, componentName) {
|
|
|
77
77
|
return `${before}forwardedAs${after}`;
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
|
-
/** Resolve symlinks so paths match the keys in transformedFiles. */
|
|
81
|
-
function toRealPath(filePath) {
|
|
82
|
-
const resolved = resolve(filePath);
|
|
83
|
-
try {
|
|
84
|
-
return realpathSync(resolved);
|
|
85
|
-
} catch {
|
|
86
|
-
return resolved;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
80
|
|
|
90
81
|
//#endregion
|
|
91
82
|
export { buildForwardedAsReplacements, patchConsumerForwardedAs };
|
package/dist/index.d.mts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -141,9 +141,9 @@ async function runTransform(options) {
|
|
|
141
141
|
`Pattern(s): ${consumerPatterns.join(", ")}`,
|
|
142
142
|
"Check that the glob pattern is correct and files exist."
|
|
143
143
|
].join("\n"));
|
|
144
|
-
const { createModuleResolver } = await import("./resolve-imports-
|
|
144
|
+
const { createModuleResolver } = await import("./resolve-imports-CN7ulI4X.mjs");
|
|
145
145
|
const sharedResolver = createModuleResolver();
|
|
146
|
-
const { runPrepass } = await import("./run-prepass-
|
|
146
|
+
const { runPrepass } = await import("./run-prepass-Dl49r3ug.mjs");
|
|
147
147
|
const absoluteFiles = filePaths.map((f) => resolve(f));
|
|
148
148
|
const absoluteConsumers = consumerFilePaths.map((f) => resolve(f));
|
|
149
149
|
let prepassResult;
|
|
@@ -234,7 +234,7 @@ async function runTransform(options) {
|
|
|
234
234
|
});
|
|
235
235
|
if (sidecarFiles.size > 0 && !dryRun) for (const [sidecarPath, content] of sidecarFiles) await writeFile(sidecarPath, mergeSidecarContent(sidecarPath, content), "utf-8");
|
|
236
236
|
if (bridgeResults.size > 0 && !dryRun) {
|
|
237
|
-
const { buildConsumerReplacements, patchConsumerFile } = await import("./bridge-consumer-patcher-
|
|
237
|
+
const { buildConsumerReplacements, patchConsumerFile } = await import("./bridge-consumer-patcher-yD2M8NhV.mjs");
|
|
238
238
|
const consumerReplacements = buildConsumerReplacements(crossFilePrepassResult.selectorUsages, bridgeResults, transformedFiles);
|
|
239
239
|
const patchedFiles = [];
|
|
240
240
|
for (const [consumerPath, replacements] of consumerReplacements) {
|
|
@@ -247,7 +247,7 @@ async function runTransform(options) {
|
|
|
247
247
|
if (formatterCommands && patchedFiles.length > 0) await runFormatters(formatterCommands, patchedFiles);
|
|
248
248
|
}
|
|
249
249
|
if (prepassResult.forwardedAsConsumers.size > 0 && !dryRun) {
|
|
250
|
-
const { buildForwardedAsReplacements, patchConsumerForwardedAs } = await import("./forwarded-as-consumer-patcher-
|
|
250
|
+
const { buildForwardedAsReplacements, patchConsumerForwardedAs } = await import("./forwarded-as-consumer-patcher-DobBjqdG.mjs");
|
|
251
251
|
const forwardedAsReplacements = buildForwardedAsReplacements(prepassResult.forwardedAsConsumers, transformedFiles);
|
|
252
252
|
const patchedFiles = [];
|
|
253
253
|
for (const [consumerPath, entries] of forwardedAsReplacements) {
|
|
@@ -260,7 +260,7 @@ async function runTransform(options) {
|
|
|
260
260
|
if (formatterCommands && patchedFiles.length > 0) await runFormatters(formatterCommands, patchedFiles);
|
|
261
261
|
}
|
|
262
262
|
if (transientPropRenames.size > 0 && !dryRun) {
|
|
263
|
-
const { collectTransientPropPatches } = await import("./transient-prop-consumer-patcher-
|
|
263
|
+
const { collectTransientPropPatches } = await import("./transient-prop-consumer-patcher-DAX9HWDH.mjs");
|
|
264
264
|
const patches = collectTransientPropPatches({
|
|
265
265
|
transientPropRenames,
|
|
266
266
|
consumerFilePaths: consumerFilePaths.map((p) => resolve(p)),
|
|
@@ -648,7 +648,7 @@ declare function defineAdapter<T extends AdapterInput>(adapter: T): T;
|
|
|
648
648
|
//#endregion
|
|
649
649
|
//#region src/internal/logger.d.ts
|
|
650
650
|
type Severity = "info" | "warning" | "error";
|
|
651
|
-
type WarningType = "`css` helper function switch must return css templates in all branches" | "`css` helper usage as a function call (css(...)) is not supported" | "`css` helper used outside of a styled component template cannot be statically transformed" | "Adapter helper call in border interpolation did not resolve to a single CSS value" | "Adapter resolveCall returned an unparseable styles expression" | "Adapter resolveCall returned an unparseable value expression" | "Adapter resolveCall returned StyleX styles for helper call where a CSS value was expected" | "Adapter resolveCall returned undefined for helper call" | "Adapter resolveBaseComponent threw an error" | "Adapter resolved StyleX styles cannot be applied under nested selectors/at-rules" | "Adapter resolved StyleX styles inside pseudo selector but did not provide cssText for property expansion — add cssText to resolveCall result to enable pseudo-wrapping" | 'Adapter resolveCall cssText could not be parsed as CSS declarations — expected semicolon-separated property: value pairs (e.g. "white-space: nowrap; overflow: hidden;")' | "Adapter resolveValue returned an unparseable value expression" | "Adapter resolveValue returned undefined for imported value" | "Arrow function: body is not a recognized pattern (expected ternary, logical, call, or member expression)" | "Arrow function: conditional branches could not be resolved to static or theme values" | "Arrow function: helper call body is not supported" | "Arrow function: indexed theme lookup pattern not matched" | "Arrow function: logical expression pattern not supported" | "Arrow function: prop access cannot be converted to style function for this CSS property" | "Arrow function: theme access path could not be resolved" | "Component selectors like `${OtherComponent}:hover &` are not directly representable in StyleX. Manual refactor is required" | "Conditional `css` block: !important is not supported in StyleX" | "Conditional `css` block: @-rules (e.g., @media, @supports) are not supported" | "CSS block contains unsupported at-rule (only @media and @container are supported; @supports, etc. require manual handling)" | "Conditional `css` block: dynamic interpolation could not be resolved to a single component prop" | "Conditional `css` block: failed to parse expression" | "Conditional `css` block: missing CSS property name" | "Conditional `css` block: missing interpolation expression" | "Conditional `css` block: mixed static/dynamic values with non-theme expressions cannot be safely transformed" | "Conditional `css` block: multiple interpolation slots in a single property value" | "Conditional `css` block: ternary branch value could not be resolved (imported values require adapter support)" | "Conditional `css` block: ternary expressions inside pseudo selectors are not supported" | "Conditional `css` block: media query interpolation must be a simple imported reference (expressions like `value + 1` are not supported)" | "Conditional `css` block: unsupported selector" | "Directional border helper styles are not supported" | "Multi-slot border interpolation could not be resolved" | "Resolved border helper value could not be expanded to longhand properties" | "createGlobalStyle is not supported in StyleX. Global styles should be handled separately (e.g., in a CSS file or using CSS reset libraries)" | "Dynamic styles inside pseudo elements (::before/::after) are not supported by StyleX. See https://github.com/facebook/stylex/issues/1396" | "Failed to parse theme expressions" | "Heterogeneous background values (mix of gradients and colors) not currently supported" | "Higher-order styled factory wrappers (e.g. hoc(styled)) are not supported" | "Imported CSS helper mixins: cannot determine inherited properties for correct pseudo selector handling" | "Local helper function returns CSS that cannot be decomposed into individual properties" | "Local helper function computes CSS values that cannot be statically traced to the component prop" | "Styled-components specificity hacks like `&&` / `&&&` are not representable in StyleX" | "Theme-dependent block-level conditional could not be fully resolved (branches may contain dynamic interpolations)" | "Theme-dependant call expression could not be resolved (e.g. theme helper calls like theme.highlight() are not supported)" | "Theme value with fallback (props.theme.X ?? / || default) cannot be resolved statically — use adapter.resolveValue to map theme paths to StyleX tokens" | "Theme-dependent nested prop access requires a project-specific theme source (e.g. useTheme())" | "Theme-dependent template literals require a project-specific theme source (e.g. useTheme())" | "Theme prop overrides on styled components are not supported" | "Universal selectors (`*`) are currently unsupported" | "Unsupported call expression (expected imported helper(...) or imported helper(...)(...))" | "Unsupported conditional test in shouldForwardProp" | "Unsupported shouldForwardProp pattern (only !prop.startsWith(), ![].includes(prop), and prop !== are supported)" | "Unsupported interpolation: arrow function" | "Unsupported interpolation: call expression" | "Unsupported interpolation: identifier" | "Unsupported interpolation: member expression" | "Unsupported interpolation: property" | "Unsupported interpolation: unknown" | "Unsupported nested conditional interpolation" | "Unsupported prop-based inline style expression cannot be safely inlined" | "Unsupported prop-based inline style props.theme access is not supported" | "Unsupported selector interpolation: imported value in selector position" | "Unsupported: media query interpolation must be a simple imported reference (expressions like `value + 1` are not supported)" | "Unsupported selector: class selector" | "Unsupported selector: comma-separated selectors must all be simple pseudos or pseudo-elements" | "Unsupported selector: descendant pseudo selector (space before pseudo)" | "Unsupported selector: descendant/child/sibling selector" | "Unsupported selector: interpolated pseudo selector" | "Unsupported selector: sibling combinator" | "Unsupported selector: unresolved interpolation in sibling selector" | "Unsupported selector: ambiguous element selector" | "Unsupported selector: attribute selector on unsupported element" | "Unsupported selector: element selector on exported component" | "Unsupported selector: element selector with combined ancestor and child pseudos" | "Unsupported selector: element selector with dynamic children" | "Unsupported selector: element selector with plain intrinsic children" | "Unsupported selector: element selector pseudo collision" | "Unsupported selector: unresolved interpolation in cross-file component selector" | "Unsupported selector: unresolved interpolation in descendant component selector" | "Unsupported selector: unresolved interpolation in element selector" | "Unsupported selector: unresolved interpolation in reverse component selector" | "Unsupported selector: grouped reverse selector references different components" | "Unsupported selector: unknown component selector" | "Unsupported css`` mixin: after-base mixin style is not a plain object" | "Unsupported css`` mixin: nested contextual conditions in after-base mixin" | "Unsupported css`` mixin: cannot infer base default for after-base contextual override (base value is non-literal)" | "css`` helper function interpolation references closure variable that cannot be hoisted" | "Sibling selector broadened: & + & (adjacent) becomes general sibling (~) in StyleX — interleaved non-matching elements will no longer block the match" | "Using styled-components components as mixins is not supported; use css`` mixins or strings instead" | "styled(ImportedComponent) wraps a component whose file contains internal styled-components — convert the base component's file first to avoid CSS cascade conflicts" | "Transient $-prefixed props renamed on exported component — update consumer call sites to use the new prop names";
|
|
651
|
+
type WarningType = "`css` helper function switch must return css templates in all branches" | "`css` helper usage as a function call (css(...)) is not supported" | "`css` helper used outside of a styled component template cannot be statically transformed" | "Adapter helper call in border interpolation did not resolve to a single CSS value" | "Adapter resolveCall returned an unparseable styles expression" | "Adapter resolveCall returned an unparseable value expression" | "Adapter resolveCall returned StyleX styles for helper call where a CSS value was expected" | "Adapter resolveCall returned undefined for helper call" | "Adapter resolveBaseComponent threw an error" | "Adapter resolved StyleX styles cannot be applied under nested selectors/at-rules" | "Adapter resolved StyleX styles inside pseudo selector but did not provide cssText for property expansion — add cssText to resolveCall result to enable pseudo-wrapping" | 'Adapter resolveCall cssText could not be parsed as CSS declarations — expected semicolon-separated property: value pairs (e.g. "white-space: nowrap; overflow: hidden;")' | "Adapter resolveValue returned an unparseable value expression" | "Adapter resolveValue returned undefined for imported value" | "Arrow function: body is not a recognized pattern (expected ternary, logical, call, or member expression)" | "Arrow function: conditional branches could not be resolved to static or theme values" | "Arrow function: helper call body is not supported" | "Arrow function: indexed theme lookup pattern not matched" | "Arrow function: logical expression pattern not supported" | "Arrow function: prop access cannot be converted to style function for this CSS property" | "Arrow function: theme access path could not be resolved" | "Component selectors like `${OtherComponent}:hover &` are not directly representable in StyleX. Manual refactor is required" | "Conditional `css` block: !important is not supported in StyleX" | "Conditional `css` block: @-rules (e.g., @media, @supports) are not supported" | "CSS block contains unsupported at-rule (only @media and @container are supported; @supports, etc. require manual handling)" | "Conditional `css` block: dynamic interpolation could not be resolved to a single component prop" | "Conditional `css` block: failed to parse expression" | "Conditional `css` block: missing CSS property name" | "Conditional `css` block: missing interpolation expression" | "Conditional `css` block: mixed static/dynamic values with non-theme expressions cannot be safely transformed" | "Conditional `css` block: multiple interpolation slots in a single property value" | "Conditional `css` block: ternary branch value could not be resolved (imported values require adapter support)" | "Conditional `css` block: ternary expressions inside pseudo selectors are not supported" | "Conditional `css` block: media query interpolation must be a simple imported reference (expressions like `value + 1` are not supported)" | "Conditional `css` block: unsupported selector" | "Directional border helper styles are not supported" | "Multi-slot border interpolation could not be resolved" | "Resolved border helper value could not be expanded to longhand properties" | "Resolved conditional border variant could not be expanded to longhand properties" | "createGlobalStyle is not supported in StyleX. Global styles should be handled separately (e.g., in a CSS file or using CSS reset libraries)" | "Dynamic styles inside pseudo elements (::before/::after) are not supported by StyleX. See https://github.com/facebook/stylex/issues/1396" | "Failed to parse theme expressions" | "Heterogeneous background values (mix of gradients and colors) not currently supported" | "Higher-order styled factory wrappers (e.g. hoc(styled)) are not supported" | "Imported CSS helper mixins: cannot determine inherited properties for correct pseudo selector handling" | "Local helper function returns CSS that cannot be decomposed into individual properties" | "Local helper function computes CSS values that cannot be statically traced to the component prop" | "Styled-components specificity hacks like `&&` / `&&&` are not representable in StyleX" | "Theme-dependent block-level conditional could not be fully resolved (branches may contain dynamic interpolations)" | "Theme-dependant call expression could not be resolved (e.g. theme helper calls like theme.highlight() are not supported)" | "Theme value with fallback (props.theme.X ?? / || default) cannot be resolved statically — use adapter.resolveValue to map theme paths to StyleX tokens" | "Theme-dependent nested prop access requires a project-specific theme source (e.g. useTheme())" | "Theme-dependent template literals require a project-specific theme source (e.g. useTheme())" | "Theme prop overrides on styled components are not supported" | "Universal selectors (`*`) are currently unsupported" | "Unsupported call expression (expected imported helper(...) or imported helper(...)(...))" | "Unsupported conditional test in shouldForwardProp" | "Unsupported shouldForwardProp pattern (only !prop.startsWith(), ![].includes(prop), and prop !== are supported)" | "Unsupported interpolation: arrow function" | "Unsupported interpolation: call expression" | "Unsupported interpolation: identifier" | "Unsupported interpolation: member expression" | "Unsupported interpolation: property" | "Unsupported interpolation: unknown" | "Unsupported nested conditional interpolation" | "Unsupported prop-based inline style expression cannot be safely inlined" | "Unsupported prop-based inline style props.theme access is not supported" | "Unsupported selector interpolation: imported value in selector position" | "Unsupported: media query interpolation must be a simple imported reference (expressions like `value + 1` are not supported)" | "Unsupported selector: class selector" | "Unsupported selector: comma-separated selectors must all be simple pseudos or pseudo-elements" | "Unsupported selector: descendant pseudo selector (space before pseudo)" | "Unsupported selector: descendant/child/sibling selector" | "Unsupported selector: interpolated pseudo selector" | "Unsupported selector: sibling combinator" | "Unsupported selector: unresolved interpolation in sibling selector" | "Unsupported selector: ambiguous element selector" | "Unsupported selector: attribute selector on unsupported element" | "Unsupported selector: element selector on exported component" | "Unsupported selector: element selector with combined ancestor and child pseudos" | "Unsupported selector: element selector with dynamic children" | "Unsupported selector: element selector with plain intrinsic children" | "Unsupported selector: element selector pseudo collision" | "Unsupported selector: cross-file component selector target has no JSX usage in this file" | "Unsupported selector: unresolved interpolation in cross-file component selector" | "Unsupported selector: unresolved interpolation in descendant component selector" | "Unsupported selector: unresolved interpolation in element selector" | "Unsupported selector: unresolved interpolation in reverse component selector" | "Unsupported selector: grouped reverse selector references different components" | "Unsupported selector: unknown component selector" | "Unsupported css`` mixin: after-base mixin style is not a plain object" | "Unsupported css`` mixin: nested contextual conditions in after-base mixin" | "Unsupported css`` mixin: cannot infer base default for after-base contextual override (base value is non-literal)" | "css`` helper function interpolation references closure variable that cannot be hoisted" | "Sibling selector broadened: & + & (adjacent) becomes general sibling (~) in StyleX — interleaved non-matching elements will no longer block the match" | "Using styled-components components as mixins is not supported; use css`` mixins or strings instead" | "styled(ImportedComponent) wraps a component whose file contains internal styled-components — convert the base component's file first to avoid CSS cascade conflicts" | "Transient $-prefixed props renamed on exported component — update consumer call sites to use the new prop names";
|
|
652
652
|
interface WarningLog {
|
|
653
653
|
severity: Severity;
|
|
654
654
|
type: WarningType;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { realpathSync } from "node:fs";
|
|
3
|
+
|
|
4
|
+
//#region src/internal/utilities/path-utils.ts
|
|
5
|
+
/**
|
|
6
|
+
* Shared path utilities for symlink resolution and path normalization.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Resolve a file path to its real (symlink-resolved) absolute path.
|
|
10
|
+
* Falls back to pathResolve if realpathSync fails (e.g. file doesn't exist yet).
|
|
11
|
+
*/
|
|
12
|
+
function toRealPath(filePath) {
|
|
13
|
+
const resolved = resolve(filePath);
|
|
14
|
+
try {
|
|
15
|
+
return realpathSync(resolved);
|
|
16
|
+
} catch {
|
|
17
|
+
return resolved;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
//#endregion
|
|
22
|
+
export { toRealPath as t };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { n as escapeRegex } from "./string-utils-J3iaDsXd.mjs";
|
|
1
2
|
import { t as PLACEHOLDER_RE } from "./styled-css-BJH7gntu.mjs";
|
|
2
|
-
import { t as isSelectorContext } from "./selector-context-heuristic-
|
|
3
|
+
import { t as isSelectorContext } from "./selector-context-heuristic-CQgP_0dH.mjs";
|
|
3
4
|
import path, { relative, resolve } from "node:path";
|
|
4
5
|
import { readFileSync, realpathSync } from "node:fs";
|
|
5
6
|
import { execSync } from "node:child_process";
|
|
@@ -738,14 +739,11 @@ function collectImportDeclarationText(source) {
|
|
|
738
739
|
function importTextMentionsIdentifier(importText, identifier) {
|
|
739
740
|
let re = IMPORT_IDENTIFIER_RE_CACHE.get(identifier);
|
|
740
741
|
if (!re) {
|
|
741
|
-
re = new RegExp(`(?:^|[^A-Za-z0-9_$])${
|
|
742
|
+
re = new RegExp(`(?:^|[^A-Za-z0-9_$])${escapeRegex(identifier)}(?:$|[^A-Za-z0-9_$])`);
|
|
742
743
|
IMPORT_IDENTIFIER_RE_CACHE.set(identifier, re);
|
|
743
744
|
}
|
|
744
745
|
return re.test(importText);
|
|
745
746
|
}
|
|
746
|
-
function escapeRegexForRegExp(s) {
|
|
747
|
-
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
748
|
-
}
|
|
749
747
|
/** Quick pre-check: does this source mention className or style in a JSX prop context? */
|
|
750
748
|
const CLASSNAME_STYLE_QUICK_RE = /\b(className|style)\s*[={]/;
|
|
751
749
|
/** Matches `import { Original as Local, ... }` — captures original and local names. */
|
package/dist/transform.d.mts
CHANGED