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/dist/types.d.ts CHANGED
@@ -1,8 +1,6 @@
1
- import { FilterPattern } from '@rollup/pluginutils';
2
-
3
1
  type BabelConfig = {
4
- plugins: any[];
5
- presets: any[];
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 };
package/dist/types.js CHANGED
@@ -0,0 +1 @@
1
+ import "./chunk-6F4PWJZI.js";
package/dist/vite.cjs CHANGED
@@ -1,11 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunk5FLQNHMUcjs = require('./chunk-5FLQNHMU.cjs');
3
+ var _chunkNVMQARFAcjs = require('./chunk-NVMQARFA.cjs');
4
+ require('./chunk-ZBPRDZS4.cjs');
4
5
  require('./chunk-N4Z3Z2PU.cjs');
5
6
 
6
7
  // src/vite.ts
7
8
  var _unplugin = require('unplugin');
8
- var vite_default = _unplugin.createVitePlugin.call(void 0, _chunk5FLQNHMUcjs.unpluginFactory);
9
+ var vite_default = _unplugin.createVitePlugin.call(void 0, _chunkNVMQARFAcjs.unpluginFactory);
9
10
 
10
11
 
11
12
  exports.default = vite_default;
package/dist/vite.d.cts CHANGED
@@ -1,3 +1,6 @@
1
- declare const _default: any;
1
+ import * as vite from 'vite';
2
+ import { UnpluginStylexOptions } from './types.cjs';
3
+
4
+ declare const _default: (options?: UnpluginStylexOptions) => vite.Plugin<any> | vite.Plugin<any>[];
2
5
 
3
6
  export { _default as default };
package/dist/vite.d.ts CHANGED
@@ -1,3 +1,6 @@
1
- declare const _default: any;
1
+ import * as vite from 'vite';
2
+ import { UnpluginStylexOptions } from './types.js';
3
+
4
+ declare const _default: (options?: UnpluginStylexOptions) => vite.Plugin<any> | vite.Plugin<any>[];
2
5
 
3
6
  export { _default as default };
package/dist/vite.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  unpluginFactory
3
- } from "./chunk-R3ITJTXO.js";
3
+ } from "./chunk-7MXMBS5H.js";
4
+ import "./chunk-6F4PWJZI.js";
4
5
  import "./chunk-36ARBXVP.js";
5
6
 
6
7
  // src/vite.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "unplugin-stylex",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "packageManager": "pnpm@8.11.0",
5
5
  "description": "Unplugin for stylex",
6
6
  "repository": "https://github.com/eryue0220/unplugin-stylex",
@@ -46,13 +46,6 @@
46
46
  },
47
47
  "./*": "./*"
48
48
  },
49
- "scripts": {
50
- "dev": "tsup src/*ts --watch src",
51
- "build": "tsup src/*.ts --format cjs,esm --dts --splitting --clean",
52
- "test": "vitest",
53
- "test:update": "vitest -u",
54
- "test:coverage": "vitest --coverage"
55
- },
56
49
  "engines": {
57
50
  "node": ">=16.14.0"
58
51
  },
@@ -62,14 +55,29 @@
62
55
  "@babel/plugin-syntax-jsx": "^7.23.3",
63
56
  "@babel/plugin-syntax-typescript": "^7.23.3",
64
57
  "@rollup/pluginutils": "^5.1.0",
65
- "@stylexjs/babel-plugin": "^0.3.0",
66
- "unplugin": "^1.5.1"
58
+ "@stylexjs/babel-plugin": "^0.5.1",
59
+ "unplugin": "^1.7.1"
67
60
  },
