unplugin-stylex 0.1.0 → 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/.eslintrc.json +4 -6
- package/.github/renovate.json +27 -0
- package/.github/workflows/release.yml +13 -0
- package/.github/workflows/typos.yml +15 -0
- package/README.md +50 -10
- package/dist/{chunk-7MXMBS5H.js → chunk-MREBYPD2.js} +16 -10
- package/dist/{chunk-NVMQARFA.cjs → chunk-TCTVGJ42.cjs} +19 -13
- package/dist/esbuild.cjs +3 -3
- package/dist/esbuild.d.cts +10 -4
- package/dist/esbuild.d.ts +10 -4
- package/dist/esbuild.js +3 -3
- package/dist/index.cjs +2 -3
- package/dist/index.d.cts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.js +1 -2
- package/dist/rollup.cjs +5 -6
- package/dist/rollup.d.cts +11 -2
- package/dist/rollup.d.ts +11 -2
- package/dist/rollup.js +6 -7
- package/dist/rspack.cjs +3 -3
- package/dist/rspack.d.cts +11 -4
- package/dist/rspack.d.ts +11 -4
- package/dist/rspack.js +3 -3
- package/dist/types.d.cts +4 -3
- package/dist/types.d.ts +4 -3
- package/dist/vite.cjs +3 -3
- package/dist/vite.d.cts +10 -4
- package/dist/vite.d.ts +10 -4
- package/dist/vite.js +3 -3
- package/dist/webpack.cjs +5 -6
- package/dist/webpack.d.cts +11 -2
- package/dist/webpack.d.ts +11 -2
- package/dist/webpack.js +6 -7
- package/jsr.json +20 -0
- package/package.json +45 -30
- package/src/esbuild.ts +27 -2
- package/src/index.ts +26 -6
- package/src/rollup.ts +26 -6
- package/src/rspack.ts +27 -2
- package/src/types.ts +4 -2
- package/src/vite.ts +26 -2
- package/src/webpack.ts +26 -6
- package/typos.toml +10 -0
- package/vitest.config.ts +2 -2
- package/dist/chunk-36ARBXVP.js +0 -8
- package/dist/chunk-N4Z3Z2PU.cjs +0 -8
package/.eslintrc.json
CHANGED
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
"env": {
|
|
3
3
|
"node": true
|
|
4
4
|
},
|
|
5
|
-
"extends": [
|
|
6
|
-
"eslint:recommended",
|
|
7
|
-
"plugin:@typescript-eslint/recommended"
|
|
8
|
-
],
|
|
9
5
|
"parser": "@typescript-eslint/parser",
|
|
10
|
-
"plugins": ["@
|
|
6
|
+
"plugins": ["@stylistic/ts"],
|
|
11
7
|
"root": true,
|
|
12
8
|
"rules": {
|
|
13
|
-
"
|
|
9
|
+
"max-len": ["error", { "code": 120 }],
|
|
10
|
+
"semi": ["error", "never"],
|
|
11
|
+
"quotes": ["error", "single"],
|
|
14
12
|
"@typescript-eslint/no-explicit-any": "off"
|
|
15
13
|
}
|
|
16
14
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
|
3
|
+
"extends": ["config:base"],
|
|
4
|
+
"lockFileMaintenance": {"enabled": true, "automerge": false},
|
|
5
|
+
"rangeStrategy": "replace",
|
|
6
|
+
"postUpdateOptions": ["pnpmDedupe"],
|
|
7
|
+
"packageRules": [
|
|
8
|
+
{
|
|
9
|
+
"matchPackageNames": ["@tsd/typescript", "typescript"],
|
|
10
|
+
"groupName": "typescript"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"matchPackageNames": [
|
|
14
|
+
"@babel/core",
|
|
15
|
+
"@babel/plugin-syntax-flow",
|
|
16
|
+
"@babel/plugin-syntax-jsx",
|
|
17
|
+
"@babel/plugin-syntax-typescript"
|
|
18
|
+
],
|
|
19
|
+
"groupName": "babel"
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
{
|
|
23
|
+
"matchPackageNames": ["@stylexjs/stylex", "@stylexjs/babel-plugin"],
|
|
24
|
+
"groupName": "stylex"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}
|
|
@@ -24,3 +24,16 @@ jobs:
|
|
|
24
24
|
- run: npx changelogithub
|
|
25
25
|
env:
|
|
26
26
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
27
|
+
|
|
28
|
+
publish-jsr:
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
|
|
31
|
+
permissions:
|
|
32
|
+
contents: read
|
|
33
|
+
id-token: write
|
|
34
|
+
|
|
35
|
+
steps:
|
|
36
|
+
- uses: actions/checkout@v4
|
|
37
|
+
|
|
38
|
+
- name: Publish package
|
|
39
|
+
run: npx jsr publish
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
name: Spell Check
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- "main"
|
|
7
|
+
jobs:
|
|
8
|
+
typos:
|
|
9
|
+
name: Spell Check with Typos
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- name: Checkout Actions Repository
|
|
13
|
+
uses: actions/checkout@v4
|
|
14
|
+
- name: Check spelling
|
|
15
|
+
uses: crate-ci/typos@master
|
package/README.md
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
# unplugin-stylex
|
|
1
|
+
# unplugin-stylex · [](https://github.com/eryue0220/unplugin-stylex/blob/main/LICENSE) [](https://www.npmjs.com/package/unplugin-stylex)
|
|
2
|
+
|
|
3
|
+
> [!WARNING]
|
|
4
|
+
> This plugin is in early development and may not work as expected. Please report any issues you find.
|
|
2
5
|
|
|
3
6
|
## Installation
|
|
4
7
|
|
|
@@ -25,7 +28,7 @@ pnpm i unplugin-stylex --save-dev
|
|
|
25
28
|
<details>
|
|
26
29
|
<summary>Vite</summary><br>
|
|
27
30
|
|
|
28
|
-
```
|
|
31
|
+
```js
|
|
29
32
|
// vite.config.js
|
|
30
33
|
import { defineConfig } from 'vite'
|
|
31
34
|
import stylexPlugin from 'unplugin-stylex/vite'
|
|
@@ -42,7 +45,7 @@ export default defineConfig({
|
|
|
42
45
|
<details>
|
|
43
46
|
<summary>esbuild</summary><br>
|
|
44
47
|
|
|
45
|
-
```
|
|
48
|
+
```js
|
|
46
49
|
// esbuild.config.js
|
|
47
50
|
import { build } from 'esbuild'
|
|
48
51
|
import stylexPlugin from 'unplugin-stylex/esbuild'
|
|
@@ -59,7 +62,7 @@ export default {
|
|
|
59
62
|
<details>
|
|
60
63
|
<summary>rspack</summary><br>
|
|
61
64
|
|
|
62
|
-
```
|
|
65
|
+
```js
|
|
63
66
|
// rspack.config.js
|
|
64
67
|
import stylexPlugin from 'unplugin-stylex/rspack'
|
|
65
68
|
|
|
@@ -73,13 +76,49 @@ module.exports = {
|
|
|
73
76
|
|
|
74
77
|
</br></details>
|
|
75
78
|
|
|
76
|
-
|
|
79
|
+
<details>
|
|
80
|
+
<summary>rollup</summary><br>
|
|
77
81
|
|
|
78
|
-
|
|
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>
|
|
79
98
|
|
|
80
|
-
|
|
99
|
+
```js
|
|
100
|
+
// webpack.config.js
|
|
101
|
+
import stylexWebpackPlugin from 'unplugin-stylex/webpack'
|
|
81
102
|
|
|
82
|
-
|
|
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
|
+
|
|
117
|
+
## Options
|
|
118
|
+
|
|
119
|
+
Current support argument, which may have change in the future
|
|
120
|
+
|
|
121
|
+
### options.dev
|
|
83
122
|
|
|
84
123
|
#### options.stylex.runtimeInjection
|
|
85
124
|
|
|
@@ -93,6 +132,7 @@ module.exports = {
|
|
|
93
132
|
|
|
94
133
|
#### options.stylex.unstable_moduleResolution
|
|
95
134
|
|
|
96
|
-
|
|
135
|
+
# Acknowledgments
|
|
97
136
|
|
|
98
|
-
|
|
137
|
+
- [@stylexjs/rollup-plugin](https://github.com/facebook/stylex/tree/main/packages/rollup-plugin)
|
|
138
|
+
- [vite-plugin-stylex](https://github.com/HorusGoul/vite-plugin-stylex)
|
|
@@ -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,12 @@
|
|
|
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
|
|
8
|
+
var esbuildPlugin = _unplugin.createEsbuildPlugin.call(void 0, _chunkTCTVGJ42cjs.unpluginFactory);
|
|
9
|
+
var esbuild_default = esbuildPlugin;
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
exports.default = esbuild_default;
|
package/dist/esbuild.d.cts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { EsbuildPlugin } from 'unplugin';
|
|
2
|
+
import { UnpluginStylexInstance } from './types.cjs';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* This entry file is for esbuild plugin. Requires esbuild >= 0.15
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
5
9
|
|
|
6
|
-
|
|
10
|
+
declare const esbuildPlugin: UnpluginStylexInstance<EsbuildPlugin | EsbuildPlugin[]>;
|
|
11
|
+
|
|
12
|
+
export { esbuildPlugin as default };
|
package/dist/esbuild.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { EsbuildPlugin } from 'unplugin';
|
|
2
|
+
import { UnpluginStylexInstance } from './types.js';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* This entry file is for esbuild plugin. Requires esbuild >= 0.15
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
5
9
|
|
|
6
|
-
|
|
10
|
+
declare const esbuildPlugin: UnpluginStylexInstance<EsbuildPlugin | EsbuildPlugin[]>;
|
|
11
|
+
|
|
12
|
+
export { esbuildPlugin as default };
|
package/dist/esbuild.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
unpluginFactory
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MREBYPD2.js";
|
|
4
4
|
import "./chunk-6F4PWJZI.js";
|
|
5
|
-
import "./chunk-36ARBXVP.js";
|
|
6
5
|
|
|
7
6
|
// src/esbuild.ts
|
|
8
7
|
import { createEsbuildPlugin } from "unplugin";
|
|
9
|
-
var
|
|
8
|
+
var esbuildPlugin = createEsbuildPlugin(unpluginFactory);
|
|
9
|
+
var esbuild_default = esbuildPlugin;
|
|
10
10
|
export {
|
|
11
11
|
esbuild_default as default
|
|
12
12
|
};
|
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
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { UnpluginFactory } from 'unplugin';
|
|
1
|
+
import { UnpluginFactory, UnpluginInstance } from 'unplugin';
|
|
3
2
|
import { UnpluginStylexOptions } from './types.cjs';
|
|
4
|
-
export { BabelConfig, StylexOptions } from './types.cjs';
|
|
3
|
+
export { BabelConfig, StylexOptions, UnpluginStylexInstance } from './types.cjs';
|
|
5
4
|
|
|
5
|
+
/**
|
|
6
|
+
* This entry file is for main unplugin.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The main unplugin factory.
|
|
13
|
+
*/
|
|
6
14
|
declare const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined>;
|
|
7
|
-
declare const unplugin:
|
|
15
|
+
declare const unplugin: UnpluginInstance<UnpluginStylexOptions | undefined, boolean>;
|
|
8
16
|
|
|
9
17
|
export { UnpluginStylexOptions, unplugin as default, unplugin, unpluginFactory };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { UnpluginFactory } from 'unplugin';
|
|
1
|
+
import { UnpluginFactory, UnpluginInstance } from 'unplugin';
|
|
3
2
|
import { UnpluginStylexOptions } from './types.js';
|
|
4
|
-
export { BabelConfig, StylexOptions } from './types.js';
|
|
3
|
+
export { BabelConfig, StylexOptions, UnpluginStylexInstance } from './types.js';
|
|
5
4
|
|
|
5
|
+
/**
|
|
6
|
+
* This entry file is for main unplugin.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The main unplugin factory.
|
|
13
|
+
*/
|
|
6
14
|
declare const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined>;
|
|
7
|
-
declare const unplugin:
|
|
15
|
+
declare const unplugin: UnpluginInstance<UnpluginStylexOptions | undefined, boolean>;
|
|
8
16
|
|
|
9
17
|
export { UnpluginStylexOptions, unplugin as default, unplugin, unpluginFactory };
|
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,3 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { RollupPlugin } from 'unplugin';
|
|
2
|
+
import { UnpluginStylexInstance } from './types.cjs';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
/**
|
|
5
|
+
* This entry file is for Rollup plugin.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
declare const rollupPlugin: UnpluginStylexInstance<RollupPlugin | RollupPlugin[]>;
|
|
11
|
+
|
|
12
|
+
export { rollupPlugin as default };
|
package/dist/rollup.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { RollupPlugin } from 'unplugin';
|
|
2
|
+
import { UnpluginStylexInstance } from './types.js';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
/**
|
|
5
|
+
* This entry file is for Rollup plugin.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
declare const rollupPlugin: UnpluginStylexInstance<RollupPlugin | RollupPlugin[]>;
|
|
11
|
+
|
|
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,12 @@
|
|
|
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
|
|
8
|
+
var rspackPlugin = _unplugin.createRspackPlugin.call(void 0, _chunkTCTVGJ42cjs.unpluginFactory);
|
|
9
|
+
var rspack_default = rspackPlugin;
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
exports.default = rspack_default;
|
package/dist/rspack.d.cts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { RspackPluginInstance } from 'unplugin';
|
|
2
|
+
import { UnpluginStylexInstance } from './types.cjs';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* This entry file is for Rspac plugin.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
5
9
|
|
|
6
|
-
|
|
10
|
+
type RspackPluginType = UnpluginStylexInstance<RspackPluginInstance | RspackPluginInstance[]>;
|
|
11
|
+
declare const rspackPlugin: RspackPluginType;
|
|
12
|
+
|
|
13
|
+
export { rspackPlugin as default };
|
package/dist/rspack.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { RspackPluginInstance } from 'unplugin';
|
|
2
|
+
import { UnpluginStylexInstance } from './types.js';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* This entry file is for Rspac plugin.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
5
9
|
|
|
6
|
-
|
|
10
|
+
type RspackPluginType = UnpluginStylexInstance<RspackPluginInstance | RspackPluginInstance[]>;
|
|
11
|
+
declare const rspackPlugin: RspackPluginType;
|
|
12
|
+
|
|
13
|
+
export { rspackPlugin as default };
|
package/dist/rspack.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
unpluginFactory
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MREBYPD2.js";
|
|
4
4
|
import "./chunk-6F4PWJZI.js";
|
|
5
|
-
import "./chunk-36ARBXVP.js";
|
|
6
5
|
|
|
7
6
|
// src/rspack.ts
|
|
8
7
|
import { createRspackPlugin } from "unplugin";
|
|
9
|
-
var
|
|
8
|
+
var rspackPlugin = createRspackPlugin(unpluginFactory);
|
|
9
|
+
var rspack_default = rspackPlugin;
|
|
10
10
|
export {
|
|
11
11
|
rspack_default as default
|
|
12
12
|
};
|
package/dist/types.d.cts
CHANGED
|
@@ -9,7 +9,7 @@ type StylexOptions = {
|
|
|
9
9
|
classNamePrefix?: string;
|
|
10
10
|
useCSSLayers?: boolean;
|
|
11
11
|
unstable_moduleResolution?: {
|
|
12
|
-
type:
|
|
12
|
+
type: 'commonjs' | 'haste';
|
|
13
13
|
rootDir: string;
|
|
14
14
|
};
|
|
15
15
|
babelConfig?: BabelConfig;
|
|
@@ -19,8 +19,9 @@ type StylexOptions = {
|
|
|
19
19
|
type UnpluginStylexOptions = {
|
|
20
20
|
compiler?: string;
|
|
21
21
|
dev?: boolean;
|
|
22
|
-
enforce?:
|
|
22
|
+
enforce?: 'post' | 'pre';
|
|
23
23
|
stylex?: StylexOptions;
|
|
24
24
|
};
|
|
25
|
+
type UnpluginStylexInstance<T> = (options?: UnpluginStylexOptions) => T;
|
|
25
26
|
|
|
26
|
-
export type { BabelConfig, StylexOptions, UnpluginStylexOptions };
|
|
27
|
+
export type { BabelConfig, StylexOptions, UnpluginStylexInstance, UnpluginStylexOptions };
|
package/dist/types.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ type StylexOptions = {
|
|
|
9
9
|
classNamePrefix?: string;
|
|
10
10
|
useCSSLayers?: boolean;
|
|
11
11
|
unstable_moduleResolution?: {
|
|
12
|
-
type:
|
|
12
|
+
type: 'commonjs' | 'haste';
|
|
13
13
|
rootDir: string;
|
|
14
14
|
};
|
|
15
15
|
babelConfig?: BabelConfig;
|
|
@@ -19,8 +19,9 @@ type StylexOptions = {
|
|
|
19
19
|
type UnpluginStylexOptions = {
|
|
20
20
|
compiler?: string;
|
|
21
21
|
dev?: boolean;
|
|
22
|
-
enforce?:
|
|
22
|
+
enforce?: 'post' | 'pre';
|
|
23
23
|
stylex?: StylexOptions;
|
|
24
24
|
};
|
|
25
|
+
type UnpluginStylexInstance<T> = (options?: UnpluginStylexOptions) => T;
|
|
25
26
|
|
|
26
|
-
export type { BabelConfig, StylexOptions, UnpluginStylexOptions };
|
|
27
|
+
export type { BabelConfig, StylexOptions, UnpluginStylexInstance, UnpluginStylexOptions };
|
package/dist/vite.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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
|
|
8
|
+
var vitePlugin = _unplugin.createVitePlugin.call(void 0, _chunkTCTVGJ42cjs.unpluginFactory);
|
|
9
|
+
var vite_default = vitePlugin;
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
exports.default = vite_default;
|
package/dist/vite.d.cts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { VitePlugin } from 'unplugin';
|
|
2
|
+
import { UnpluginStylexInstance } from './types.cjs';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* This entry file is for Vite plugin.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
5
9
|
|
|
6
|
-
|
|
10
|
+
declare const vitePlugin: UnpluginStylexInstance<VitePlugin | VitePlugin[]>;
|
|
11
|
+
|
|
12
|
+
export { vitePlugin as default };
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { VitePlugin } from 'unplugin';
|
|
2
|
+
import { UnpluginStylexInstance } from './types.js';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* This entry file is for Vite plugin.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
5
9
|
|
|
6
|
-
|
|
10
|
+
declare const vitePlugin: UnpluginStylexInstance<VitePlugin | VitePlugin[]>;
|
|
11
|
+
|
|
12
|
+
export { vitePlugin as default };
|
package/dist/vite.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
unpluginFactory
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MREBYPD2.js";
|
|
4
4
|
import "./chunk-6F4PWJZI.js";
|
|
5
|
-
import "./chunk-36ARBXVP.js";
|
|
6
5
|
|
|
7
6
|
// src/vite.ts
|
|
8
7
|
import { createVitePlugin } from "unplugin";
|
|
9
|
-
var
|
|
8
|
+
var vitePlugin = createVitePlugin(unpluginFactory);
|
|
9
|
+
var vite_default = vitePlugin;
|
|
10
10
|
export {
|
|
11
11
|
vite_default as default
|
|
12
12
|
};
|
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,3 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { WebpackPluginInstance } from 'unplugin';
|
|
2
|
+
import { UnpluginStylexInstance } from './types.cjs';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
/**
|
|
5
|
+
* This entry file is for Webpack plugin.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
declare const webpackPlugin: UnpluginStylexInstance<WebpackPluginInstance>;
|
|
11
|
+
|
|
12
|
+
export { webpackPlugin as default };
|
package/dist/webpack.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { WebpackPluginInstance } from 'unplugin';
|
|
2
|
+
import { UnpluginStylexInstance } from './types.js';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
/**
|
|
5
|
+
* This entry file is for Webpack plugin.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
declare const webpackPlugin: UnpluginStylexInstance<WebpackPluginInstance>;
|
|
11
|
+
|
|
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
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@eryue0220/unplugin-stylex",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"exports": {
|
|
5
|
+
"./index": "./src/index.ts",
|
|
6
|
+
"./esbuild": "./src/esbuild.ts",
|
|
7
|
+
"./rollup": "./src/rollup.ts",
|
|
8
|
+
"./rspack": "./src/rspack.ts",
|
|
9
|
+
"./vite": "./src/vite.ts",
|
|
10
|
+
"./webpack": "./src/webpack.ts"
|
|
11
|
+
},
|
|
12
|
+
"exclude": [
|
|
13
|
+
".eslintrc.json",
|
|
14
|
+
".eslintignore",
|
|
15
|
+
"test",
|
|
16
|
+
"examples",
|
|
17
|
+
"pnpm-lock.yaml",
|
|
18
|
+
"pnpm-workspace.yaml"
|
|
19
|
+
]
|
|
20
|
+
}
|
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",
|
|
@@ -46,30 +57,6 @@
|
|
|
46
57
|
},
|
|
47
58
|
"./*": "./*"
|
|
48
59
|
},
|
|
49
|
-
"engines": {
|
|
50
|
-
"node": ">=16.14.0"
|
|
51
|
-
},
|
|
52
|
-
"dependencies": {
|
|
53
|
-
"@babel/core": "^7.23.6",
|
|
54
|
-
"@babel/plugin-syntax-flow": "^7.23.3",
|
|
55
|
-
"@babel/plugin-syntax-jsx": "^7.23.3",
|
|
56
|
-
"@babel/plugin-syntax-typescript": "^7.23.3",
|
|
57
|
-
"@rollup/pluginutils": "^5.1.0",
|
|
58
|
-
"@stylexjs/babel-plugin": "^0.5.1",
|
|
59
|
-
"unplugin": "^1.7.1"
|
|
60
|
-
},
|
|
61
|
-
"devDependencies": {
|
|
62
|
-
"@types/node": "^20.10.5",
|
|
63
|
-
"@typescript-eslint/eslint-plugin": "^6.16.0",
|
|
64
|
-
"@typescript-eslint/parser": "^6.16.0",
|
|
65
|
-
"@vitest/coverage-v8": "^1.1.1",
|
|
66
|
-
"babel-plugin-syntax-hermes-parser": "^0.19.1",
|
|
67
|
-
"eslint": "^8.56.0",
|
|
68
|
-
"tsup": "^8.0.1",
|
|
69
|
-
"typescript": "^5.3.3",
|
|
70
|
-
"vite": "^5.0.10",
|
|
71
|
-
"vitest": "^1.1.0"
|
|
72
|
-
},
|
|
73
60
|
"scripts": {
|
|
74
61
|
"dev": "tsup src/*ts --watch src",
|
|
75
62
|
"build": "tsup src/*.ts --format cjs,esm --dts --splitting --clean",
|
|
@@ -79,5 +66,33 @@
|
|
|
79
66
|
"lint": "eslint . --ext .ts,.tsx,.js,.jsx",
|
|
80
67
|
"check": "pnpm run lint && pnpm run typecheck",
|
|
81
68
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
69
|
+
},
|
|
70
|
+
"engines": {
|
|
71
|
+
"node": ">=16.14.0"
|
|
72
|
+
},
|
|
73
|
+
"peerDependencies": {
|
|
74
|
+
"@stylexjs/stylex": "^0.5.1"
|
|
75
|
+
},
|
|
76
|
+
"dependencies": {
|
|
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",
|
|
81
|
+
"@rollup/pluginutils": "^5.1.0",
|
|
82
|
+
"@stylexjs/babel-plugin": "^0.5.1",
|
|
83
|
+
"unplugin": "^1.10.1"
|
|
84
|
+
},
|
|
85
|
+
"devDependencies": {
|
|
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"
|
|
82
97
|
}
|
|
83
|
-
}
|
|
98
|
+
}
|
package/src/esbuild.ts
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This entry file is for esbuild plugin. Requires esbuild >= 0.15
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
|
|
1
7
|
import { createEsbuildPlugin } from 'unplugin'
|
|
2
|
-
import {
|
|
8
|
+
import type { EsbuildPlugin } from 'unplugin'
|
|
9
|
+
import { unpluginFactory } from './index'
|
|
10
|
+
import type { UnpluginStylexInstance } from './types'
|
|
11
|
+
|
|
12
|
+
const esbuildPlugin: UnpluginStylexInstance<EsbuildPlugin | EsbuildPlugin[]> = createEsbuildPlugin(unpluginFactory)
|
|
13
|
+
|
|
3
14
|
|
|
4
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Esbuild plugin
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
*
|
|
20
|
+
* import { build } from 'esbuild'
|
|
21
|
+
* import stylexPlugin from 'unplugin-stylex/esbuild'
|
|
22
|
+
*
|
|
23
|
+
* export default {
|
|
24
|
+
* plugins: [
|
|
25
|
+
* stylexPlugin(),
|
|
26
|
+
* ],
|
|
27
|
+
* }
|
|
28
|
+
*/
|
|
29
|
+
export default esbuildPlugin
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
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'
|
|
4
|
-
import type { UnpluginFactory } from 'unplugin'
|
|
10
|
+
import type { UnpluginFactory, UnpluginInstance } from 'unplugin'
|
|
11
|
+
import type { BuildOptions } from 'vite'
|
|
5
12
|
|
|
6
13
|
import { buildStylexRules } from './core/build'
|
|
7
14
|
import { PLUGIN_NAME } from './core/constants'
|
|
@@ -9,14 +16,27 @@ import { getOptions } from './core/options'
|
|
|
9
16
|
import { transformer } from './core/transformer'
|
|
10
17
|
import type { UnpluginStylexOptions } from './types'
|
|
11
18
|
|
|
19
|
+
/**
|
|
20
|
+
* The main unplugin factory.
|
|
21
|
+
*/
|
|
12
22
|
export const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined> = (rawOptions = {}) => {
|
|
13
23
|
const options = getOptions(rawOptions)
|
|
14
24
|
const stylexRules = {}
|
|
15
|
-
let viteConfig = null
|
|
25
|
+
let viteConfig: { build: BuildOptions | undefined; base: string | undefined; } | null = null
|
|
16
26
|
|
|
17
27
|
return {
|
|
18
28
|
name: PLUGIN_NAME,
|
|
19
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
|
+
|
|
20
40
|
async transform(code, id) {
|
|
21
41
|
const dir = path.dirname(id)
|
|
22
42
|
const basename = path.basename(id)
|
|
@@ -74,7 +94,7 @@ export const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined>
|
|
|
74
94
|
},
|
|
75
95
|
|
|
76
96
|
buildEnd() {
|
|
77
|
-
const fileName = `${viteConfig
|
|
97
|
+
const fileName = `${viteConfig!.build?.assetsDir ?? 'assets'}/${options.stylex.filename}`
|
|
78
98
|
const collectedCSS = buildStylexRules(stylexRules, options.stylex.useCSSLayers)
|
|
79
99
|
|
|
80
100
|
if (!collectedCSS) return
|
|
@@ -87,7 +107,7 @@ export const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined>
|
|
|
87
107
|
},
|
|
88
108
|
|
|
89
109
|
transformIndexHtml(html, ctx) {
|
|
90
|
-
const fileName = `${viteConfig
|
|
110
|
+
const fileName = `${viteConfig!.build?.assetsDir ?? 'assets'}/${options.stylex.filename}`
|
|
91
111
|
const css = ctx.bundle?.[fileName]
|
|
92
112
|
|
|
93
113
|
if (!css) {
|
|
@@ -95,7 +115,7 @@ export const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined>
|
|
|
95
115
|
}
|
|
96
116
|
|
|
97
117
|
const publicPath = path.posix.join(
|
|
98
|
-
viteConfig
|
|
118
|
+
viteConfig!.base ?? '/',
|
|
99
119
|
fileName.replace(/\\/g, '/')
|
|
100
120
|
)
|
|
101
121
|
|
|
@@ -114,7 +134,7 @@ export const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined>
|
|
|
114
134
|
}
|
|
115
135
|
}
|
|
116
136
|
|
|
117
|
-
export const unplugin = createUnplugin(unpluginFactory)
|
|
137
|
+
export const unplugin: UnpluginInstance<UnpluginStylexOptions | undefined, boolean> = createUnplugin(unpluginFactory)
|
|
118
138
|
|
|
119
139
|
export * from './types'
|
|
120
140
|
|
package/src/rollup.ts
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This entry file is for Rollup plugin.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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)
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Rollup plugin
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
*
|
|
19
|
+
* import stylexPlugin from 'unplugin-stylex/rollup'
|
|
20
|
+
*
|
|
21
|
+
* export default {
|
|
22
|
+
* plugins: [
|
|
23
|
+
* stylexPlugin(),
|
|
24
|
+
* ],
|
|
25
|
+
* }
|
|
26
|
+
*/
|
|
27
|
+
export default rollupPlugin
|
package/src/rspack.ts
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This entry file is for Rspac plugin.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
|
|
1
7
|
import { createRspackPlugin } from 'unplugin'
|
|
2
|
-
import {
|
|
8
|
+
import type { RspackPluginInstance } from 'unplugin'
|
|
9
|
+
import { unpluginFactory } from './index'
|
|
10
|
+
import type { UnpluginStylexInstance } from './types'
|
|
11
|
+
|
|
12
|
+
type RspackPluginType = UnpluginStylexInstance<RspackPluginInstance | RspackPluginInstance[]>
|
|
13
|
+
|
|
14
|
+
const rspackPlugin: RspackPluginType = createRspackPlugin(unpluginFactory)
|
|
3
15
|
|
|
4
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Rsapck plugin
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
*
|
|
21
|
+
* import stylexPlugin from 'unplugin-stylex/rspack'
|
|
22
|
+
*
|
|
23
|
+
* module.exports = {
|
|
24
|
+
* plugins: [
|
|
25
|
+
* stylexPlugin(),
|
|
26
|
+
* ],
|
|
27
|
+
* }
|
|
28
|
+
*/
|
|
29
|
+
export default rspackPlugin
|
package/src/types.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type StylexOptions = {
|
|
|
10
10
|
classNamePrefix?: string
|
|
11
11
|
useCSSLayers?: boolean
|
|
12
12
|
unstable_moduleResolution?: {
|
|
13
|
-
type:
|
|
13
|
+
type: 'commonjs' | 'haste'
|
|
14
14
|
rootDir: string
|
|
15
15
|
}
|
|
16
16
|
babelConfig?: BabelConfig
|
|
@@ -21,6 +21,8 @@ export type StylexOptions = {
|
|
|
21
21
|
export type UnpluginStylexOptions = {
|
|
22
22
|
compiler?: string
|
|
23
23
|
dev?: boolean
|
|
24
|
-
enforce?:
|
|
24
|
+
enforce?: 'post' | 'pre'
|
|
25
25
|
stylex?: StylexOptions
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
export type UnpluginStylexInstance<T> = (options?: UnpluginStylexOptions) => T
|
package/src/vite.ts
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This entry file is for Vite plugin.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
|
|
1
7
|
import { createVitePlugin } from 'unplugin'
|
|
2
|
-
import {
|
|
8
|
+
import type { VitePlugin } from 'unplugin'
|
|
9
|
+
import { unpluginFactory } from './index'
|
|
10
|
+
import type { UnpluginStylexInstance } from './types'
|
|
11
|
+
|
|
12
|
+
const vitePlugin: UnpluginStylexInstance<VitePlugin | VitePlugin[]> = createVitePlugin(unpluginFactory)
|
|
3
13
|
|
|
4
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Vite example
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
*
|
|
19
|
+
* import { defineConfig } from 'vite'
|
|
20
|
+
* import stylexPlugin from 'unplugin-stylex/vite'
|
|
21
|
+
*
|
|
22
|
+
* export default defineConfig({
|
|
23
|
+
* plugins: [
|
|
24
|
+
* stylexPlugin(),
|
|
25
|
+
* ],
|
|
26
|
+
* })
|
|
27
|
+
*/
|
|
28
|
+
export default vitePlugin
|
package/src/webpack.ts
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* This entry file is for Webpack plugin.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
2
6
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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)
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Webpack plugin
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
*
|
|
19
|
+
* import stylexPlugin from 'unplugin-stylex/webpack'
|
|
20
|
+
*
|
|
21
|
+
* module.exports = {
|
|
22
|
+
* plugins: [
|
|
23
|
+
* stylexPlugin(),
|
|
24
|
+
* ],
|
|
25
|
+
* }
|
|
26
|
+
*/
|
|
27
|
+
export default webpackPlugin
|
package/typos.toml
ADDED
package/vitest.config.ts
CHANGED
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;
|