unplugin-stylex 0.3.2 → 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,7 @@ function getOptions(options) {
21
20
  const isDev = options.dev || isDevelopment;
22
21
  return {
23
22
  ...options,
24
- dev: options.dev || isDev,
23
+ dev: isDev,
25
24
  invalidExts: [".json", ".html", ".jade", ".json5", ...options.invalidExts ?? []],
26
25
  stylex: {
27
26
  filename: stylex2.filename || "stylex.css",
@@ -85,7 +84,12 @@ async function transformer(context) {
85
84
  stylexRules[id] = metadata.stylex;
86
85
  }
87
86
  if (!((_d = stylex2.babelConfig) == null ? void 0 : _d.babelrc)) {
88
- 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
+ };
89
93
  }
90
94
  return { code, stylexRules };
91
95
  }
@@ -131,8 +135,7 @@ var unpluginFactory = (rawOptions = {}) => {
131
135
  buildEnd() {
132
136
  const fileName = options.stylex.filename;
133
137
  const collectedCSS = buildStylexRules(stylexRules, options.stylex.useCSSLayers);
134
- if (!collectedCSS)
135
- return;
138
+ if (!collectedCSS) return;
136
139
  this.emitFile({
137
140
  fileName,
138
141
  source: collectedCSS,
@@ -154,8 +157,7 @@ var unpluginFactory = (rawOptions = {}) => {
154
157
  var _a;
155
158
  const fileName = `${((_a = viteConfig.build) == null ? void 0 : _a.assetsDir) ?? "assets"}/${options.stylex.filename}`;
156
159
  const collectedCSS = buildStylexRules(stylexRules, options.stylex.useCSSLayers);
157
- if (!collectedCSS)
158
- return;
160
+ if (!collectedCSS) return;
159
161
  this.emitFile({
160
162
  fileName,
161
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,7 @@ function getOptions(options) {
21
20
  const isDev = options.dev || isDevelopment;
22
21
  return {
23
22
  ...options,
24
- dev: options.dev || isDev,
23
+ dev: isDev,
25
24
  invalidExts: [".json", ".html", ".jade", ".json5", ..._nullishCoalesce(options.invalidExts, () => ( []))],
26
25
  stylex: {
27
26
  filename: stylex2.filename || "stylex.css",
@@ -85,7 +84,12 @@ async function transformer(context) {
85
84
  stylexRules[id] = metadata.stylex;
86
85
  }
87
86
  if (!((_d = stylex2.babelConfig) == null ? void 0 : _d.babelrc)) {
88
- 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
+ };
89
93
  }
90
94
  return { code, stylexRules };
91
95
  }
@@ -131,8 +135,7 @@ var unpluginFactory = (rawOptions = {}) => {
131
135
  buildEnd() {
132
136
  const fileName = options.stylex.filename;
133
137
  const collectedCSS = buildStylexRules(stylexRules, options.stylex.useCSSLayers);
134
- if (!collectedCSS)
135
- return;
138
+ if (!collectedCSS) return;
136
139
  this.emitFile({
137
140
  fileName,
138
141
  source: collectedCSS,
@@ -154,8 +157,7 @@ var unpluginFactory = (rawOptions = {}) => {
154
157
  var _a;
155
158
  const fileName = `${_nullishCoalesce(((_a = viteConfig.build) == null ? void 0 : _a.assetsDir), () => ( "assets"))}/${options.stylex.filename}`;
156
159
  const collectedCSS = buildStylexRules(stylexRules, options.stylex.useCSSLayers);
157
- if (!collectedCSS)
158
- return;
160
+ if (!collectedCSS) return;
159
161
  this.emitFile({
160
162
  fileName,
161
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 _chunk33MWAEKIcjs = require('./chunk-33MWAEKI.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, _chunk33MWAEKIcjs.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-QTHUNRNO.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 _chunk33MWAEKIcjs = require('./chunk-33MWAEKI.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 = _chunk33MWAEKIcjs.src_default; exports.unplugin = _chunk33MWAEKIcjs.unplugin; exports.unpluginFactory = _chunk33MWAEKIcjs.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-QTHUNRNO.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 _chunk33MWAEKIcjs = require('./chunk-33MWAEKI.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, _chunk33MWAEKIcjs.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-QTHUNRNO.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 _chunk33MWAEKIcjs = require('./chunk-33MWAEKI.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, _chunk33MWAEKIcjs.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-QTHUNRNO.js";
3
+ } from "./chunk-3YBPBWJO.js";
4
4
  import "./chunk-6F4PWJZI.js";
5
5
 
6
6
  // src/rspack.ts
package/dist/vite.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk33MWAEKIcjs = require('./chunk-33MWAEKI.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, _chunk33MWAEKIcjs.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-QTHUNRNO.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 _chunk33MWAEKIcjs = require('./chunk-33MWAEKI.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, _chunk33MWAEKIcjs.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-QTHUNRNO.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.2",
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.2",
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",
@@ -57,6 +63,16 @@
57
63
  },
58
64
  "./*": "./*"
59
65
  },
66
+ "scripts": {
67
+ "dev": "tsup src/*ts --watch src",
68
+ "build": "tsup src/*.ts --format cjs,esm --dts --splitting --clean",
69
+ "test": "vitest",
70
+ "test:update": "vitest -u",
71
+ "test:cov": "vitest --coverage",
72
+ "lint": "eslint . --ext .ts,.tsx,.js,.jsx",
73
+ "check": "pnpm run lint && pnpm run typecheck",
74
+ "typecheck": "tsc -p tsconfig.json --noEmit"
75
+ },
60
76
  "engines": {
61
77
  "node": ">=16.14.0"
62
78
  },
@@ -64,35 +80,25 @@
64
80
  "@stylexjs/stylex": "^0.5.1"
65
81
  },
66
82
  "dependencies": {
67
- "@babel/core": "^7.24.5",
68
- "@babel/plugin-syntax-flow": "^7.24.1",
69
- "@babel/plugin-syntax-jsx": "^7.24.1",
70
- "@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",
71
87
  "@rollup/pluginutils": "^5.1.0",
72
88
  "@stylexjs/babel-plugin": "^0.5.1",
73
- "unplugin": "^1.10.1"
89
+ "unplugin": "^1.11.0"
74
90
  },
75
91
  "devDependencies": {
76
92
  "@stylistic/eslint-plugin-ts": "^1.8.1",
77
- "@types/node": "^20.12.11",
93
+ "@types/node": "^20.14.10",
78
94
  "@typescript-eslint/eslint-plugin": "^6.21.0",
79
95
  "@typescript-eslint/parser": "^6.21.0",
80
96
  "@vitest/coverage-v8": "^1.6.0",
81
97
  "babel-plugin-syntax-hermes-parser": "^0.19.2",
82
98
  "eslint": "^8.57.0",
83
- "tsup": "^8.0.2",
84
- "typescript": "^5.4.5",
85
- "vite": "^5.2.11",
99
+ "tsup": "^8.1.0",
100
+ "typescript": "^5.5.3",
101
+ "vite": "^5.3.3",
86
102
  "vitest": "^1.6.0"
87
- },
88
- "scripts": {
89
- "dev": "tsup src/*ts --watch src",
90
- "build": "tsup src/*.ts --format cjs,esm --dts --splitting --clean",
91
- "test": "vitest",
92
- "test:update": "vitest -u",
93
- "test:cov": "vitest --coverage",
94
- "lint": "eslint . --ext .ts,.tsx,.js,.jsx",
95
- "check": "pnpm run lint && pnpm run typecheck",
96
- "typecheck": "tsc -p tsconfig.json --noEmit"
97
103
  }
98
- }
104
+ }