unplugin-oxc 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright © 2024-PRESENT 三咲智子 (https://github.com/sxzz)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # unplugin-oxc [![npm](https://img.shields.io/npm/v/unplugin-oxc.svg)](https://npmjs.com/package/unplugin-oxc)
2
+
3
+ [![Unit Test](https://github.com/unplugin/unplugin-oxc/actions/workflows/unit-test.yml/badge.svg)](https://github.com/unplugin/unplugin-oxc/actions/workflows/unit-test.yml)
4
+
5
+ Oxc integration for unplugin.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm i -D unplugin-oxc
11
+ ```
12
+
13
+ <details>
14
+ <summary>Vite</summary><br>
15
+
16
+ ```ts
17
+ // vite.config.ts
18
+ import Oxc from 'unplugin-oxc/vite'
19
+
20
+ export default defineConfig({
21
+ plugins: [Oxc()],
22
+ })
23
+ ```
24
+
25
+ <br></details>
26
+
27
+ <details>
28
+ <summary>Rollup</summary><br>
29
+
30
+ ```ts
31
+ // rollup.config.js
32
+ import Oxc from 'unplugin-oxc/rollup'
33
+
34
+ export default {
35
+ plugins: [Oxc()],
36
+ }
37
+ ```
38
+
39
+ <br></details>
40
+
41
+ <details>
42
+ <summary>Rolldown</summary><br>
43
+
44
+ ```ts
45
+ // rolldown.config.js
46
+ import Oxc from 'unplugin-oxc/rolldown'
47
+
48
+ export default {
49
+ plugins: [Oxc()],
50
+ }
51
+ ```
52
+
53
+ <br></details>
54
+
55
+ <details>
56
+ <summary>esbuild</summary><br>
57
+
58
+ ```ts
59
+ import { build } from 'esbuild'
60
+ import Oxc from 'unplugin-oxc/esbuild'
61
+
62
+ build({
63
+ plugins: [Oxc()],
64
+ })
65
+ ```
66
+
67
+ <br></details>
68
+
69
+ <details>
70
+ <summary>Webpack</summary><br>
71
+
72
+ ```js
73
+ // webpack.config.js
74
+ import Oxc from 'unplugin-oxc/webpack'
75
+
76
+ export default {
77
+ /* ... */
78
+ plugins: [Oxc()],
79
+ }
80
+ ```
81
+
82
+ <br></details>
83
+
84
+ <details>
85
+ <summary>Rspack</summary><br>
86
+
87
+ ```ts
88
+ // rspack.config.js
89
+ import Oxc from 'unplugin-oxc/rspack'
90
+
91
+ export default {
92
+ /* ... */
93
+ plugins: [Oxc()],
94
+ }
95
+ ```
96
+
97
+ <br></details>
98
+
99
+ ## Sponsors
100
+
101
+ <p align="center">
102
+ <a href="https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg">
103
+ <img src='https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg'/>
104
+ </a>
105
+ </p>
106
+
107
+ ## License
108
+
109
+ [MIT](./LICENSE) License © 2025-PRESENT [三咲智子](https://github.com/sxzz)
package/dist/api.d.ts ADDED
@@ -0,0 +1,2 @@
1
+
2
+ export { }
package/dist/api.js ADDED
File without changes
@@ -0,0 +1,27 @@
1
+ import { Oxc } from './index.js';
2
+ import 'unplugin';
3
+ import 'oxc-minify';
4
+ import 'oxc-resolver';
5
+ import 'oxc-transform';
6
+ import 'unplugin-utils';
7
+
8
+ /**
9
+ * This entry file is for esbuild plugin. Requires esbuild >= 0.15
10
+ *
11
+ * @module
12
+ */
13
+
14
+ /**
15
+ * Esbuild plugin
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * import { build } from 'esbuild'
20
+ * import Oxc from 'unplugin-oxc/esbuild'
21
+ *
22
+ * build({ plugins: [Oxc()] })
23
+ ```
24
+ */
25
+ declare const esbuild: typeof Oxc.esbuild;
26
+
27
+ export { esbuild as "module.exports", esbuild as default };
@@ -0,0 +1,19 @@
1
+ import { Oxc } from "./src-3VZolPlj.js";
2
+
3
+ //#region src/esbuild.ts
4
+ /**
5
+ * Esbuild plugin
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { build } from 'esbuild'
10
+ * import Oxc from 'unplugin-oxc/esbuild'
11
+ *
12
+ * build({ plugins: [Oxc()] })
13
+ ```
14
+ */
15
+ const esbuild = Oxc.esbuild;
16
+ var esbuild_default = esbuild;
17
+
18
+ //#endregion
19
+ export { esbuild_default as default, esbuild as 'module.exports' };
package/dist/farm.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ import { Oxc } from './index.js';
2
+ import 'unplugin';
3
+ import 'oxc-minify';
4
+ import 'oxc-resolver';
5
+ import 'oxc-transform';
6
+ import 'unplugin-utils';
7
+
8
+ /**
9
+ * This entry file is for Farm plugin.
10
+ *
11
+ * @module
12
+ */
13
+
14
+ /**
15
+ * Farm plugin
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * // farm.config.js
20
+ * import Oxc from 'unplugin-oxc/farm'
21
+ *
22
+ * export default {
23
+ * plugins: [Oxc()],
24
+ * }
25
+ * ```
26
+ */
27
+ declare const farm: typeof Oxc.farm;
28
+
29
+ export { farm as "module.exports", farm as default };
package/dist/farm.js ADDED
@@ -0,0 +1,21 @@
1
+ import { Oxc } from "./src-3VZolPlj.js";
2
+
3
+ //#region src/farm.ts
4
+ /**
5
+ * Farm plugin
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * // farm.config.js
10
+ * import Oxc from 'unplugin-oxc/farm'
11
+ *
12
+ * export default {
13
+ * plugins: [Oxc()],
14
+ * }
15
+ * ```
16
+ */
17
+ const farm = Oxc.farm;
18
+ var farm_default = farm;
19
+
20
+ //#endregion
21
+ export { farm_default as default, farm as 'module.exports' };
@@ -0,0 +1,20 @@
1
+ import { UnpluginInstance } from 'unplugin';
2
+ import { MinifyOptions } from 'oxc-minify';
3
+ import { NapiResolveOptions } from 'oxc-resolver';
4
+ import { TransformOptions } from 'oxc-transform';
5
+ import { FilterPattern } from 'unplugin-utils';
6
+
7
+ interface Options {
8
+ include?: FilterPattern;
9
+ exclude?: FilterPattern;
10
+ enforce?: "pre" | "post" | undefined;
11
+ transform?: Omit<TransformOptions, "sourcemap"> | false;
12
+ resolve?: NapiResolveOptions | false;
13
+ resolveNodeModules?: boolean;
14
+ minify?: Omit<MinifyOptions, "sourcemap"> | false;
15
+ sourcemap?: boolean;
16
+ }
17
+
18
+ declare const Oxc: UnpluginInstance<Options | undefined, false>;
19
+
20
+ export { Oxc };
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ import { Oxc } from "./src-3VZolPlj.js";
2
+
3
+ export { Oxc };
@@ -0,0 +1,29 @@
1
+ import { Oxc } from './index.js';
2
+ import 'unplugin';
3
+ import 'oxc-minify';
4
+ import 'oxc-resolver';
5
+ import 'oxc-transform';
6
+ import 'unplugin-utils';
7
+
8
+ /**
9
+ * This entry file is for Rolldown plugin.
10
+ *
11
+ * @module
12
+ */
13
+
14
+ /**
15
+ * Rolldown plugin
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * // rolldown.config.js
20
+ * import Oxc from 'unplugin-oxc/rolldown'
21
+ *
22
+ * export default {
23
+ * plugins: [Oxc()],
24
+ * }
25
+ * ```
26
+ */
27
+ declare const rolldown: typeof Oxc.rolldown;
28
+
29
+ export { rolldown as "module.exports", rolldown as default };
@@ -0,0 +1,21 @@
1
+ import { Oxc } from "./src-3VZolPlj.js";
2
+
3
+ //#region src/rolldown.ts
4
+ /**
5
+ * Rolldown plugin
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * // rolldown.config.js
10
+ * import Oxc from 'unplugin-oxc/rolldown'
11
+ *
12
+ * export default {
13
+ * plugins: [Oxc()],
14
+ * }
15
+ * ```
16
+ */
17
+ const rolldown = Oxc.rolldown;
18
+ var rolldown_default = rolldown;
19
+
20
+ //#endregion
21
+ export { rolldown_default as default, rolldown as 'module.exports' };
@@ -0,0 +1,29 @@
1
+ import { Oxc } from './index.js';
2
+ import 'unplugin';
3
+ import 'oxc-minify';
4
+ import 'oxc-resolver';
5
+ import 'oxc-transform';
6
+ import 'unplugin-utils';
7
+
8
+ /**
9
+ * This entry file is for Rollup plugin.
10
+ *
11
+ * @module
12
+ */
13
+
14
+ /**
15
+ * Rollup plugin
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * // rollup.config.js
20
+ * import Oxc from 'unplugin-oxc/rollup'
21
+ *
22
+ * export default {
23
+ * plugins: [Oxc()],
24
+ * }
25
+ * ```
26
+ */
27
+ declare const rollup: typeof Oxc.rollup;
28
+
29
+ export { rollup as "module.exports", rollup as default };
package/dist/rollup.js ADDED
@@ -0,0 +1,21 @@
1
+ import { Oxc } from "./src-3VZolPlj.js";
2
+
3
+ //#region src/rollup.ts
4
+ /**
5
+ * Rollup plugin
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * // rollup.config.js
10
+ * import Oxc from 'unplugin-oxc/rollup'
11
+ *
12
+ * export default {
13
+ * plugins: [Oxc()],
14
+ * }
15
+ * ```
16
+ */
17
+ const rollup = Oxc.rollup;
18
+ var rollup_default = rollup;
19
+
20
+ //#endregion
21
+ export { rollup_default as default, rollup as 'module.exports' };
@@ -0,0 +1,29 @@
1
+ import { Oxc } from './index.js';
2
+ import 'unplugin';
3
+ import 'oxc-minify';
4
+ import 'oxc-resolver';
5
+ import 'oxc-transform';
6
+ import 'unplugin-utils';
7
+
8
+ /**
9
+ * This entry file is for Rspack plugin.
10
+ *
11
+ * @module
12
+ */
13
+
14
+ /**
15
+ * Rspack plugin
16
+ *
17
+ * @example
18
+ * ```js
19
+ * // rspack.config.js
20
+ * import Oxc from 'unplugin-oxc/rspack'
21
+ *
22
+ * default export {
23
+ * plugins: [Oxc()],
24
+ * }
25
+ * ```
26
+ */
27
+ declare const rspack: typeof Oxc.rspack;
28
+
29
+ export { rspack as "module.exports", rspack as default };
package/dist/rspack.js ADDED
@@ -0,0 +1,21 @@
1
+ import { Oxc } from "./src-3VZolPlj.js";
2
+
3
+ //#region src/rspack.ts
4
+ /**
5
+ * Rspack plugin
6
+ *
7
+ * @example
8
+ * ```js
9
+ * // rspack.config.js
10
+ * import Oxc from 'unplugin-oxc/rspack'
11
+ *
12
+ * default export {
13
+ * plugins: [Oxc()],
14
+ * }
15
+ * ```
16
+ */
17
+ const rspack = Oxc.rspack;
18
+ var rspack_default = rspack;
19
+
20
+ //#endregion
21
+ export { rspack_default as default, rspack as 'module.exports' };
@@ -0,0 +1,76 @@
1
+ import path from "node:path";
2
+ import { minify } from "oxc-minify";
3
+ import { ResolverFactory } from "oxc-resolver";
4
+ import { transform } from "oxc-transform";
5
+ import { createUnplugin } from "unplugin";
6
+ import { createFilter } from "unplugin-utils";
7
+
8
+ //#region src/core/options.ts
9
+ function resolveOptions(options) {
10
+ return {
11
+ include: options.include || [/\.[cm]?[jt]sx?$/],
12
+ exclude: options.exclude || [/node_modules/],
13
+ enforce: "enforce" in options ? options.enforce : "pre",
14
+ transform: options.transform || {},
15
+ resolve: options.resolve || {},
16
+ resolveNodeModules: options.resolveNodeModules || false,
17
+ minify: options.minify || false,
18
+ sourcemap: options.sourcemap || false
19
+ };
20
+ }
21
+
22
+ //#endregion
23
+ //#region src/index.ts
24
+ const Oxc = createUnplugin((rawOptions = {}) => {
25
+ const options = resolveOptions(rawOptions);
26
+ const filter = createFilter(options.include, options.exclude);
27
+ const renderChunk = options.minify !== false ? (code, chunk) => {
28
+ const result = minify(chunk.fileName, code, {
29
+ ...options.minify,
30
+ sourcemap: options.sourcemap
31
+ });
32
+ return {
33
+ code: result.code,
34
+ map: result.map
35
+ };
36
+ } : undefined;
37
+ return {
38
+ name: "unplugin-oxc",
39
+ enforce: options.enforce,
40
+ resolveId: options.resolve !== false ? async (id, importer) => {
41
+ if (!importer) return;
42
+ if (!options.resolveNodeModules && id[0] !== "." && id[0] !== "/") return;
43
+ const resolver = new ResolverFactory({
44
+ extensions: [
45
+ ".ts",
46
+ ".mts",
47
+ ".cts",
48
+ ".tsx"
49
+ ],
50
+ ...options.resolve
51
+ });
52
+ const directory = path.dirname(importer);
53
+ const resolved = await resolver.async(directory, id);
54
+ if (resolved.path) return resolved.path;
55
+ } : undefined,
56
+ transformInclude(id) {
57
+ return filter(id);
58
+ },
59
+ transform: options.transform !== false ? (code, id) => {
60
+ const result = transform(id, code, {
61
+ ...options.transform,
62
+ sourcemap: options.sourcemap
63
+ });
64
+ return {
65
+ code: result.code,
66
+ map: result.map
67
+ };
68
+ } : undefined,
69
+ rollup: { renderChunk },
70
+ rolldown: { renderChunk },
71
+ vite: { renderChunk }
72
+ };
73
+ });
74
+
75
+ //#endregion
76
+ export { Oxc };
package/dist/vite.d.ts ADDED
@@ -0,0 +1,29 @@
1
+ import { Oxc } from './index.js';
2
+ import 'unplugin';
3
+ import 'oxc-minify';
4
+ import 'oxc-resolver';
5
+ import 'oxc-transform';
6
+ import 'unplugin-utils';
7
+
8
+ /**
9
+ * This entry file is for Vite plugin.
10
+ *
11
+ * @module
12
+ */
13
+
14
+ /**
15
+ * Vite plugin
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * // vite.config.ts
20
+ * import Oxc from 'unplugin-oxc/vite'
21
+ *
22
+ * export default defineConfig({
23
+ * plugins: [Oxc()],
24
+ * })
25
+ * ```
26
+ */
27
+ declare const vite: typeof Oxc.vite;
28
+
29
+ export { vite as "module.exports", vite as default };
package/dist/vite.js ADDED
@@ -0,0 +1,21 @@
1
+ import { Oxc } from "./src-3VZolPlj.js";
2
+
3
+ //#region src/vite.ts
4
+ /**
5
+ * Vite plugin
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * // vite.config.ts
10
+ * import Oxc from 'unplugin-oxc/vite'
11
+ *
12
+ * export default defineConfig({
13
+ * plugins: [Oxc()],
14
+ * })
15
+ * ```
16
+ */
17
+ const vite = Oxc.vite;
18
+ var vite_default = vite;
19
+
20
+ //#endregion
21
+ export { vite_default as default, vite as 'module.exports' };
@@ -0,0 +1,29 @@
1
+ import { Oxc } from './index.js';
2
+ import 'unplugin';
3
+ import 'oxc-minify';
4
+ import 'oxc-resolver';
5
+ import 'oxc-transform';
6
+ import 'unplugin-utils';
7
+
8
+ /**
9
+ * This entry file is for webpack plugin.
10
+ *
11
+ * @module
12
+ */
13
+
14
+ /**
15
+ * Webpack plugin
16
+ *
17
+ * @example
18
+ * ```js
19
+ * // webpack.config.js
20
+ * import Oxc from 'unplugin-oxc/webpack'
21
+ *
22
+ * default export {
23
+ * plugins: [Oxc()],
24
+ * }
25
+ * ```
26
+ */
27
+ declare const webpack: typeof Oxc.webpack;
28
+
29
+ export { webpack as "module.exports", webpack as default };
@@ -0,0 +1,21 @@
1
+ import { Oxc } from "./src-3VZolPlj.js";
2
+
3
+ //#region src/webpack.ts
4
+ /**
5
+ * Webpack plugin
6
+ *
7
+ * @example
8
+ * ```js
9
+ * // webpack.config.js
10
+ * import Oxc from 'unplugin-oxc/webpack'
11
+ *
12
+ * default export {
13
+ * plugins: [Oxc()],
14
+ * }
15
+ * ```
16
+ */
17
+ const webpack = Oxc.webpack;
18
+ var webpack_default = webpack;
19
+
20
+ //#endregion
21
+ export { webpack_default as default, webpack as 'module.exports' };
package/package.json ADDED
@@ -0,0 +1,91 @@
1
+ {
2
+ "name": "unplugin-oxc",
3
+ "version": "0.1.0",
4
+ "description": "Oxc integration for unplugin.",
5
+ "type": "module",
6
+ "keywords": [
7
+ "unplugin",
8
+ "vite",
9
+ "webpack",
10
+ "rspack",
11
+ "rollup",
12
+ "rolldown",
13
+ "esbuild",
14
+ "farm"
15
+ ],
16
+ "license": "MIT",
17
+ "homepage": "https://github.com/unplugin/unplugin-oxc#readme",
18
+ "bugs": {
19
+ "url": "https://github.com/unplugin/unplugin-oxc/issues"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/unplugin/unplugin-oxc.git"
24
+ },
25
+ "author": "三咲智子 Kevin Deng <sxzz@sxzz.moe>",
26
+ "funding": "https://github.com/sponsors/sxzz",
27
+ "files": [
28
+ "dist"
29
+ ],
30
+ "main": "./dist/index.js",
31
+ "module": "./dist/index.js",
32
+ "types": "./dist/index.d.ts",
33
+ "exports": {
34
+ ".": "./dist/index.js",
35
+ "./vite": "./dist/vite.js",
36
+ "./webpack": "./dist/webpack.js",
37
+ "./rspack": "./dist/rspack.js",
38
+ "./rollup": "./dist/rollup.js",
39
+ "./rolldown": "./dist/rolldown.js",
40
+ "./esbuild": "./dist/esbuild.js",
41
+ "./farm": "./dist/farm.js",
42
+ "./api": "./dist/api.js",
43
+ "./*": "./*"
44
+ },
45
+ "typesVersions": {
46
+ "*": {
47
+ "*": [
48
+ "./dist/*",
49
+ "./*"
50
+ ]
51
+ }
52
+ },
53
+ "publishConfig": {
54
+ "access": "public"
55
+ },
56
+ "dependencies": {
57
+ "oxc-minify": "^0.48.2",
58
+ "oxc-resolver": "^4.0.0",
59
+ "oxc-transform": "^0.48.2",
60
+ "unplugin": "^2.1.2",
61
+ "unplugin-utils": "^0.2.3"
62
+ },
63
+ "devDependencies": {
64
+ "@sxzz/eslint-config": "^5.0.1",
65
+ "@sxzz/prettier-config": "^2.1.2",
66
+ "@sxzz/test-utils": "^0.5.1",
67
+ "@types/node": "^22.13.1",
68
+ "bumpp": "^10.0.2",
69
+ "eslint": "^9.20.0",
70
+ "prettier": "^3.5.0",
71
+ "rollup": "^4.34.6",
72
+ "tsdown": "^0.5.9",
73
+ "tsx": "^4.19.2",
74
+ "typescript": "^5.7.3",
75
+ "vite": "^6.1.0",
76
+ "vitest": "^3.0.5"
77
+ },
78
+ "engines": {
79
+ "node": ">=18.12.0"
80
+ },
81
+ "prettier": "@sxzz/prettier-config",
82
+ "scripts": {
83
+ "lint": "eslint --cache .",
84
+ "lint:fix": "pnpm run lint --fix",
85
+ "build": "tsdown",
86
+ "dev": "tsdown --watch",
87
+ "test": "vitest",
88
+ "typecheck": "tsc --noEmit",
89
+ "release": "bumpp && pnpm publish"
90
+ }
91
+ }