unplugin-oxc 0.1.0 → 0.2.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/README.md +58 -1
- package/dist/esbuild.js +1 -1
- package/dist/farm.js +1 -1
- package/dist/index.d.ts +20 -0
- package/dist/index.js +1 -1
- package/dist/rolldown.js +1 -1
- package/dist/rollup.js +1 -1
- package/dist/rspack.js +1 -1
- package/dist/{src-3VZolPlj.js → src-DBx3R6Bc.js} +8 -3
- package/dist/unloader.d.ts +29 -0
- package/dist/unloader.js +21 -0
- package/dist/vite.js +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +10 -5
package/README.md
CHANGED
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://github.com/unplugin/unplugin-oxc/actions/workflows/unit-test.yml)
|
|
4
4
|
|
|
5
|
-
Oxc integration for unplugin.
|
|
5
|
+
[Oxc](https://oxc.rs/) integration for unplugin.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- 🚀 **Blazing Fast**: Transform, resolve, and minify files with Oxc, built in Rust.
|
|
10
|
+
- 🦾 **Powerful**: Supports TypeScript and React JSX transformation, identifier replacement, syntax lowering, and more.
|
|
11
|
+
- 📦 **Zero Config**: No configuration needed for TypeScript support.
|
|
12
|
+
- 🎨 **Customizable**: Fine-tune transform, resolve, and minify options.
|
|
13
|
+
- 😈 **Drop-in Replacement**: Easily replace [rollup-plugin-esbuild](https://github.com/egoist/rollup-plugin-esbuild).
|
|
6
14
|
|
|
7
15
|
## Installation
|
|
8
16
|
|
|
@@ -96,6 +104,55 @@ export default {
|
|
|
96
104
|
|
|
97
105
|
<br></details>
|
|
98
106
|
|
|
107
|
+
<details>
|
|
108
|
+
<summary>unloader</summary><br>
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
// unloader.config.ts
|
|
112
|
+
import Oxc from 'unplugin-oxc/unloader'
|
|
113
|
+
|
|
114
|
+
export default defineConfig({
|
|
115
|
+
plugins: [Oxc()],
|
|
116
|
+
})
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
<br></details>
|
|
120
|
+
|
|
121
|
+
## Usage
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
interface Options {
|
|
125
|
+
/**
|
|
126
|
+
* @default [/\.[cm]?[jt]sx?$/],
|
|
127
|
+
*/
|
|
128
|
+
include?: FilterPattern
|
|
129
|
+
/**
|
|
130
|
+
* @default [/node_modules/],
|
|
131
|
+
*/
|
|
132
|
+
exclude?: FilterPattern
|
|
133
|
+
enforce?: 'pre' | 'post' | undefined
|
|
134
|
+
/**
|
|
135
|
+
* Transform options passed to `oxc-transform`
|
|
136
|
+
*/
|
|
137
|
+
transform?: Omit<TransformOptions, 'sourcemap'> | false
|
|
138
|
+
/**
|
|
139
|
+
* Resolve options passed to `oxc-resolver`
|
|
140
|
+
*/
|
|
141
|
+
resolve?: NapiResolveOptions | false
|
|
142
|
+
/**
|
|
143
|
+
* The plugin will skip resolving node_modules by default.
|
|
144
|
+
* Set this to `true` to resolve node_modules.
|
|
145
|
+
* @default false
|
|
146
|
+
*/
|
|
147
|
+
resolveNodeModules?: boolean
|
|
148
|
+
/**
|
|
149
|
+
* Minify options passed to `oxc-minify`
|
|
150
|
+
*/
|
|
151
|
+
minify?: Omit<MinifyOptions, 'sourcemap'> | false
|
|
152
|
+
sourcemap?: boolean
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
99
156
|
## Sponsors
|
|
100
157
|
|
|
101
158
|
<p align="center">
|
package/dist/esbuild.js
CHANGED
package/dist/farm.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -5,12 +5,32 @@ import { TransformOptions } from 'oxc-transform';
|
|
|
5
5
|
import { FilterPattern } from 'unplugin-utils';
|
|
6
6
|
|
|
7
7
|
interface Options {
|
|
8
|
+
/**
|
|
9
|
+
* @default [/\.[cm]?[jt]sx?$/],
|
|
10
|
+
*/
|
|
8
11
|
include?: FilterPattern;
|
|
12
|
+
/**
|
|
13
|
+
* @default [/node_modules/],
|
|
14
|
+
*/
|
|
9
15
|
exclude?: FilterPattern;
|
|
10
16
|
enforce?: "pre" | "post" | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Transform options passed to `oxc-transform`
|
|
19
|
+
*/
|
|
11
20
|
transform?: Omit<TransformOptions, "sourcemap"> | false;
|
|
21
|
+
/**
|
|
22
|
+
* Resolve options passed to `oxc-resolver`
|
|
23
|
+
*/
|
|
12
24
|
resolve?: NapiResolveOptions | false;
|
|
25
|
+
/**
|
|
26
|
+
* The plugin will skip resolving node_modules by default.
|
|
27
|
+
* Set this to `true` to resolve node_modules.
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
13
30
|
resolveNodeModules?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Minify options passed to `oxc-minify`
|
|
33
|
+
*/
|
|
14
34
|
minify?: Omit<MinifyOptions, "sourcemap"> | false;
|
|
15
35
|
sourcemap?: boolean;
|
|
16
36
|
}
|
package/dist/index.js
CHANGED
package/dist/rolldown.js
CHANGED
package/dist/rollup.js
CHANGED
package/dist/rspack.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
1
2
|
import path from "node:path";
|
|
2
3
|
import { minify } from "oxc-minify";
|
|
3
4
|
import { ResolverFactory } from "oxc-resolver";
|
|
@@ -38,7 +39,6 @@ const Oxc = createUnplugin((rawOptions = {}) => {
|
|
|
38
39
|
name: "unplugin-oxc",
|
|
39
40
|
enforce: options.enforce,
|
|
40
41
|
resolveId: options.resolve !== false ? async (id, importer) => {
|
|
41
|
-
if (!importer) return;
|
|
42
42
|
if (!options.resolveNodeModules && id[0] !== "." && id[0] !== "/") return;
|
|
43
43
|
const resolver = new ResolverFactory({
|
|
44
44
|
extensions: [
|
|
@@ -49,7 +49,7 @@ const Oxc = createUnplugin((rawOptions = {}) => {
|
|
|
49
49
|
],
|
|
50
50
|
...options.resolve
|
|
51
51
|
});
|
|
52
|
-
const directory = path.dirname(importer);
|
|
52
|
+
const directory = path.dirname(importer || id);
|
|
53
53
|
const resolved = await resolver.async(directory, id);
|
|
54
54
|
if (resolved.path) return resolved.path;
|
|
55
55
|
} : undefined,
|
|
@@ -68,7 +68,12 @@ const Oxc = createUnplugin((rawOptions = {}) => {
|
|
|
68
68
|
} : undefined,
|
|
69
69
|
rollup: { renderChunk },
|
|
70
70
|
rolldown: { renderChunk },
|
|
71
|
-
vite: { renderChunk }
|
|
71
|
+
vite: { renderChunk },
|
|
72
|
+
unloader: { async load(id) {
|
|
73
|
+
if (!filter(id)) return;
|
|
74
|
+
const contents = await readFile(id, "utf8");
|
|
75
|
+
return contents;
|
|
76
|
+
} }
|
|
72
77
|
};
|
|
73
78
|
});
|
|
74
79
|
|
|
@@ -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 Unloader plugin.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Unloader plugin
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* // unloader.config.js
|
|
20
|
+
* import Oxc from 'unplugin-oxc/unloader'
|
|
21
|
+
*
|
|
22
|
+
* export default {
|
|
23
|
+
* plugins: [Oxc()],
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
declare const unloader: typeof Oxc.unloader;
|
|
28
|
+
|
|
29
|
+
export { unloader as "module.exports", unloader as default };
|
package/dist/unloader.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Oxc } from "./src-DBx3R6Bc.js";
|
|
2
|
+
|
|
3
|
+
//#region src/unloader.ts
|
|
4
|
+
/**
|
|
5
|
+
* Unloader plugin
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* // unloader.config.js
|
|
10
|
+
* import Oxc from 'unplugin-oxc/unloader'
|
|
11
|
+
*
|
|
12
|
+
* export default {
|
|
13
|
+
* plugins: [Oxc()],
|
|
14
|
+
* }
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
const unloader = Oxc.unloader;
|
|
18
|
+
var unloader_default = unloader;
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { unloader_default as default, unloader as 'module.exports' };
|
package/dist/vite.js
CHANGED
package/dist/webpack.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-oxc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Oxc integration for unplugin.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"./rolldown": "./dist/rolldown.js",
|
|
40
40
|
"./esbuild": "./dist/esbuild.js",
|
|
41
41
|
"./farm": "./dist/farm.js",
|
|
42
|
+
"./unloader": "./dist/unloader.js",
|
|
42
43
|
"./api": "./dist/api.js",
|
|
43
44
|
"./*": "./*"
|
|
44
45
|
},
|
|
@@ -53,11 +54,14 @@
|
|
|
53
54
|
"publishConfig": {
|
|
54
55
|
"access": "public"
|
|
55
56
|
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"unloader": "*"
|
|
59
|
+
},
|
|
56
60
|
"dependencies": {
|
|
57
|
-
"oxc-minify": "^0.
|
|
61
|
+
"oxc-minify": "^0.49.0",
|
|
58
62
|
"oxc-resolver": "^4.0.0",
|
|
59
|
-
"oxc-transform": "^0.
|
|
60
|
-
"unplugin": "^2.
|
|
63
|
+
"oxc-transform": "^0.49.0",
|
|
64
|
+
"unplugin": "^2.2.0",
|
|
61
65
|
"unplugin-utils": "^0.2.3"
|
|
62
66
|
},
|
|
63
67
|
"devDependencies": {
|
|
@@ -65,13 +69,14 @@
|
|
|
65
69
|
"@sxzz/prettier-config": "^2.1.2",
|
|
66
70
|
"@sxzz/test-utils": "^0.5.1",
|
|
67
71
|
"@types/node": "^22.13.1",
|
|
68
|
-
"bumpp": "^10.0.
|
|
72
|
+
"bumpp": "^10.0.3",
|
|
69
73
|
"eslint": "^9.20.0",
|
|
70
74
|
"prettier": "^3.5.0",
|
|
71
75
|
"rollup": "^4.34.6",
|
|
72
76
|
"tsdown": "^0.5.9",
|
|
73
77
|
"tsx": "^4.19.2",
|
|
74
78
|
"typescript": "^5.7.3",
|
|
79
|
+
"unloader": "^0.3.0",
|
|
75
80
|
"vite": "^6.1.0",
|
|
76
81
|
"vitest": "^3.0.5"
|
|
77
82
|
},
|