68
61
  "devDependencies": {
69
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",
70
68
  "tsup": "^8.0.1",
71
69
  "typescript": "^5.3.3",
72
70
  "vite": "^5.0.10",
73
71
  "vitest": "^1.1.0"
72
+ },
73
+ "scripts": {
74
+ "dev": "tsup src/*ts --watch src",
75
+ "build": "tsup src/*.ts --format cjs,esm --dts --splitting --clean",
76
+ "test": "vitest",
77
+ "test:update": "vitest -u",
78
+ "test:cov": "vitest --coverage",
79
+ "lint": "eslint . --ext .ts,.tsx,.js,.jsx",
80
+ "check": "pnpm run lint && pnpm run typecheck",
81
+ "typecheck": "tsc -p tsconfig.json --noEmit"
74
82
  }
75
- }
83
+ }
@@ -0,0 +1,9 @@
1
+ import stylex from '@stylexjs/babel-plugin'
2
+ import type { Rule } from '@stylexjs/babel-plugin'
3
+
4
+ export function buildStylexRules(stylexRules: { [key: string]: Rule[] }, useCSSLayers: boolean): string {
5
+ const rules = Object.values(stylexRules).flat()
6
+ if (rules.length === 0) return ''
7
+
8
+ return stylex.processStylexRules(rules, useCSSLayers)
9
+ }
@@ -1,19 +1,18 @@
1
- import type { UnpluginStylexOptions, BabelConfig } from '@/types'
1
+ import type { StylexOptions, UnpluginStylexOptions } from '@/types'
2
2
  import { isDevelopment } from './constants'
3
3
 
