unplugin-stylex 0.2.4 → 0.3.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 +41 -3
- package/dist/{chunk-7MXMBS5H.js → chunk-MREBYPD2.js} +16 -10
- package/dist/{chunk-NVMQARFA.cjs → chunk-TCTVGJ42.cjs} +19 -13
- package/dist/esbuild.cjs +2 -3
- package/dist/esbuild.js +1 -2
- package/dist/index.cjs +2 -3
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +1 -2
- package/dist/rollup.cjs +5 -6
- package/dist/rollup.d.cts +4 -6
- package/dist/rollup.d.ts +4 -6
- package/dist/rollup.js +6 -7
- package/dist/rspack.cjs +2 -3
- package/dist/rspack.js +1 -2
- package/dist/vite.cjs +2 -3
- package/dist/vite.js +1 -2
- package/dist/webpack.cjs +5 -6
- package/dist/webpack.d.cts +4 -6
- package/dist/webpack.d.ts +4 -6
- package/dist/webpack.js +6 -7
- package/jsr.json +1 -1
- package/package.json +32 -21
- package/src/index.ts +19 -0
- package/src/rollup.ts +18 -8
- package/src/webpack.ts +18 -8
- package/dist/chunk-36ARBXVP.js +0 -8
- package/dist/chunk-N4Z3Z2PU.cjs +0 -8
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ pnpm i unplugin-stylex --save-dev
|
|
|
28
28
|
<details>
|
|
29
29
|
<summary>Vite</summary><br>
|
|
30
30
|
|
|
31
|
-
```
|
|
31
|
+
```js
|
|
32
32
|
// vite.config.js
|
|
33
33
|
import { defineConfig } from 'vite'
|
|
34
34
|
import stylexPlugin from 'unplugin-stylex/vite'
|
|
@@ -45,7 +45,7 @@ export default defineConfig({
|
|
|
45
45
|
<details>
|
|
46
46
|
<summary>esbuild</summary><br>
|
|
47
47
|
|
|
48
|
-
```
|
|
48
|
+
```js
|
|
49
49
|
// esbuild.config.js
|
|
50
50
|
import { build } from 'esbuild'
|
|
51
51
|
import stylexPlugin from 'unplugin-stylex/esbuild'
|
|
@@ -62,7 +62,7 @@ export default {
|
|
|
62
62
|
<details>
|
|
63
63
|
<summary>rspack</summary><br>
|
|
64
64
|
|
|
65
|
-
```
|
|
65
|
+
```js
|
|
66
66
|
// rspack.config.js
|
|
67
67
|
import stylexPlugin from 'unplugin-stylex/rspack'
|
|
68
68
|
|
|
@@ -76,6 +76,44 @@ module.exports = {
|
|
|
76
76
|
|
|
77
77
|
</br></details>
|
|
78
78
|
|
|
79
|
+
<details>
|
|
80
|
+
<summary>rollup</summary><br>
|
|
81
|
+
|
|
82
|
+
```js
|
|
83
|
+
// rollup.config.js
|
|
84
|
+
import stylexRollupPlugin from 'unplugin-stylex/rollup'
|
|
85
|
+
|
|
86
|
+
export default {
|
|
87
|
+
// other rollup config
|
|
88
|
+
plugins: [
|
|
89
|
+
stylexRollupPlugin({ /* options */}),
|
|
90
|
+
],
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
</br></details>
|
|
95
|
+
|
|
96
|
+
<details>
|
|
97
|
+
<summary>webpack</summary><br>
|
|
98
|
+
|
|
99
|
+
```js
|
|
100
|
+
// webpack.config.js
|
|
101
|
+
import stylexWebpackPlugin from 'unplugin-stylex/webpack'
|
|
102
|
+
|
|
103
|
+
module.exports = {
|
|
104
|
+
// other webpack config
|
|
105
|
+
plugins: [
|
|
106
|
+
stylexWebpackPlugin({ /* options */}),
|
|
107
|
+
],
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
</br></details>
|
|
112
|
+
|
|
113
|
+
## Usage
|
|
114
|
+
|
|
115
|
+
More detail usage can check [examples](https://github.com/eryue0220/unplugin-stylex/tree/main/examples)
|
|
116
|
+
|
|
79
117
|
## Options
|
|
80
118
|
|
|
81
119
|
Current support argument, which may have change in the future
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PLUGIN_NAME,
|
|
3
|
-
isDevelopment
|
|
4
|
-
} from "./chunk-36ARBXVP.js";
|
|
5
|
-
|
|
6
1
|
// src/index.ts
|
|
7
2
|
import * as path from "node:path";
|
|
8
3
|
import { createUnplugin } from "unplugin";
|
|
@@ -16,6 +11,10 @@ function buildStylexRules(stylexRules, useCSSLayers) {
|
|
|
16
11
|
return stylex.processStylexRules(rules, useCSSLayers);
|
|
17
12
|
}
|
|
18
13
|
|
|
14
|
+
// src/core/constants.ts
|
|
15
|
+
var PLUGIN_NAME = "unplugin-stylex";
|
|
16
|
+
var isDevelopment = process.env.NODE_ENV !== "production" || process.env.BABEL_ENV !== "production";
|
|
17
|
+
|
|
19
18
|
// src/core/options.ts
|
|
20
19
|
function getOptions(options) {
|
|
21
20
|
const stylex2 = options.stylex || {};
|
|
@@ -49,9 +48,9 @@ import stylexBabelPlugin from "@stylexjs/babel-plugin";
|
|
|
49
48
|
// src/core/plugins.ts
|
|
50
49
|
import typescriptSyntaxPlugin from "@babel/plugin-syntax-typescript";
|
|
51
50
|
import flowSyntaxPlugin from "@babel/plugin-syntax-flow";
|
|
52
|
-
function getSyntaxPlugins(
|
|
53
|
-
const TSPlugin =
|
|
54
|
-
return [".js", ".jsx"].includes(
|
|
51
|
+
function getSyntaxPlugins(extname2) {
|
|
52
|
+
const TSPlugin = extname2 === ".tsx" ? [[typescriptSyntaxPlugin, { isTSX: true }]] : [typescriptSyntaxPlugin];
|
|
53
|
+
return [".js", ".jsx"].includes(extname2) ? [flowSyntaxPlugin] : TSPlugin;
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
// src/core/transformer.ts
|
|
@@ -59,7 +58,7 @@ async function transformer(context) {
|
|
|
59
58
|
var _a, _b, _c, _d;
|
|
60
59
|
const { id, inputCode, options } = context;
|
|
61
60
|
const stylex2 = options.stylex;
|
|
62
|
-
const
|
|
61
|
+
const extname2 = pathExtname(id);
|
|
63
62
|
const stylexRules = {};
|
|
64
63
|
const stylexBabelPluginOptions = {
|
|
65
64
|
dev: options.dev,
|
|
@@ -68,7 +67,7 @@ async function transformer(context) {
|
|
|
68
67
|
};
|
|
69
68
|
const plugins = [
|
|
70
69
|
...((_a = stylex2.babelConfig) == null ? void 0 : _a.plugins) || [],
|
|
71
|
-
...getSyntaxPlugins(
|
|
70
|
+
...getSyntaxPlugins(extname2),
|
|
72
71
|
jsxSyntaxPlugin,
|
|
73
72
|
stylexBabelPlugin.withOptions(stylexBabelPluginOptions)
|
|
74
73
|
];
|
|
@@ -97,6 +96,13 @@ var unpluginFactory = (rawOptions = {}) => {
|
|
|
97
96
|
let viteConfig = null;
|
|
98
97
|
return {
|
|
99
98
|
name: PLUGIN_NAME,
|
|
99
|
+
transformInclude(id) {
|
|
100
|
+
const invalidExts = [".json", ".html", ".jade", ".json5"];
|
|
101
|
+
const extname2 = path.extname(id);
|
|
102
|
+
const questionMarkIndex = extname2.indexOf("?");
|
|
103
|
+
const validExtName = questionMarkIndex > -1 ? extname2.slice(0, questionMarkIndex) : extname2;
|
|
104
|
+
return !invalidExts.includes(validExtName);
|
|
105
|
+
},
|
|
100
106
|
async transform(code, id) {
|
|
101
107
|
const dir = path.dirname(id);
|
|
102
108
|
const basename2 = path.basename(id);
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _chunkN4Z3Z2PUcjs = require('./chunk-N4Z3Z2PU.cjs');
|
|
5
|
-
|
|
6
|
-
// src/index.ts
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/index.ts
|
|
7
2
|
var _path = require('path'); var path = _interopRequireWildcard(_path);
|
|
8
3
|
var _unplugin = require('unplugin');
|
|
9
4
|
|
|
@@ -16,10 +11,14 @@ function buildStylexRules(stylexRules, useCSSLayers) {
|
|
|
16
11
|
return _babelplugin2.default.processStylexRules(rules, useCSSLayers);
|
|
17
12
|
}
|
|
18
13
|
|
|
14
|
+
// src/core/constants.ts
|
|
15
|
+
var PLUGIN_NAME = "unplugin-stylex";
|
|
16
|
+
var isDevelopment = process.env.NODE_ENV !== "production" || process.env.BABEL_ENV !== "production";
|
|
17
|
+
|
|
19
18
|
// src/core/options.ts
|
|
20
19
|
function getOptions(options) {
|
|
21
20
|
const stylex2 = options.stylex || {};
|
|
22
|
-
const isDev = options.dev ||
|
|
21
|
+
const isDev = options.dev || isDevelopment;
|
|
23
22
|
return {
|
|
24
23
|
...options,
|
|
25
24
|
dev: options.dev || isDev,
|
|
@@ -49,9 +48,9 @@ var _pluginsyntaxjsx = require('@babel/plugin-syntax-jsx'); var _pluginsyntaxjsx
|
|
|
49
48
|
// src/core/plugins.ts
|
|
50
49
|
var _pluginsyntaxtypescript = require('@babel/plugin-syntax-typescript'); var _pluginsyntaxtypescript2 = _interopRequireDefault(_pluginsyntaxtypescript);
|
|
51
50
|
var _pluginsyntaxflow = require('@babel/plugin-syntax-flow'); var _pluginsyntaxflow2 = _interopRequireDefault(_pluginsyntaxflow);
|
|
52
|
-
function getSyntaxPlugins(
|
|
53
|
-
const TSPlugin =
|
|
54
|
-
return [".js", ".jsx"].includes(
|
|
51
|
+
function getSyntaxPlugins(extname2) {
|
|
52
|
+
const TSPlugin = extname2 === ".tsx" ? [[_pluginsyntaxtypescript2.default, { isTSX: true }]] : [_pluginsyntaxtypescript2.default];
|
|
53
|
+
return [".js", ".jsx"].includes(extname2) ? [_pluginsyntaxflow2.default] : TSPlugin;
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
// src/core/transformer.ts
|
|
@@ -59,7 +58,7 @@ async function transformer(context) {
|
|
|
59
58
|
var _a, _b, _c, _d;
|
|
60
59
|
const { id, inputCode, options } = context;
|
|
61
60
|
const stylex2 = options.stylex;
|
|
62
|
-
const
|
|
61
|
+
const extname2 = _path.extname.call(void 0, id);
|
|
63
62
|
const stylexRules = {};
|
|
64
63
|
const stylexBabelPluginOptions = {
|
|
65
64
|
dev: options.dev,
|
|
@@ -68,7 +67,7 @@ async function transformer(context) {
|
|
|
68
67
|
};
|
|
69
68
|
const plugins = [
|
|
70
69
|
...((_a = stylex2.babelConfig) == null ? void 0 : _a.plugins) || [],
|
|
71
|
-
...getSyntaxPlugins(
|
|
70
|
+
...getSyntaxPlugins(extname2),
|
|
72
71
|
_pluginsyntaxjsx2.default,
|
|
73
72
|
_babelplugin2.default.withOptions(stylexBabelPluginOptions)
|
|
74
73
|
];
|
|
@@ -96,7 +95,14 @@ var unpluginFactory = (rawOptions = {}) => {
|
|
|
96
95
|
const stylexRules = {};
|
|
97
96
|
let viteConfig = null;
|
|
98
97
|
return {
|
|
99
|
-
name:
|
|
98
|
+
name: PLUGIN_NAME,
|
|
99
|
+
transformInclude(id) {
|
|
100
|
+
const invalidExts = [".json", ".html", ".jade", ".json5"];
|
|
101
|
+
const extname2 = path.extname(id);
|
|
102
|
+
const questionMarkIndex = extname2.indexOf("?");
|
|
103
|
+
const validExtName = questionMarkIndex > -1 ? extname2.slice(0, questionMarkIndex) : extname2;
|
|
104
|
+
return !invalidExts.includes(validExtName);
|
|
105
|
+
},
|
|
100
106
|
async transform(code, id) {
|
|
101
107
|
const dir = path.dirname(id);
|
|
102
108
|
const basename2 = path.basename(id);
|
package/dist/esbuild.cjs
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkTCTVGJ42cjs = require('./chunk-TCTVGJ42.cjs');
|
|
4
4
|
require('./chunk-ZBPRDZS4.cjs');
|
|
5
|
-
require('./chunk-N4Z3Z2PU.cjs');
|
|
6
5
|
|
|
7
6
|
// src/esbuild.ts
|
|
8
7
|
var _unplugin = require('unplugin');
|
|
9
|
-
var esbuildPlugin = _unplugin.createEsbuildPlugin.call(void 0,
|
|
8
|
+
var esbuildPlugin = _unplugin.createEsbuildPlugin.call(void 0, _chunkTCTVGJ42cjs.unpluginFactory);
|
|
10
9
|
var esbuild_default = esbuildPlugin;
|
|
11
10
|
|
|
12
11
|
|
package/dist/esbuild.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkTCTVGJ42cjs = require('./chunk-TCTVGJ42.cjs');
|
|
6
6
|
require('./chunk-ZBPRDZS4.cjs');
|
|
7
|
-
require('./chunk-N4Z3Z2PU.cjs');
|
|
8
7
|
|
|
9
8
|
|
|
10
9
|
|
|
11
10
|
|
|
12
|
-
exports.default =
|
|
11
|
+
exports.default = _chunkTCTVGJ42cjs.src_default; exports.unplugin = _chunkTCTVGJ42cjs.unplugin; exports.unpluginFactory = _chunkTCTVGJ42cjs.unpluginFactory;
|
package/dist/index.d.cts
CHANGED
|
@@ -2,6 +2,15 @@ import { UnpluginFactory, UnpluginInstance } from 'unplugin';
|
|
|
2
2
|
import { UnpluginStylexOptions } from './types.cjs';
|
|
3
3
|
export { BabelConfig, StylexOptions, UnpluginStylexInstance } from './types.cjs';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* This entry file is for main unplugin.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The main unplugin factory.
|
|
13
|
+
*/
|
|
5
14
|
declare const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined>;
|
|
6
15
|
declare const unplugin: UnpluginInstance<UnpluginStylexOptions | undefined, boolean>;
|
|
7
16
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,15 @@ import { UnpluginFactory, UnpluginInstance } from 'unplugin';
|
|
|
2
2
|
import { UnpluginStylexOptions } from './types.js';
|
|
3
3
|
export { BabelConfig, StylexOptions, UnpluginStylexInstance } from './types.js';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* This entry file is for main unplugin.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The main unplugin factory.
|
|
13
|
+
*/
|
|
5
14
|
declare const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined>;
|
|
6
15
|
declare const unplugin: UnpluginInstance<UnpluginStylexOptions | undefined, boolean>;
|
|
7
16
|
|
package/dist/index.js
CHANGED
package/dist/rollup.cjs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkTCTVGJ42cjs = require('./chunk-TCTVGJ42.cjs');
|
|
4
|
+
require('./chunk-ZBPRDZS4.cjs');
|
|
4
5
|
|
|
5
6
|
// src/rollup.ts
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
};
|
|
7
|
+
var _unplugin = require('unplugin');
|
|
8
|
+
var rollupPlugin = _unplugin.createRollupPlugin.call(void 0, _chunkTCTVGJ42cjs.unpluginFactory);
|
|
9
|
+
var rollup_default = rollupPlugin;
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
exports.default = rollup_default;
|
package/dist/rollup.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RollupPlugin } from 'unplugin';
|
|
2
|
+
import { UnpluginStylexInstance } from './types.cjs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* This entry file is for Rollup plugin.
|
|
@@ -6,9 +7,6 @@ import { UnpluginStylexOptions } from './types.cjs';
|
|
|
6
7
|
* @module
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
* Note: Current, please use @stylexjs/rollup-plugin
|
|
11
|
-
*/
|
|
12
|
-
declare const _default: (options?: UnpluginStylexOptions) => void;
|
|
10
|
+
declare const rollupPlugin: UnpluginStylexInstance<RollupPlugin | RollupPlugin[]>;
|
|
13
11
|
|
|
14
|
-
export {
|
|
12
|
+
export { rollupPlugin as default };
|
package/dist/rollup.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RollupPlugin } from 'unplugin';
|
|
2
|
+
import { UnpluginStylexInstance } from './types.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* This entry file is for Rollup plugin.
|
|
@@ -6,9 +7,6 @@ import { UnpluginStylexOptions } from './types.js';
|
|
|
6
7
|
* @module
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
* Note: Current, please use @stylexjs/rollup-plugin
|
|
11
|
-
*/
|
|
12
|
-
declare const _default: (options?: UnpluginStylexOptions) => void;
|
|
10
|
+
declare const rollupPlugin: UnpluginStylexInstance<RollupPlugin | RollupPlugin[]>;
|
|
13
11
|
|
|
14
|
-
export {
|
|
12
|
+
export { rollupPlugin as default };
|
package/dist/rollup.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
unpluginFactory
|
|
3
|
+
} from "./chunk-MREBYPD2.js";
|
|
4
|
+
import "./chunk-6F4PWJZI.js";
|
|
4
5
|
|
|
5
6
|
// src/rollup.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
};
|
|
7
|
+
import { createRollupPlugin } from "unplugin";
|
|
8
|
+
var rollupPlugin = createRollupPlugin(unpluginFactory);
|
|
9
|
+
var rollup_default = rollupPlugin;
|
|
11
10
|
export {
|
|
12
11
|
rollup_default as default
|
|
13
12
|
};
|
package/dist/rspack.cjs
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkTCTVGJ42cjs = require('./chunk-TCTVGJ42.cjs');
|
|
4
4
|
require('./chunk-ZBPRDZS4.cjs');
|
|
5
|
-
require('./chunk-N4Z3Z2PU.cjs');
|
|
6
5
|
|
|
7
6
|
// src/rspack.ts
|
|
8
7
|
var _unplugin = require('unplugin');
|
|
9
|
-
var rspackPlugin = _unplugin.createRspackPlugin.call(void 0,
|
|
8
|
+
var rspackPlugin = _unplugin.createRspackPlugin.call(void 0, _chunkTCTVGJ42cjs.unpluginFactory);
|
|
10
9
|
var rspack_default = rspackPlugin;
|
|
11
10
|
|
|
12
11
|
|
package/dist/rspack.js
CHANGED
package/dist/vite.cjs
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkTCTVGJ42cjs = require('./chunk-TCTVGJ42.cjs');
|
|
4
4
|
require('./chunk-ZBPRDZS4.cjs');
|
|
5
|
-
require('./chunk-N4Z3Z2PU.cjs');
|
|
6
5
|
|
|
7
6
|
// src/vite.ts
|
|
8
7
|
var _unplugin = require('unplugin');
|
|
9
|
-
var vitePlugin = _unplugin.createVitePlugin.call(void 0,
|
|
8
|
+
var vitePlugin = _unplugin.createVitePlugin.call(void 0, _chunkTCTVGJ42cjs.unpluginFactory);
|
|
10
9
|
var vite_default = vitePlugin;
|
|
11
10
|
|
|
12
11
|
|
package/dist/vite.js
CHANGED
package/dist/webpack.cjs
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkTCTVGJ42cjs = require('./chunk-TCTVGJ42.cjs');
|
|
4
|
+
require('./chunk-ZBPRDZS4.cjs');
|
|
4
5
|
|
|
5
6
|
// src/webpack.ts
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
};
|
|
7
|
+
var _unplugin = require('unplugin');
|
|
8
|
+
var webpackPlugin = _unplugin.createWebpackPlugin.call(void 0, _chunkTCTVGJ42cjs.unpluginFactory);
|
|
9
|
+
var webpack_default = webpackPlugin;
|
|
11
10
|
|
|
12
11
|
|
|
13
12
|
exports.default = webpack_default;
|
package/dist/webpack.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WebpackPluginInstance } from 'unplugin';
|
|
2
|
+
import { UnpluginStylexInstance } from './types.cjs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* This entry file is for Webpack plugin.
|
|
@@ -6,9 +7,6 @@ import { UnpluginStylexOptions } from './types.cjs';
|
|
|
6
7
|
* @module
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
* Note: Current, please use @stylexjs/webpack-plugin
|
|
11
|
-
*/
|
|
12
|
-
declare const _default: (options?: UnpluginStylexOptions) => void;
|
|
10
|
+
declare const webpackPlugin: UnpluginStylexInstance<WebpackPluginInstance>;
|
|
13
11
|
|
|
14
|
-
export {
|
|
12
|
+
export { webpackPlugin as default };
|
package/dist/webpack.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WebpackPluginInstance } from 'unplugin';
|
|
2
|
+
import { UnpluginStylexInstance } from './types.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* This entry file is for Webpack plugin.
|
|
@@ -6,9 +7,6 @@ import { UnpluginStylexOptions } from './types.js';
|
|
|
6
7
|
* @module
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
* Note: Current, please use @stylexjs/webpack-plugin
|
|
11
|
-
*/
|
|
12
|
-
declare const _default: (options?: UnpluginStylexOptions) => void;
|
|
10
|
+
declare const webpackPlugin: UnpluginStylexInstance<WebpackPluginInstance>;
|
|
13
11
|
|
|
14
|
-
export {
|
|
12
|
+
export { webpackPlugin as default };
|
package/dist/webpack.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
unpluginFactory
|
|
3
|
+
} from "./chunk-MREBYPD2.js";
|
|
4
|
+
import "./chunk-6F4PWJZI.js";
|
|
4
5
|
|
|
5
6
|
// src/webpack.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
};
|
|
7
|
+
import { createWebpackPlugin } from "unplugin";
|
|
8
|
+
var webpackPlugin = createWebpackPlugin(unpluginFactory);
|
|
9
|
+
var webpack_default = webpackPlugin;
|
|
11
10
|
export {
|
|
12
11
|
webpack_default as default
|
|
13
12
|
};
|
package/jsr.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-stylex",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"packageManager": "pnpm@8.11.0",
|
|
5
5
|
"description": "Unplugin for stylex",
|
|
6
6
|
"repository": "https://github.com/eryue0220/unplugin-stylex",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"stylex",
|
|
10
10
|
"stylex-plugin",
|
|
11
11
|
"esbuild",
|
|
12
|
+
"rollup",
|
|
12
13
|
"rspack",
|
|
13
14
|
"vite"
|
|
14
15
|
],
|
|
@@ -29,16 +30,26 @@
|
|
|
29
30
|
"require": "./dist/esbuild.cjs",
|
|
30
31
|
"import": "./dist/esbuild.js"
|
|
31
32
|
},
|
|
32
|
-
"./
|
|
33
|
-
"types": "./dist/
|
|
34
|
-
"require": "./dist/
|
|
35
|
-
"import": "./dist/
|
|
33
|
+
"./rollup": {
|
|
34
|
+
"types": "./dist/rollup.d.ts",
|
|
35
|
+
"require": "./dist/rollup.cjs",
|
|
36
|
+
"import": "./dist/rollup.js"
|
|
36
37
|
},
|
|
37
38
|
"./rspack": {
|
|
38
39
|
"types": "./dist/rspack.d.ts",
|
|
39
40
|
"require": "./dist/rspack.cjs",
|
|
40
41
|
"import": "./dist/rspack.js"
|
|
41
42
|
},
|
|
43
|
+
"./vite": {
|
|
44
|
+
"types": "./dist/vite.d.ts",
|
|
45
|
+
"require": "./dist/vite.cjs",
|
|
46
|
+
"import": "./dist/vite.js"
|
|
47
|
+
},
|
|
48
|
+
"./webpack": {
|
|
49
|
+
"types": "./dist/webpack.d.ts",
|
|
50
|
+
"require": "./dist/webpack.cjs",
|
|
51
|
+
"import": "./dist/webpack.js"
|
|
52
|
+
},
|
|
42
53
|
"./types": {
|
|
43
54
|
"types": "./dist/types.d.ts",
|
|
44
55
|
"import": "./dist/types.js",
|
|
@@ -63,25 +74,25 @@
|
|
|
63
74
|
"@stylexjs/stylex": "^0.5.1"
|
|
64
75
|
},
|
|
65
76
|
"dependencies": {
|
|
66
|
-
"@babel/core": "^7.
|
|
67
|
-
"@babel/plugin-syntax-flow": "^7.
|
|
68
|
-
"@babel/plugin-syntax-jsx": "^7.
|
|
69
|
-
"@babel/plugin-syntax-typescript": "^7.
|
|
77
|
+
"@babel/core": "^7.24.4",
|
|
78
|
+
"@babel/plugin-syntax-flow": "^7.24.1",
|
|
79
|
+
"@babel/plugin-syntax-jsx": "^7.24.1",
|
|
80
|
+
"@babel/plugin-syntax-typescript": "^7.24.1",
|
|
70
81
|
"@rollup/pluginutils": "^5.1.0",
|
|
71
82
|
"@stylexjs/babel-plugin": "^0.5.1",
|
|
72
|
-
"unplugin": "^1.
|
|
83
|
+
"unplugin": "^1.10.1"
|
|
73
84
|
},
|
|
74
85
|
"devDependencies": {
|
|
75
|
-
"@stylistic/eslint-plugin-ts": "^1.
|
|
76
|
-
"@types/node": "^20.
|
|
77
|
-
"@typescript-eslint/eslint-plugin": "^6.
|
|
78
|
-
"@typescript-eslint/parser": "^6.
|
|
79
|
-
"@vitest/coverage-v8": "^1.
|
|
80
|
-
"babel-plugin-syntax-hermes-parser": "^0.19.
|
|
81
|
-
"eslint": "^8.
|
|
82
|
-
"tsup": "^8.0.
|
|
83
|
-
"typescript": "^5.
|
|
84
|
-
"vite": "^5.
|
|
85
|
-
"vitest": "^1.
|
|
86
|
+
"@stylistic/eslint-plugin-ts": "^1.7.2",
|
|
87
|
+
"@types/node": "^20.12.7",
|
|
88
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
89
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
90
|
+
"@vitest/coverage-v8": "^1.5.0",
|
|
91
|
+
"babel-plugin-syntax-hermes-parser": "^0.19.2",
|
|
92
|
+
"eslint": "^8.57.0",
|
|
93
|
+
"tsup": "^8.0.2",
|
|
94
|
+
"typescript": "^5.4.5",
|
|
95
|
+
"vite": "^5.2.9",
|
|
96
|
+
"vitest": "^1.5.0"
|
|
86
97
|
}
|
|
87
98
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This entry file is for main unplugin.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
|
|
1
7
|
import * as path from 'node:path'
|
|
2
8
|
|
|
3
9
|
import { createUnplugin } from 'unplugin'
|
|
@@ -10,6 +16,9 @@ import { getOptions } from './core/options'
|
|
|
10
16
|
import { transformer } from './core/transformer'
|
|
11
17
|
import type { UnpluginStylexOptions } from './types'
|
|
12
18
|
|
|
19
|
+
/**
|
|
20
|
+
* The main unplugin factory.
|
|
21
|
+
*/
|
|
13
22
|
export const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined> = (rawOptions = {}) => {
|
|
14
23
|
const options = getOptions(rawOptions)
|
|
15
24
|
const stylexRules = {}
|
|
@@ -18,6 +27,16 @@ export const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined>
|
|
|
18
27
|
return {
|
|
19
28
|
name: PLUGIN_NAME,
|
|
20
29
|
|
|
30
|
+
transformInclude(id) {
|
|
31
|
+
// webpack will contain these files, which will occur errors
|
|
32
|
+
const invalidExts = ['.json', '.html', '.jade', '.json5']
|
|
33
|
+
const extname = path.extname(id)
|
|
34
|
+
// for handle vite
|
|
35
|
+
const questionMarkIndex = extname.indexOf('?')
|
|
36
|
+
const validExtName = questionMarkIndex > -1 ? extname.slice(0, questionMarkIndex) : extname
|
|
37
|
+
return !invalidExts.includes(validExtName)
|
|
38
|
+
},
|
|
39
|
+
|
|
21
40
|
async transform(code, id) {
|
|
22
41
|
const dir = path.dirname(id)
|
|
23
42
|
const basename = path.basename(id)
|
package/src/rollup.ts
CHANGED
|
@@ -4,14 +4,24 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import type {
|
|
7
|
+
import { createRollupPlugin } from 'unplugin'
|
|
8
|
+
import type { RollupPlugin } from 'unplugin'
|
|
9
|
+
import { unpluginFactory } from './index'
|
|
10
|
+
import type { UnpluginStylexInstance } from './types'
|
|
11
|
+
|
|
12
|
+
const rollupPlugin: UnpluginStylexInstance<RollupPlugin | RollupPlugin[]> = createRollupPlugin(unpluginFactory)
|
|
9
13
|
|
|
10
14
|
/**
|
|
11
|
-
*
|
|
15
|
+
* Rollup plugin
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
*
|
|
19
|
+
* import stylexPlugin from 'unplugin-stylex/rollup'
|
|
20
|
+
*
|
|
21
|
+
* export default {
|
|
22
|
+
* plugins: [
|
|
23
|
+
* stylexPlugin(),
|
|
24
|
+
* ],
|
|
25
|
+
* }
|
|
12
26
|
*/
|
|
13
|
-
export default
|
|
14
|
-
if (isDevelopment || options?.dev) {
|
|
15
|
-
throw new Error('If you want to use this plugin through rollup, please use "@stylexjs/rollup-plugin" instead')
|
|
16
|
-
}
|
|
17
|
-
}
|
|
27
|
+
export default rollupPlugin
|
package/src/webpack.ts
CHANGED
|
@@ -4,14 +4,24 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import type {
|
|
7
|
+
import { createWebpackPlugin } from 'unplugin'
|
|
8
|
+
import type { WebpackPluginInstance } from 'unplugin'
|
|
9
|
+
import { unpluginFactory } from './index'
|
|
10
|
+
import type { UnpluginStylexInstance } from './types'
|
|
11
|
+
|
|
12
|
+
const webpackPlugin: UnpluginStylexInstance<WebpackPluginInstance> = createWebpackPlugin(unpluginFactory)
|
|
9
13
|
|
|
10
14
|
/**
|
|
11
|
-
*
|
|
15
|
+
* Webpack plugin
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
*
|
|
19
|
+
* import stylexPlugin from 'unplugin-stylex/webpack'
|
|
20
|
+
*
|
|
21
|
+
* module.exports = {
|
|
22
|
+
* plugins: [
|
|
23
|
+
* stylexPlugin(),
|
|
24
|
+
* ],
|
|
25
|
+
* }
|
|
12
26
|
*/
|
|
13
|
-
export default
|
|
14
|
-
if (isDevelopment || options?.dev) {
|
|
15
|
-
throw new Error('If you want to use this plugin through webpack, please use "@stylexjs/webpack-plugin" instead')
|
|
16
|
-
}
|
|
17
|
-
}
|
|
27
|
+
export default webpackPlugin
|
package/dist/chunk-36ARBXVP.js
DELETED
package/dist/chunk-N4Z3Z2PU.cjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/core/constants.ts
|
|
2
|
-
var PLUGIN_NAME = "unplugin-stylex";
|
|
3
|
-
var isDevelopment = process.env.NODE_ENV !== "production" || process.env.BABEL_ENV !== "production";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
exports.PLUGIN_NAME = PLUGIN_NAME; exports.isDevelopment = isDevelopment;
|