unplugin-stylex 0.0.1 → 0.1.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/.eslintignore +4 -0
- package/.eslintrc.json +12 -1
- package/.github/actions/setup-and-cache/action.yml +18 -0
- package/.github/workflows/ci.yml +43 -0
- package/.github/workflows/release.yml +26 -0
- package/dist/chunk-6F4PWJZI.js +0 -0
- package/dist/chunk-7MXMBS5H.js +190 -0
- package/dist/chunk-NVMQARFA.cjs +190 -0
- package/dist/chunk-ZBPRDZS4.cjs +1 -0
- package/dist/esbuild.cjs +3 -2
- package/dist/esbuild.d.cts +0 -1
- package/dist/esbuild.d.ts +0 -1
- package/dist/esbuild.js +2 -1
- package/dist/index.cjs +3 -2
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -1
- package/dist/rspack.cjs +3 -2
- package/dist/rspack.d.cts +4 -1
- package/dist/rspack.d.ts +4 -1
- package/dist/rspack.js +2 -1
- package/dist/types.cjs +1 -1
- package/dist/types.d.cts +6 -7
- package/dist/types.d.ts +6 -7
- package/dist/types.js +1 -0
- package/dist/vite.cjs +3 -2
- package/dist/vite.d.cts +4 -1
- package/dist/vite.d.ts +4 -1
- package/dist/vite.js +2 -1
- package/package.json +19 -11
- package/src/core/build.ts +9 -0
- package/src/core/{utils.ts → options.ts} +9 -9
- package/src/core/plugins.ts +12 -0
- package/src/core/transformer.ts +31 -48
- package/src/index.ts +77 -17
- package/src/rspack.ts +1 -1
- package/src/types.ts +6 -7
- package/src/vite.ts +1 -1
- package/tsconfig.json +5 -0
- package/vitest.config.ts +13 -0
- package/dist/chunk-5FLQNHMU.cjs +0 -131
- package/dist/chunk-R3ITJTXO.js +0 -131
package/.eslintignore
ADDED
package/.eslintrc.json
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
{
|
|
2
|
+
"env": {
|
|
3
|
+
"node": true
|
|
4
|
+
},
|
|
5
|
+
"extends": [
|
|
6
|
+
"eslint:recommended",
|
|
7
|
+
"plugin:@typescript-eslint/recommended"
|
|
8
|
+
],
|
|
9
|
+
"parser": "@typescript-eslint/parser",
|
|
10
|
+
"plugins": ["@typescript-eslint"],
|
|
11
|
+
"root": true,
|
|
2
12
|
"rules": {
|
|
3
|
-
"semi":
|
|
13
|
+
"semi": "off",
|
|
14
|
+
"@typescript-eslint/no-explicit-any": "off"
|
|
4
15
|
}
|
|
5
16
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
name: Setup and Cache
|
|
2
|
+
description: Setup for node, pnpm and cache for browser testing binaries
|
|
3
|
+
inputs:
|
|
4
|
+
node-version:
|
|
5
|
+
required: false
|
|
6
|
+
description: Node version for setup-node
|
|
7
|
+
default: 20.x
|
|
8
|
+
|
|
9
|
+
runs:
|
|
10
|
+
using: composite
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- name: install pnpm
|
|
14
|
+
uses: pnpm/action-setup@v2
|
|
15
|
+
- name: Set node version to ${{ inputs.node-version }}
|
|
16
|
+
uses: actions/setup-node@v4
|
|
17
|
+
with:
|
|
18
|
+
node-version: ${{ inputs.node-version }}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
|
|
7
|
+
pull_request:
|
|
8
|
+
branches: [main]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
lint:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- uses: ./.github/actions/setup-and-cache
|
|
17
|
+
|
|
18
|
+
- name: Install
|
|
19
|
+
run: pnpm i
|
|
20
|
+
|
|
21
|
+
- name: Lint
|
|
22
|
+
run: pnpm run check
|
|
23
|
+
|
|
24
|
+
test:
|
|
25
|
+
runs-on: ${{ matrix.os }}
|
|
26
|
+
|
|
27
|
+
strategy:
|
|
28
|
+
matrix:
|
|
29
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
30
|
+
node: [16, 18, 20]
|
|
31
|
+
|
|
32
|
+
steps:
|
|
33
|
+
- uses: actions/checkout@v4
|
|
34
|
+
|
|
35
|
+
- uses: ./.github/actions/setup-and-cache
|
|
36
|
+
with:
|
|
37
|
+
node-version: ${{ matrix.node }}
|
|
38
|
+
|
|
39
|
+
- name: Install
|
|
40
|
+
run: pnpm i
|
|
41
|
+
|
|
42
|
+
- name: Unit Test
|
|
43
|
+
run: pnpm run test
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
permissions:
|
|
4
|
+
contents: write
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
tags:
|
|
9
|
+
- 'v*'
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
release:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
with:
|
|
17
|
+
fetch-depth: 0
|
|
18
|
+
|
|
19
|
+
- name: Set node
|
|
20
|
+
uses: actions/setup-node@v4
|
|
21
|
+
with:
|
|
22
|
+
node-version: lts/*
|
|
23
|
+
|
|
24
|
+
- run: npx changelogithub
|
|
25
|
+
env:
|
|
26
|
+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
File without changes
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import {
|
|
2
|
+
PLUGIN_NAME,
|
|
3
|
+
isDevelopment
|
|
4
|
+
} from "./chunk-36ARBXVP.js";
|
|
5
|
+
|
|
6
|
+
// src/index.ts
|
|
7
|
+
import * as path from "node:path";
|
|
8
|
+
import { createUnplugin } from "unplugin";
|
|
9
|
+
|
|
10
|
+
// src/core/build.ts
|
|
11
|
+
import stylex from "@stylexjs/babel-plugin";
|
|
12
|
+
function buildStylexRules(stylexRules, useCSSLayers) {
|
|
13
|
+
const rules = Object.values(stylexRules).flat();
|
|
14
|
+
if (rules.length === 0)
|
|
15
|
+
return "";
|
|
16
|
+
return stylex.processStylexRules(rules, useCSSLayers);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// src/core/options.ts
|
|
20
|
+
function getOptions(options) {
|
|
21
|
+
const stylex2 = options.stylex || {};
|
|
22
|
+
const isDev = options.dev || isDevelopment;
|
|
23
|
+
return {
|
|
24
|
+
...options,
|
|
25
|
+
dev: options.dev || isDev,
|
|
26
|
+
stylex: {
|
|
27
|
+
filename: stylex2.filename || "stylex.css",
|
|
28
|
+
stylexImports: stylex2.stylexImports || ["@stylexjs/stylex"],
|
|
29
|
+
runtimeInjection: stylex2.runtimeInjection ?? isDev,
|
|
30
|
+
aliases: stylex2.aliases,
|
|
31
|
+
useCSSLayers: stylex2.useCSSLayers || false,
|
|
32
|
+
unstable_moduleResolution: stylex2.unstable_moduleResolution || { type: "commonJS", rootDir: process.cwd() },
|
|
33
|
+
babelConfig: {
|
|
34
|
+
babelrc: (stylex2.babelConfig || {}).babelrc || false,
|
|
35
|
+
plugins: (stylex2.babelConfig || {}).plugins || [],
|
|
36
|
+
presets: (stylex2.babelConfig || {}).presets || []
|
|
37
|
+
},
|
|
38
|
+
...stylex2
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/core/transformer.ts
|
|
44
|
+
import { extname as pathExtname } from "node:path";
|
|
45
|
+
import { transformAsync } from "@babel/core";
|
|
46
|
+
import jsxSyntaxPlugin from "@babel/plugin-syntax-jsx";
|
|
47
|
+
import stylexBabelPlugin from "@stylexjs/babel-plugin";
|
|
48
|
+
|
|
49
|
+
// src/core/plugins.ts
|
|
50
|
+
import typescriptSyntaxPlugin from "@babel/plugin-syntax-typescript";
|
|
51
|
+
import flowSyntaxPlugin from "@babel/plugin-syntax-flow";
|
|
52
|
+
function getSyntaxPlugins(extname) {
|
|
53
|
+
const TSPlugin = extname === ".tsx" ? [[typescriptSyntaxPlugin, { isTSX: true }]] : [typescriptSyntaxPlugin];
|
|
54
|
+
return [".js", ".jsx"].includes(extname) ? [flowSyntaxPlugin] : TSPlugin;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// src/core/transformer.ts
|
|
58
|
+
async function transformer(context) {
|
|
59
|
+
var _a, _b, _c, _d;
|
|
60
|
+
const { id, inputCode, options } = context;
|
|
61
|
+
const stylex2 = options.stylex;
|
|
62
|
+
const extname = pathExtname(id);
|
|
63
|
+
const stylexRules = {};
|
|
64
|
+
const stylexBabelPluginOptions = {
|
|
65
|
+
dev: options.dev,
|
|
66
|
+
importSources: stylex2.stylexImports,
|
|
67
|
+
...stylex2
|
|
68
|
+
};
|
|
69
|
+
const plugins = [
|
|
70
|
+
...((_a = stylex2.babelConfig) == null ? void 0 : _a.plugins) || [],
|
|
71
|
+
...getSyntaxPlugins(extname),
|
|
72
|
+
jsxSyntaxPlugin,
|
|
73
|
+
stylexBabelPlugin.withOptions(stylexBabelPluginOptions)
|
|
74
|
+
];
|
|
75
|
+
const { code, map, metadata } = await transformAsync(
|
|
76
|
+
inputCode,
|
|
77
|
+
{
|
|
78
|
+
babelrc: (_b = stylex2.babelConfig) == null ? void 0 : _b.babelrc,
|
|
79
|
+
filename: id,
|
|
80
|
+
presets: (_c = stylex2.babelConfig) == null ? void 0 : _c.presets,
|
|
81
|
+
plugins
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
if (metadata.stylex && metadata.stylex.length > 0) {
|
|
85
|
+
stylexRules[id] = metadata.stylex;
|
|
86
|
+
}
|
|
87
|
+
if (!((_d = stylex2.babelConfig) == null ? void 0 : _d.babelrc)) {
|
|
88
|
+
return { code, map, stylexRules };
|
|
89
|
+
}
|
|
90
|
+
return { code, stylexRules };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// src/index.ts
|
|
94
|
+
var unpluginFactory = (rawOptions = {}) => {
|
|
95
|
+
const options = getOptions(rawOptions);
|
|
96
|
+
const stylexRules = {};
|
|
97
|
+
let viteConfig = null;
|
|
98
|
+
return {
|
|
99
|
+
name: PLUGIN_NAME,
|
|
100
|
+
async transform(code, id) {
|
|
101
|
+
const dir = path.dirname(id);
|
|
102
|
+
const basename2 = path.basename(id);
|
|
103
|
+
const file = path.join(dir, basename2.includes("?") ? basename2.split("?")[0] : basename2);
|
|
104
|
+
if (!options.stylex.stylexImports.some((importName) => code.includes(importName))) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const context = {
|
|
108
|
+
id: file,
|
|
109
|
+
inputCode: code,
|
|
110
|
+
pluginContext: this,
|
|
111
|
+
options
|
|
112
|
+
};
|
|
113
|
+
try {
|
|
114
|
+
const result = await transformer(context);
|
|
115
|
+
if (result.stylexRules && result.stylexRules[id]) {
|
|
116
|
+
stylexRules[id] = result.stylexRules[id];
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error("transform::error::", error);
|
|
121
|
+
this.error(error);
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
buildEnd() {
|
|
125
|
+
const fileName = options.stylex.filename;
|
|
126
|
+
const collectedCSS = buildStylexRules(stylexRules, options.stylex.useCSSLayers);
|
|
127
|
+
if (!collectedCSS)
|
|
128
|
+
return;
|
|
129
|
+
this.emitFile({
|
|
130
|
+
fileName,
|
|
131
|
+
source: collectedCSS,
|
|
132
|
+
type: "asset"
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
vite: {
|
|
136
|
+
config(config) {
|
|
137
|
+
viteConfig = {
|
|
138
|
+
build: config.build,
|
|
139
|
+
base: config.base
|
|
140
|
+
};
|
|
141
|
+
},
|
|
142
|
+
configResolved(config) {
|
|
143
|
+
config.optimizeDeps.exclude = config.optimizeDeps.exclude || [];
|
|
144
|
+
config.optimizeDeps.exclude.push("@stylexjs/open-props");
|
|
145
|
+
},
|
|
146
|
+
buildEnd() {
|
|
147
|
+
var _a;
|
|
148
|
+
const fileName = `${((_a = viteConfig.build) == null ? void 0 : _a.assetsDir) ?? "assets"}/${options.stylex.filename}`;
|
|
149
|
+
const collectedCSS = buildStylexRules(stylexRules, options.stylex.useCSSLayers);
|
|
150
|
+
if (!collectedCSS)
|
|
151
|
+
return;
|
|
152
|
+
this.emitFile({
|
|
153
|
+
fileName,
|
|
154
|
+
source: collectedCSS,
|
|
155
|
+
type: "asset"
|
|
156
|
+
});
|
|
157
|
+
},
|
|
158
|
+
transformIndexHtml(html, ctx) {
|
|
159
|
+
var _a, _b;
|
|
160
|
+
const fileName = `${((_a = viteConfig.build) == null ? void 0 : _a.assetsDir) ?? "assets"}/${options.stylex.filename}`;
|
|
161
|
+
const css = (_b = ctx.bundle) == null ? void 0 : _b[fileName];
|
|
162
|
+
if (!css) {
|
|
163
|
+
return html;
|
|
164
|
+
}
|
|
165
|
+
const publicPath = path.posix.join(
|
|
166
|
+
viteConfig.base ?? "/",
|
|
167
|
+
fileName.replace(/\\/g, "/")
|
|
168
|
+
);
|
|
169
|
+
return [
|
|
170
|
+
{
|
|
171
|
+
tag: "link",
|
|
172
|
+
attrs: {
|
|
173
|
+
rel: "stylesheet",
|
|
174
|
+
href: publicPath
|
|
175
|
+
},
|
|
176
|
+
injectTo: "head"
|
|
177
|
+
}
|
|
178
|
+
];
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
var unplugin = createUnplugin(unpluginFactory);
|
|
184
|
+
var src_default = unplugin;
|
|
185
|
+
|
|
186
|
+
export {
|
|
187
|
+
unpluginFactory,
|
|
188
|
+
unplugin,
|
|
189
|
+
src_default
|
|
190
|
+
};
|
|
@@ -0,0 +1,190 @@
|
|
|
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
|
|
7
|
+
var _path = require('path'); var path = _interopRequireWildcard(_path);
|
|
8
|
+
var _unplugin = require('unplugin');
|
|
9
|
+
|
|
10
|
+
// src/core/build.ts
|
|
11
|
+
var _babelplugin = require('@stylexjs/babel-plugin'); var _babelplugin2 = _interopRequireDefault(_babelplugin);
|
|
12
|
+
function buildStylexRules(stylexRules, useCSSLayers) {
|
|
13
|
+
const rules = Object.values(stylexRules).flat();
|
|
14
|
+
if (rules.length === 0)
|
|
15
|
+
return "";
|
|
16
|
+
return _babelplugin2.default.processStylexRules(rules, useCSSLayers);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// src/core/options.ts
|
|
20
|
+
function getOptions(options) {
|
|
21
|
+
const stylex2 = options.stylex || {};
|
|
22
|
+
const isDev = options.dev || _chunkN4Z3Z2PUcjs.isDevelopment;
|
|
23
|
+
return {
|
|
24
|
+
...options,
|
|
25
|
+
dev: options.dev || isDev,
|
|
26
|
+
stylex: {
|
|
27
|
+
filename: stylex2.filename || "stylex.css",
|
|
28
|
+
stylexImports: stylex2.stylexImports || ["@stylexjs/stylex"],
|
|
29
|
+
runtimeInjection: _nullishCoalesce(stylex2.runtimeInjection, () => ( isDev)),
|
|
30
|
+
aliases: stylex2.aliases,
|
|
31
|
+
useCSSLayers: stylex2.useCSSLayers || false,
|
|
32
|
+
unstable_moduleResolution: stylex2.unstable_moduleResolution || { type: "commonJS", rootDir: process.cwd() },
|
|
33
|
+
babelConfig: {
|
|
34
|
+
babelrc: (stylex2.babelConfig || {}).babelrc || false,
|
|
35
|
+
plugins: (stylex2.babelConfig || {}).plugins || [],
|
|
36
|
+
presets: (stylex2.babelConfig || {}).presets || []
|
|
37
|
+
},
|
|
38
|
+
...stylex2
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/core/transformer.ts
|
|
44
|
+
|
|
45
|
+
var _core = require('@babel/core');
|
|
46
|
+
var _pluginsyntaxjsx = require('@babel/plugin-syntax-jsx'); var _pluginsyntaxjsx2 = _interopRequireDefault(_pluginsyntaxjsx);
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
// src/core/plugins.ts
|
|
50
|
+
var _pluginsyntaxtypescript = require('@babel/plugin-syntax-typescript'); var _pluginsyntaxtypescript2 = _interopRequireDefault(_pluginsyntaxtypescript);
|
|
51
|
+
var _pluginsyntaxflow = require('@babel/plugin-syntax-flow'); var _pluginsyntaxflow2 = _interopRequireDefault(_pluginsyntaxflow);
|
|
52
|
+
function getSyntaxPlugins(extname) {
|
|
53
|
+
const TSPlugin = extname === ".tsx" ? [[_pluginsyntaxtypescript2.default, { isTSX: true }]] : [_pluginsyntaxtypescript2.default];
|
|
54
|
+
return [".js", ".jsx"].includes(extname) ? [_pluginsyntaxflow2.default] : TSPlugin;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// src/core/transformer.ts
|
|
58
|
+
async function transformer(context) {
|
|
59
|
+
var _a, _b, _c, _d;
|
|
60
|
+
const { id, inputCode, options } = context;
|
|
61
|
+
const stylex2 = options.stylex;
|
|
62
|
+
const extname = _path.extname.call(void 0, id);
|
|
63
|
+
const stylexRules = {};
|
|
64
|
+
const stylexBabelPluginOptions = {
|
|
65
|
+
dev: options.dev,
|
|
66
|
+
importSources: stylex2.stylexImports,
|
|
67
|
+
...stylex2
|
|
68
|
+
};
|
|
69
|
+
const plugins = [
|
|
70
|
+
...((_a = stylex2.babelConfig) == null ? void 0 : _a.plugins) || [],
|
|
71
|
+
...getSyntaxPlugins(extname),
|
|
72
|
+
_pluginsyntaxjsx2.default,
|
|
73
|
+
_babelplugin2.default.withOptions(stylexBabelPluginOptions)
|
|
74
|
+
];
|
|
75
|
+
const { code, map, metadata } = await _core.transformAsync.call(void 0,
|
|
76
|
+
inputCode,
|
|
77
|
+
{
|
|
78
|
+
babelrc: (_b = stylex2.babelConfig) == null ? void 0 : _b.babelrc,
|
|
79
|
+
filename: id,
|
|
80
|
+
presets: (_c = stylex2.babelConfig) == null ? void 0 : _c.presets,
|
|
81
|
+
plugins
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
if (metadata.stylex && metadata.stylex.length > 0) {
|
|
85
|
+
stylexRules[id] = metadata.stylex;
|
|
86
|
+
}
|
|
87
|
+
if (!((_d = stylex2.babelConfig) == null ? void 0 : _d.babelrc)) {
|
|
88
|
+
return { code, map, stylexRules };
|
|
89
|
+
}
|
|
90
|
+
return { code, stylexRules };
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// src/index.ts
|
|
94
|
+
var unpluginFactory = (rawOptions = {}) => {
|
|
95
|
+
const options = getOptions(rawOptions);
|
|
96
|
+
const stylexRules = {};
|
|
97
|
+
let viteConfig = null;
|
|
98
|
+
return {
|
|
99
|
+
name: _chunkN4Z3Z2PUcjs.PLUGIN_NAME,
|
|
100
|
+
async transform(code, id) {
|
|
101
|
+
const dir = path.dirname(id);
|
|
102
|
+
const basename2 = path.basename(id);
|
|
103
|
+
const file = path.join(dir, basename2.includes("?") ? basename2.split("?")[0] : basename2);
|
|
104
|
+
if (!options.stylex.stylexImports.some((importName) => code.includes(importName))) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const context = {
|
|
108
|
+
id: file,
|
|
109
|
+
inputCode: code,
|
|
110
|
+
pluginContext: this,
|
|
111
|
+
options
|
|
112
|
+
};
|
|
113
|
+
try {
|
|
114
|
+
const result = await transformer(context);
|
|
115
|
+
if (result.stylexRules && result.stylexRules[id]) {
|
|
116
|
+
stylexRules[id] = result.stylexRules[id];
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error("transform::error::", error);
|
|
121
|
+
this.error(error);
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
buildEnd() {
|
|
125
|
+
const fileName = options.stylex.filename;
|
|
126
|
+
const collectedCSS = buildStylexRules(stylexRules, options.stylex.useCSSLayers);
|
|
127
|
+
if (!collectedCSS)
|
|
128
|
+
return;
|
|
129
|
+
this.emitFile({
|
|
130
|
+
fileName,
|
|
131
|
+
source: collectedCSS,
|
|
132
|
+
type: "asset"
|
|
133
|
+
});
|
|
134
|
+
},
|
|
135
|
+
vite: {
|
|
136
|
+
config(config) {
|
|
137
|
+
viteConfig = {
|
|
138
|
+
build: config.build,
|
|
139
|
+
base: config.base
|
|
140
|
+
};
|
|
141
|
+
},
|
|
142
|
+
configResolved(config) {
|
|
143
|
+
config.optimizeDeps.exclude = config.optimizeDeps.exclude || [];
|
|
144
|
+
config.optimizeDeps.exclude.push("@stylexjs/open-props");
|
|
145
|
+
},
|
|
146
|
+
buildEnd() {
|
|
147
|
+
var _a;
|
|
148
|
+
const fileName = `${_nullishCoalesce(((_a = viteConfig.build) == null ? void 0 : _a.assetsDir), () => ( "assets"))}/${options.stylex.filename}`;
|
|
149
|
+
const collectedCSS = buildStylexRules(stylexRules, options.stylex.useCSSLayers);
|
|
150
|
+
if (!collectedCSS)
|
|
151
|
+
return;
|
|
152
|
+
this.emitFile({
|
|
153
|
+
fileName,
|
|
154
|
+
source: collectedCSS,
|
|
155
|
+
type: "asset"
|
|
156
|
+
});
|
|
157
|
+
},
|
|
158
|
+
transformIndexHtml(html, ctx) {
|
|
159
|
+
var _a, _b;
|
|
160
|
+
const fileName = `${_nullishCoalesce(((_a = viteConfig.build) == null ? void 0 : _a.assetsDir), () => ( "assets"))}/${options.stylex.filename}`;
|
|
161
|
+
const css = (_b = ctx.bundle) == null ? void 0 : _b[fileName];
|
|
162
|
+
if (!css) {
|
|
163
|
+
return html;
|
|
164
|
+
}
|
|
165
|
+
const publicPath = path.posix.join(
|
|
166
|
+
_nullishCoalesce(viteConfig.base, () => ( "/")),
|
|
167
|
+
fileName.replace(/\\/g, "/")
|
|
168
|
+
);
|
|
169
|
+
return [
|
|
170
|
+
{
|
|
171
|
+
tag: "link",
|
|
172
|
+
attrs: {
|
|
173
|
+
rel: "stylesheet",
|
|
174
|
+
href: publicPath
|
|
175
|
+
},
|
|
176
|
+
injectTo: "head"
|
|
177
|
+
}
|
|
178
|
+
];
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
var unplugin = _unplugin.createUnplugin.call(void 0, unpluginFactory);
|
|
184
|
+
var src_default = unplugin;
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
exports.unpluginFactory = unpluginFactory; exports.unplugin = unplugin; exports.src_default = src_default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/dist/esbuild.cjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkNVMQARFAcjs = require('./chunk-NVMQARFA.cjs');
|
|
4
|
+
require('./chunk-ZBPRDZS4.cjs');
|
|
4
5
|
require('./chunk-N4Z3Z2PU.cjs');
|
|
5
6
|
|
|
6
7
|
// src/esbuild.ts
|
|
7
8
|
var _unplugin = require('unplugin');
|
|
8
|
-
var esbuild_default = _unplugin.createEsbuildPlugin.call(void 0,
|
|
9
|
+
var esbuild_default = _unplugin.createEsbuildPlugin.call(void 0, _chunkNVMQARFAcjs.unpluginFactory);
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
exports.default = esbuild_default;
|
package/dist/esbuild.d.cts
CHANGED
package/dist/esbuild.d.ts
CHANGED
package/dist/esbuild.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -2,10 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkNVMQARFAcjs = require('./chunk-NVMQARFA.cjs');
|
|
6
|
+
require('./chunk-ZBPRDZS4.cjs');
|
|
6
7
|
require('./chunk-N4Z3Z2PU.cjs');
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
|
|
11
|
-
exports.default =
|
|
12
|
+
exports.default = _chunkNVMQARFAcjs.src_default; exports.unplugin = _chunkNVMQARFAcjs.unplugin; exports.unpluginFactory = _chunkNVMQARFAcjs.unpluginFactory;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as unplugin$1 from 'unplugin';
|
|
2
2
|
import { UnpluginFactory } from 'unplugin';
|
|
3
3
|
import { UnpluginStylexOptions } from './types.cjs';
|
|
4
|
-
|
|
4
|
+
export { BabelConfig, StylexOptions } from './types.cjs';
|
|
5
5
|
|
|
6
6
|
declare const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined>;
|
|
7
7
|
declare const unplugin: unplugin$1.UnpluginInstance<UnpluginStylexOptions, boolean>;
|
|
8
8
|
|
|
9
|
-
export { unplugin as default, unplugin, unpluginFactory };
|
|
9
|
+
export { UnpluginStylexOptions, unplugin as default, unplugin, unpluginFactory };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as unplugin$1 from 'unplugin';
|
|
2
2
|
import { UnpluginFactory } from 'unplugin';
|
|
3
3
|
import { UnpluginStylexOptions } from './types.js';
|
|
4
|
-
|
|
4
|
+
export { BabelConfig, StylexOptions } from './types.js';
|
|
5
5
|
|
|
6
6
|
declare const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined>;
|
|
7
7
|
declare const unplugin: unplugin$1.UnpluginInstance<UnpluginStylexOptions, boolean>;
|
|
8
8
|
|
|
9
|
-
export { unplugin as default, unplugin, unpluginFactory };
|
|
9
|
+
export { UnpluginStylexOptions, unplugin as default, unplugin, unpluginFactory };
|
package/dist/index.js
CHANGED
package/dist/rspack.cjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkNVMQARFAcjs = require('./chunk-NVMQARFA.cjs');
|
|
4
|
+
require('./chunk-ZBPRDZS4.cjs');
|
|
4
5
|
require('./chunk-N4Z3Z2PU.cjs');
|
|
5
6
|
|
|
6
7
|
// src/rspack.ts
|
|
7
8
|
var _unplugin = require('unplugin');
|
|
8
|
-
var rspack_default = _unplugin.createRspackPlugin.call(void 0,
|
|
9
|
+
var rspack_default = _unplugin.createRspackPlugin.call(void 0, _chunkNVMQARFAcjs.unpluginFactory);
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
exports.default = rspack_default;
|
package/dist/rspack.d.cts
CHANGED
package/dist/rspack.d.ts
CHANGED
package/dist/rspack.js
CHANGED
package/dist/types.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";require('./chunk-ZBPRDZS4.cjs');
|
package/dist/types.d.cts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { FilterPattern } from '@rollup/pluginutils';
|
|
2
|
-
|
|
3
1
|
type BabelConfig = {
|
|
4
|
-
plugins:
|
|
5
|
-
presets:
|
|
2
|
+
plugins: unknown[];
|
|
3
|
+
presets: unknown[];
|
|
6
4
|
babelrc: boolean;
|
|
7
5
|
};
|
|
8
6
|
type StylexOptions = {
|
|
@@ -15,13 +13,14 @@ type StylexOptions = {
|
|
|
15
13
|
rootDir: string;
|
|
16
14
|
};
|
|
17
15
|
babelConfig?: BabelConfig;
|
|
16
|
+
runtimeInjection: boolean;
|
|
17
|
+
aliases?: string[];
|
|
18
18
|
};
|
|
19
19
|
type UnpluginStylexOptions = {
|
|
20
|
+
compiler?: string;
|
|
20
21
|
dev?: boolean;
|
|
21
|
-
include?: FilterPattern;
|
|
22
|
-
exclude?: FilterPattern;
|
|
23
22
|
enforce?: "post" | "pre";
|
|
24
23
|
stylex?: StylexOptions;
|
|
25
24
|
};
|
|
26
25
|
|
|
27
|
-
export type { BabelConfig, UnpluginStylexOptions };
|
|
26
|
+
export type { BabelConfig, StylexOptions, UnpluginStylexOptions };
|