4
- export function getOptions(options: UnpluginStylexOptions = ({} as UnpluginStylexOptions)) {
5
- const stylex = options.stylex || {}
4
+ export function getOptions(options: UnpluginStylexOptions) {
5
+ const stylex = options.stylex || ({} as StylexOptions)
6
+ const isDev = options.dev || isDevelopment
6
7
 
7
8
  return {
8
9
  ...options,
9
- dev: options.dev || isDevelopment,
10
- include: options.include || [/\.[jt]sx?$/],
11
- exclude: options.exclude || [/node_modules/, /\.git/],
12
- enforce: options.enforce || 'pre',
10
+ dev: options.dev || isDev,
13
11
  stylex: {
14
- ...stylex,
15
12
  filename: stylex.filename || 'stylex.css',
16
- stylexImports: stylex.stylexImports || ['stylex', '@stylexjs/stylex'],
13
+ stylexImports: stylex.stylexImports || ['@stylexjs/stylex'],
14
+ runtimeInjection: stylex.runtimeInjection ?? isDev,
15
+ aliases: stylex.aliases,
17
16
  useCSSLayers: stylex.useCSSLayers || false,
18
17
  unstable_moduleResolution: stylex.unstable_moduleResolution || { type: 'commonJS', rootDir: process.cwd() },
19
18
  babelConfig: {
@@ -21,6 +20,7 @@ export function getOptions(options: UnpluginStylexOptions = ({} as UnpluginStyle
21
20
  plugins: (stylex.babelConfig || {}).plugins || [],
22
21
  presets: (stylex.babelConfig || {}).presets || [],
23
22
  },
23
+ ...stylex,
24
24
  },
25
25
  }
26
26
  }
@@ -0,0 +1,12 @@
1
+ import typescriptSyntaxPlugin from '@babel/plugin-syntax-typescript'
2
+ import flowSyntaxPlugin from '@babel/plugin-syntax-flow'
3
+
4
+ export function getSyntaxPlugins(extname: string) {
5
+ const TSPlugin = extname === '.tsx'
6
+ ? [[typescriptSyntaxPlugin, { isTSX: true }]]
7
+ : [typescriptSyntaxPlugin]
8
+
9
+ return ['.js', '.jsx'].includes(extname)
10
+ ? [flowSyntaxPlugin]
11
+ : TSPlugin
12
+ }
@@ -1,61 +1,44 @@
1
- import * as fs from 'fs/promises'
2
- import * as path from 'path'
3
-
1
+ import { extname as pathExtname } from 'node:path'
4
2
  import { transformAsync } from '@babel/core'
5
- import flowSyntaxPlugin from '@babel/plugin-syntax-flow'
6
3
  import jsxSyntaxPlugin from '@babel/plugin-syntax-jsx'
7
- import typescriptSyntaxPlugin from '@babel/plugin-syntax-typescript'
8
4
  import stylexBabelPlugin from '@stylexjs/babel-plugin'
9
5
 
6
+ import { getSyntaxPlugins } from './plugins'
7
+
10
8
  export async function transformer(context) {
11
- const { id, source, options } = context
9
+ const { id, inputCode, options } = context
12
10
  const stylex = options.stylex
13
- const extname = path.extname(id)
11
+ const extname = pathExtname(id)
14
12
  const stylexRules = {}
15
-
16
- if (stylex.stylexImports.some((importName) => source.includes(importName))) {
17
- const originSource = stylex.babelConfig.babelrc
18
- ? await fs.readFile(id, 'utf-8')
19
- : source
20
-
21
- const { code, map, metadata } = await transformAsync(
22
- originSource,
23
- {
24
- babelrc: stylex.babelConfig.babelrc,
25
- filename: id,
26
- plugins: [
27
- ...(stylex.babelConfig.plugins || []),
28
- extname === '.ts'
29
- ? typescriptSyntaxPlugin
30
- : extname === '.tsx'
31
- ? [typescriptSyntaxPlugin, { isTSX: true }]
32
- : flowSyntaxPlugin,
33
-
34
- jsxSyntaxPlugin,
35
- [
36
- stylexBabelPlugin,
37
- {
38
- dev: options.dev,
39
- unstable_moduleResolution: stylex.unstable_moduleResolution,
40
- importSources: stylex.stylexImports,
41
- ...stylex,
42
- }
43
- ],
44
- ],
45
- presets: stylex.babelConfig.presets,
46
- }
47
- )
48
-
49
- if (metadata.stylex && metadata.stylex.length > 0) {
50
- stylexRules[id] = metadata.stylex
13
+ const stylexBabelPluginOptions = {
14
+ dev: options.dev,
15
+ importSources: stylex.stylexImports,
16
+ ...stylex,
17
+ }
18
+ const plugins = [
19
+ ...(stylex.babelConfig?.plugins || []),
20
+ ...getSyntaxPlugins(extname),
21
+ jsxSyntaxPlugin,
22
+ stylexBabelPlugin.withOptions(stylexBabelPluginOptions),
23
+ ]
24
+
25
+ const { code, map, metadata } = await transformAsync(
26
+ inputCode,
27
+ {
28
+ babelrc: stylex.babelConfig?.babelrc,
29
+ filename: id,
30
+ presets: stylex.babelConfig?.presets,
31
+ plugins,
51
32
  }
33
+ )
52
34
 
53
- if (!stylex.babelConfig.babelrc) {
54
- return { code, map, stylexRules }
55
- }
35
+ if (metadata.stylex && metadata.stylex.length > 0) {
36
+ stylexRules[id] = metadata.stylex
37
+ }
56
38
 
57
- return { code, stylexRules }
39
+ if (!stylex.babelConfig?.babelrc) {
40
+ return { code, map, stylexRules }
58
41
  }
59
42
 
60
- return { code: source }
43
+ return { code, stylexRules }
61
44
  }
package/src/index.ts CHANGED
@@ -1,32 +1,36 @@
1
- import { createFilter } from '@rollup/pluginutils'
2
- import stylexBabelPlugin from '@stylexjs/babel-plugin'
1
+ import * as path from 'node:path'
2
+
3
3
  import { createUnplugin } from 'unplugin'
4
4
  import type { UnpluginFactory } from 'unplugin'
5
5
 
6
+ import { buildStylexRules } from './core/build'
6
7
  import { PLUGIN_NAME } from './core/constants'
7
- import { getOptions } from './core/utils'
8
+ import { getOptions } from './core/options'
8
9
  import { transformer } from './core/transformer'
9
10
  import type { UnpluginStylexOptions } from './types'
10
11
 
11
- export const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined> = (rawOptions = {}, meta) => {
12
+ export const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined> = (rawOptions = {}) => {
12
13
  const options = getOptions(rawOptions)
13
- const filter = createFilter(options.include, options.exclude)
14
14
  const stylexRules = {}
15
+ let viteConfig = null
15
16
 
16
17
  return {
17
18
  name: PLUGIN_NAME,
18
- enforce: options.enforce,
19
19
 
20
- transformInclude(id) {
21
- return filter(id)
22
- },
20
+ async transform(code, id) {
21
+ const dir = path.dirname(id)
22
+ const basename = path.basename(id)
23
+ const file = path.join(dir, basename.includes('?') ? basename.split('?')[0] : basename)
24
+
25
+ if (!options.stylex.stylexImports.some((importName) => code.includes(importName))) {
26
+ return
27
+ }
23
28
 
24
- async transform(source, id) {
25
29
  const context = {
30
+ id: file,
31
+ inputCode: code,
26
32
  pluginContext: this,
27
33
  options,
28
- source,
29
- id,
30
34
  }
31
35
 
32
36
  try {
@@ -38,24 +42,80 @@ export const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined>
38
42
 
39
43
  return result
40
44
  } catch (error) {
45
+ console.error('transform::error::', error)
41
46
  this.error(error)
42
47
  }
43
48
  },
44
49
 
45
50
  buildEnd() {
46
- const rules = Object.values(stylexRules).flat()
47
- if (rules.length > 0) {
48
- const collectedCSS = (stylexBabelPlugin as any).processStylexRules(rules, options.stylex.useCSSLayers)
51
+ const fileName = options.stylex.filename
52
+ const collectedCSS = buildStylexRules(stylexRules, options.stylex.useCSSLayers)
53
+
54
+ if (!collectedCSS) return
55
+
56
+ this.emitFile({
57
+ fileName,
58
+ source: collectedCSS,
59
+ type: 'asset',
60
+ })
61
+ },
62
+
63
+ vite: {
64
+ config(config) {
65
+ viteConfig = {
66
+ build: config.build,
67
+ base: config.base,
68
+ }
69
+ },
70
+
71
+ configResolved(config) {
72
+ config.optimizeDeps.exclude = config.optimizeDeps.exclude || []
73
+ config.optimizeDeps.exclude.push('@stylexjs/open-props')
74
+ },
75
+
76
+ buildEnd() {
77
+ const fileName = `${viteConfig.build?.assetsDir ?? 'assets'}/${options.stylex.filename}`
78
+ const collectedCSS = buildStylexRules(stylexRules, options.stylex.useCSSLayers)
79
+
80
+ if (!collectedCSS) return
81
+
49
82
  this.emitFile({
50
- fileName: options.stylex.filename,
83
+ fileName,
51
84
  source: collectedCSS,
52
85
  type: 'asset',
53
86
  })
54
- }
87
+ },
88
+
89
+ transformIndexHtml(html, ctx) {
90
+ const fileName = `${viteConfig.build?.assetsDir ?? 'assets'}/${options.stylex.filename}`
91
+ const css = ctx.bundle?.[fileName]
92
+
93
+ if (!css) {
94
+ return html
95
+ }
96
+
97
+ const publicPath = path.posix.join(
98
+ viteConfig.base ?? '/',
99
+ fileName.replace(/\\/g, '/')
100
+ )
101
+
102
+ return [
103
+ {
104
+ tag: 'link',
105
+ attrs: {
106
+ rel: 'stylesheet',
107
+ href: publicPath,
108
+ },
109
+ injectTo: 'head',
110
+ },
111
+ ]
112
+ },
55
113
  },
56
114
  }
57
115
  }
58
116
 
59
117
  export const unplugin = createUnplugin(unpluginFactory)
60
118
 
119
+ export * from './types'
120
+
61
121
  export default unplugin
package/src/rspack.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { createRspackPlugin } from 'unplugin'
2
2
  import { unpluginFactory } from '.'
3
3
 
4
- export default createRspackPlugin(unpluginFactory) as any
4
+ export default createRspackPlugin(unpluginFactory)
package/src/types.ts CHANGED
@@ -1,12 +1,10 @@
1
- import type { FilterPattern } from '@rollup/pluginutils'
2
-
3
1
  export type BabelConfig = {
4
- plugins: any[]
5
- presets: any[]
2
+ plugins: unknown[]
3
+ presets: unknown[]
6
4
  babelrc: boolean
7
5
  }
8
6
 
9
- type StylexOptions = {
7
+ export type StylexOptions = {
10
8
  filename?: string
11
9
  stylexImports?: string[]
12
10
  classNamePrefix?: string
@@ -16,12 +14,13 @@ type StylexOptions = {
16
14
  rootDir: string
17
15
  }
18
16
  babelConfig?: BabelConfig
17
+ runtimeInjection: boolean
18
+ aliases?: string[]
19
19
  }
20
20
 
21
21
  export type UnpluginStylexOptions = {
22
+ compiler?: string
22
23
  dev?: boolean
23
- include?: FilterPattern
24
- exclude?: FilterPattern
25
24
  enforce?: "post" | "pre"
26
25
  stylex?: StylexOptions
27
26
  }
package/src/vite.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { createVitePlugin } from 'unplugin'
2
2
  import { unpluginFactory } from '.'
3
3
 
4
- export default createVitePlugin(unpluginFactory) as any
4
+ export default createVitePlugin(unpluginFactory)
package/tsconfig.json CHANGED
@@ -8,11 +8,16 @@
8
8
  "lib": ["ESNext"],
9
9
  "moduleResolution": "Node",
10
10
  "preserveSymlinks": true,
11
+ "module": "esnext",
12
+ "skipLibCheck": true,
11
13
  "paths": {
12
14
  "@/*": ["./src/*"]
13
15
  }
14
16
  },
15
17
  "include": [
16
18
  "src"
19
+ ],
20
+ "exclude": [
21
+ "node_modules"
17
22
  ]
18
23
  }
@@ -0,0 +1,13 @@
1
+ import { defineConfig } from 'vitest/config'
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ coverage: {
6
+ exclude: [
7
+ "examples/**",
8
+ "test/**"
9
+ ],
10
+ reporter: ['text', 'json', 'html'],
11
+ },
12
+ },
13
+ })
@@ -1,131 +0,0 @@
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 }; }
2
-
3
-
4
- var _chunkN4Z3Z2PUcjs = require('./chunk-N4Z3Z2PU.cjs');
5
-
6
- // src/index.ts
7
- var _pluginutils = require('@rollup/pluginutils');
8
- var _babelplugin = require('@stylexjs/babel-plugin'); var _babelplugin2 = _interopRequireDefault(_babelplugin);
9
- var _unplugin = require('unplugin');
10
-
11
- // src/core/utils.ts
12
- function getOptions(options = {}) {
13
- const stylex = options.stylex || {};
14
- return {
15
- ...options,
16
- dev: options.dev || _chunkN4Z3Z2PUcjs.isDevelopment,
17
- include: options.include || [/\.[jt]sx?$/],
18
- exclude: options.exclude || [/node_modules/, /\.git/],
19
- enforce: options.enforce || "pre",
20
- stylex: {
21
- ...stylex,
22
- filename: stylex.filename || "stylex.css",
23
- stylexImports: stylex.stylexImports || ["stylex", "@stylexjs/stylex"],
24
- useCSSLayers: stylex.useCSSLayers || false,
25
- unstable_moduleResolution: stylex.unstable_moduleResolution || { type: "commonJS", rootDir: process.cwd() },
26
- babelConfig: {
27
- babelrc: (stylex.babelConfig || {}).babelrc || false,
28
- plugins: (stylex.babelConfig || {}).plugins || [],
29
- presets: (stylex.babelConfig || {}).presets || []
30
- }
31
- }
32
- };
33
- }
34
-
35
- // src/core/transformer.ts
36
- var _promises = require('fs/promises'); var fs = _interopRequireWildcard(_promises);
37
- var _path = require('path'); var path = _interopRequireWildcard(_path);
38
- var _core = require('@babel/core');
39
- var _pluginsyntaxflow = require('@babel/plugin-syntax-flow'); var _pluginsyntaxflow2 = _interopRequireDefault(_pluginsyntaxflow);
40
- var _pluginsyntaxjsx = require('@babel/plugin-syntax-jsx'); var _pluginsyntaxjsx2 = _interopRequireDefault(_pluginsyntaxjsx);
41
- var _pluginsyntaxtypescript = require('@babel/plugin-syntax-typescript'); var _pluginsyntaxtypescript2 = _interopRequireDefault(_pluginsyntaxtypescript);
42
-
43
- async function transformer(context) {
44
- const { id, source, options } = context;
45
- const stylex = options.stylex;
46
- const extname2 = path.extname(id);
47
- const stylexRules = {};
48
- if (stylex.stylexImports.some((importName) => source.includes(importName))) {
49
- const originSource = stylex.babelConfig.babelrc ? await fs.readFile(id, "utf-8") : source;
50
- const { code, map, metadata } = await _core.transformAsync.call(void 0,
51
- originSource,
52
- {
53
- babelrc: stylex.babelConfig.babelrc,
54
- filename: id,
55
- plugins: [
56
- ...stylex.babelConfig.plugins || [],
57
- extname2 === ".ts" ? _pluginsyntaxtypescript2.default : extname2 === ".tsx" ? [_pluginsyntaxtypescript2.default, { isTSX: true }] : _pluginsyntaxflow2.default,
58
- _pluginsyntaxjsx2.default,
59
- [
60
- _babelplugin2.default,
61
- {
62
- dev: options.dev,
63
- unstable_moduleResolution: stylex.unstable_moduleResolution,
64
- importSources: stylex.stylexImports,
65
- ...stylex
66
- }
67
- ]
68
- ],
69
- presets: stylex.babelConfig.presets
70
- }
71
- );
72
- if (metadata.stylex && metadata.stylex.length > 0) {
73
- stylexRules[id] = metadata.stylex;
74
- }
75
- if (!stylex.babelConfig.babelrc) {
76
- return { code, map, stylexRules };
77
- }
78
- return { code, stylexRules };
79
- }
80
- return { code: source };
81
- }
82
-
83
- // src/index.ts
84
- var unpluginFactory = (rawOptions = {}, meta) => {
85
- const options = getOptions(rawOptions);
86
- const filter = _pluginutils.createFilter.call(void 0, options.include, options.exclude);
87
- const stylexRules = {};
88
- return {
89
- name: _chunkN4Z3Z2PUcjs.PLUGIN_NAME,
90
- enforce: options.enforce,
91
- transformInclude(id) {
92
- return filter(id);
93
- },
94
- async transform(source, id) {
95
- const context = {
96
- pluginContext: this,
97
- options,
98
- source,
99
- id
100
- };
101
- try {
102
- const result = await transformer(context);
103
- if (result.stylexRules && result.stylexRules[id]) {
104
- stylexRules[id] = result.stylexRules[id];
105
- }
106
- return result;
107
- } catch (error) {
108
- this.error(error);
109
- }
110
- },
111
- buildEnd() {
112
- const rules = Object.values(stylexRules).flat();
113
- if (rules.length > 0) {
114
- const collectedCSS = _babelplugin2.default.processStylexRules(rules, options.stylex.useCSSLayers);
115
- this.emitFile({
116
- fileName: options.stylex.filename,
117
- source: collectedCSS,
118
- type: "asset"
119
- });
120
- }
121
- }
122
- };
123
- };
124
- var unplugin = _unplugin.createUnplugin.call(void 0, unpluginFactory);
125
- var src_default = unplugin;
126
-
127
-
128
-
129
-
130
-
131
- exports.unpluginFactory = unpluginFactory; exports.unplugin = unplugin; exports.src_default = src_default;