@stylexswc/webpack-plugin 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,42 @@
1
- # Webpack plugin 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
- `Webpack plugin` 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/webpack-plugin
2
+
3
+ > StyleX plugin for webpack, powered by a Rust compiler (NAPI-RS + SWC). Part of
4
+ > the [StyleX SWC Plugin](https://github.com/Dwlad90/stylex-swc-plugin#readme)
5
+ > workspace.
6
+
7
+ This plugin compiles [StyleX](https://stylexjs.com) code in your webpack build
8
+ with
9
+ [`@stylexswc/rs-compiler`](https://www.npmjs.com/package/@stylexswc/rs-compiler),
10
+ a Rust implementation of the StyleX transform, instead of the official Babel
11
+ plugin. Your StyleX code stays exactly the same — only the build step changes,
12
+ with per-file transforms 2x to 5x faster than Babel
13
+ ([performance](https://github.com/Dwlad90/stylex-swc-plugin#performance)).
14
+ The plugin transforms your source files, collects the generated rules, and
15
+ extracts them into a dedicated CSS chunk.
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. For Next.js projects, use
21
+ [`@stylexswc/nextjs-plugin`](https://www.npmjs.com/package/@stylexswc/nextjs-plugin)
22
+ instead — it wires this plugin into the Next.js build for you.
8
23
 
9
24
  ## Installation
10
25
 
11
- To install the package, run the following command:
12
-
13
26
  ```bash
14
27
  npm install --save-dev @stylexswc/webpack-plugin
15
28
  ```
16
29
 
17
- Please install `@stylexswc/rs-compiler` if you haven't done so already:
30
+ The Rust compiler (`@stylexswc/rs-compiler`) is installed automatically as a
31
+ dependency. Your application still needs the StyleX runtime:
18
32
 
19
33
  ```bash
20
- npm install --save-dev @stylexswc/rs-compiler
34
+ npm install @stylexjs/stylex
21
35
  ```
22
36
 
23
37
  ## Usage
24
38
 
25
- Modify Webpack config. For example:
39
+ Add the plugin to your webpack config:
26
40
 
27
41
  ```js
28
42
  const StylexPlugin = require('@stylexswc/webpack-plugin');
@@ -38,17 +52,8 @@ const config = (env, argv) => ({
38
52
  },
39
53
  plugins: [
40
54
  new StylexPlugin({
41
- // ... Other StyleX options
42
- transformCss: async (css, filePath) => {
43
- const postcss = require('postcss');
44
- const result = await postcss([require('autoprefixer')]).process(css, {
45
- from: filePath,
46
- map: {
47
- inline: false,
48
- annotation: false,
49
- },
50
- });
51
- return result.css;
55
+ rsOptions: {
56
+ dev: argv.mode === 'development',
52
57
  },
53
58
  }),
54
59
  ],
@@ -66,95 +71,105 @@ module.exports = config;
66
71
 
67
72
  - Type: `Partial<StyleXOptions>`
68
73
  - Optional
69
- - Description: StyleX compiler options that will be passed to the NAPI-RS compiler.
70
- For standard StyleX options, see the [official StyleX documentation](https://stylexjs.com/docs/api/configuration/babel-plugin/).
74
+ - Description: StyleX compiler options passed to `@stylexswc/rs-compiler`. For
75
+ the standard options, see the
76
+ [official StyleX documentation](https://stylexjs.com/docs/api/configuration/babel-plugin/).
71
77
 
72
78
  > [!NOTE]
73
- > **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.
79
+ > The `include` and `exclude` options are exclusive to the Rust compiler
80
+ > and are not available in the official StyleX Babel plugin.
74
81
 
75
82
  ##### `rsOptions.include`
76
83
 
77
84
  - Type: `(string | RegExp)[]`
78
85
  - Optional
79
- - Description: **RS-compiler Only** An array of glob patterns or regular expressions to include specific files for StyleX transformation.
80
- When specified, only files matching at least one of these patterns will be transformed.
81
- Patterns are matched against paths relative to the current working directory.
86
+ - Description: Glob patterns or regular expressions selecting the files to
87
+ transform. When specified, only files matching at least one pattern are
88
+ transformed. Patterns are matched against paths relative to the current
89
+ working directory.
82
90
 
83
91
  ##### `rsOptions.exclude`
84
92
 
85
93
  - Type: `(string | RegExp)[]`
86
94
  - Optional
87
- - Description: **RS-compiler Only** An array of glob patterns or regular expressions to exclude specific files from StyleX transformation.
88
- Files matching any of these patterns will not be transformed, even if they match an `include` pattern.
89
- Patterns are matched against paths relative to the current working directory.
95
+ - Description: Glob patterns or regular expressions excluding files from the
96
+ transform. A file matching any exclude pattern is skipped even if it matches
97
+ an `include` pattern. Patterns are matched against paths relative to the
98
+ current working directory.
90
99
 
91
100
  #### `stylexImports`
92
101
 
93
102
  - Type: `Array<string | { as: string, from: string }>`
94
103
  - Default: `['stylex', '@stylexjs/stylex']`
95
- - Description: Specifies where StyleX will be imported from. Supports both
96
- string paths and import aliases.
104
+ - Description: Specifies where StyleX is imported from. Supports both string
105
+ paths and import aliases.
97
106
 
98
107
  #### `useCSSLayers`
99
108
 
100
109
  - Type: `boolean`
101
110
  - Default: `false`
102
- - Description: Enables CSS cascade layers support for better style isolation.
111
+ - Description: Wraps the generated CSS in cascade layers for better style
112
+ isolation.
103
113
 
104
114
  #### `nextjsMode`
105
115
 
106
116
  - Type: `boolean`
107
117
  - Default: `false`
108
118
  - Description: Enables Next.js-specific optimizations and compatibility
109
- features.
119
+ features. Leave off unless the plugin is driven by the Next.js integration.
110
120
 
111
121
  #### `extractCSS`
112
122
 
113
123
  - Type: `boolean`
114
124
  - Optional
115
125
  - Default: `true`
116
- - Description: Controls whether CSS should be extracted into a separate file
126
+ - Description: Controls whether the generated CSS is extracted into a separate
127
+ file.
117
128
 
118
129
  #### `loaderOrder`
119
130
 
120
131
  - Type: `'first' | 'last'`
121
132
  - Optional
122
133
  - Default: `'first'`
123
- - Description: Determines when the StyleX transformation is applied relative to other webpack loaders.
124
- - `'first'` (recommended): StyleX processes the source code before any other loaders run.
125
- Automatically enables `injectStylexSideEffects` to prevent tree-shaking from removing `.stylex` and `.consts` imports.
126
- - `'last'`: StyleX processes after all other loaders have completed.
127
- Use this if you need other loaders (like TypeScript or SWC plugins) to transform your code before StyleX processing.
134
+ - Description: When the StyleX transformation runs relative to other webpack
135
+ loaders.
136
+ - `'first'` (recommended): StyleX processes the source code before any other
137
+ loaders run. Automatically enables `injectStylexSideEffects` so tree-shaking
138
+ cannot remove `.stylex` and `.consts` imports.
139
+ - `'last'`: StyleX processes after all other loaders have completed. Use this
140
+ if other loaders (TypeScript, SWC plugins) must transform your code before
141
+ StyleX sees it.
142
+
143
+ Why `'first'` is recommended: after StyleX rewrites your code, imports from
144
+ `.stylex` and `.consts` files can look unused to subsequent loaders and
145
+ bundler passes and get tree-shaken away:
128
146
 
129
- **Why `'first'` is recommended:**
130
- When StyleX transforms your code first, imports from `.stylex` and `.consts` files may appear unused to subsequent loaders/bundlers and get removed by tree-shaking. The plugin automatically injects side-effect imports to prevent this issue.
131
-
132
- **Example of the problem:**
133
147
  ```ts
134
148
  // Before transformation
135
149
  import { colors } from './theme.stylex';
136
150
  const styles = stylex.create({
137
- root: { backgroundColor: colors.primary }
151
+ root: { backgroundColor: colors.primary },
138
152
  });
139
153
 
140
- // After StyleX transformation (appears unused to bundler)
141
- import { colors } from './theme.stylex'; // May be tree-shaken!
154
+ // After StyleX transformation (appears unused to the bundler)
155
+ import { colors } from './theme.stylex'; // may be tree-shaken!
142
156
  const styles = { root: { backgroundColor: 'x1a2b3c', $$css: true } };
143
157
  ```
144
158
 
145
- With `loaderOrder: 'first'`, the plugin automatically preserves these imports by injecting side-effect imports.
159
+ With `loaderOrder: 'first'`, the plugin preserves these imports by injecting
160
+ side-effect imports automatically.
146
161
 
147
162
  #### `stylexPackages`
148
163
 
149
164
  - Type: `string[]`
150
165
  - Optional
151
166
  - Default: `['@stylexjs/']`
152
- - Description: `node_modules` is **excluded by default**, even for files that
153
- reference a StyleX import. Packages that ship untransformed StyleX source
154
- (e.g. component libraries) must be allowlisted here with path fragments so
155
- the StyleX loader still processes them:
167
+ - Description: `node_modules` is excluded from the transform by default, even
168
+ for files that reference a StyleX import. Packages that ship untransformed
169
+ StyleX source (component libraries, token packages) must be allowlisted here
170
+ with path fragments:
156
171
 
157
- ```javascript
172
+ ```js
158
173
  new StylexPlugin({
159
174
  stylexPackages: ['@stylexjs/', 'my-design-system'],
160
175
  });
@@ -167,19 +182,34 @@ new StylexPlugin({
167
182
  - Type:
168
183
  `(css: string, filePath: string | undefined) => string | Buffer | Promise<string | Buffer>`
169
184
  - Optional
170
- - Description: Custom CSS transformation function. Since the plugin injects CSS
171
- after all loaders, use this to apply PostCSS or other CSS transformations.
185
+ - Description: Custom CSS post-processing. The plugin injects CSS after all
186
+ loaders have run, so `postcss-loader` never sees it apply PostCSS,
187
+ autoprefixer, or a minifier here instead:
188
+
189
+ ```js
190
+ new StylexPlugin({
191
+ transformCss: async (css, filePath) => {
192
+ const postcss = require('postcss');
193
+ const result = await postcss([require('autoprefixer')]).process(css, {
194
+ from: filePath,
195
+ });
196
+ return result.css;
197
+ },
198
+ });
199
+ ```
172
200
 
173
201
  #### `cacheGroup`
174
202
 
175
203
  - Type: `CacheGroupOptions` (webpack cache group configuration)
176
204
  - Optional
177
- - Description: Allows overriding the default webpack cache group parameters for StyleX CSS extraction.
178
- By default, the plugin creates a dedicated cache group named `stylex` for extracted StyleX CSS.
179
- Use this option to customize cache group behavior such as chunk naming, priority, or other split chunks options.
205
+ - Description: Overrides the default webpack cache group used for StyleX CSS
206
+ extraction. By default the plugin creates a dedicated cache group named
207
+ `stylex`. Use this to customize chunk naming, priority, or other split chunks
208
+ options.
209
+
210
+ Default cache group configuration:
180
211
 
181
- **Default cache group configuration:**
182
- ```javascript
212
+ ```js
183
213
  {
184
214
  name: 'stylex',
185
215
  test: /\.stylex\.virtual\.css$/,
@@ -189,8 +219,9 @@ new StylexPlugin({
189
219
  }
190
220
  ```
191
221
 
192
- **Example - Custom cache group:**
193
- ```javascript
222
+ Custom cache group:
223
+
224
+ ```js
194
225
  new StylexPlugin({
195
226
  cacheGroup: {
196
227
  name: 'my-stylex-bundle',
@@ -198,12 +229,12 @@ new StylexPlugin({
198
229
  priority: 20,
199
230
  enforce: true,
200
231
  },
201
- })
232
+ });
202
233
  ```
203
234
 
204
235
  ### Example Configuration
205
236
 
206
- ```javascript
237
+ ```js
207
238
  const StylexPlugin = require('@stylexswc/webpack-plugin');
208
239
 
209
240
  module.exports = {
@@ -211,95 +242,110 @@ module.exports = {
211
242
  new StylexPlugin({
212
243
  rsOptions: {
213
244
  dev: process.env.NODE_ENV !== 'production',
214
- // Include only specific directories
215
245
  include: ['src/**/*.{ts,tsx}', 'components/**/*.{ts,tsx}'],
216
- // Exclude test files and stories
217
246
  exclude: ['**/*.test.*', '**/*.stories.*', '**/__tests__/**'],
218
247
  },
219
248
  stylexImports: ['@stylexjs/stylex', { from: './theme', as: 'tokens' }],
220
249
  useCSSLayers: true,
221
- nextjsMode: false,
222
- loaderOrder: 'first', // Process before other loaders (default)
250
+ loaderOrder: 'first',
223
251
  transformCss: async css => {
224
252
  const postcss = require('postcss');
225
253
  const result = await postcss([require('autoprefixer')]).process(css);
226
254
  return result.css;
227
255
  },
228
- // Optional: Override cache group settings
229
- cacheGroup: {
230
- name: 'stylex',
231
- priority: 30,
232
- },
233
256
  }),
234
257
  ],
235
258
  };
236
259
  ```
237
260
 
238
- #### Path Filtering Examples
261
+ ### Path Filtering Examples
239
262
 
240
- **Include only specific directories:**
263
+ Include only specific directories:
241
264
 
242
- ```javascript
265
+ ```js
243
266
  new StylexPlugin({
244
267
  rsOptions: {
245
268
  include: ['src/**/*.tsx', 'app/**/*.tsx'],
246
269
  },
247
- })
270
+ });
248
271
  ```
249
272
 
250
- **Exclude test and build files:**
273
+ Exclude test and build files:
251
274
 
252
- ```javascript
275
+ ```js
253
276
  new StylexPlugin({
254
277
  rsOptions: {
255
- exclude: ['**/*.test.*', '**/*.spec.*', '**/dist/**', '**/node_modules/**'],
278
+ exclude: ['**/*.test.*', '**/*.spec.*', '**/dist/**'],
256
279
  },
257
- })
280
+ });
258
281
  ```
259
282
 
260
- **Using regular expressions:**
283
+ Using regular expressions:
261
284
 
262
- ```javascript
285
+ ```js
263
286
  new StylexPlugin({
264
287
  rsOptions: {
265
288
  include: [/src\/.*\.tsx$/],
266
289
  exclude: [/\.test\./, /\.stories\./],
267
290
  },
268
- })
291
+ });
269
292
  ```
270
293
 
271
- **Combined include and exclude (exclude takes precedence):**
294
+ Transform only specific packages from `node_modules` — note that `node_modules`
295
+ is excluded regardless of `rsOptions.include`/`exclude`, so allowlist packages
296
+ with `stylexPackages` instead:
272
297
 
273
- ```javascript
298
+ ```js
274
299
  new StylexPlugin({
275
300
  rsOptions: {
276
301
  include: ['src/**/*.{ts,tsx}'],
277
- exclude: ['**/__tests__/**', '**/__mocks__/**'],
302
+ exclude: ['**/*.test.*'],
278
303
  },
279
- })
304
+ stylexPackages: ['@stylexjs/open-props', '@my-org/design-system'],
305
+ });
280
306
  ```
281
307
 
282
- **Transform only specific packages from node_modules:**
308
+ ## FAQ
283
309
 
284
- `node_modules` is excluded by default regardless of `rsOptions.include`/
285
- `exclude` — allowlist packages with `stylexPackages` instead:
310
+ ### Do I still need `@stylexjs/babel-plugin`?
286
311
 
287
- ```javascript
288
- new StylexPlugin({
289
- rsOptions: {
290
- include: ['src/**/*.{ts,tsx}'],
291
- exclude: ['**/*.test.*'],
292
- },
293
- stylexPackages: ['@stylexjs/open-props', '@my-org/design-system'],
294
- })
295
- ```
312
+ No. This plugin replaces the Babel plugin in your build. You only keep
313
+ `@stylexjs/stylex` as your app's runtime dependency, and your `stylex.create` /
314
+ `stylex.props` code does not change.
315
+
316
+ ### My styles from a component library are missing. Why?
317
+
318
+ `node_modules` is excluded by default. Add the package to `stylexPackages` (for
319
+ example `stylexPackages: ['@stylexjs/', 'my-design-system']`) so the StyleX
320
+ loader processes it.
321
+
322
+ ### Imports from my `.stylex.ts` token files disappear after the build
323
+
324
+ That is tree-shaking removing imports that look unused after the transform. Keep
325
+ the default `loaderOrder: 'first'`, which injects side-effect imports to protect
326
+ them.
327
+
328
+ ### Can I run PostCSS on the generated CSS?
329
+
330
+ Yes — through the `transformCss` option. The StyleX CSS is produced after the
331
+ regular loader pipeline, so `postcss-loader` alone will not see it.
332
+
333
+ ### Is this an official StyleX package?
334
+
335
+ No. It is a community-maintained alternative to the official tooling and is not
336
+ affiliated with or supported by Meta.
296
337
 
297
338
  ## Documentation
298
339
 
299
- - [StyleX Documentation](https://stylexjs.com)
300
- - [NAPI-RS compiler for StyleX](https://github.com/Dwlad90/stylex-swc-plugin/tree/develop/crates/stylex-rs-compiler)
340
+ - [StyleX documentation](https://stylexjs.com)
341
+ - [`@stylexswc/rs-compiler` compiler options](https://github.com/Dwlad90/stylex-swc-plugin/tree/develop/crates/stylex-rs-compiler)
301
342
 
302
343
  ## Acknowledgments
303
344
 
304
345
  This plugin was inspired by
305
346
  [`stylex-webpack`](https://github.com/SukkaW/stylex-webpack).
347
+
348
+ ## License
349
+
350
+ MIT — see
351
+ [LICENSE](https://github.com/Dwlad90/stylex-swc-plugin/blob/develop/LICENSE)
@@ -1 +1 @@
1
- {"version":3,"file":"stylex-loader.d.ts","sourceRoot":"","sources":["../src/stylex-loader.ts"],"names":[],"mappings":"AACA,OAAoB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAGpE,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAI7C,wBAA8B,YAAY,CACxC,IAAI,EAAE,aAAa,CAAC,uBAAuB,GAAG,0BAA0B,CAAC,EACzE,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,SAAS,iBA0G1B"}
1
+ {"version":3,"file":"stylex-loader.d.ts","sourceRoot":"","sources":["../src/stylex-loader.ts"],"names":[],"mappings":"AACA,OAAoB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAGpE,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAI7C,wBAA8B,YAAY,CACxC,IAAI,EAAE,aAAa,CAAC,uBAAuB,GAAG,0BAA0B,CAAC,EACzE,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,SAAS,iBA2G1B"}
@@ -30,7 +30,7 @@ async function stylexLoader(inputCode, inputSourceMap) {
30
30
  return callback(new Error('stylex-loader: loader context is not SupplementedLoaderContext!'));
31
31
  }
32
32
  try {
33
- const { code, map, metadata } = (0, utils_1.generateStyleXOutput)(this.resourcePath, stringifiedInputCode, rsOptions);
33
+ const { code, map, metadata } = (0, utils_1.generateStyleXOutput)(this.resourcePath, stringifiedInputCode, rsOptions, inputSourceMap);
34
34
  let parsedMap = undefined;
35
35
  if (map) {
36
36
  try {
package/dist/utils.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type webpack from 'webpack';
2
- import type { SupplementedLoaderContext } from './types';
2
+ import type { SourceMap, SupplementedLoaderContext } from './types';
3
3
  import type { StyleXOptions, StyleXTransformResult } from '@stylexswc/rs-compiler';
4
4
  export declare function stringifyRequest(loaderContext: webpack.LoaderContext<unknown>, request: string): string;
5
5
  export declare const isSupplementedLoaderContext: <T>(context: webpack.LoaderContext<T>) => context is SupplementedLoaderContext<T>;
6
- export declare function generateStyleXOutput(resourcePath: string, inputSource: string, rsOptions: Partial<StyleXOptions>): StyleXTransformResult;
6
+ export declare function generateStyleXOutput(resourcePath: string, inputSource: string, rsOptions: Partial<StyleXOptions>, inputSourceMap?: SourceMap): StyleXTransformResult;
7
7
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEnF,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,UAI9F;AAED,eAAO,MAAM,2BAA2B,GAAI,CAAC,EAC3C,SAAS,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,KAChC,OAAO,IAAI,yBAAyB,CAAC,CAAC,CAExC,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,OAAO,CAAC,aAAa,CAAC,GAChC,qBAAqB,CAEvB"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,EAAE,SAAS,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAEnF,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,UAI9F;AAED,eAAO,MAAM,2BAA2B,GAAI,CAAC,EAC3C,SAAS,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,KAChC,OAAO,IAAI,yBAAyB,CAAC,CAAC,CAExC,CAAC;AAEF,wBAAgB,oBAAoB,CAClC,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,OAAO,CAAC,aAAa,CAAC,EACjC,cAAc,CAAC,EAAE,SAAS,GACzB,qBAAqB,CAYvB"}
package/dist/utils.js CHANGED
@@ -11,6 +11,14 @@ const isSupplementedLoaderContext = (context) => {
11
11
  return Object.prototype.hasOwnProperty.call(context, 'StyleXWebpackContextKey');
12
12
  };
13
13
  exports.isSupplementedLoaderContext = isSupplementedLoaderContext;
14
- function generateStyleXOutput(resourcePath, inputSource, rsOptions) {
15
- return (0, rs_compiler_1.transform)(resourcePath, inputSource, (0, rs_compiler_1.normalizeRsOptions)(rsOptions ?? {}));
14
+ function generateStyleXOutput(resourcePath, inputSource, rsOptions, inputSourceMap) {
15
+ const options = (0, rs_compiler_1.normalizeRsOptions)(rsOptions ?? {});
16
+ // Forward the previous loader's source map so debug source-map annotations
17
+ // and the emitted map resolve to the original authored file instead of the
18
+ // (possibly already transformed) loader input.
19
+ if (inputSourceMap != null && options.inputSourceMap === undefined) {
20
+ options.inputSourceMap =
21
+ typeof inputSourceMap === 'string' ? inputSourceMap : JSON.stringify(inputSourceMap);
22
+ }
23
+ return (0, rs_compiler_1.transform)(resourcePath, inputSource, options);
16
24
  }
package/package.json CHANGED
@@ -1,26 +1,10 @@
1
1
  {
2
2
  "name": "@stylexswc/webpack-plugin",
3
- "description": "StyleX webpack plugin with NAPI-RS compiler",
4
- "version": "0.17.0",
5
- "config": {
6
- "scripty": {
7
- "path": "../../scripts/packages"
8
- }
9
- },
10
- "dependencies": {
11
- "@stylexjs/babel-plugin": "^0.19.0",
12
- "@stylexswc/rs-compiler": "0.17.0",
13
- "loader-utils": "^3.3.1"
14
- },
15
- "devDependencies": {
16
- "@stylexswc/eslint-config": "0.17.0",
17
- "@stylexswc/typescript-config": "0.17.0",
18
- "@types/loader-utils": "^3.0.0",
19
- "@types/node": "^26.1.0",
20
- "mini-css-extract-plugin": "^2.10.2",
21
- "vitest": "^4.1.9",
22
- "webpack": "^5.108.3"
23
- },
3
+ "description": "StyleX plugin for webpack powered by a Rust NAPI-RS/SWC compiler. Fast StyleX transforms and CSS extraction without Babel.",
4
+ "version": "0.17.1-rc.1",
5
+ "private": false,
6
+ "license": "MIT",
7
+ "sideEffects": false,
24
8
  "exports": {
25
9
  ".": {
26
10
  "types": "./dist/index.d.ts",
@@ -37,21 +21,49 @@
37
21
  "files": [
38
22
  "dist"
39
23
  ],
24
+ "publishConfig": {
25
+ "registry": "https://registry.npmjs.org/",
26
+ "access": "public"
27
+ },
28
+ "config": {
29
+ "scripty": {
30
+ "path": "../../scripts/packages"
31
+ }
32
+ },
33
+ "dependencies": {
34
+ "@stylexjs/babel-plugin": "^0.19.0",
35
+ "@stylexswc/rs-compiler": "0.17.1-rc.1",
36
+ "loader-utils": "^3.3.1"
37
+ },
38
+ "devDependencies": {
39
+ "@stylexswc/eslint-config": "0.17.1-rc.1",
40
+ "@stylexswc/typescript-config": "0.17.1-rc.1",
41
+ "@types/loader-utils": "^3.0.0",
42
+ "@types/node": "^26.1.0",
43
+ "mini-css-extract-plugin": "^2.10.2",
44
+ "vitest": "^4.1.9",
45
+ "webpack": "^5.108.3"
46
+ },
47
+ "bugs": "https://github.com/Dwlad90/stylex-swc-plugin/issues",
48
+ "homepage": "https://github.com/Dwlad90/stylex-swc-plugin/tree/develop/packages/webpack-plugin#readme",
40
49
  "keywords": [
50
+ "atomic-css",
51
+ "css-extraction",
52
+ "css-in-js",
53
+ "napi-rs",
54
+ "react",
55
+ "rust",
41
56
  "stylex",
42
57
  "swc",
43
58
  "webpack",
44
59
  "webpack-plugin"
45
60
  ],
46
- "license": "MIT",
47
61
  "main": "dist/index.js",
48
- "private": false,
49
- "publishConfig": {
50
- "registry": "https://registry.npmjs.org/",
51
- "access": "public"
62
+ "repository": {
63
+ "type": "git",
64
+ "url": "git+https://github.com/Dwlad90/stylex-swc-plugin.git",
65
+ "directory": "packages/webpack-plugin"
52
66
  },
53
- "repository": "https://github.com/Dwlad90/stylex-swc-plugin",
54
- "sideEffects": false,
55
67
  "scripts": {
56
68
  "build": "scripty --ts",
57
69
  "check:artifacts": "scripty",