@stylexswc/rs-compiler 0.15.1 → 0.15.2
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/README.md +284 -93
- package/dist/index.d.ts +22 -0
- package/dist/index.js +52 -52
- package/package.json +21 -11
package/README.md
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
# NAPI-RS compiler for StyleX (\*\*unofficial)
|
|
2
2
|
|
|
3
|
+
> Part of the
|
|
4
|
+
> [StyleX SWC Plugin](https://github.com/Dwlad90/stylex-swc-plugin#readme)
|
|
5
|
+
> workspace
|
|
6
|
+
|
|
3
7
|
StyleX is a JavaScript library developed by Meta for defining styles optimized
|
|
4
|
-
for user interfaces. You can find the
|
|
5
|
-
[
|
|
8
|
+
for user interfaces. You can find the
|
|
9
|
+
[official StyleX repository](https://www.github.com/facebook/stylex) here.
|
|
6
10
|
|
|
7
11
|
> [!WARNING]
|
|
8
12
|
> This is an unofficial style compiler for StyleX.
|
|
9
13
|
|
|
10
14
|
## Overview
|
|
11
15
|
|
|
12
|
-
This package provides an unofficial, high-performance compiler for
|
|
13
|
-
popular library from Meta for building optimized user interfaces. It
|
|
14
|
-
the
|
|
16
|
+
This package provides an unofficial, high-performance NAPI-RS compiler for
|
|
17
|
+
StyleX, a popular library from Meta for building optimized user interfaces. It
|
|
18
|
+
is the top-level consumer crate that exposes the full StyleX pipeline to
|
|
19
|
+
Node.js, leveraging SWC for parsing and transformation.
|
|
15
20
|
|
|
16
21
|
> [!IMPORTANT]
|
|
17
22
|
> The usage of StyleX does not change. All changes are internal.
|
|
@@ -39,6 +44,171 @@ the power of NAPI-RS and SWC to achieve several key advantages:
|
|
|
39
44
|
addons in Rust, making it easier to create high-performance and efficient
|
|
40
45
|
tools.
|
|
41
46
|
|
|
47
|
+
## Architecture
|
|
48
|
+
|
|
49
|
+
- **Layer**: 9 — Compilers (top-level consumer)
|
|
50
|
+
- **Depends on**: `stylex-ast`, `stylex-enums`, `stylex-logs`, `stylex-macros`,
|
|
51
|
+
`stylex-regex`, `stylex-structures`, `stylex-transform`, `stylex-types`,
|
|
52
|
+
`stylex-utils`
|
|
53
|
+
- **Depended on by**: None (top-level entry point)
|
|
54
|
+
|
|
55
|
+
### Public API
|
|
56
|
+
|
|
57
|
+
- `transform()` — Main entry point: takes source code + options, returns
|
|
58
|
+
transformed output
|
|
59
|
+
- `should_transform_file()` — File filtering based on path patterns
|
|
60
|
+
- `normalize_rs_options()` — Options normalization and validation
|
|
61
|
+
|
|
62
|
+
### Modules
|
|
63
|
+
|
|
64
|
+
- `enums` — Compiler-specific enum types
|
|
65
|
+
- `structs` — Compiler-specific struct types
|
|
66
|
+
- `utils::fn_parser` — Function argument parsing
|
|
67
|
+
- `utils::metadata` — Build metadata handling
|
|
68
|
+
- `utils::path_filter` — File path filtering logic
|
|
69
|
+
|
|
70
|
+
## Dependency Graph
|
|
71
|
+
|
|
72
|
+
<details>
|
|
73
|
+
<summary><h3>Dependency Graph</h3></summary>
|
|
74
|
+
|
|
75
|
+
```mermaid
|
|
76
|
+
graph TD
|
|
77
|
+
subgraph L0["Primitives"]
|
|
78
|
+
stylex_constants["constants"]
|
|
79
|
+
stylex_regex["regex"]
|
|
80
|
+
stylex_utils["utils"]
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
subgraph L1["Proc Macros"]
|
|
84
|
+
stylex_macros["macros"]
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
subgraph L2["Domain Leaves"]
|
|
88
|
+
stylex_enums["enums"]
|
|
89
|
+
stylex_js["js"]
|
|
90
|
+
stylex_logs["logs"]
|
|
91
|
+
stylex_css_parser["css-parser"]
|
|
92
|
+
stylex_path_resolver["path-resolver"]
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
subgraph L3["Core Data Structures"]
|
|
96
|
+
stylex_structures["structures"]
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
subgraph L4["Type System"]
|
|
100
|
+
stylex_types["types"]
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
subgraph L5["AST Foundations"]
|
|
104
|
+
stylex_ast["ast"]
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
subgraph L6["Evaluation"]
|
|
108
|
+
stylex_evaluator["evaluator"]
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
subgraph L7["CSS Processing"]
|
|
112
|
+
stylex_css["css"]
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
subgraph L8["StyleX Transform"]
|
|
116
|
+
stylex_transform["transform"]
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
subgraph L9["Compilers"]
|
|
120
|
+
stylex_compiler_rs["rs-compiler"]
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
stylex_macros --> stylex_constants
|
|
124
|
+
|
|
125
|
+
stylex_enums --> stylex_macros
|
|
126
|
+
stylex_js --> stylex_constants
|
|
127
|
+
stylex_js --> stylex_macros
|
|
128
|
+
stylex_logs --> stylex_macros
|
|
129
|
+
stylex_css_parser --> stylex_macros
|
|
130
|
+
stylex_path_resolver --> stylex_macros
|
|
131
|
+
|
|
132
|
+
stylex_structures --> stylex_constants
|
|
133
|
+
stylex_structures --> stylex_enums
|
|
134
|
+
stylex_structures --> stylex_macros
|
|
135
|
+
|
|
136
|
+
stylex_types --> stylex_constants
|
|
137
|
+
stylex_types --> stylex_enums
|
|
138
|
+
stylex_types --> stylex_macros
|
|
139
|
+
stylex_types --> stylex_structures
|
|
140
|
+
stylex_types --> stylex_utils
|
|
141
|
+
|
|
142
|
+
stylex_ast --> stylex_constants
|
|
143
|
+
stylex_ast --> stylex_macros
|
|
144
|
+
stylex_ast --> stylex_types
|
|
145
|
+
stylex_ast --> stylex_utils
|
|
146
|
+
|
|
147
|
+
stylex_evaluator --> stylex_ast
|
|
148
|
+
stylex_evaluator --> stylex_constants
|
|
149
|
+
stylex_evaluator --> stylex_js
|
|
150
|
+
stylex_evaluator --> stylex_macros
|
|
151
|
+
stylex_evaluator --> stylex_path_resolver
|
|
152
|
+
stylex_evaluator --> stylex_types
|
|
153
|
+
|
|
154
|
+
stylex_css --> stylex_ast
|
|
155
|
+
stylex_css --> stylex_constants
|
|
156
|
+
stylex_css --> stylex_css_parser
|
|
157
|
+
stylex_css --> stylex_enums
|
|
158
|
+
stylex_css --> stylex_evaluator
|
|
159
|
+
stylex_css --> stylex_macros
|
|
160
|
+
stylex_css --> stylex_regex
|
|
161
|
+
stylex_css --> stylex_structures
|
|
162
|
+
stylex_css --> stylex_types
|
|
163
|
+
|
|
164
|
+
stylex_transform --> stylex_ast
|
|
165
|
+
stylex_transform --> stylex_constants
|
|
166
|
+
stylex_transform --> stylex_css
|
|
167
|
+
stylex_transform --> stylex_css_parser
|
|
168
|
+
stylex_transform --> stylex_enums
|
|
169
|
+
stylex_transform --> stylex_logs
|
|
170
|
+
stylex_transform --> stylex_macros
|
|
171
|
+
stylex_transform --> stylex_path_resolver
|
|
172
|
+
stylex_transform --> stylex_regex
|
|
173
|
+
stylex_transform --> stylex_structures
|
|
174
|
+
stylex_transform --> stylex_types
|
|
175
|
+
stylex_transform --> stylex_utils
|
|
176
|
+
|
|
177
|
+
stylex_compiler_rs --> stylex_ast
|
|
178
|
+
stylex_compiler_rs --> stylex_enums
|
|
179
|
+
stylex_compiler_rs --> stylex_logs
|
|
180
|
+
stylex_compiler_rs --> stylex_macros
|
|
181
|
+
stylex_compiler_rs --> stylex_regex
|
|
182
|
+
stylex_compiler_rs --> stylex_structures
|
|
183
|
+
stylex_compiler_rs --> stylex_transform
|
|
184
|
+
stylex_compiler_rs --> stylex_types
|
|
185
|
+
stylex_compiler_rs --> stylex_utils
|
|
186
|
+
|
|
187
|
+
classDef l0 fill:#e8e8e8,stroke:#999,color:#333
|
|
188
|
+
classDef l1 fill:#dce8ff,stroke:#6699cc,color:#333
|
|
189
|
+
classDef l2 fill:#dcf5dc,stroke:#66aa66,color:#333
|
|
190
|
+
classDef l3 fill:#fff3dc,stroke:#cc9933,color:#333
|
|
191
|
+
classDef l4 fill:#ffe8dc,stroke:#cc6633,color:#333
|
|
192
|
+
classDef l5 fill:#f5dcff,stroke:#9933cc,color:#333
|
|
193
|
+
classDef l6 fill:#dcfff5,stroke:#33aaaa,color:#333
|
|
194
|
+
classDef l7 fill:#ffdcdc,stroke:#cc3333,color:#333
|
|
195
|
+
classDef l8 fill:#fffdc0,stroke:#aaaa33,color:#333
|
|
196
|
+
classDef l9 fill:#ffc0c0,stroke:#cc0000,color:#333
|
|
197
|
+
|
|
198
|
+
class stylex_constants,stylex_regex,stylex_utils l0
|
|
199
|
+
class stylex_macros l1
|
|
200
|
+
class stylex_enums,stylex_js,stylex_logs,stylex_css_parser,stylex_path_resolver l2
|
|
201
|
+
class stylex_structures l3
|
|
202
|
+
class stylex_types l4
|
|
203
|
+
class stylex_ast l5
|
|
204
|
+
class stylex_evaluator l6
|
|
205
|
+
class stylex_css l7
|
|
206
|
+
class stylex_transform l8
|
|
207
|
+
class stylex_compiler_rs l9
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
</details>
|
|
211
|
+
|
|
42
212
|
## Installation
|
|
43
213
|
|
|
44
214
|
To install the package, run the following command:
|
|
@@ -69,9 +239,13 @@ const { code, metadata, sourcemap } = transform(
|
|
|
69
239
|
### Path Filtering
|
|
70
240
|
|
|
71
241
|
> [!NOTE]
|
|
72
|
-
> **New Feature:** The `include` and `exclude` options are exclusive to
|
|
242
|
+
> **New Feature:** The `include` and `exclude` options are exclusive to
|
|
243
|
+
> this NAPI-RS compiler implementation and are not available in the official
|
|
244
|
+
> StyleX Babel plugin. They provide powerful file filtering capabilities to
|
|
245
|
+
> control which files are transformed.
|
|
73
246
|
|
|
74
|
-
The compiler exports a `shouldTransformFile` function to determine whether a
|
|
247
|
+
The compiler exports a `shouldTransformFile` function to determine whether a
|
|
248
|
+
file should be transformed based on include/exclude patterns:
|
|
75
249
|
|
|
76
250
|
```ts
|
|
77
251
|
import { shouldTransformFile } from '@stylexswc/rs-compiler';
|
|
@@ -100,10 +274,11 @@ if (shouldTransform) {
|
|
|
100
274
|
|
|
101
275
|
**Advanced: Lookahead/Lookbehind Support**
|
|
102
276
|
|
|
103
|
-
The Rust regex engine fully supports lookahead and lookbehind assertions,
|
|
104
|
-
|
|
277
|
+
The Rust regex engine fully supports lookahead and lookbehind assertions,
|
|
278
|
+
enabling sophisticated filtering patterns:
|
|
105
279
|
- **Negative Lookahead** `(?!...)`: Match if NOT followed by pattern
|
|
106
|
-
- `/node_modules(?!\/@stylexjs)/` - Exclude all node_modules except
|
|
280
|
+
- `/node_modules(?!\/@stylexjs)/` - Exclude all node_modules except
|
|
281
|
+
@stylexjs packages
|
|
107
282
|
- `/\.tsx(?!\.test)/` - Match .tsx files that are NOT test files
|
|
108
283
|
|
|
109
284
|
- **Positive Lookahead** `(?=...)`: Match if followed by pattern
|
|
@@ -117,7 +292,8 @@ if (shouldTransform) {
|
|
|
117
292
|
|
|
118
293
|
#### Filtering Rules
|
|
119
294
|
|
|
120
|
-
1. If `include` patterns are specified and not empty, files must match at least
|
|
295
|
+
1. If `include` patterns are specified and not empty, files must match at least
|
|
296
|
+
one pattern
|
|
121
297
|
2. If `exclude` patterns are specified, files matching any pattern are excluded
|
|
122
298
|
3. Exclude patterns take precedence over include patterns
|
|
123
299
|
4. All paths are matched relative to the current working directory
|
|
@@ -128,11 +304,9 @@ if (shouldTransform) {
|
|
|
128
304
|
|
|
129
305
|
```ts
|
|
130
306
|
// Exclude all node_modules except @stylexjs/open-props
|
|
131
|
-
shouldTransformFile(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
[/node_modules(?!\/@stylexjs\/open-props)/]
|
|
135
|
-
);
|
|
307
|
+
shouldTransformFile(filePath, undefined, [
|
|
308
|
+
/node_modules(?!\/@stylexjs\/open-props)/,
|
|
309
|
+
]);
|
|
136
310
|
```
|
|
137
311
|
|
|
138
312
|
**Transform only specific packages from node_modules:**
|
|
@@ -153,56 +327,54 @@ shouldTransformFile(
|
|
|
153
327
|
|
|
154
328
|
```ts
|
|
155
329
|
// Exclude all node_modules except @stylexjs packages
|
|
156
|
-
shouldTransformFile(
|
|
157
|
-
filePath,
|
|
158
|
-
undefined,
|
|
159
|
-
[/node_modules(?!\/@stylexjs)/]
|
|
160
|
-
);
|
|
330
|
+
shouldTransformFile(filePath, undefined, [/node_modules(?!\/@stylexjs)/]);
|
|
161
331
|
```
|
|
162
332
|
|
|
163
333
|
### SWC Plugin Support
|
|
164
334
|
|
|
165
335
|
> [!NOTE]
|
|
166
|
-
> **New Feature:** The compiler now supports running SWC WASM plugins
|
|
336
|
+
> **New Feature:** The compiler now supports running SWC WASM plugins
|
|
337
|
+
> before StyleX transformation. This allows you to chain transformations and
|
|
338
|
+
> integrate custom SWC plugins seamlessly.
|
|
167
339
|
|
|
168
|
-
The `transform` function accepts an optional `swcPlugins` array in the options
|
|
340
|
+
The `transform` function accepts an optional `swcPlugins` array in the options
|
|
341
|
+
object, allowing you to run SWC WASM plugins before the StyleX transformation:
|
|
169
342
|
|
|
170
343
|
```ts
|
|
171
344
|
const { transform } = require('@stylexswc/rs-compiler');
|
|
172
345
|
|
|
173
|
-
const { code, metadata, map } = transform(
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
'
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
]
|
|
197
|
-
]
|
|
198
|
-
}
|
|
199
|
-
);
|
|
346
|
+
const { code, metadata, map } = transform('Button.tsx', sourceCode, {
|
|
347
|
+
dev: true,
|
|
348
|
+
// Other StyleX options...
|
|
349
|
+
|
|
350
|
+
// SWC plugins to run before StyleX transformation
|
|
351
|
+
swcPlugins: [
|
|
352
|
+
// Plugin as [pluginPath, config]
|
|
353
|
+
[
|
|
354
|
+
'/path/to/swc_plugin_theme.wasm',
|
|
355
|
+
{
|
|
356
|
+
themeName: 'my-theme',
|
|
357
|
+
customOption: 'value',
|
|
358
|
+
},
|
|
359
|
+
],
|
|
360
|
+
// You can chain multiple plugins
|
|
361
|
+
[
|
|
362
|
+
'@swc/plugin-emotion',
|
|
363
|
+
{
|
|
364
|
+
sourceMap: true,
|
|
365
|
+
},
|
|
366
|
+
],
|
|
367
|
+
],
|
|
368
|
+
});
|
|
200
369
|
```
|
|
201
370
|
|
|
202
371
|
#### How It Works
|
|
203
372
|
|
|
204
|
-
1. **Plugin Execution Phase**: If `swcPlugins` are provided, the source code is
|
|
205
|
-
|
|
373
|
+
1. **Plugin Execution Phase**: If `swcPlugins` are provided, the source code is
|
|
374
|
+
first transformed using `@swc/core`'s `transformSync` with the specified WASM
|
|
375
|
+
plugins
|
|
376
|
+
2. **StyleX Transformation Phase**: The plugin-transformed code is then passed
|
|
377
|
+
to the StyleX compiler
|
|
206
378
|
|
|
207
379
|
#### Plugin Configuration
|
|
208
380
|
|
|
@@ -225,11 +397,11 @@ transform(filename, code, {
|
|
|
225
397
|
themeName: 'theme-name',
|
|
226
398
|
themeConfig: {
|
|
227
399
|
primaryColor: 'blue',
|
|
228
|
-
spacing: 8
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
]
|
|
232
|
-
]
|
|
400
|
+
spacing: 8,
|
|
401
|
+
},
|
|
402
|
+
},
|
|
403
|
+
],
|
|
404
|
+
],
|
|
233
405
|
});
|
|
234
406
|
```
|
|
235
407
|
|
|
@@ -316,14 +488,16 @@ const styleProps = {
|
|
|
316
488
|
|
|
317
489
|
### `injectStylexSideEffects`
|
|
318
490
|
|
|
319
|
-
**Type:** `boolean`
|
|
320
|
-
**Default:** `false`
|
|
491
|
+
**Type:** `boolean` **Default:** `false`
|
|
321
492
|
|
|
322
|
-
Automatically injects side-effect imports for `.stylex` and `.consts` files to
|
|
493
|
+
Automatically injects side-effect imports for `.stylex` and `.consts` files to
|
|
494
|
+
prevent tree-shaking from removing them during bundling.
|
|
323
495
|
|
|
324
496
|
#### Problem
|
|
325
497
|
|
|
326
|
-
When using build tools that perform tree-shaking (like webpack, rollup, vite),
|
|
498
|
+
When using build tools that perform tree-shaking (like webpack, rollup, vite),
|
|
499
|
+
imports from `.stylex` or `.consts` files may appear unused after StyleX
|
|
500
|
+
transformation and get removed:
|
|
327
501
|
|
|
328
502
|
```ts
|
|
329
503
|
// Before StyleX transformation
|
|
@@ -332,67 +506,75 @@ import { spacing } from './tokens.consts';
|
|
|
332
506
|
|
|
333
507
|
const styles = stylex.create({
|
|
334
508
|
root: {
|
|
335
|
-
backgroundColor: colors.primary,
|
|
336
|
-
padding: spacing.md,
|
|
337
|
-
}
|
|
509
|
+
backgroundColor: colors.primary, // Uses colors
|
|
510
|
+
padding: spacing.md, // Uses spacing
|
|
511
|
+
},
|
|
338
512
|
});
|
|
339
513
|
|
|
340
514
|
// After StyleX transformation
|
|
341
|
-
import { colors } from './theme.stylex';
|
|
515
|
+
import { colors } from './theme.stylex'; // Appears unused!
|
|
342
516
|
import { spacing } from './tokens.consts'; // Appears unused!
|
|
343
517
|
|
|
344
518
|
const styles = {
|
|
345
519
|
root: {
|
|
346
520
|
backgroundColor: 'x1a2b3c',
|
|
347
521
|
padding: 'x4d5e6f',
|
|
348
|
-
$$css: true
|
|
349
|
-
}
|
|
522
|
+
$$css: true,
|
|
523
|
+
},
|
|
350
524
|
};
|
|
351
525
|
```
|
|
352
526
|
|
|
353
|
-
The bundler may remove these "unused" imports, but they're needed for other
|
|
527
|
+
The bundler may remove these "unused" imports, but they're needed for other
|
|
528
|
+
files to resolve the same StyleX/const references correctly.
|
|
354
529
|
|
|
355
530
|
#### Solution
|
|
356
531
|
|
|
357
|
-
When `injectStylexSideEffects: true`, the compiler automatically adds
|
|
532
|
+
When `injectStylexSideEffects: true`, the compiler automatically adds
|
|
533
|
+
side-effect imports to preserve these modules:
|
|
358
534
|
|
|
359
535
|
```ts
|
|
360
536
|
// After transformation with injectStylexSideEffects: true
|
|
361
537
|
import { colors } from './theme.stylex';
|
|
362
538
|
import { spacing } from './tokens.consts';
|
|
363
|
-
import './theme.stylex';
|
|
364
|
-
import './tokens.consts';
|
|
539
|
+
import './theme.stylex'; // Side-effect import (prevents tree-shaking)
|
|
540
|
+
import './tokens.consts'; // Side-effect import (prevents tree-shaking)
|
|
365
541
|
|
|
366
542
|
const styles = {
|
|
367
543
|
root: {
|
|
368
544
|
backgroundColor: 'x1a2b3c',
|
|
369
545
|
padding: 'x4d5e6f',
|
|
370
|
-
$$css: true
|
|
371
|
-
}
|
|
546
|
+
$$css: true,
|
|
547
|
+
},
|
|
372
548
|
};
|
|
373
549
|
```
|
|
374
550
|
|
|
375
551
|
#### When to Use
|
|
376
552
|
|
|
377
|
-
- ✅ **Use `true`** when your bundler runs StyleX transformation **before**
|
|
553
|
+
- ✅ **Use `true`** when your bundler runs StyleX transformation **before**
|
|
554
|
+
other optimizations (recommended)
|
|
378
555
|
- ✅ **Use `true`** with webpack's `loaderOrder: 'first'` option
|
|
379
|
-
- ❌ **Use `false`** when StyleX runs **after** tree-shaking (e.g., webpack's
|
|
556
|
+
- ❌ **Use `false`** when StyleX runs **after** tree-shaking (e.g., webpack's
|
|
557
|
+
`loaderOrder: 'last'`)
|
|
380
558
|
|
|
381
559
|
> [!TIP]
|
|
382
|
-
> This option is automatically enabled when using
|
|
560
|
+
> This option is automatically enabled when using
|
|
561
|
+
> `@stylexswc/webpack-plugin` with `loaderOrder: 'first'` (the default).
|
|
383
562
|
|
|
384
563
|
### `useRealFileForSource`
|
|
385
564
|
|
|
386
|
-
**Type:** `boolean`
|
|
387
|
-
**Default:** `true`
|
|
565
|
+
**Type:** `boolean` **Default:** `true`
|
|
388
566
|
|
|
389
|
-
Controls whether the compiler should read source files from disk for error
|
|
567
|
+
Controls whether the compiler should read source files from disk for error
|
|
568
|
+
reporting and source map generation.
|
|
390
569
|
|
|
391
570
|
#### Behavior
|
|
392
571
|
|
|
393
|
-
- **`true` (default)**: The compiler reads the actual source file from disk when
|
|
572
|
+
- **`true` (default)**: The compiler reads the actual source file from disk when
|
|
573
|
+
generating error messages and source maps. This provides accurate line numbers
|
|
574
|
+
and source context that match what you see in your editor.
|
|
394
575
|
|
|
395
|
-
- **`false`**: The compiler uses the transformed AST representation for error
|
|
576
|
+
- **`false`**: The compiler uses the transformed AST representation for error
|
|
577
|
+
reporting. This is useful when:
|
|
396
578
|
- Working with in-memory transformations
|
|
397
579
|
- Source files are not available on disk
|
|
398
580
|
- You want faster compilation (skips file I/O)
|
|
@@ -424,20 +606,28 @@ transform(filename, code, {
|
|
|
424
606
|
- Build pipelines where source files are not available
|
|
425
607
|
|
|
426
608
|
> [!TIP]
|
|
427
|
-
> Keep the default `true` value for most use cases. Only set it to
|
|
609
|
+
> Keep the default `true` value for most use cases. Only set it to
|
|
610
|
+
> `false` if you have specific requirements for in-memory transformations or
|
|
611
|
+
> performance-critical scenarios where file I/O is a bottleneck.
|
|
428
612
|
|
|
429
613
|
> [!WARNING]
|
|
430
|
-
> When `useRealFileForSource` is set to `false`, error messages may
|
|
614
|
+
> When `useRealFileForSource` is set to `false`, error messages may
|
|
615
|
+
> report **incorrect line numbers**. The compiler will use the transformed AST
|
|
616
|
+
> representation instead of the original source code, which can lead to line
|
|
617
|
+
> number mismatches. This happens because:
|
|
431
618
|
>
|
|
432
619
|
> - The AST may have been modified by previous transformations
|
|
433
620
|
> - Comments and whitespace are normalized in the AST
|
|
434
621
|
> - The structure may differ from what's in your actual source file
|
|
435
622
|
>
|
|
436
|
-
> For accurate error reporting and debugging, always use
|
|
623
|
+
> For accurate error reporting and debugging, always use
|
|
624
|
+
> `useRealFileForSource: true` (the default) during development.
|
|
437
625
|
|
|
438
626
|
## Debug
|
|
439
627
|
|
|
440
|
-
You can enable debug logging for the StyleX compiler using the `STYLEX_DEBUG`
|
|
628
|
+
You can enable debug logging for the StyleX compiler using the `STYLEX_DEBUG`
|
|
629
|
+
environment variable. This is useful for troubleshooting and understanding the
|
|
630
|
+
internal processing of StyleX code.
|
|
441
631
|
|
|
442
632
|
### Log Levels
|
|
443
633
|
|
|
@@ -476,8 +666,8 @@ $env:STYLEX_DEBUG="debug"; npm run build
|
|
|
476
666
|
## Error Handling
|
|
477
667
|
|
|
478
668
|
The compiler produces clean, structured error messages with a branded `[StyleX]`
|
|
479
|
-
prefix, replacing Rust's default panic boilerplate with user-friendly
|
|
480
|
-
in both the terminal and at the NAPI boundary.
|
|
669
|
+
prefix, replacing Rust's default panic boilerplate with user-friendly
|
|
670
|
+
diagnostics in both the terminal and at the NAPI boundary.
|
|
481
671
|
|
|
482
672
|
### Error Format
|
|
483
673
|
|
|
@@ -491,12 +681,13 @@ All StyleX errors follow this format in the terminal:
|
|
|
491
681
|
|
|
492
682
|
Errors are color-coded for readability:
|
|
493
683
|
|
|
494
|
-
| Category
|
|
495
|
-
|
|
496
|
-
| Regular error
|
|
497
|
-
| Unimplemented feature
|
|
498
|
-
| Internal unreachable state | `[UNREACHABLE]`
|
|
684
|
+
| Category | Label | Color |
|
|
685
|
+
| -------------------------- | ----------------- | ------------- |
|
|
686
|
+
| Regular error | _(none)_ | Red prefix |
|
|
687
|
+
| Unimplemented feature | `[UNIMPLEMENTED]` | Magenta label |
|
|
688
|
+
| Internal unreachable state | `[UNREACHABLE]` | Blue label |
|
|
499
689
|
|
|
500
690
|
## License
|
|
501
691
|
|
|
502
|
-
|
|
692
|
+
MIT — see
|
|
693
|
+
[LICENSE](https://github.com/Dwlad90/stylex-swc-plugin/blob/develop/LICENSE)
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
/* auto-generated by NAPI-RS */
|
|
2
3
|
/* eslint-disable */
|
|
3
4
|
export interface ImportSourceInput {
|
|
@@ -82,3 +83,24 @@ export interface TransformOutput {
|
|
|
82
83
|
output?: string
|
|
83
84
|
diagnostics: Array<string>
|
|
84
85
|
}
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
// === Types (injected by scripts/inject-types.mjs) ===
|
|
90
|
+
|
|
91
|
+
export type UseLayersType =
|
|
92
|
+
| boolean
|
|
93
|
+
| {
|
|
94
|
+
before?: ReadonlyArray<string>;
|
|
95
|
+
after?: ReadonlyArray<string>;
|
|
96
|
+
prefix?: string;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export type TransformedOptions = Partial<
|
|
100
|
+
Pick<StyleXOptions, 'legacyDisableLayers' | 'enableLTRRTLComments'> & {
|
|
101
|
+
useLayers: UseLayersType;
|
|
102
|
+
}
|
|
103
|
+
>;
|
|
104
|
+
|
|
105
|
+
// === End Types ===
|
|
106
|
+
|
package/dist/index.js
CHANGED
|
@@ -77,8 +77,8 @@ function requireNative() {
|
|
|
77
77
|
try {
|
|
78
78
|
const binding = require('@stylexswc/rs-compiler-android-arm64')
|
|
79
79
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-android-arm64/package.json').version
|
|
80
|
-
if (bindingPackageVersion !== '0.15.
|
|
81
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
80
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
81
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
82
82
|
}
|
|
83
83
|
return binding
|
|
84
84
|
} catch (e) {
|
|
@@ -93,8 +93,8 @@ function requireNative() {
|
|
|
93
93
|
try {
|
|
94
94
|
const binding = require('@stylexswc/rs-compiler-android-arm-eabi')
|
|
95
95
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-android-arm-eabi/package.json').version
|
|
96
|
-
if (bindingPackageVersion !== '0.15.
|
|
97
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
96
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
97
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
98
98
|
}
|
|
99
99
|
return binding
|
|
100
100
|
} catch (e) {
|
|
@@ -114,8 +114,8 @@ function requireNative() {
|
|
|
114
114
|
try {
|
|
115
115
|
const binding = require('@stylexswc/rs-compiler-win32-x64-gnu')
|
|
116
116
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-win32-x64-gnu/package.json').version
|
|
117
|
-
if (bindingPackageVersion !== '0.15.
|
|
118
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
117
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
118
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
119
119
|
}
|
|
120
120
|
return binding
|
|
121
121
|
} catch (e) {
|
|
@@ -130,8 +130,8 @@ function requireNative() {
|
|
|
130
130
|
try {
|
|
131
131
|
const binding = require('@stylexswc/rs-compiler-win32-x64-msvc')
|
|
132
132
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-win32-x64-msvc/package.json').version
|
|
133
|
-
if (bindingPackageVersion !== '0.15.
|
|
134
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
133
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
134
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
135
135
|
}
|
|
136
136
|
return binding
|
|
137
137
|
} catch (e) {
|
|
@@ -147,8 +147,8 @@ function requireNative() {
|
|
|
147
147
|
try {
|
|
148
148
|
const binding = require('@stylexswc/rs-compiler-win32-ia32-msvc')
|
|
149
149
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-win32-ia32-msvc/package.json').version
|
|
150
|
-
if (bindingPackageVersion !== '0.15.
|
|
151
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
150
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
151
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
152
152
|
}
|
|
153
153
|
return binding
|
|
154
154
|
} catch (e) {
|
|
@@ -163,8 +163,8 @@ function requireNative() {
|
|
|
163
163
|
try {
|
|
164
164
|
const binding = require('@stylexswc/rs-compiler-win32-arm64-msvc')
|
|
165
165
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-win32-arm64-msvc/package.json').version
|
|
166
|
-
if (bindingPackageVersion !== '0.15.
|
|
167
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
166
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
167
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
168
168
|
}
|
|
169
169
|
return binding
|
|
170
170
|
} catch (e) {
|
|
@@ -182,8 +182,8 @@ function requireNative() {
|
|
|
182
182
|
try {
|
|
183
183
|
const binding = require('@stylexswc/rs-compiler-darwin-universal')
|
|
184
184
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-darwin-universal/package.json').version
|
|
185
|
-
if (bindingPackageVersion !== '0.15.
|
|
186
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
185
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
186
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
187
187
|
}
|
|
188
188
|
return binding
|
|
189
189
|
} catch (e) {
|
|
@@ -198,8 +198,8 @@ function requireNative() {
|
|
|
198
198
|
try {
|
|
199
199
|
const binding = require('@stylexswc/rs-compiler-darwin-x64')
|
|
200
200
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-darwin-x64/package.json').version
|
|
201
|
-
if (bindingPackageVersion !== '0.15.
|
|
202
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
201
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
202
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
203
203
|
}
|
|
204
204
|
return binding
|
|
205
205
|
} catch (e) {
|
|
@@ -214,8 +214,8 @@ function requireNative() {
|
|
|
214
214
|
try {
|
|
215
215
|
const binding = require('@stylexswc/rs-compiler-darwin-arm64')
|
|
216
216
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-darwin-arm64/package.json').version
|
|
217
|
-
if (bindingPackageVersion !== '0.15.
|
|
218
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
217
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
218
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
219
219
|
}
|
|
220
220
|
return binding
|
|
221
221
|
} catch (e) {
|
|
@@ -234,8 +234,8 @@ function requireNative() {
|
|
|
234
234
|
try {
|
|
235
235
|
const binding = require('@stylexswc/rs-compiler-freebsd-x64')
|
|
236
236
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-freebsd-x64/package.json').version
|
|
237
|
-
if (bindingPackageVersion !== '0.15.
|
|
238
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
237
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
238
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
239
239
|
}
|
|
240
240
|
return binding
|
|
241
241
|
} catch (e) {
|
|
@@ -250,8 +250,8 @@ function requireNative() {
|
|
|
250
250
|
try {
|
|
251
251
|
const binding = require('@stylexswc/rs-compiler-freebsd-arm64')
|
|
252
252
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-freebsd-arm64/package.json').version
|
|
253
|
-
if (bindingPackageVersion !== '0.15.
|
|
254
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
253
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
254
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
255
255
|
}
|
|
256
256
|
return binding
|
|
257
257
|
} catch (e) {
|
|
@@ -271,8 +271,8 @@ function requireNative() {
|
|
|
271
271
|
try {
|
|
272
272
|
const binding = require('@stylexswc/rs-compiler-linux-x64-musl')
|
|
273
273
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-linux-x64-musl/package.json').version
|
|
274
|
-
if (bindingPackageVersion !== '0.15.
|
|
275
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
274
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
275
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
276
276
|
}
|
|
277
277
|
return binding
|
|
278
278
|
} catch (e) {
|
|
@@ -287,8 +287,8 @@ function requireNative() {
|
|
|
287
287
|
try {
|
|
288
288
|
const binding = require('@stylexswc/rs-compiler-linux-x64-gnu')
|
|
289
289
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-linux-x64-gnu/package.json').version
|
|
290
|
-
if (bindingPackageVersion !== '0.15.
|
|
291
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
290
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
291
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
292
292
|
}
|
|
293
293
|
return binding
|
|
294
294
|
} catch (e) {
|
|
@@ -305,8 +305,8 @@ function requireNative() {
|
|
|
305
305
|
try {
|
|
306
306
|
const binding = require('@stylexswc/rs-compiler-linux-arm64-musl')
|
|
307
307
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-linux-arm64-musl/package.json').version
|
|
308
|
-
if (bindingPackageVersion !== '0.15.
|
|
309
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
308
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
309
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
310
310
|
}
|
|
311
311
|
return binding
|
|
312
312
|
} catch (e) {
|
|
@@ -321,8 +321,8 @@ function requireNative() {
|
|
|
321
321
|
try {
|
|
322
322
|
const binding = require('@stylexswc/rs-compiler-linux-arm64-gnu')
|
|
323
323
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-linux-arm64-gnu/package.json').version
|
|
324
|
-
if (bindingPackageVersion !== '0.15.
|
|
325
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
324
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
325
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
326
326
|
}
|
|
327
327
|
return binding
|
|
328
328
|
} catch (e) {
|
|
@@ -339,8 +339,8 @@ function requireNative() {
|
|
|
339
339
|
try {
|
|
340
340
|
const binding = require('@stylexswc/rs-compiler-linux-arm-musleabihf')
|
|
341
341
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-linux-arm-musleabihf/package.json').version
|
|
342
|
-
if (bindingPackageVersion !== '0.15.
|
|
343
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
342
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
343
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
344
344
|
}
|
|
345
345
|
return binding
|
|
346
346
|
} catch (e) {
|
|
@@ -355,8 +355,8 @@ function requireNative() {
|
|
|
355
355
|
try {
|
|
356
356
|
const binding = require('@stylexswc/rs-compiler-linux-arm-gnueabihf')
|
|
357
357
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-linux-arm-gnueabihf/package.json').version
|
|
358
|
-
if (bindingPackageVersion !== '0.15.
|
|
359
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
358
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
359
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
360
360
|
}
|
|
361
361
|
return binding
|
|
362
362
|
} catch (e) {
|
|
@@ -373,8 +373,8 @@ function requireNative() {
|
|
|
373
373
|
try {
|
|
374
374
|
const binding = require('@stylexswc/rs-compiler-linux-loong64-musl')
|
|
375
375
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-linux-loong64-musl/package.json').version
|
|
376
|
-
if (bindingPackageVersion !== '0.15.
|
|
377
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
376
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
377
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
378
378
|
}
|
|
379
379
|
return binding
|
|
380
380
|
} catch (e) {
|
|
@@ -389,8 +389,8 @@ function requireNative() {
|
|
|
389
389
|
try {
|
|
390
390
|
const binding = require('@stylexswc/rs-compiler-linux-loong64-gnu')
|
|
391
391
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-linux-loong64-gnu/package.json').version
|
|
392
|
-
if (bindingPackageVersion !== '0.15.
|
|
393
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
392
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
393
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
394
394
|
}
|
|
395
395
|
return binding
|
|
396
396
|
} catch (e) {
|
|
@@ -407,8 +407,8 @@ function requireNative() {
|
|
|
407
407
|
try {
|
|
408
408
|
const binding = require('@stylexswc/rs-compiler-linux-riscv64-musl')
|
|
409
409
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-linux-riscv64-musl/package.json').version
|
|
410
|
-
if (bindingPackageVersion !== '0.15.
|
|
411
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
410
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
411
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
412
412
|
}
|
|
413
413
|
return binding
|
|
414
414
|
} catch (e) {
|
|
@@ -423,8 +423,8 @@ function requireNative() {
|
|
|
423
423
|
try {
|
|
424
424
|
const binding = require('@stylexswc/rs-compiler-linux-riscv64-gnu')
|
|
425
425
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-linux-riscv64-gnu/package.json').version
|
|
426
|
-
if (bindingPackageVersion !== '0.15.
|
|
427
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
426
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
427
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
428
428
|
}
|
|
429
429
|
return binding
|
|
430
430
|
} catch (e) {
|
|
@@ -440,8 +440,8 @@ function requireNative() {
|
|
|
440
440
|
try {
|
|
441
441
|
const binding = require('@stylexswc/rs-compiler-linux-ppc64-gnu')
|
|
442
442
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-linux-ppc64-gnu/package.json').version
|
|
443
|
-
if (bindingPackageVersion !== '0.15.
|
|
444
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
443
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
444
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
445
445
|
}
|
|
446
446
|
return binding
|
|
447
447
|
} catch (e) {
|
|
@@ -456,8 +456,8 @@ function requireNative() {
|
|
|
456
456
|
try {
|
|
457
457
|
const binding = require('@stylexswc/rs-compiler-linux-s390x-gnu')
|
|
458
458
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-linux-s390x-gnu/package.json').version
|
|
459
|
-
if (bindingPackageVersion !== '0.15.
|
|
460
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
459
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
460
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
461
461
|
}
|
|
462
462
|
return binding
|
|
463
463
|
} catch (e) {
|
|
@@ -476,8 +476,8 @@ function requireNative() {
|
|
|
476
476
|
try {
|
|
477
477
|
const binding = require('@stylexswc/rs-compiler-openharmony-arm64')
|
|
478
478
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-openharmony-arm64/package.json').version
|
|
479
|
-
if (bindingPackageVersion !== '0.15.
|
|
480
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
479
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
480
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
481
481
|
}
|
|
482
482
|
return binding
|
|
483
483
|
} catch (e) {
|
|
@@ -492,8 +492,8 @@ function requireNative() {
|
|
|
492
492
|
try {
|
|
493
493
|
const binding = require('@stylexswc/rs-compiler-openharmony-x64')
|
|
494
494
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-openharmony-x64/package.json').version
|
|
495
|
-
if (bindingPackageVersion !== '0.15.
|
|
496
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
495
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
496
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
497
497
|
}
|
|
498
498
|
return binding
|
|
499
499
|
} catch (e) {
|
|
@@ -508,8 +508,8 @@ function requireNative() {
|
|
|
508
508
|
try {
|
|
509
509
|
const binding = require('@stylexswc/rs-compiler-openharmony-arm')
|
|
510
510
|
const bindingPackageVersion = require('@stylexswc/rs-compiler-openharmony-arm/package.json').version
|
|
511
|
-
if (bindingPackageVersion !== '0.15.
|
|
512
|
-
throw new Error(`Native binding package version mismatch, expected 0.15.
|
|
511
|
+
if (bindingPackageVersion !== '0.15.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
512
|
+
throw new Error(`Native binding package version mismatch, expected 0.15.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
513
|
}
|
|
514
514
|
return binding
|
|
515
515
|
} catch (e) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stylexswc/rs-compiler",
|
|
3
3
|
"description": "NAPI-RS compiler for transform StyleX code",
|
|
4
|
-
"version": "0.15.
|
|
4
|
+
"version": "0.15.2",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"files": [
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@napi-rs/cli": "^3.5.1",
|
|
24
24
|
"@stylexjs/open-props": "^0.11.1",
|
|
25
|
-
"@stylexjs/stylex": "^0.18.
|
|
25
|
+
"@stylexjs/stylex": "^0.18.2",
|
|
26
26
|
"@swc-node/register": "^1.11.1",
|
|
27
27
|
"@swc/core": "^1.15.11",
|
|
28
28
|
"@taplo/cli": "^0.7.0",
|
|
@@ -35,7 +35,16 @@
|
|
|
35
35
|
"oxlint": "^1.50.0",
|
|
36
36
|
"prettier": "^3.8.1",
|
|
37
37
|
"tinybench": "^6.0.0",
|
|
38
|
-
"typescript": "^5.9.3"
|
|
38
|
+
"typescript": "^5.9.3",
|
|
39
|
+
"@stylexswc/ast": "0.15.2",
|
|
40
|
+
"@stylexswc/logs": "0.15.2",
|
|
41
|
+
"@stylexswc/misc": "0.15.2",
|
|
42
|
+
"@stylexswc/stylex-enums": "0.15.2",
|
|
43
|
+
"@stylexswc/transform": "0.15.2",
|
|
44
|
+
"@stylexswc/macros": "0.15.2",
|
|
45
|
+
"@stylexswc/types": "0.15.2",
|
|
46
|
+
"@stylexswc/regex": "0.15.2",
|
|
47
|
+
"@stylexswc/stylex-structures": "0.15.2"
|
|
39
48
|
},
|
|
40
49
|
"peerDependencies": {
|
|
41
50
|
"@swc/core": "^1"
|
|
@@ -82,13 +91,13 @@
|
|
|
82
91
|
},
|
|
83
92
|
"repository": "https://github.com/Dwlad90/stylex-swc-plugin",
|
|
84
93
|
"optionalDependencies": {
|
|
85
|
-
"@stylexswc/rs-compiler-linux-x64-gnu": "0.15.
|
|
86
|
-
"@stylexswc/rs-compiler-win32-x64-msvc": "0.15.
|
|
87
|
-
"@stylexswc/rs-compiler-darwin-x64": "0.15.
|
|
88
|
-
"@stylexswc/rs-compiler-darwin-arm64": "0.15.
|
|
89
|
-
"@stylexswc/rs-compiler-linux-arm64-gnu": "0.15.
|
|
90
|
-
"@stylexswc/rs-compiler-linux-x64-musl": "0.15.
|
|
91
|
-
"@stylexswc/rs-compiler-win32-arm64-msvc": "0.15.
|
|
94
|
+
"@stylexswc/rs-compiler-linux-x64-gnu": "0.15.2",
|
|
95
|
+
"@stylexswc/rs-compiler-win32-x64-msvc": "0.15.2",
|
|
96
|
+
"@stylexswc/rs-compiler-darwin-x64": "0.15.2",
|
|
97
|
+
"@stylexswc/rs-compiler-darwin-arm64": "0.15.2",
|
|
98
|
+
"@stylexswc/rs-compiler-linux-arm64-gnu": "0.15.2",
|
|
99
|
+
"@stylexswc/rs-compiler-linux-x64-musl": "0.15.2",
|
|
100
|
+
"@stylexswc/rs-compiler-win32-arm64-msvc": "0.15.2"
|
|
92
101
|
},
|
|
93
102
|
"scripts": {
|
|
94
103
|
"artifacts": "napi artifacts",
|
|
@@ -96,6 +105,7 @@
|
|
|
96
105
|
"build": "napi build --platform --release --output-dir dist",
|
|
97
106
|
"build:debug": "napi build --platform",
|
|
98
107
|
"build:swc": "node scripts/inject-swc-plugins.mjs",
|
|
108
|
+
"build:types": "node scripts/inject-types.mjs",
|
|
99
109
|
"check:artifacts": "scripty ./dist/rs-compiler.*.node",
|
|
100
110
|
"format": "run-p format:prettier format:rs format:toml",
|
|
101
111
|
"format:check": "run-p format:rs:check format:toml:check",
|
|
@@ -106,7 +116,7 @@
|
|
|
106
116
|
"format:toml:check": "taplo format --check",
|
|
107
117
|
"lint": "oxlint .",
|
|
108
118
|
"lint:check": " cargo clippy --all-targets --all-features -- -D warnings",
|
|
109
|
-
"postbuild": "
|
|
119
|
+
"postbuild": "pnpm run build:swc && pnpm run build:types && pnpm run check:artifacts",
|
|
110
120
|
"test": "ava",
|
|
111
121
|
"typecheck": "scripty --rs",
|
|
112
122
|
"version": "napi version"
|