@stylexswc/unplugin 0.17.0 → 0.17.1-rc.1

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 CHANGED
@@ -1,28 +1,43 @@
1
- # Unplugin with NAPI-RS StyleX compiler integration
2
-
3
- > Part of the [StyleX SWC Plugin](https://github.com/Dwlad90/stylex-swc-plugin#readme) workspace
4
-
5
- `Unplugin` for an unofficial
6
- [`napi-rs`](https://github.com/dwlad90/stylex-swc-plugin/tree/develop/crates/stylex-rs-compiler)
7
- compiler that includes the StyleX SWC code transformation under the hood.
1
+ # @stylexswc/unplugin
2
+
3
+ > Universal StyleX plugin for Vite, webpack, Rspack, Rollup, esbuild, Farm,
4
+ > Rsbuild, Nuxt, and Astro — powered by a Rust compiler (NAPI-RS + SWC). Part of
5
+ > the [StyleX SWC Plugin](https://github.com/Dwlad90/stylex-swc-plugin#readme)
6
+ > workspace.
7
+
8
+ Built on [unplugin](https://unplugin.unjs.io/), this package gives every major
9
+ bundler the same [StyleX](https://stylexjs.com) integration: it compiles your
10
+ StyleX code with
11
+ [`@stylexswc/rs-compiler`](https://www.npmjs.com/package/@stylexswc/rs-compiler),
12
+ a Rust implementation of the StyleX transform, and extracts the generated CSS.
13
+ Your StyleX code stays exactly the same — only the build step changes, with
14
+ per-file transforms 2x to 5x faster than Babel
15
+ ([performance](https://github.com/Dwlad90/stylex-swc-plugin#performance)).
16
+
17
+ This is a community project and is not affiliated with Meta. It tracks the
18
+ official StyleX releases
19
+ <!-- stylex-compatibility:start -->(currently compatible with StyleX v0.19.0)<!-- stylex-compatibility:end -->
20
+ and requires Node.js 20 or newer.
8
21
 
9
22
  ## Installation
10
23
 
11
- To install the package, run the following command:
12
-
13
24
  ```bash
14
25
  npm install --save-dev @stylexswc/unplugin
15
26
  ```
16
27
 
17
- ## Usage
28
+ The Rust compiler (`@stylexswc/rs-compiler`) is installed automatically as a
29
+ dependency. Your application still needs the StyleX runtime:
18
30
 
19
- To use the plugin, you need to add it to your build tool configuration.
31
+ ```bash
32
+ npm install @stylexjs/stylex
33
+ ```
20
34
 
21
- For every plugin have an example of how to use it in
22
- [`apps/{pluginName}-unplugin-example`](https://github.com/Dwlad90/stylex-swc-plugin/tree/develop/apps)
23
- folder.
35
+ ## Usage
24
36
 
25
- ## Plugins
37
+ Import the entry point matching your build tool and add it to the plugin list. A
38
+ working example for each bundler lives in the
39
+ [`apps/{pluginName}-unplugin-example`](https://github.com/Dwlad90/stylex-swc-plugin/tree/develop/apps)
40
+ folders.
26
41
 
27
42
  <details>
28
43
  <summary>Vite</summary><br>
@@ -32,11 +47,7 @@ folder.
32
47
  import StylexRsPlugin from '@stylexswc/unplugin/vite';
33
48
 
34
49
  export default defineConfig({
35
- plugins: [
36
- StylexRsPlugin({
37
- /* options */
38
- }),
39
- ],
50
+ plugins: [StylexRsPlugin({/* options */})],
40
51
  });
41
52
  ```
42
53
 
@@ -50,11 +61,7 @@ export default defineConfig({
50
61
  import StylexRsPlugin from '@stylexswc/unplugin/rollup';
51
62
 
52
63
  export default {
53
- plugins: [
54
- StylexRsPlugin({
55
- /* options */
56
- }),
57
- ],
64
+ plugins: [StylexRsPlugin({/* options */})],
58
65
  };
59
66
  ```
60
67
 
@@ -67,11 +74,7 @@ export default {
67
74
  // webpack.config.js
68
75
  module.exports = {
69
76
  /* ... */
70
- plugins: [
71
- require('@stylexswc/unplugin/webpack')({
72
- /* options */
73
- }),
74
- ],
77
+ plugins: [require('@stylexswc/unplugin/webpack')({/* options */})],
75
78
  };
76
79
  ```
77
80
 
@@ -84,11 +87,7 @@ module.exports = {
84
87
  // rspack.config.js
85
88
  module.exports = {
86
89
  /* ... */
87
- plugins: [
88
- require('@stylexswc/unplugin/rspack')({
89
- /* options */
90
- }),
91
- ],
90
+ plugins: [require('@stylexswc/unplugin/rspack')({/* options */})],
92
91
  };
93
92
  ```
94
93
 
@@ -100,14 +99,7 @@ module.exports = {
100
99
  ```ts
101
100
  // nuxt.config.js
102
101
  export default defineNuxtConfig({
103
- modules: [
104
- [
105
- '@stylexswc/unplugin/nuxt',
106
- {
107
- /* options */
108
- },
109
- ],
110
- ],
102
+ modules: [['@stylexswc/unplugin/nuxt', {/* options */}]],
111
103
  });
112
104
  ```
113
105
 
@@ -123,11 +115,7 @@ export default defineNuxtConfig({
123
115
  // vue.config.js
124
116
  module.exports = {
125
117
  configureWebpack: {
126
- plugins: [
127
- require('@stylexswc/unplugin/webpack')({
128
- /* options */
129
- }),
130
- ],
118
+ plugins: [require('@stylexswc/unplugin/webpack')({/* options */})],
131
119
  },
132
120
  };
133
121
  ```
@@ -157,27 +145,31 @@ build({
157
145
 
158
146
  - Type: `Partial<StyleXOptions>`
159
147
  - Optional
160
- - Description: StyleX compiler options that will be passed to the NAPI-RS compiler.
161
- For standard StyleX options, see the [official StyleX documentation](https://stylexjs.com/docs/api/configuration/babel-plugin/).
148
+ - Description: StyleX compiler options passed to `@stylexswc/rs-compiler`. For
149
+ the standard options, see the
150
+ [official StyleX documentation](https://stylexjs.com/docs/api/configuration/babel-plugin/).
162
151
 
163
152
  > [!NOTE]
164
- > **New Features:** The `include` and `exclude` options are exclusive to this NAPI-RS compiler implementation and are not available in the official StyleX Babel plugin.
153
+ > The `include` and `exclude` options are exclusive to the Rust compiler
154
+ > and are not available in the official StyleX Babel plugin.
165
155
 
166
156
  ##### `rsOptions.include`
167
157
 
168
158
  - Type: `(string | RegExp)[]`
169
159
  - Optional
170
- - Description: **RS-compiler Only** An array of glob patterns or regular expressions to include specific files for StyleX transformation.
171
- When specified, only files matching at least one of these patterns will be transformed.
172
- Patterns are matched against paths relative to the current working directory.
160
+ - Description: Glob patterns or regular expressions selecting the files to
161
+ transform. When specified, only files matching at least one pattern are
162
+ transformed. Patterns are matched against paths relative to the current
163
+ working directory.
173
164
 
174
165
  ##### `rsOptions.exclude`
175
166
 
176
167
  - Type: `(string | RegExp)[]`
177
168
  - Optional
178
- - Description: **RS-compiler Only** An array of glob patterns or regular expressions to exclude specific files from StyleX transformation.
179
- Files matching any of these patterns will not be transformed, even if they match an `include` pattern.
180
- Patterns are matched against paths relative to the current working directory.
169
+ - Description: Glob patterns or regular expressions excluding files from the
170
+ transform. A file matching any exclude pattern is skipped even if it matches
171
+ an `include` pattern. Patterns are matched against paths relative to the
172
+ current working directory.
181
173
 
182
174
  #### `fileName`
183
175
 
@@ -189,13 +181,15 @@ build({
189
181
 
190
182
  - Type: `UseLayersType`
191
183
  - Default: `false`
192
- - Description: Enables CSS cascade layers support for better style isolation.
184
+ - Description: Wraps the generated CSS in cascade layers for better style
185
+ isolation.
193
186
 
194
187
  #### `extractCSS`
195
188
 
196
189
  - Type: `boolean`
197
190
  - Default: `true`
198
- - Description: Controls whether CSS should be extracted into a separate file.
191
+ - Description: Controls whether the generated CSS is extracted into a separate
192
+ file.
199
193
 
200
194
  #### `pageExtensions`
201
195
 
@@ -209,7 +203,7 @@ build({
209
203
  - Optional
210
204
  - Description: Transforms the extracted StyleX CSS before it is emitted or
211
205
  injected. Matches the `@stylexswc/webpack-plugin` API. Use it to run the
212
- generated CSS through PostCSS, LightningCSS, a minifier, or any custom
206
+ generated CSS through PostCSS, Lightning CSS, a minifier, or any custom
213
207
  post-processing step.
214
208
 
215
209
  ```ts
@@ -219,7 +213,7 @@ type CSSTransformer = (
219
213
  ) => string | Buffer | Promise<string | Buffer>;
220
214
  ```
221
215
 
222
- ```typescript
216
+ ```ts
223
217
  import postcss from 'postcss';
224
218
  import autoprefixer from 'autoprefixer';
225
219
 
@@ -230,45 +224,46 @@ StylexRsPlugin({
230
224
  });
231
225
  return result.css;
232
226
  },
233
- })
227
+ });
234
228
  ```
235
229
 
236
- The `filePath` argument identifies the CSS destination and is
237
- bundler-specific:
230
+ The `filePath` argument identifies the CSS destination and is bundler-specific:
238
231
 
239
232
  - webpack/rspack/rollup injection: the output asset name (e.g. `app.css`)
240
233
  - esbuild disk writes: the absolute path of the written file
241
234
  - Vite placeholder replacement: the id of the CSS module being loaded
242
235
  - generated assets: the configured `fileName`, with `[hash]` left unresolved
243
- (the hash is computed from the transformed CSS, so it cannot be known
244
- earlier)
236
+ (the hash is computed from the transformed CSS, so it cannot be known earlier)
245
237
  - `undefined` when no destination is known
246
238
 
247
239
  > [!NOTE]
248
- > `Buffer` results are decoded as UTF-8. Results are memoized per `filePath`
249
- > while the input CSS is unchanged, so the callback must be a pure function of
250
- > its arguments — the same input may be served from cache instead of invoking
251
- > the callback again.
240
+ > `Buffer` results are decoded as UTF-8. Results are memoized per
241
+ > `filePath` while the input CSS is unchanged, so the callback must be a pure
242
+ > function of its arguments — the same input may be served from cache instead of
243
+ > invoking the callback again.
252
244
 
253
245
  #### `useCssPlaceholder`
254
246
 
255
247
  - Type: `boolean | string`
256
248
  - Default: `false`
257
- - Description: Enable CSS injection into CSS files via placeholder marker.
258
- - When set to `true`, the plugin will look for the default `@stylex;` marker
259
- - When set to a string, the plugin will use that string as the custom marker
249
+ - Description: Injects the generated CSS into an existing CSS file via a
250
+ placeholder marker.
251
+ - When set to `true`, the plugin looks for the default `@stylex;` marker
252
+ - When set to a string, the plugin uses that string as the custom marker
260
253
 
261
- ##### Benefits
254
+ Routing the StyleX output through a real CSS file has practical benefits:
262
255
 
263
- - **CSS Processing**: Generated StyleX CSS goes through the bundler's CSS pipeline (PostCSS, LightningCSS, css-loader, etc.)
264
- - **Deterministic Builds**: No race conditions or hash instability from virtual modules
265
- - **Consistent Output**: All CSS follows the same processing rules and bundling strategy
266
- - **Build Optimization**: CSS can be code-split and optimized alongside other stylesheets
267
- - **Works Everywhere**: Same approach works for Vite, Webpack, Rspack, esbuild, Rollup, and Farm
256
+ - The generated CSS goes through the bundler's CSS pipeline (PostCSS, Lightning
257
+ CSS, css-loader, and so on)
258
+ - Deterministic builds no race conditions or hash instability from virtual
259
+ modules
260
+ - All CSS follows the same processing rules and bundling strategy
261
+ - CSS can be code-split and optimized alongside other stylesheets
262
+ - The same approach works for Vite, webpack, Rspack, esbuild, Rollup, and Farm
268
263
 
269
- ##### How to Use
264
+ How to use it:
270
265
 
271
- 1. Create a CSS file with a marker (e.g., `global.css`):
266
+ 1. Create a CSS file with a marker (e.g. `global.css`):
272
267
 
273
268
  ```css
274
269
  /* global.css */
@@ -286,7 +281,7 @@ body {
286
281
 
287
282
  2. Import the CSS file in your entry point:
288
283
 
289
- ```typescript
284
+ ```ts
290
285
  // src/main.ts
291
286
  import './global.css';
292
287
  import { App } from './App';
@@ -294,7 +289,7 @@ import { App } from './App';
294
289
 
295
290
  3. Configure the plugin with `useCssPlaceholder`:
296
291
 
297
- ```typescript
292
+ ```ts
298
293
  // vite.config.ts (or webpack.config.js, rspack.config.js, etc.)
299
294
  import StylexRsPlugin from '@stylexswc/unplugin/vite';
300
295
  import { defineConfig } from 'vite';
@@ -309,9 +304,7 @@ export default defineConfig({
309
304
  });
310
305
  ```
311
306
 
312
- ##### Using a Custom Marker
313
-
314
- You can specify a custom marker string:
307
+ Or with a custom marker string:
315
308
 
316
309
  ```css
317
310
  /* global.css */
@@ -322,33 +315,33 @@ You can specify a custom marker string:
322
315
  /* INJECT_STYLEX_HERE */
323
316
  ```
324
317
 
325
- ```typescript
318
+ ```ts
326
319
  StylexRsPlugin({
327
320
  useCssPlaceholder: '/* INJECT_STYLEX_HERE */',
328
321
  useCSSLayers: true,
329
- })
322
+ });
330
323
  ```
331
324
 
332
- The plugin will replace the marker with the generated StyleX CSS during the build process.
325
+ The plugin replaces the marker with the generated StyleX CSS during the build.
333
326
 
334
327
  > [!NOTE]
335
- > When `useCssPlaceholder` is enabled, the plugin will no longer inject CSS automatically into HTML or emit a separate `stylex.css` file. The CSS is injected into your specified CSS file.
328
+ > When `useCssPlaceholder` is enabled, the plugin no longer injects CSS
329
+ > automatically into HTML or emits a separate `stylex.css` file. The CSS goes
330
+ > into your specified CSS file instead.
336
331
 
337
332
  > [!IMPORTANT]
338
333
  > **Migration from `useViteCssPipeline`**
339
334
  >
340
- > The `useViteCssPipeline` option (which used virtual CSS modules) has been replaced with the `useCssPlaceholder` approach.
341
- > The new approach uses real CSS files instead of virtual modules, which provides:
342
- >
343
- > - Better compatibility across all bundlers
344
- > - No race conditions or timing issues
345
- > - Deterministic builds with stable hashes
346
- >
347
- > To migrate, simply create a CSS file with a marker and set `useCssPlaceholder: true` (or use a custom marker string).
335
+ > The `useViteCssPipeline` option (which used virtual CSS modules) has been
336
+ > replaced by `useCssPlaceholder`. The new approach uses real CSS files instead
337
+ > of virtual modules, which provides better compatibility across all bundlers,
338
+ > no race conditions or timing issues, and deterministic builds with stable
339
+ > hashes. To migrate, create a CSS file with a marker and set
340
+ > `useCssPlaceholder: true` (or use a custom marker string).
348
341
 
349
342
  ### Example Configuration
350
343
 
351
- ```typescript
344
+ ```ts
352
345
  // vite.config.ts
353
346
  import StylexRsPlugin from '@stylexswc/unplugin/vite';
354
347
  import { defineConfig } from 'vite';
@@ -358,9 +351,7 @@ export default defineConfig({
358
351
  StylexRsPlugin({
359
352
  rsOptions: {
360
353
  dev: process.env.NODE_ENV !== 'production',
361
- // Include only specific directories
362
354
  include: ['src/**/*.{ts,tsx}', 'components/**/*.{ts,tsx}'],
363
- // Exclude test files and stories
364
355
  exclude: ['**/*.test.*', '**/*.stories.*', '**/__tests__/**'],
365
356
  },
366
357
  useCSSLayers: true,
@@ -372,40 +363,39 @@ export default defineConfig({
372
363
 
373
364
  ### Path Filtering Examples
374
365
 
375
- **Include only specific directories:**
366
+ Include only specific directories:
376
367
 
377
- ```typescript
368
+ ```ts
378
369
  StylexRsPlugin({
379
370
  rsOptions: {
380
371
  include: ['src/**/*.tsx', 'app/**/*.tsx'],
381
372
  },
382
- })
373
+ });
383
374
  ```
384
375
 
385
- **Exclude test and build files:**
376
+ Exclude test and build files:
386
377
 
387
- ```typescript
378
+ ```ts
388
379
  StylexRsPlugin({
389
380
  rsOptions: {
390
- exclude: ['**/*.test.*', '**/*.spec.*', '**/dist/**', '**/node_modules/**'],
381
+ exclude: ['**/*.test.*', '**/*.spec.*', '**/dist/**'],
391
382
  },
392
- })
383
+ });
393
384
  ```
394
385
 
395
- **Using RegExp with lookahead/lookbehind - exclude node_modules except specific packages:**
386
+ Exclude `node_modules` except specific packages (negative lookahead):
396
387
 
397
- ```typescript
388
+ ```ts
398
389
  StylexRsPlugin({
399
390
  rsOptions: {
400
- // Exclude all node_modules except @stylexjs packages
401
391
  exclude: [/node_modules(?!\/@stylexjs)/],
402
392
  },
403
- })
393
+ });
404
394
  ```
405
395
 
406
- **Transform only specific packages from node_modules:**
396
+ Transform only specific packages from `node_modules`:
407
397
 
408
- ```typescript
398
+ ```ts
409
399
  StylexRsPlugin({
410
400
  rsOptions: {
411
401
  include: [
@@ -415,31 +405,59 @@ StylexRsPlugin({
415
405
  ],
416
406
  exclude: ['**/*.test.*'],
417
407
  },
418
- })
419
- ```
420
-
421
- **Using regular expressions:**
422
-
423
- ```typescript
424
- StylexRsPlugin({
425
- rsOptions: {
426
- include: [/src\/.*\.tsx$/],
427
- exclude: [/\.test\./, /\.stories\./],
428
- },
429
- })
408
+ });
430
409
  ```
431
410
 
432
- **Combined include and exclude (exclude takes precedence):**
411
+ Combined include and exclude (exclude takes precedence):
433
412
 
434
- ```typescript
413
+ ```ts
435
414
  StylexRsPlugin({
436
415
  rsOptions: {
437
416
  include: ['src/**/*.{ts,tsx}'],
438
417
  exclude: ['**/__tests__/**', '**/__mocks__/**'],
439
418
  },
440
- })
419
+ });
441
420
  ```
442
421
 
422
+ ## FAQ
423
+
424
+ ### Should I use this package or the bundler-specific plugin?
425
+
426
+ If you are on Vite, esbuild, Farm, Rsbuild, Nuxt, or Astro, this is the package
427
+ to use. For webpack and Rspack, the dedicated `@stylexswc/webpack-plugin` and
428
+ `@stylexswc/rspack-plugin` packages offer a few deeper integrations (loader
429
+ ordering, cache groups); this plugin covers the common cases with one consistent
430
+ API. For Next.js, use `@stylexswc/nextjs-plugin`.
431
+
432
+ ### Do I still need `@stylexjs/babel-plugin`?
433
+
434
+ No. This plugin replaces the Babel plugin in your build. You only keep
435
+ `@stylexjs/stylex` as your app's runtime dependency, and your `stylex.create` /
436
+ `stylex.props` code does not change.
437
+
438
+ ### How do I run the generated CSS through PostCSS or Tailwind pipelines?
439
+
440
+ Either pass a `transformCss` function, or enable `useCssPlaceholder` so the
441
+ generated CSS lands in a real CSS file and flows through your bundler's normal
442
+ CSS pipeline.
443
+
444
+ ### Does hot module replacement work?
445
+
446
+ Yes. The plugin participates in each bundler's standard transform pipeline, so
447
+ style changes update through the dev server like any other module.
448
+
449
+ ### Is this an official StyleX package?
450
+
451
+ No. It is a community-maintained alternative to the official tooling and is not
452
+ affiliated with or supported by Meta.
453
+
454
+ ## Documentation
455
+
456
+ - [StyleX documentation](https://stylexjs.com)
457
+ - [unplugin documentation](https://unplugin.unjs.io/)
458
+ - [`@stylexswc/rs-compiler` compiler options](https://github.com/Dwlad90/stylex-swc-plugin/tree/develop/crates/stylex-rs-compiler)
459
+
443
460
  ## License
444
461
 
445
- MIT — see [LICENSE](https://github.com/Dwlad90/stylex-swc-plugin/blob/develop/LICENSE)
462
+ MIT — see
463
+ [LICENSE](https://github.com/Dwlad90/stylex-swc-plugin/blob/develop/LICENSE)
package/dist/astro.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkDSDMZSD3cjs = require('./chunk-DSDMZSD3.cjs');
3
+ var _chunkVS4EGBCScjs = require('./chunk-VS4EGBCS.cjs');
4
4
  require('./chunk-ZBPRDZS4.cjs');
5
5
 
6
6
  // src/astro.ts
@@ -10,7 +10,7 @@ var astro_default = (options) => ({
10
10
  "astro:config:setup": async (astro) => {
11
11
  var _a;
12
12
  (_a = astro.config.vite).plugins || (_a.plugins = []);
13
- astro.config.vite.plugins.push(_chunkDSDMZSD3cjs.index_default.vite(options));
13
+ astro.config.vite.plugins.push(_chunkVS4EGBCScjs.index_default.vite(options));
14
14
  }
15
15
  }
16
16
  });
package/dist/astro.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  index_default
3
- } from "./chunk-7B4XDVOL.js";
3
+ } from "./chunk-URE4E2NA.js";
4
4
  import "./chunk-6F4PWJZI.js";
5
5
 
6
6
  // src/astro.ts
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-7B4XDVOL.js";
3
+ } from "./chunk-URE4E2NA.js";
4
4
 
5
5
  // src/webpack.ts
6
6
  import { createWebpackPlugin } from "unplugin";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-7B4XDVOL.js";
3
+ } from "./chunk-URE4E2NA.js";
4
4
 
5
5
  // src/vite.ts
6
6
  import { createVitePlugin } from "unplugin";
@@ -1,10 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkDSDMZSD3cjs = require('./chunk-DSDMZSD3.cjs');
3
+ var _chunkVS4EGBCScjs = require('./chunk-VS4EGBCS.cjs');
4
4
 
5
5
  // src/vite.ts
6
6
  var _unplugin = require('unplugin');
7
- var vite_default = _unplugin.createVitePlugin.call(void 0, _chunkDSDMZSD3cjs.unpluginFactory);
7
+ var vite_default = _unplugin.createVitePlugin.call(void 0, _chunkVS4EGBCScjs.unpluginFactory);
8
8
 
9
9
 
10
10
 
@@ -196,12 +196,23 @@ var unpluginFactory = (options = {}) => {
196
196
  const basename2 = path.basename(id);
197
197
  const file = path.join(dir, basename2.split("?")[0] || basename2);
198
198
  try {
199
+ let inputSourceMap;
200
+ if (hasCombinedSourcemap(this)) {
201
+ try {
202
+ const combinedMap = this.getCombinedSourcemap();
203
+ if (combinedMap == null ? void 0 : combinedMap.mappings) {
204
+ inputSourceMap = JSON.stringify(combinedMap);
205
+ }
206
+ } catch (e) {
207
+ }
208
+ }
199
209
  const { code, map } = transformStyleXCode(
200
210
  file,
201
211
  inputCode,
202
212
  normalizedOptions,
203
213
  stylexRules,
204
- id
214
+ id,
215
+ inputSourceMap
205
216
  );
206
217
  if (normalizedOptions.useCssPlaceholder && viteDevServer && !hasInvalidatedInitialCSS) {
207
218
  hasInvalidatedInitialCSS = true;
@@ -702,10 +713,16 @@ function hasStyleXCode(normalizedOptions, inputCode) {
702
713
  (importName) => typeof importName === "string" ? inputCode.includes(importName) : inputCode.includes(importName.from)
703
714
  );
704
715
  }
705
- function transformStyleXCode(file, inputCode, normalizedOptions, stylexRules, id) {
716
+ function hasCombinedSourcemap(context) {
717
+ return "getCombinedSourcemap" in context && typeof context.getCombinedSourcemap === "function";
718
+ }
719
+ function transformStyleXCode(file, inputCode, normalizedOptions, stylexRules, id, inputSourceMap) {
706
720
  const rsOptions = __spreadValues({}, normalizedOptions.rsOptions);
707
721
  rsOptions.include = void 0;
708
722
  rsOptions.exclude = void 0;
723
+ if (inputSourceMap !== void 0 && rsOptions.inputSourceMap === void 0) {
724
+ rsOptions.inputSourceMap = inputSourceMap;
725
+ }
709
726
  const result = stylexTransform(file, inputCode, rsOptions);
710
727
  const { metadata } = result;
711
728
  if (normalizedOptions.extractCSS && metadata.stylex && metadata.stylex.length > 0) {
@@ -196,12 +196,23 @@ var unpluginFactory = (options = {}) => {
196
196
  const basename2 = path.basename(id);
197
197
  const file = path.join(dir, basename2.split("?")[0] || basename2);
198
198
  try {
199
+ let inputSourceMap;
200
+ if (hasCombinedSourcemap(this)) {
201
+ try {
202
+ const combinedMap = this.getCombinedSourcemap();
203
+ if (combinedMap == null ? void 0 : combinedMap.mappings) {
204
+ inputSourceMap = JSON.stringify(combinedMap);
205
+ }
206
+ } catch (e) {
207
+ }
208
+ }
199
209
  const { code, map } = transformStyleXCode(
200
210
  file,
201
211
  inputCode,
202
212
  normalizedOptions,
203
213
  stylexRules,
204
- id
214
+ id,
215
+ inputSourceMap
205
216
  );
206
217
  if (normalizedOptions.useCssPlaceholder && viteDevServer && !hasInvalidatedInitialCSS) {
207
218
  hasInvalidatedInitialCSS = true;
@@ -702,10 +713,16 @@ function hasStyleXCode(normalizedOptions, inputCode) {
702
713
  (importName) => typeof importName === "string" ? inputCode.includes(importName) : inputCode.includes(importName.from)
703
714
  );
704
715
  }
705
- function transformStyleXCode(file, inputCode, normalizedOptions, stylexRules, id) {
716
+ function hasCombinedSourcemap(context) {
717
+ return "getCombinedSourcemap" in context && typeof context.getCombinedSourcemap === "function";
718
+ }
719
+ function transformStyleXCode(file, inputCode, normalizedOptions, stylexRules, id, inputSourceMap) {
706
720
  const rsOptions = __spreadValues({}, normalizedOptions.rsOptions);
707
721
  rsOptions.include = void 0;
708
722
  rsOptions.exclude = void 0;
723
+ if (inputSourceMap !== void 0 && rsOptions.inputSourceMap === void 0) {
724
+ rsOptions.inputSourceMap = inputSourceMap;
725
+ }
709
726
  const result = _rscompiler.transform.call(void 0, file, inputCode, rsOptions);
710
727
  const { metadata } = result;
711
728
  if (normalizedOptions.extractCSS && metadata.stylex && metadata.stylex.length > 0) {
@@ -1,10 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkDSDMZSD3cjs = require('./chunk-DSDMZSD3.cjs');
3
+ var _chunkVS4EGBCScjs = require('./chunk-VS4EGBCS.cjs');
4
4
 
5
5
  // src/webpack.ts
6
6
  var _unplugin = require('unplugin');
7
- var webpack_default = _unplugin.createWebpackPlugin.call(void 0, _chunkDSDMZSD3cjs.unpluginFactory);
7
+ var webpack_default = _unplugin.createWebpackPlugin.call(void 0, _chunkVS4EGBCScjs.unpluginFactory);
8
8
 
9
9
 
10
10
 
package/dist/esbuild.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkDSDMZSD3cjs = require('./chunk-DSDMZSD3.cjs');
3
+ var _chunkVS4EGBCScjs = require('./chunk-VS4EGBCS.cjs');
4
4
  require('./chunk-ZBPRDZS4.cjs');
5
5
 
6
6
  // src/esbuild.ts
7
7
  var _unplugin = require('unplugin');
8
- var esbuild_default = _unplugin.createEsbuildPlugin.call(void 0, _chunkDSDMZSD3cjs.unpluginFactory);
8
+ var esbuild_default = _unplugin.createEsbuildPlugin.call(void 0, _chunkVS4EGBCScjs.unpluginFactory);
9
9
 
10
10
 
11
11
  exports.default = esbuild_default;
package/dist/esbuild.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-7B4XDVOL.js";
3
+ } from "./chunk-URE4E2NA.js";
4
4
  import "./chunk-6F4PWJZI.js";
5
5
 
6
6
  // src/esbuild.ts
package/dist/farm.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkDSDMZSD3cjs = require('./chunk-DSDMZSD3.cjs');
3
+ var _chunkVS4EGBCScjs = require('./chunk-VS4EGBCS.cjs');
4
4
  require('./chunk-ZBPRDZS4.cjs');
5
5
 
6
6
  // src/farm.ts
7
7
  var _unplugin = require('unplugin');
8
- var plugin = _unplugin.createFarmPlugin.call(void 0, _chunkDSDMZSD3cjs.unpluginFactory);
8
+ var plugin = _unplugin.createFarmPlugin.call(void 0, _chunkVS4EGBCScjs.unpluginFactory);
9
9
  var farm_default = plugin;
10
10
 
11
11
 
package/dist/farm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-7B4XDVOL.js";
3
+ } from "./chunk-URE4E2NA.js";
4
4
  import "./chunk-6F4PWJZI.js";
5
5
 
6
6
  // src/farm.ts
package/dist/index.cjs CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkDSDMZSD3cjs = require('./chunk-DSDMZSD3.cjs');
5
+ var _chunkVS4EGBCScjs = require('./chunk-VS4EGBCS.cjs');
6
6
  require('./chunk-ZBPRDZS4.cjs');
7
7
 
8
8
 
9
9
 
10
10
 
11
- exports.default = _chunkDSDMZSD3cjs.index_default; exports.unplugin = _chunkDSDMZSD3cjs.unplugin; exports.unpluginFactory = _chunkDSDMZSD3cjs.unpluginFactory;
11
+ exports.default = _chunkVS4EGBCScjs.index_default; exports.unplugin = _chunkVS4EGBCScjs.unplugin; exports.unpluginFactory = _chunkVS4EGBCScjs.unpluginFactory;
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  index_default,
3
3
  unplugin,
4
4
  unpluginFactory
5
- } from "./chunk-7B4XDVOL.js";
5
+ } from "./chunk-URE4E2NA.js";
6
6
  import "./chunk-6F4PWJZI.js";
7
7
  export {
8
8
  index_default as default,
package/dist/nuxt.cjs CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkIEJV2VJWcjs = require('./chunk-IEJV2VJW.cjs');
3
+ var _chunkS32CGSL7cjs = require('./chunk-S32CGSL7.cjs');
4
4
 
5
5
 
6
- var _chunkK4NOYZX4cjs = require('./chunk-K4NOYZX4.cjs');
7
- require('./chunk-DSDMZSD3.cjs');
6
+ var _chunkWDIBNKVOcjs = require('./chunk-WDIBNKVO.cjs');
7
+ require('./chunk-VS4EGBCS.cjs');
8
8
  require('./chunk-ZBPRDZS4.cjs');
9
9
 
10
10
  // src/nuxt.ts
@@ -19,8 +19,8 @@ var nuxt_default = _kit.defineNuxtModule.call(void 0, {
19
19
  // ...default options
20
20
  },
21
21
  setup(options, _nuxt) {
22
- _kit.addVitePlugin.call(void 0, () => _chunkIEJV2VJWcjs.vite_default.call(void 0, options));
23
- _kit.addWebpackPlugin.call(void 0, () => _chunkK4NOYZX4cjs.webpack_default.call(void 0, options));
22
+ _kit.addVitePlugin.call(void 0, () => _chunkS32CGSL7cjs.vite_default.call(void 0, options));
23
+ _kit.addWebpackPlugin.call(void 0, () => _chunkWDIBNKVOcjs.webpack_default.call(void 0, options));
24
24
  }
25
25
  });
26
26
 
package/dist/nuxt.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  vite_default
3
- } from "./chunk-D4H2D3B6.js";
3
+ } from "./chunk-QRJII2H5.js";
4
4
  import {
5
5
  webpack_default
6
- } from "./chunk-ZV3C53H2.js";
7
- import "./chunk-7B4XDVOL.js";
6
+ } from "./chunk-DSQA5FUR.js";
7
+ import "./chunk-URE4E2NA.js";
8
8
  import "./chunk-6F4PWJZI.js";
9
9
 
10
10
  // src/nuxt.ts
package/dist/rollup.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkDSDMZSD3cjs = require('./chunk-DSDMZSD3.cjs');
3
+ var _chunkVS4EGBCScjs = require('./chunk-VS4EGBCS.cjs');
4
4
  require('./chunk-ZBPRDZS4.cjs');
5
5
 
6
6
  // src/rollup.ts
7
7
  var _unplugin = require('unplugin');
8
- var rollup_default = _unplugin.createRollupPlugin.call(void 0, _chunkDSDMZSD3cjs.unpluginFactory);
8
+ var rollup_default = _unplugin.createRollupPlugin.call(void 0, _chunkVS4EGBCScjs.unpluginFactory);
9
9
 
10
10
 
11
11
  exports.default = rollup_default;
package/dist/rollup.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-7B4XDVOL.js";
3
+ } from "./chunk-URE4E2NA.js";
4
4
  import "./chunk-6F4PWJZI.js";
5
5
 
6
6
  // src/rollup.ts
package/dist/rspack.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkDSDMZSD3cjs = require('./chunk-DSDMZSD3.cjs');
3
+ var _chunkVS4EGBCScjs = require('./chunk-VS4EGBCS.cjs');
4
4
  require('./chunk-ZBPRDZS4.cjs');
5
5
 
6
6
  // src/rspack.ts
7
7
  var _unplugin = require('unplugin');
8
- var rspack_default = _unplugin.createRspackPlugin.call(void 0, _chunkDSDMZSD3cjs.unpluginFactory);
8
+ var rspack_default = _unplugin.createRspackPlugin.call(void 0, _chunkVS4EGBCScjs.unpluginFactory);
9
9
 
10
10
 
11
11
  exports.default = rspack_default;
package/dist/rspack.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-7B4XDVOL.js";
3
+ } from "./chunk-URE4E2NA.js";
4
4
  import "./chunk-6F4PWJZI.js";
5
5
 
6
6
  // src/rspack.ts
package/dist/vite.cjs CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkIEJV2VJWcjs = require('./chunk-IEJV2VJW.cjs');
4
- require('./chunk-DSDMZSD3.cjs');
3
+ var _chunkS32CGSL7cjs = require('./chunk-S32CGSL7.cjs');
4
+ require('./chunk-VS4EGBCS.cjs');
5
5
  require('./chunk-ZBPRDZS4.cjs');
6
6
 
7
7
 
8
- exports.default = _chunkIEJV2VJWcjs.vite_default;
8
+ exports.default = _chunkS32CGSL7cjs.vite_default;
9
9
 
10
10
  module.exports = exports.default;
package/dist/vite.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  vite_default
3
- } from "./chunk-D4H2D3B6.js";
4
- import "./chunk-7B4XDVOL.js";
3
+ } from "./chunk-QRJII2H5.js";
4
+ import "./chunk-URE4E2NA.js";
5
5
  import "./chunk-6F4PWJZI.js";
6
6
  export {
7
7
  vite_default as default
package/dist/webpack.cjs CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkK4NOYZX4cjs = require('./chunk-K4NOYZX4.cjs');
4
- require('./chunk-DSDMZSD3.cjs');
3
+ var _chunkWDIBNKVOcjs = require('./chunk-WDIBNKVO.cjs');
4
+ require('./chunk-VS4EGBCS.cjs');
5
5
  require('./chunk-ZBPRDZS4.cjs');
6
6
 
7
7
 
8
- exports.default = _chunkK4NOYZX4cjs.webpack_default;
8
+ exports.default = _chunkWDIBNKVOcjs.webpack_default;
9
9
 
10
10
  module.exports = exports.default;
package/dist/webpack.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  webpack_default
3
- } from "./chunk-ZV3C53H2.js";
4
- import "./chunk-7B4XDVOL.js";
3
+ } from "./chunk-DSQA5FUR.js";
4
+ import "./chunk-URE4E2NA.js";
5
5
  import "./chunk-6F4PWJZI.js";
6
6
  export {
7
7
  webpack_default as default
package/package.json CHANGED
@@ -1,32 +1,12 @@
1
1
  {
2
2
  "name": "@stylexswc/unplugin",
3
- "description": "Unplugin for StyleX RS compiler",
4
- "version": "0.17.0",
5
- "bugs": "https://github.com/Dwlad90/stylex-swc-plugin/issues",
6
- "config": {
7
- "scripty": {
8
- "path": "../../scripts/packages"
9
- }
10
- },
11
- "dependencies": {
12
- "@stylexjs/babel-plugin": "^0.19.0",
13
- "@stylexswc/rs-compiler": "0.17.0",
14
- "unplugin": "^3.0.0",
15
- "vite": "^8.1.2"
16
- },
17
- "devDependencies": {
18
- "@nuxt/kit": "^4.4.8",
19
- "@nuxt/schema": "^4.4.8",
20
- "@rollup/plugin-commonjs": "^29.0.3",
21
- "@rollup/plugin-node-resolve": "^16.0.3",
22
- "@types/node": "^26.1.0",
23
- "eslint": "^10.6.0",
24
- "esno": "^4.7.0",
25
- "rollup": "^4.62.2",
26
- "tsup": "^8.5.1",
27
- "typescript": "^6.0.3",
28
- "vitest": "^4.1.9"
29
- },
3
+ "description": "Universal StyleX plugin for Vite, webpack, Rspack, Rollup, esbuild, Farm, Rsbuild, Nuxt, and Astro, powered by a Rust NAPI-RS/SWC compiler.",
4
+ "version": "0.17.1-rc.1",
5
+ "private": false,
6
+ "license": "MIT",
7
+ "sideEffects": false,
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
30
10
  "exports": {
31
11
  ".": {
32
12
  "types": "./dist/index.d.ts",
@@ -83,32 +63,65 @@
83
63
  "files": [
84
64
  "dist"
85
65
  ],
66
+ "publishConfig": {
67
+ "registry": "https://registry.npmjs.org/",
68
+ "access": "public"
69
+ },
70
+ "config": {
71
+ "scripty": {
72
+ "path": "../../scripts/packages"
73
+ }
74
+ },
75
+ "dependencies": {
76
+ "@stylexjs/babel-plugin": "^0.19.0",
77
+ "@stylexswc/rs-compiler": "0.17.1-rc.1",
78
+ "unplugin": "^3.0.0",
79
+ "vite": "^8.1.2"
80
+ },
81
+ "devDependencies": {
82
+ "@nuxt/kit": "^4.4.8",
83
+ "@nuxt/schema": "^4.4.8",
84
+ "@rollup/plugin-commonjs": "^29.0.3",
85
+ "@rollup/plugin-node-resolve": "^16.0.3",
86
+ "@types/node": "^26.1.0",
87
+ "eslint": "^10.6.0",
88
+ "esno": "^4.7.0",
89
+ "rollup": "^4.62.2",
90
+ "tsup": "^8.5.1",
91
+ "typescript": "^6.0.3",
92
+ "vitest": "^4.1.9"
93
+ },
94
+ "peerDependencies": {
95
+ "@farmfe/core": ">=1.7.11 <2.0.0",
96
+ "@nuxt/kit": ">=3.0.0",
97
+ "@nuxt/schema": ">=3.0.0",
98
+ "esbuild": ">=0.25.0",
99
+ "rollup": ">=3.0.0",
100
+ "vite": ">=4.0.0",
101
+ "webpack": ">=5.0.0"
102
+ },
103
+ "bugs": "https://github.com/Dwlad90/stylex-swc-plugin/issues",
86
104
  "homepage": "https://github.com/Dwlad90/stylex-swc-plugin/tree/develop/packages/unplugin#readme",
87
105
  "keywords": [
106
+ "astro",
107
+ "atomic-css",
108
+ "css-extraction",
109
+ "css-in-js",
88
110
  "esbuild",
89
111
  "farm",
112
+ "napi-rs",
113
+ "nuxt",
90
114
  "rollup",
91
115
  "rsbuild",
92
116
  "rspack",
117
+ "rust",
93
118
  "stylex",
94
119
  "swc",
95
- "transform",
96
120
  "unplugin",
97
121
  "vite",
98
122
  "webpack"
99
123
  ],
100
- "license": "MIT",
101
124
  "main": "./dist/index.js",
102
- "module": "./dist/index.js",
103
- "peerDependencies": {
104
- "@farmfe/core": ">=1.7.11 <2.0.0",
105
- "@nuxt/kit": ">=3.0.0",
106
- "@nuxt/schema": ">=3.0.0",
107
- "esbuild": ">=0.25.0",
108
- "rollup": ">=3.0.0",
109
- "vite": ">=4.0.0",
110
- "webpack": ">=5.0.0"
111
- },
112
125
  "peerDependenciesMeta": {
113
126
  "@farmfe/core": {
114
127
  "optional": true
@@ -132,15 +145,12 @@
132
145
  "optional": true
133
146
  }
134
147
  },
135
- "private": false,
136
- "publishConfig": {
137
- "registry": "https://registry.npmjs.org/",
138
- "access": "public"
148
+ "repository": {
149
+ "type": "git",
150
+ "url": "git+https://github.com/Dwlad90/stylex-swc-plugin.git",
151
+ "directory": "packages/unplugin"
139
152
  },
140
- "repository": "https://github.com/Dwlad90/stylex-swc-plugin",
141
- "sideEffects": false,
142
153
  "type": "module",
143
- "types": "./dist/index.d.ts",
144
154
  "typesVersions": {
145
155
  "*": {
146
156
  "*": [