@stylexswc/webpack-plugin 0.17.0-rc.4 → 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 +150 -104
- package/dist/stylex-loader.d.ts.map +1 -1
- package/dist/stylex-loader.js +1 -1
- package/dist/utils.d.ts +2 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +10 -2
- package/package.json +40 -28
package/README.md
CHANGED
|
@@ -1,28 +1,42 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
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
|
|
34
|
+
npm install @stylexjs/stylex
|
|
21
35
|
```
|
|
22
36
|
|
|
23
37
|
## Usage
|
|
24
38
|
|
|
25
|
-
|
|
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
|
-
|
|
42
|
-
|
|
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
|
|
70
|
-
|
|
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
|
-
>
|
|
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:
|
|
80
|
-
When specified, only files matching at least one
|
|
81
|
-
Patterns are matched against paths relative to the current
|
|
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:
|
|
88
|
-
|
|
89
|
-
Patterns are matched against paths relative to the
|
|
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
|
|
96
|
-
|
|
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:
|
|
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
|
|
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:
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
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';
|
|
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
|
|
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
|
|
153
|
-
reference a StyleX import. Packages that ship untransformed
|
|
154
|
-
(
|
|
155
|
-
|
|
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
|
-
```
|
|
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
|
|
171
|
-
|
|
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:
|
|
178
|
-
By default
|
|
179
|
-
Use this
|
|
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
|
-
|
|
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
|
-
|
|
193
|
-
|
|
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
|
-
```
|
|
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
|
-
|
|
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
|
-
|
|
261
|
+
### Path Filtering Examples
|
|
239
262
|
|
|
240
|
-
|
|
263
|
+
Include only specific directories:
|
|
241
264
|
|
|
242
|
-
```
|
|
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
|
-
|
|
273
|
+
Exclude test and build files:
|
|
251
274
|
|
|
252
|
-
```
|
|
275
|
+
```js
|
|
253
276
|
new StylexPlugin({
|
|
254
277
|
rsOptions: {
|
|
255
|
-
exclude: ['**/*.test.*', '**/*.spec.*', '**/dist/**'
|
|
278
|
+
exclude: ['**/*.test.*', '**/*.spec.*', '**/dist/**'],
|
|
256
279
|
},
|
|
257
|
-
})
|
|
280
|
+
});
|
|
258
281
|
```
|
|
259
282
|
|
|
260
|
-
|
|
283
|
+
Using regular expressions:
|
|
261
284
|
|
|
262
|
-
```
|
|
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
|
-
|
|
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
|
-
```
|
|
298
|
+
```js
|
|
274
299
|
new StylexPlugin({
|
|
275
300
|
rsOptions: {
|
|
276
301
|
include: ['src/**/*.{ts,tsx}'],
|
|
277
|
-
exclude: ['
|
|
302
|
+
exclude: ['**/*.test.*'],
|
|
278
303
|
},
|
|
279
|
-
|
|
304
|
+
stylexPackages: ['@stylexjs/open-props', '@my-org/design-system'],
|
|
305
|
+
});
|
|
280
306
|
```
|
|
281
307
|
|
|
282
|
-
|
|
308
|
+
## FAQ
|
|
283
309
|
|
|
284
|
-
|
|
285
|
-
`exclude` — allowlist packages with `stylexPackages` instead:
|
|
310
|
+
### Do I still need `@stylexjs/babel-plugin`?
|
|
286
311
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
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
|
|
300
|
-
- [
|
|
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,
|
|
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"}
|
package/dist/stylex-loader.js
CHANGED
|
@@ -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
|
|
6
|
+
export declare function generateStyleXOutput(resourcePath: string, inputSource: string, rsOptions: Partial<StyleXOptions>, inputSourceMap?: SourceMap): StyleXTransformResult;
|
|
7
7
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -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;
|
|
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
|
-
|
|
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
|
|
4
|
-
"version": "0.17.
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
},
|
|
10
|
-
"dependencies": {
|
|
11
|
-
"@stylexjs/babel-plugin": "^0.19.0",
|
|
12
|
-
"@stylexswc/rs-compiler": "0.17.0-rc.4",
|
|
13
|
-
"loader-utils": "^3.3.1"
|
|
14
|
-
},
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"@stylexswc/eslint-config": "0.17.0-rc.4",
|
|
17
|
-
"@stylexswc/typescript-config": "0.17.0-rc.4",
|
|
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
|
-
"
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
"
|
|
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",
|