@stylexswc/webpack-plugin 0.5.1 → 0.6.0-rc.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 CHANGED
@@ -57,40 +57,47 @@ module.exports = config;
57
57
 
58
58
  #### `rsOptions`
59
59
 
60
- * Type: `Partial<StyleXOptions>`
61
- * Optional
62
- * Description: StyleX compiler options that will be passed to the NAPI-RS
60
+ - Type: `Partial<StyleXOptions>`
61
+ - Optional
62
+ - Description: StyleX compiler options that will be passed to the NAPI-RS
63
63
  compiler. See
64
64
  [StyleX configuration docs](https://stylexjs.com/docs/api/configuration/babel-plugin/)
65
65
  for details.
66
66
 
67
67
  #### `stylexImports`
68
68
 
69
- * Type: `Array<string | { as: string, from: string }>`
70
- * Default: `['stylex', '@stylexjs/stylex']`
71
- * Description: Specifies where StyleX will be imported from. Supports both
69
+ - Type: `Array<string | { as: string, from: string }>`
70
+ - Default: `['stylex', '@stylexjs/stylex']`
71
+ - Description: Specifies where StyleX will be imported from. Supports both
72
72
  string paths and import aliases.
73
73
 
74
74
  #### `useCSSLayers`
75
75
 
76
- * Type: `boolean`
77
- * Default: `false`
78
- * Description: Enables CSS cascade layers support for better style isolation.
76
+ - Type: `boolean`
77
+ - Default: `false`
78
+ - Description: Enables CSS cascade layers support for better style isolation.
79
79
 
80
80
  #### `nextjsMode`
81
81
 
82
- * Type: `boolean`
83
- * Default: `false`
84
- * Description: Enables Next.js-specific optimizations and compatibility
82
+ - Type: `boolean`
83
+ - Default: `false`
84
+ - Description: Enables Next.js-specific optimizations and compatibility
85
85
  features.
86
86
 
87
+ #### `extractCSS`
88
+
89
+ - Type: `boolean`
90
+ - Optional
91
+ - Default: `true`
92
+ - Description: Controls whether CSS should be extracted into a separate file
93
+
87
94
  ### Advanced Options
88
95
 
89
96
  #### `transformCss`
90
97
 
91
- * Type: `(css: string) => string | Buffer | Promise<string | Buffer>`
92
- * Optional
93
- * Description: Custom CSS transformation function. Since the plugin injects CSS
98
+ - Type: `(css: string) => string | Buffer | Promise<string | Buffer>`
99
+ - Optional
100
+ - Description: Custom CSS transformation function. Since the plugin injects CSS
94
101
  after all loaders, use this to apply PostCSS or other CSS transformations.
95
102
 
96
103
  ### Example Configuration
@@ -120,8 +127,8 @@ module.exports = {
120
127
 
121
128
  ## Documentation
122
129
 
123
- * [StyleX Documentation](https://stylexjs.com)
124
- * [NAPI-RS compiler for StyleX](https://github.com/Dwlad90/stylex-swc-plugin/tree/develop/crates/stylex-rs-compiler)
130
+ - [StyleX Documentation](https://stylexjs.com)
131
+ - [NAPI-RS compiler for StyleX](https://github.com/Dwlad90/stylex-swc-plugin/tree/develop/crates/stylex-rs-compiler)
125
132
 
126
133
  ## Acknowledgments
127
134
 
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ export default class StyleXPlugin {
8
8
  useCSSLayers: boolean;
9
9
  loaderOption: StyleXWebpackLoaderOptions;
10
10
  transformCss: CSSTransformer;
11
- constructor({ stylexImports, useCSSLayers, rsOptions, nextjsMode, transformCss, transformer, }?: StyleXPluginOption);
11
+ constructor({ stylexImports, useCSSLayers, rsOptions, nextjsMode, transformCss, transformer, extractCSS, }?: StyleXPluginOption);
12
12
  apply(compiler: webpack.Compiler): void;
13
13
  }
14
14
  export { VIRTUAL_CSS_PATTERN };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAML,mBAAmB,EACpB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,EAAE,IAAI,IAAI,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EAClB,0BAA0B,EAE3B,MAAM,SAAS,CAAC;AAkBjB,MAAM,MAAM,mBAAmB,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,K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AAE,kBAAkB,EAAE,MAAM,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -24,7 +24,7 @@ class StyleXPlugin {
24
24
  useCSSLayers;
25
25
  loaderOption;
26
26
  transformCss;
27
- constructor({ stylexImports = ['stylex', '@stylexjs/stylex'], useCSSLayers = false, rsOptions = {}, nextjsMode = false, transformCss = identityTransfrom, transformer = 'rs-compiler', } = {}) {
27
+ constructor({ stylexImports = ['stylex', '@stylexjs/stylex'], useCSSLayers = false, rsOptions = {}, nextjsMode = false, transformCss = identityTransfrom, transformer = 'rs-compiler', extractCSS = true, } = {}) {
28
28
  this.useCSSLayers = useCSSLayers;
29
29
  this.loaderOption = {
30
30
  stylexImports,
@@ -39,6 +39,7 @@ class StyleXPlugin {
39
39
  },
40
40
  nextjsMode,
41
41
  transformer,
42
+ extractCSS,
42
43
  };
43
44
  this.transformCss = transformCss;
44
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"stylex-loader.d.ts","sourceRoot":"","sources":["../src/stylex-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,0BAA0B,EAC1B,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAEjB,wBAA8B,YAAY,CACxC,IAAI,EAAE,yBAAyB,CAAC,0BAA0B,CAAC,EAC3D,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,SAAS,iBA8F1B"}
1
+ {"version":3,"file":"stylex-loader.d.ts","sourceRoot":"","sources":["../src/stylex-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,SAAS,EACT,SAAS,EACT,0BAA0B,EAC1B,yBAAyB,EAC1B,MAAM,SAAS,CAAC;AAEjB,wBAA8B,YAAY,CACxC,IAAI,EAAE,yBAAyB,CAAC,0BAA0B,CAAC,EAC3D,SAAS,EAAE,SAAS,EACpB,cAAc,EAAE,SAAS,iBAqG1B"}
@@ -9,7 +9,7 @@ const loader_utils_1 = __importDefault(require("loader-utils"));
9
9
  const utils_1 = require("./utils");
10
10
  async function stylexLoader(inputCode, inputSourceMap) {
11
11
  const callback = this.async();
12
- const { stylexImports, rsOptions, nextjsMode, transformer } = this.getOptions();
12
+ const { stylexImports, rsOptions, nextjsMode, transformer, extractCSS = true, } = this.getOptions();
13
13
  const logger = this._compiler?.getInfrastructureLogger(constants_1.PLUGIN_NAME);
14
14
  if (!inputCode) {
15
15
  if (!this.resourcePath.includes('empty')) {
@@ -31,11 +31,12 @@ async function stylexLoader(inputCode, inputSourceMap) {
31
31
  try {
32
32
  const { code, map, metadata } = (0, utils_1.generateStyleXOutput)(this.resourcePath, stringifiedInputCode, rsOptions, transformer);
33
33
  // If metadata.stylex doesn't exist at all, we only need to return the transformed code
34
- if (!metadata ||
34
+ if (!extractCSS ||
35
+ !metadata ||
35
36
  !('stylex' in metadata) ||
36
37
  metadata.stylex == null ||
37
38
  !metadata.stylex.length) {
38
- logger?.debug(`No stylex styles generated from ${this.resourcePath}`);
39
+ extractCSS && logger?.debug(`No stylex styles generated from ${this.resourcePath}`);
39
40
  return callback(null, code ?? undefined, map ?? undefined);
40
41
  }
41
42
  logger?.debug(`Read stylex styles from ${this.resourcePath}:`, metadata.stylex);
package/dist/types.d.ts CHANGED
@@ -38,6 +38,12 @@ export interface StyleXPluginOption extends Pick<StyleXWebpackLoaderOptions, 'tr
38
38
  * With this you can incovate `postcss()` here.
39
39
  */
40
40
  transformCss?: CSSTransformer;
41
+ /**
42
+ * Whether to extract CSS
43
+ *
44
+ * @default true
45
+ */
46
+ extractCSS?: boolean;
41
47
  }
42
48
  export type StyleXWebpackLoaderOptions = {
43
49
  stylexImports: StyleXOptions['importSources'];
@@ -49,6 +55,7 @@ export type StyleXWebpackLoaderOptions = {
49
55
  * @default 'rs-compiler'
50
56
  */
51
57
  transformer?: 'rs-compiler' | 'swc';
58
+ extractCSS?: boolean;
52
59
  };
53
60
  export type SupplementedLoaderContext<Options = unknown> = webpack.LoaderContext<Options> & {
54
61
  StyleXWebpackContextKey: {
@@ -1 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,CAAC,eAAe,CAAC,CAAC;IAC/C;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,cAAc,CAAC;IAE9B;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AACD,MAAM,MAAM,0BAA0B,GAAG;IACvC,aAAa,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAC9C,SAAS,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IAClC,UAAU,EAAE,OAAO,CAAC;IAEpB;;;;OAIG;IACH,WAAW,CAAC,EAAE,aAAa,GAAG,KAAK,CAAC;IACpC,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,CAAC;AAEF,MAAM,MAAM,yBAAyB,CAAC,OAAO,GAAG,OAAO,IAAI,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG;IAC1F,uBAAuB,EAAE;QACvB,mBAAmB,EAAE,mBAAmB,CAAC;KAC1C,CAAC;CACH,CAAC;AAGF,MAAM,MAAM,aAAa,GAAG;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,IAAI,GAAG,MAAM,CAAA;KAAE,CAAC;IAC5C,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stylexswc/webpack-plugin",
3
- "description": "Stylex webpack plugin with NAPI-RS compiler",
4
- "version": "0.5.1",
3
+ "description": "StyleX webpack plugin with NAPI-RS compiler",
4
+ "version": "0.6.0-rc.2",
5
5
  "config": {
6
6
  "scripty": {
7
7
  "path": "../../scripts/packages"
@@ -13,9 +13,9 @@
13
13
  },
14
14
  "devDependencies": {
15
15
  "@babel/types": "^7.23.9",
16
- "@stylexswc/eslint-config": "0.5.1",
17
- "@stylexswc/rs-compiler": "0.5.1",
18
- "@stylexswc/typescript-config": "0.5.1",
16
+ "@stylexswc/eslint-config": "0.6.0-rc.2",
17
+ "@stylexswc/rs-compiler": "0.6.0-rc.2",
18
+ "@stylexswc/typescript-config": "0.6.0-rc.2",
19
19
  "@types/babel__core": "^7.20.5",
20
20
  "@types/loader-utils": "^2.0.6",
21
21
  "@types/node": "^22.5.1",
@@ -27,6 +27,7 @@
27
27
  ],
28
28
  "keywords": [
29
29
  "stylex",
30
+ "swc",
30
31
  "webpack",
31
32
  "webpack-plugin"
32
33
  ],