unplugin-stylex 0.1.0 → 0.2.4

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 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": ["@typescript-eslint"],
6
+ "plugins": ["@stylistic/ts"],
11
7
  "root": true,
12
8
  "rules": {
13
- "semi": "off",
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 · [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/eryue0220/unplugin-stylex/blob/main/LICENSE) [![npm version](https://img.shields.io/npm/v/unplugin-stylex.svg?style=flat)](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
 
@@ -75,11 +78,9 @@ module.exports = {
75
78
 
76
79
  ## Options
77
80
 
78
- ### options.dev
79
-
80
- ### options.enforce
81
+ Current support argument, which may have change in the future
81
82
 
82
- ### options.stylex
83
+ ### options.dev
83
84
 
84
85
  #### options.stylex.runtimeInjection
85
86
 
@@ -93,6 +94,7 @@ module.exports = {
93
94
 
94
95
  #### options.stylex.unstable_moduleResolution
95
96
 
96
- ## License
97
+ # Acknowledgments
97
98
 
98
- StyleX is [MIT licensed](./LICENSE)
99
+ - [@stylexjs/rollup-plugin](https://github.com/facebook/stylex/tree/main/packages/rollup-plugin)
100
+ - [vite-plugin-stylex](https://github.com/HorusGoul/vite-plugin-stylex)
package/dist/esbuild.cjs CHANGED
@@ -6,7 +6,8 @@ require('./chunk-N4Z3Z2PU.cjs');
6
6
 
7
7
  // src/esbuild.ts
8
8
  var _unplugin = require('unplugin');
9
- var esbuild_default = _unplugin.createEsbuildPlugin.call(void 0, _chunkNVMQARFAcjs.unpluginFactory);
9
+ var esbuildPlugin = _unplugin.createEsbuildPlugin.call(void 0, _chunkNVMQARFAcjs.unpluginFactory);
10
+ var esbuild_default = esbuildPlugin;
10
11
 
11
12
 
12
13
  exports.default = esbuild_default;
@@ -1,6 +1,12 @@
1
- import * as unplugin from 'unplugin';
2
- import { UnpluginStylexOptions } from './types.cjs';
1
+ import { EsbuildPlugin } from 'unplugin';
2
+ import { UnpluginStylexInstance } from './types.cjs';
3
3
 
4
- declare const _default: (options?: UnpluginStylexOptions) => unplugin.EsbuildPlugin;
4
+ /**
5
+ * This entry file is for esbuild plugin. Requires esbuild >= 0.15
6
+ *
7
+ * @module
8
+ */
5
9
 
6
- export { _default as default };
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 * as unplugin from 'unplugin';
2
- import { UnpluginStylexOptions } from './types.js';
1
+ import { EsbuildPlugin } from 'unplugin';
2
+ import { UnpluginStylexInstance } from './types.js';
3
3
 
4
- declare const _default: (options?: UnpluginStylexOptions) => unplugin.EsbuildPlugin;
4
+ /**
5
+ * This entry file is for esbuild plugin. Requires esbuild >= 0.15
6
+ *
7
+ * @module
8
+ */
5
9
 
6
- export { _default as default };
10
+ declare const esbuildPlugin: UnpluginStylexInstance<EsbuildPlugin | EsbuildPlugin[]>;
11
+
12
+ export { esbuildPlugin as default };
package/dist/esbuild.js CHANGED
@@ -6,7 +6,8 @@ import "./chunk-36ARBXVP.js";
6
6
 
7
7
  // src/esbuild.ts
8
8
  import { createEsbuildPlugin } from "unplugin";
9
- var esbuild_default = createEsbuildPlugin(unpluginFactory);
9
+ var esbuildPlugin = createEsbuildPlugin(unpluginFactory);
10
+ var esbuild_default = esbuildPlugin;
10
11
  export {
11
12
  esbuild_default as default
12
13
  };
package/dist/index.d.cts CHANGED
@@ -1,9 +1,8 @@
1
- import * as unplugin$1 from 'unplugin';
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
 
6
5
  declare const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined>;
7
- declare const unplugin: unplugin$1.UnpluginInstance<UnpluginStylexOptions, boolean>;
6
+ declare const unplugin: UnpluginInstance<UnpluginStylexOptions | undefined, boolean>;
8
7
 
9
8
  export { UnpluginStylexOptions, unplugin as default, unplugin, unpluginFactory };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- import * as unplugin$1 from 'unplugin';
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
 
6
5
  declare const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined>;
7
- declare const unplugin: unplugin$1.UnpluginInstance<UnpluginStylexOptions, boolean>;
6
+ declare const unplugin: UnpluginInstance<UnpluginStylexOptions | undefined, boolean>;
8
7
 
9
8
  export { UnpluginStylexOptions, unplugin as default, unplugin, unpluginFactory };
package/dist/rollup.cjs CHANGED
@@ -5,7 +5,7 @@ var _chunkN4Z3Z2PUcjs = require('./chunk-N4Z3Z2PU.cjs');
5
5
  // src/rollup.ts
6
6
  var rollup_default = (options) => {
7
7
  if (_chunkN4Z3Z2PUcjs.isDevelopment || (options == null ? void 0 : options.dev)) {
8
- throw new Error(`If you want to use this plugin through rollup, please use "@stylexjs/rollup-plugin" instead`);
8
+ throw new Error('If you want to use this plugin through rollup, please use "@stylexjs/rollup-plugin" instead');
9
9
  }
10
10
  };
11
11
 
package/dist/rollup.d.cts CHANGED
@@ -1,3 +1,14 @@
1
- declare const _default: (options?: any) => void;
1
+ import { UnpluginStylexOptions } from './types.cjs';
2
+
3
+ /**
4
+ * This entry file is for Rollup plugin.
5
+ *
6
+ * @module
7
+ */
8
+
9
+ /**
10
+ * Note: Current, please use @stylexjs/rollup-plugin
11
+ */
12
+ declare const _default: (options?: UnpluginStylexOptions) => void;
2
13
 
3
14
  export { _default as default };
package/dist/rollup.d.ts CHANGED
@@ -1,3 +1,14 @@
1
- declare const _default: (options?: any) => void;
1
+ import { UnpluginStylexOptions } from './types.js';
2
+
3
+ /**
4
+ * This entry file is for Rollup plugin.
5
+ *
6
+ * @module
7
+ */
8
+
9
+ /**
10
+ * Note: Current, please use @stylexjs/rollup-plugin
11
+ */
12
+ declare const _default: (options?: UnpluginStylexOptions) => void;
2
13
 
3
14
  export { _default as default };
package/dist/rollup.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  // src/rollup.ts
6
6
  var rollup_default = (options) => {
7
7
  if (isDevelopment || (options == null ? void 0 : options.dev)) {
8
- throw new Error(`If you want to use this plugin through rollup, please use "@stylexjs/rollup-plugin" instead`);
8
+ throw new Error('If you want to use this plugin through rollup, please use "@stylexjs/rollup-plugin" instead');
9
9
  }
10
10
  };
11
11
  export {
package/dist/rspack.cjs CHANGED
@@ -6,7 +6,8 @@ require('./chunk-N4Z3Z2PU.cjs');
6
6
 
7
7
  // src/rspack.ts
8
8
  var _unplugin = require('unplugin');
9
- var rspack_default = _unplugin.createRspackPlugin.call(void 0, _chunkNVMQARFAcjs.unpluginFactory);
9
+ var rspackPlugin = _unplugin.createRspackPlugin.call(void 0, _chunkNVMQARFAcjs.unpluginFactory);
10
+ var rspack_default = rspackPlugin;
10
11
 
11
12
 
12
13
  exports.default = rspack_default;
package/dist/rspack.d.cts CHANGED
@@ -1,6 +1,13 @@
1
- import * as unplugin from 'unplugin';
2
- import { UnpluginStylexOptions } from './types.cjs';
1
+ import { RspackPluginInstance } from 'unplugin';
2
+ import { UnpluginStylexInstance } from './types.cjs';
3
3
 
4
- declare const _default: (options?: UnpluginStylexOptions) => unplugin.RspackPluginInstance;
4
+ /**
5
+ * This entry file is for Rspac plugin.
6
+ *
7
+ * @module
8
+ */
5
9
 
6
- export { _default as default };
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 * as unplugin from 'unplugin';
2
- import { UnpluginStylexOptions } from './types.js';
1
+ import { RspackPluginInstance } from 'unplugin';
2
+ import { UnpluginStylexInstance } from './types.js';
3
3
 
4
- declare const _default: (options?: UnpluginStylexOptions) => unplugin.RspackPluginInstance;
4
+ /**
5
+ * This entry file is for Rspac plugin.
6
+ *
7
+ * @module
8
+ */
5
9
 
6
- export { _default as default };
10
+ type RspackPluginType = UnpluginStylexInstance<RspackPluginInstance | RspackPluginInstance[]>;
11
+ declare const rspackPlugin: RspackPluginType;
12
+
13
+ export { rspackPlugin as default };
package/dist/rspack.js CHANGED
@@ -6,7 +6,8 @@ import "./chunk-36ARBXVP.js";
6
6
 
7
7
  // src/rspack.ts
8
8
  import { createRspackPlugin } from "unplugin";
9
- var rspack_default = createRspackPlugin(unpluginFactory);
9
+ var rspackPlugin = createRspackPlugin(unpluginFactory);
10
+ var rspack_default = rspackPlugin;
10
11
  export {
11
12
  rspack_default as default
12
13
  };
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: "commonjs" | "haste";
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?: "post" | "pre";
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: "commonjs" | "haste";
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?: "post" | "pre";
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
@@ -6,7 +6,8 @@ require('./chunk-N4Z3Z2PU.cjs');
6
6
 
7
7
  // src/vite.ts
8
8
  var _unplugin = require('unplugin');
9
- var vite_default = _unplugin.createVitePlugin.call(void 0, _chunkNVMQARFAcjs.unpluginFactory);
9
+ var vitePlugin = _unplugin.createVitePlugin.call(void 0, _chunkNVMQARFAcjs.unpluginFactory);
10
+ var vite_default = vitePlugin;
10
11
 
11
12
 
12
13
  exports.default = vite_default;
package/dist/vite.d.cts CHANGED
@@ -1,6 +1,12 @@
1
- import * as vite from 'vite';
2
- import { UnpluginStylexOptions } from './types.cjs';
1
+ import { VitePlugin } from 'unplugin';
2
+ import { UnpluginStylexInstance } from './types.cjs';
3
3
 
4
- declare const _default: (options?: UnpluginStylexOptions) => vite.Plugin<any> | vite.Plugin<any>[];
4
+ /**
5
+ * This entry file is for Vite plugin.
6
+ *
7
+ * @module
8
+ */
5
9
 
6
- export { _default as default };
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 * as vite from 'vite';
2
- import { UnpluginStylexOptions } from './types.js';
1
+ import { VitePlugin } from 'unplugin';
2
+ import { UnpluginStylexInstance } from './types.js';
3
3
 
4
- declare const _default: (options?: UnpluginStylexOptions) => vite.Plugin<any> | vite.Plugin<any>[];
4
+ /**
5
+ * This entry file is for Vite plugin.
6
+ *
7
+ * @module
8
+ */
5
9
 
6
- export { _default as default };
10
+ declare const vitePlugin: UnpluginStylexInstance<VitePlugin | VitePlugin[]>;
11
+
12
+ export { vitePlugin as default };
package/dist/vite.js CHANGED
@@ -6,7 +6,8 @@ import "./chunk-36ARBXVP.js";
6
6
 
7
7
  // src/vite.ts
8
8
  import { createVitePlugin } from "unplugin";
9
- var vite_default = createVitePlugin(unpluginFactory);
9
+ var vitePlugin = createVitePlugin(unpluginFactory);
10
+ var vite_default = vitePlugin;
10
11
  export {
11
12
  vite_default as default
12
13
  };
package/dist/webpack.cjs CHANGED
@@ -5,7 +5,7 @@ var _chunkN4Z3Z2PUcjs = require('./chunk-N4Z3Z2PU.cjs');
5
5
  // src/webpack.ts
6
6
  var webpack_default = (options) => {
7
7
  if (_chunkN4Z3Z2PUcjs.isDevelopment || (options == null ? void 0 : options.dev)) {
8
- throw new Error(`If you want to use this plugin through webpack, please use "@stylexjs/webpack-plugin" instead`);
8
+ throw new Error('If you want to use this plugin through webpack, please use "@stylexjs/webpack-plugin" instead');
9
9
  }
10
10
  };
11
11
 
@@ -1,3 +1,14 @@
1
- declare const _default: (options?: any) => void;
1
+ import { UnpluginStylexOptions } from './types.cjs';
2
+
3
+ /**
4
+ * This entry file is for Webpack plugin.
5
+ *
6
+ * @module
7
+ */
8
+
9
+ /**
10
+ * Note: Current, please use @stylexjs/webpack-plugin
11
+ */
12
+ declare const _default: (options?: UnpluginStylexOptions) => void;
2
13
 
3
14
  export { _default as default };
package/dist/webpack.d.ts CHANGED
@@ -1,3 +1,14 @@
1
- declare const _default: (options?: any) => void;
1
+ import { UnpluginStylexOptions } from './types.js';
2
+
3
+ /**
4
+ * This entry file is for Webpack plugin.
5
+ *
6
+ * @module
7
+ */
8
+
9
+ /**
10
+ * Note: Current, please use @stylexjs/webpack-plugin
11
+ */
12
+ declare const _default: (options?: UnpluginStylexOptions) => void;
2
13
 
3
14
  export { _default as default };
package/dist/webpack.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  // src/webpack.ts
6
6
  var webpack_default = (options) => {
7
7
  if (isDevelopment || (options == null ? void 0 : options.dev)) {
8
- throw new Error(`If you want to use this plugin through webpack, please use "@stylexjs/webpack-plugin" instead`);
8
+ throw new Error('If you want to use this plugin through webpack, please use "@stylexjs/webpack-plugin" instead');
9
9
  }
10
10
  };
11
11
  export {
package/jsr.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@eryue0220/unplugin-stylex",
3
+ "version": "0.2.4",
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.1.0",
3
+ "version": "0.2.4",
4
4
  "packageManager": "pnpm@8.11.0",
5
5
  "description": "Unplugin for stylex",
6
6
  "repository": "https://github.com/eryue0220/unplugin-stylex",
@@ -46,9 +46,22 @@
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:cov": "vitest --coverage",
55
+ "lint": "eslint . --ext .ts,.tsx,.js,.jsx",
56
+ "check": "pnpm run lint && pnpm run typecheck",
57
+ "typecheck": "tsc -p tsconfig.json --noEmit"
58
+ },
49
59
  "engines": {
50
60
  "node": ">=16.14.0"
51
61
  },
62
+ "peerDependencies": {
63
+ "@stylexjs/stylex": "^0.5.1"
64
+ },
52
65
  "dependencies": {
53
66
  "@babel/core": "^7.23.6",
54
67
  "@babel/plugin-syntax-flow": "^7.23.3",
@@ -59,6 +72,7 @@
59
72
  "unplugin": "^1.7.1"
60
73
  },
61
74
  "devDependencies": {
75
+ "@stylistic/eslint-plugin-ts": "^1.6.2",
62
76
  "@types/node": "^20.10.5",
63
77
  "@typescript-eslint/eslint-plugin": "^6.16.0",
64
78
  "@typescript-eslint/parser": "^6.16.0",
@@ -69,15 +83,5 @@
69
83
  "typescript": "^5.3.3",
70
84
  "vite": "^5.0.10",
71
85
  "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"
82
86
  }
83
- }
87
+ }
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 { unpluginFactory } from '.'
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
- export default createEsbuildPlugin(unpluginFactory)
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,8 @@
1
1
  import * as path from 'node:path'
2
2
 
3
3
  import { createUnplugin } from 'unplugin'
4
- import type { UnpluginFactory } from 'unplugin'
4
+ import type { UnpluginFactory, UnpluginInstance } from 'unplugin'
5
+ import type { BuildOptions } from 'vite'
5
6
 
6
7
  import { buildStylexRules } from './core/build'
7
8
  import { PLUGIN_NAME } from './core/constants'
@@ -12,7 +13,7 @@ import type { UnpluginStylexOptions } from './types'
12
13
  export const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined> = (rawOptions = {}) => {
13
14
  const options = getOptions(rawOptions)
14
15
  const stylexRules = {}
15
- let viteConfig = null
16
+ let viteConfig: { build: BuildOptions | undefined; base: string | undefined; } | null = null
16
17
 
17
18
  return {
18
19
  name: PLUGIN_NAME,
@@ -74,7 +75,7 @@ export const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined>
74
75
  },
75
76
 
76
77
  buildEnd() {
77
- const fileName = `${viteConfig.build?.assetsDir ?? 'assets'}/${options.stylex.filename}`
78
+ const fileName = `${viteConfig!.build?.assetsDir ?? 'assets'}/${options.stylex.filename}`
78
79
  const collectedCSS = buildStylexRules(stylexRules, options.stylex.useCSSLayers)
79
80
 
80
81
  if (!collectedCSS) return
@@ -87,7 +88,7 @@ export const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined>
87
88
  },
88
89
 
89
90
  transformIndexHtml(html, ctx) {
90
- const fileName = `${viteConfig.build?.assetsDir ?? 'assets'}/${options.stylex.filename}`
91
+ const fileName = `${viteConfig!.build?.assetsDir ?? 'assets'}/${options.stylex.filename}`
91
92
  const css = ctx.bundle?.[fileName]
92
93
 
93
94
  if (!css) {
@@ -95,7 +96,7 @@ export const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined>
95
96
  }
96
97
 
97
98
  const publicPath = path.posix.join(
98
- viteConfig.base ?? '/',
99
+ viteConfig!.base ?? '/',
99
100
  fileName.replace(/\\/g, '/')
100
101
  )
101
102
 
@@ -114,7 +115,7 @@ export const unpluginFactory: UnpluginFactory<UnpluginStylexOptions | undefined>
114
115
  }
115
116
  }
116
117
 
117
- export const unplugin = createUnplugin(unpluginFactory)
118
+ export const unplugin: UnpluginInstance<UnpluginStylexOptions | undefined, boolean> = createUnplugin(unpluginFactory)
118
119
 
119
120
  export * from './types'
120
121
 
package/src/rollup.ts CHANGED
@@ -1,7 +1,17 @@
1
+ /**
2
+ * This entry file is for Rollup plugin.
3
+ *
4
+ * @module
5
+ */
6
+
1
7
  import { isDevelopment } from './core/constants'
8
+ import type { UnpluginStylexOptions } from './types'
2
9
 
3
- export default (options?) => {
10
+ /**
11
+ * Note: Current, please use @stylexjs/rollup-plugin
12
+ */
13
+ export default (options?: UnpluginStylexOptions) => {
4
14
  if (isDevelopment || options?.dev) {
5
- throw new Error(`If you want to use this plugin through rollup, please use "@stylexjs/rollup-plugin" instead`)
15
+ throw new Error('If you want to use this plugin through rollup, please use "@stylexjs/rollup-plugin" instead')
6
16
  }
7
17
  }
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 { unpluginFactory } from '.'
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
- export default createRspackPlugin(unpluginFactory)
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: "commonjs" | "haste"
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?: "post" | "pre"
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 { unpluginFactory } from '.'
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
- export default createVitePlugin(unpluginFactory)
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,17 @@
1
+ /**
2
+ * This entry file is for Webpack plugin.
3
+ *
4
+ * @module
5
+ */
6
+
1
7
  import { isDevelopment } from './core/constants'
8
+ import type { UnpluginStylexOptions } from './types'
2
9
 
3
- export default (options?) => {
10
+ /**
11
+ * Note: Current, please use @stylexjs/webpack-plugin
12
+ */
13
+ export default (options?: UnpluginStylexOptions) => {
4
14
  if (isDevelopment || options?.dev) {
5
- throw new Error(`If you want to use this plugin through webpack, please use "@stylexjs/webpack-plugin" instead`)
15
+ throw new Error('If you want to use this plugin through webpack, please use "@stylexjs/webpack-plugin" instead')
6
16
  }
7
17
  }
package/typos.toml ADDED
@@ -0,0 +1,10 @@
1
+ [files]
2
+ extend-exclude = [
3
+ "*.snap",
4
+ "examples/*",
5
+ ]
6
+
7
+ [default.extend-words]
8
+ # Ignore false-positives
9
+ stylex = "stylex"
10
+ unplugin = "unplugin"
package/vitest.config.ts CHANGED
@@ -4,8 +4,8 @@ export default defineConfig({
4
4
  test: {
5
5
  coverage: {
6
6
  exclude: [
7
- "examples/**",
8
- "test/**"
7
+ 'examples/**',
8
+ 'test/**'
9
9
  ],
10
10
  reporter: ['text', 'json', 'html'],
11
11
  },