unplugin-stylex 0.3.1 → 0.4.0

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
@@ -59,6 +59,24 @@ export default {
59
59
 
60
60
  </br></details>
61
61
 
62
+ <details>
63
+ <summary>farm</summary><br>
64
+
65
+ ```js
66
+ // farm.config.js
67
+ import { defineConfig } from '@farmfe/core'
68
+ import stylexPlugin from 'unplugin-stylex/farm'
69
+
70
+ export default defineConfig({
71
+ // other rollup config
72
+ plugins: [
73
+ stylexPlugin({ /* options */}),
74
+ ],
75
+ })
76
+ ```
77
+
78
+ </br></details>
79
+
62
80
  <details>
63
81
  <summary>rspack</summary><br>
64
82
 
@@ -6,8 +6,7 @@ import { createUnplugin } from "unplugin";
6
6
  import stylex from "@stylexjs/babel-plugin";
7
7
  function buildStylexRules(stylexRules, useCSSLayers) {
8
8
  const rules = Object.values(stylexRules).flat();
9
- if (rules.length === 0)
10
- return "";
9
+ if (rules.length === 0) return "";
11
10
  return stylex.processStylexRules(rules, useCSSLayers);
12
11
  }
13
12
 
@@ -21,7 +20,8 @@ function getOptions(options) {
21
20
  const isDev = options.dev || isDevelopment;
22
21
  return {
23
22
  ...options,
24
- dev: options.dev || isDev,
23
+ dev: isDev,
24
+ invalidExts: [".json", ".html", ".jade", ".json5", ...options.invalidExts ?? []],
25
25
  stylex: {
26
26
  filename: stylex2.filename || "stylex.css",
27
27
  stylexImports: stylex2.stylexImports || ["@stylexjs/stylex"],
@@ -84,7 +84,12 @@ async function transformer(context) {
84
84
  stylexRules[id] = metadata.stylex;
85
85
  }
86
86
  if (!((_d = stylex2.babelConfig) == null ? void 0 : _d.babelrc)) {
87
- return { code, map, stylexRules };
87
+ return {
88
+ code,
89
+ // compatible for farm, null will occur an error
90
+ map: map || void 0,
91
+ stylexRules
92
+ };
88
93
  }
89
94
  return { code, stylexRules };
90
95
  }
@@ -97,7 +102,7 @@ var unpluginFactory = (rawOptions = {}) => {
97
102
  return {
98
103
  name: PLUGIN_NAME,
99
104
  transformInclude(id) {
100
- const invalidExts = [".json", ".html", ".jade", ".json5"];
105
+ const invalidExts = options.invalidExts;
101
106
  const extname2 = path.extname(id);
102
107
  const questionMarkIndex = extname2.indexOf("?");
103
108
  const validExtName = questionMarkIndex > -1 ? extname2.slice(0, questionMarkIndex) : extname2;
@@ -130,8 +135,7 @@ var unpluginFactory = (rawOptions = {}) => {
130
135
  buildEnd() {
131
136
  const fileName = options.stylex.filename;
132
137
  const collectedCSS = buildStylexRules(stylexRules, options.stylex.useCSSLayers);
133
- if (!collectedCSS)
134
- return;
138
+ if (!collectedCSS) return;
135
139
  this.emitFile({
136
140
  fileName,
137
141
  source: collectedCSS,
@@ -153,8 +157,7 @@ var unpluginFactory = (rawOptions = {}) => {
153
157
  var _a;
154
158
  const fileName = `${((_a = viteConfig.build) == null ? void 0 : _a.assetsDir) ?? "assets"}/${options.stylex.filename}`;
155
159
  const collectedCSS = buildStylexRules(stylexRules, options.stylex.useCSSLayers);
156
- if (!collectedCSS)
157
- return;
160
+ if (!collectedCSS) return;
158
161
  this.emitFile({
159
162
  fileName,
160
163
  source: collectedCSS,
@@ -6,8 +6,7 @@ var _unplugin = require('unplugin');
6
6
  var _babelplugin = require('@stylexjs/babel-plugin'); var _babelplugin2 = _interopRequireDefault(_babelplugin);
7
7
  function buildStylexRules(stylexRules, useCSSLayers) {
8
8
  const rules = Object.values(stylexRules).flat();
9
- if (rules.length === 0)
10
- return "";
9
+ if (rules.length === 0) return "";
11
10
  return _babelplugin2.default.processStylexRules(rules, useCSSLayers);
12
11
  }
13
12
 
@@ -21,7 +20,8 @@ function getOptions(options) {
21
20
  const isDev = options.dev || isDevelopment;
22
21
  return {
23
22
  ...options,
24
- dev: options.dev || isDev,
23
+ dev: isDev,
24
+ invalidExts: [".json", ".html", ".jade", ".json5", ..._nullishCoalesce(options.invalidExts, () => ( []))],
25
25
  stylex: {
26
26
  filename: stylex2.filename || "stylex.css",
27
27
  stylexImports: stylex2.stylexImports || ["@stylexjs/stylex"],
@@ -84,7 +84,12 @@ async function transformer(context) {
84
84
  stylexRules[id] = metadata.stylex;
85
85
  }
86
86
  if (!((_d = stylex2.babelConfig) == null ? void 0 : _d.babelrc)) {
87
- return { code, map, stylexRules };
87
+ return {
88
+ code,
89
+ // compatible for farm, null will occur an error
90
+ map: map || void 0,
91
+ stylexRules
92
+ };
88
93
  }
89
94
  return { code, stylexRules };
90
95
  }
@@ -97,7 +102,7 @@ var unpluginFactory = (rawOptions = {}) => {
97
102
  return {
98
103
  name: PLUGIN_NAME,
99
104
  transformInclude(id) {
100
- const invalidExts = [".json", ".html", ".jade", ".json5"];
105
+ const invalidExts = options.invalidExts;
101
106
  const extname2 = path.extname(id);
102
107
  const questionMarkIndex = extname2.indexOf("?");
103
108
  const validExtName = questionMarkIndex > -1 ? extname2.slice(0, questionMarkIndex) : extname2;
@@ -130,8 +135,7 @@ var unpluginFactory = (rawOptions = {}) => {
130
135
  buildEnd() {
131
136
  const fileName = options.stylex.filename;
132
137
  const collectedCSS = buildStylexRules(stylexRules, options.stylex.useCSSLayers);
133
- if (!collectedCSS)
134
- return;
138
+ if (!collectedCSS) return;
135
139
  this.emitFile({
136
140
  fileName,
137
141
  source: collectedCSS,
@@ -153,8 +157,7 @@ var unpluginFactory = (rawOptions = {}) => {
153
157
  var _a;
154
158
  const fileName = `${_nullishCoalesce(((_a = viteConfig.build) == null ? void 0 : _a.assetsDir), () => ( "assets"))}/${options.stylex.filename}`;
155
159
  const collectedCSS = buildStylexRules(stylexRules, options.stylex.useCSSLayers);
156
- if (!collectedCSS)
157
- return;
160
+ if (!collectedCSS) return;
158
161
  this.emitFile({
159
162
  fileName,
160
163
  source: collectedCSS,
package/dist/esbuild.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkTCTVGJ42cjs = require('./chunk-TCTVGJ42.cjs');
3
+ var _chunk6L2G6TUNcjs = require('./chunk-6L2G6TUN.cjs');
4
4
  require('./chunk-ZBPRDZS4.cjs');
5
5
 
6
6
  // src/esbuild.ts
7
7
  var _unplugin = require('unplugin');
8
- var esbuildPlugin = _unplugin.createEsbuildPlugin.call(void 0, _chunkTCTVGJ42cjs.unpluginFactory);
8
+ var esbuildPlugin = _unplugin.createEsbuildPlugin.call(void 0, _chunk6L2G6TUNcjs.unpluginFactory);
9
9
  var esbuild_default = esbuildPlugin;
10
10
 
11
11
 
package/dist/esbuild.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-MREBYPD2.js";
3
+ } from "./chunk-3YBPBWJO.js";
4
4
  import "./chunk-6F4PWJZI.js";
5
5
 
6
6
  // src/esbuild.ts
package/dist/farm.cjs ADDED
@@ -0,0 +1,12 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+ var _chunk6L2G6TUNcjs = require('./chunk-6L2G6TUN.cjs');
4
+ require('./chunk-ZBPRDZS4.cjs');
5
+
6
+ // src/farm.ts
7
+ var _unplugin = require('unplugin');
8
+ var farmPlugin = _unplugin.createFarmPlugin.call(void 0, _chunk6L2G6TUNcjs.unpluginFactory);
9
+ var farm_default = farmPlugin;
10
+
11
+
12
+ exports.default = farm_default;
@@ -0,0 +1,12 @@
1
+ import { JsPluginExtended } from 'unplugin';
2
+ import { UnpluginStylexInstance } from './types.cjs';
3
+
4
+ /**
5
+ * This entry file is for farm plugin.
6
+ *
7
+ * @module
8
+ */
9
+
10
+ declare const farmPlugin: UnpluginStylexInstance<JsPluginExtended | JsPluginExtended[]>;
11
+
12
+ export { farmPlugin as default };
package/dist/farm.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { JsPluginExtended } from 'unplugin';
2
+ import { UnpluginStylexInstance } from './types.js';
3
+
4
+ /**
5
+ * This entry file is for farm plugin.
6
+ *
7
+ * @module
8
+ */
9
+
10
+ declare const farmPlugin: UnpluginStylexInstance<JsPluginExtended | JsPluginExtended[]>;
11
+
12
+ export { farmPlugin as default };
package/dist/farm.js ADDED
@@ -0,0 +1,12 @@
1
+ import {
2
+ unpluginFactory
3
+ } from "./chunk-3YBPBWJO.js";
4
+ import "./chunk-6F4PWJZI.js";
5
+
6
+ // src/farm.ts
7
+ import { createFarmPlugin } from "unplugin";
8
+ var farmPlugin = createFarmPlugin(unpluginFactory);
9
+ var farm_default = farmPlugin;
10
+ export {
11
+ farm_default as default
12
+ };
package/dist/index.cjs CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
 
4
4
 
5
- var _chunkTCTVGJ42cjs = require('./chunk-TCTVGJ42.cjs');
5
+ var _chunk6L2G6TUNcjs = require('./chunk-6L2G6TUN.cjs');
6
6
  require('./chunk-ZBPRDZS4.cjs');
7
7
 
8
8
 
9
9
 
10
10
 
11
- exports.default = _chunkTCTVGJ42cjs.src_default; exports.unplugin = _chunkTCTVGJ42cjs.unplugin; exports.unpluginFactory = _chunkTCTVGJ42cjs.unpluginFactory;
11
+ exports.default = _chunk6L2G6TUNcjs.src_default; exports.unplugin = _chunk6L2G6TUNcjs.unplugin; exports.unpluginFactory = _chunk6L2G6TUNcjs.unpluginFactory;
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  src_default,
3
3
  unplugin,
4
4
  unpluginFactory
5
- } from "./chunk-MREBYPD2.js";
5
+ } from "./chunk-3YBPBWJO.js";
6
6
  import "./chunk-6F4PWJZI.js";
7
7
  export {
8
8
  src_default as default,
package/dist/rollup.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkTCTVGJ42cjs = require('./chunk-TCTVGJ42.cjs');
3
+ var _chunk6L2G6TUNcjs = require('./chunk-6L2G6TUN.cjs');
4
4
  require('./chunk-ZBPRDZS4.cjs');
5
5
 
6
6
  // src/rollup.ts
7
7
  var _unplugin = require('unplugin');
8
- var rollupPlugin = _unplugin.createRollupPlugin.call(void 0, _chunkTCTVGJ42cjs.unpluginFactory);
8
+ var rollupPlugin = _unplugin.createRollupPlugin.call(void 0, _chunk6L2G6TUNcjs.unpluginFactory);
9
9
  var rollup_default = rollupPlugin;
10
10
 
11
11
 
package/dist/rollup.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-MREBYPD2.js";
3
+ } from "./chunk-3YBPBWJO.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 _chunkTCTVGJ42cjs = require('./chunk-TCTVGJ42.cjs');
3
+ var _chunk6L2G6TUNcjs = require('./chunk-6L2G6TUN.cjs');
4
4
  require('./chunk-ZBPRDZS4.cjs');
5
5
 
6
6
  // src/rspack.ts
7
7
  var _unplugin = require('unplugin');
8
- var rspackPlugin = _unplugin.createRspackPlugin.call(void 0, _chunkTCTVGJ42cjs.unpluginFactory);
8
+ var rspackPlugin = _unplugin.createRspackPlugin.call(void 0, _chunk6L2G6TUNcjs.unpluginFactory);
9
9
  var rspack_default = rspackPlugin;
10
10
 
11
11
 
package/dist/rspack.d.cts CHANGED
@@ -2,7 +2,7 @@ import { RspackPluginInstance } from 'unplugin';
2
2
  import { UnpluginStylexInstance } from './types.cjs';
3
3
 
4
4
  /**
5
- * This entry file is for Rspac plugin.
5
+ * This entry file is for Rspack plugin.
6
6
  *
7
7
  * @module
8
8
  */
package/dist/rspack.d.ts CHANGED
@@ -2,7 +2,7 @@ import { RspackPluginInstance } from 'unplugin';
2
2
  import { UnpluginStylexInstance } from './types.js';
3
3
 
4
4
  /**
5
- * This entry file is for Rspac plugin.
5
+ * This entry file is for Rspack plugin.
6
6
  *
7
7
  * @module
8
8
  */
package/dist/rspack.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-MREBYPD2.js";
3
+ } from "./chunk-3YBPBWJO.js";
4
4
  import "./chunk-6F4PWJZI.js";
5
5
 
6
6
  // src/rspack.ts
package/dist/types.d.cts CHANGED
@@ -9,7 +9,7 @@ type StylexOptions = {
9
9
  stylexImports?: string[];
10
10
  classNamePrefix?: string;
11
11
  unstable_moduleResolution?: {
12
- type: 'commonjs' | 'haste';
12
+ type: 'commonJS' | 'haste';
13
13
  rootDir: string;
14
14
  };
15
15
  babelConfig?: BabelConfig;
@@ -19,9 +19,8 @@ type StylexOptions = {
19
19
  runtimeInjection?: boolean;
20
20
  };
21
21
  type UnpluginStylexOptions = {
22
- compiler?: string;
22
+ invalidExts?: string[];
23
23
  dev?: boolean;
24
- enforce?: 'post' | 'pre';
25
24
  stylex?: StylexOptions;
26
25
  };
27
26
  type UnpluginStylexInstance<T> = (options?: UnpluginStylexOptions) => T;
package/dist/types.d.ts CHANGED
@@ -9,7 +9,7 @@ type StylexOptions = {
9
9
  stylexImports?: string[];
10
10
  classNamePrefix?: string;
11
11
  unstable_moduleResolution?: {
12
- type: 'commonjs' | 'haste';
12
+ type: 'commonJS' | 'haste';
13
13
  rootDir: string;
14
14
  };
15
15
  babelConfig?: BabelConfig;
@@ -19,9 +19,8 @@ type StylexOptions = {
19
19
  runtimeInjection?: boolean;
20
20
  };
21
21
  type UnpluginStylexOptions = {
22
- compiler?: string;
22
+ invalidExts?: string[];
23
23
  dev?: boolean;
24
- enforce?: 'post' | 'pre';
25
24
  stylex?: StylexOptions;
26
25
  };
27
26
  type UnpluginStylexInstance<T> = (options?: UnpluginStylexOptions) => T;
package/dist/vite.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkTCTVGJ42cjs = require('./chunk-TCTVGJ42.cjs');
3
+ var _chunk6L2G6TUNcjs = require('./chunk-6L2G6TUN.cjs');
4
4
  require('./chunk-ZBPRDZS4.cjs');
5
5
 
6
6
  // src/vite.ts
7
7
  var _unplugin = require('unplugin');
8
- var vitePlugin = _unplugin.createVitePlugin.call(void 0, _chunkTCTVGJ42cjs.unpluginFactory);
8
+ var vitePlugin = _unplugin.createVitePlugin.call(void 0, _chunk6L2G6TUNcjs.unpluginFactory);
9
9
  var vite_default = vitePlugin;
10
10
 
11
11
 
package/dist/vite.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-MREBYPD2.js";
3
+ } from "./chunk-3YBPBWJO.js";
4
4
  import "./chunk-6F4PWJZI.js";
5
5
 
6
6
  // src/vite.ts
package/dist/webpack.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkTCTVGJ42cjs = require('./chunk-TCTVGJ42.cjs');
3
+ var _chunk6L2G6TUNcjs = require('./chunk-6L2G6TUN.cjs');
4
4
  require('./chunk-ZBPRDZS4.cjs');
5
5
 
6
6
  // src/webpack.ts
7
7
  var _unplugin = require('unplugin');
8
- var webpackPlugin = _unplugin.createWebpackPlugin.call(void 0, _chunkTCTVGJ42cjs.unpluginFactory);
8
+ var webpackPlugin = _unplugin.createWebpackPlugin.call(void 0, _chunk6L2G6TUNcjs.unpluginFactory);
9
9
  var webpack_default = webpackPlugin;
10
10
 
11
11
 
package/dist/webpack.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-MREBYPD2.js";
3
+ } from "./chunk-3YBPBWJO.js";
4
4
  import "./chunk-6F4PWJZI.js";
5
5
 
6
6
  // src/webpack.ts
package/jsr.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@eryue0220/unplugin-stylex",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "exports": {
5
5
  "./index": "./src/index.ts",
6
6
  "./esbuild": "./src/esbuild.ts",
7
+ "./farm": "./src/farm.ts",
7
8
  "./rollup": "./src/rollup.ts",
8
9
  "./rspack": "./src/rspack.ts",
9
10
  "./vite": "./src/vite.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-stylex",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "packageManager": "pnpm@8.11.0",
5
5
  "description": "Unplugin for stylex",
6
6
  "repository": "https://github.com/eryue0220/unplugin-stylex",
@@ -8,6 +8,7 @@
8
8
  "unplugin",
9
9
  "stylex",
10
10
  "stylex-plugin",
11
+ "farm",
11
12
  "esbuild",
12
13
  "rollup",
13
14
  "rspack",
@@ -30,6 +31,11 @@
30
31
  "require": "./dist/esbuild.cjs",
31
32
  "import": "./dist/esbuild.js"
32
33
  },
34
+ "./farm": {
35
+ "types": "./dist/farm.d.ts",
36
+ "require": "./dist/farm.cjs",
37
+ "import": "./dist/farm.js"
38
+ },
33
39
  "./rollup": {
34
40
  "types": "./dist/rollup.d.ts",
35
41
  "require": "./dist/rollup.cjs",
@@ -74,25 +80,25 @@
74
80
  "@stylexjs/stylex": "^0.5.1"
75
81
  },
76
82
  "dependencies": {
77
- "@babel/core": "^7.24.5",
78
- "@babel/plugin-syntax-flow": "^7.24.1",
79
- "@babel/plugin-syntax-jsx": "^7.24.1",
80
- "@babel/plugin-syntax-typescript": "^7.24.1",
83
+ "@babel/core": "^7.24.7",
84
+ "@babel/plugin-syntax-flow": "^7.24.7",
85
+ "@babel/plugin-syntax-jsx": "^7.24.7",
86
+ "@babel/plugin-syntax-typescript": "^7.24.7",
81
87
  "@rollup/pluginutils": "^5.1.0",
82
88
  "@stylexjs/babel-plugin": "^0.5.1",
83
- "unplugin": "^1.10.1"
89
+ "unplugin": "^1.11.0"
84
90
  },
85
91
  "devDependencies": {
86
92
  "@stylistic/eslint-plugin-ts": "^1.8.1",
87
- "@types/node": "^20.12.11",
93
+ "@types/node": "^20.14.10",
88
94
  "@typescript-eslint/eslint-plugin": "^6.21.0",
89
95
  "@typescript-eslint/parser": "^6.21.0",
90
96
  "@vitest/coverage-v8": "^1.6.0",
91
97
  "babel-plugin-syntax-hermes-parser": "^0.19.2",
92
98
  "eslint": "^8.57.0",
93
- "tsup": "^8.0.2",
94
- "typescript": "^5.4.5",
95
- "vite": "^5.2.11",
99
+ "tsup": "^8.1.0",
100
+ "typescript": "^5.5.3",
101
+ "vite": "^5.3.3",
96
102
  "vitest": "^1.6.0"
97
103
  }
98
104
  }