unplugin-oxc 0.2.0 → 0.2.2
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 +1 -1
- package/dist/esbuild.js +1 -1
- package/dist/farm.js +1 -1
- package/dist/index.d.ts +3 -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-DBx3R6Bc.js → src-Ctwdi8QE.js} +29 -12
- package/dist/unloader.js +1 -1
- package/dist/vite.js +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
- 🦾 **Powerful**: Supports TypeScript and React JSX transformation, identifier replacement, syntax lowering, and more.
|
|
11
11
|
- 📦 **Zero Config**: No configuration needed for TypeScript support.
|
|
12
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).
|
|
13
|
+
- 😈 **Drop-in Replacement**: Easily replace [rollup-plugin-esbuild](https://github.com/egoist/rollup-plugin-esbuild) and [@rollup/plugin-node-resolve](https://github.com/rollup/plugins/tree/master/packages/node-resolve).
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
package/dist/esbuild.js
CHANGED
package/dist/farm.js
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/rolldown.js
CHANGED
package/dist/rollup.js
CHANGED
package/dist/rspack.js
CHANGED
|
@@ -7,7 +7,7 @@ import { createUnplugin } from "unplugin";
|
|
|
7
7
|
import { createFilter } from "unplugin-utils";
|
|
8
8
|
|
|
9
9
|
//#region src/core/options.ts
|
|
10
|
-
function resolveOptions(options) {
|
|
10
|
+
function resolveOptions(options, framework) {
|
|
11
11
|
return {
|
|
12
12
|
include: options.include || [/\.[cm]?[jt]sx?$/],
|
|
13
13
|
exclude: options.exclude || [/node_modules/],
|
|
@@ -16,14 +16,14 @@ function resolveOptions(options) {
|
|
|
16
16
|
resolve: options.resolve || {},
|
|
17
17
|
resolveNodeModules: options.resolveNodeModules || false,
|
|
18
18
|
minify: options.minify || false,
|
|
19
|
-
sourcemap: options.sourcemap
|
|
19
|
+
sourcemap: options.sourcemap ?? framework === "unloader"
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
//#endregion
|
|
24
24
|
//#region src/index.ts
|
|
25
|
-
const Oxc = createUnplugin((rawOptions = {}) => {
|
|
26
|
-
const options = resolveOptions(rawOptions);
|
|
25
|
+
const Oxc = createUnplugin((rawOptions = {}, { framework }) => {
|
|
26
|
+
const options = resolveOptions(rawOptions, framework);
|
|
27
27
|
const filter = createFilter(options.include, options.exclude);
|
|
28
28
|
const renderChunk = options.minify !== false ? (code, chunk) => {
|
|
29
29
|
const result = minify(chunk.fileName, code, {
|
|
@@ -42,11 +42,22 @@ const Oxc = createUnplugin((rawOptions = {}) => {
|
|
|
42
42
|
if (!options.resolveNodeModules && id[0] !== "." && id[0] !== "/") return;
|
|
43
43
|
const resolver = new ResolverFactory({
|
|
44
44
|
extensions: [
|
|
45
|
+
".mjs",
|
|
46
|
+
".js",
|
|
45
47
|
".ts",
|
|
46
|
-
".
|
|
47
|
-
".
|
|
48
|
-
".
|
|
48
|
+
".jsx",
|
|
49
|
+
".tsx",
|
|
50
|
+
".json",
|
|
51
|
+
".node"
|
|
49
52
|
],
|
|
53
|
+
conditionNames: [
|
|
54
|
+
"import",
|
|
55
|
+
"require",
|
|
56
|
+
"browser",
|
|
57
|
+
"node",
|
|
58
|
+
"default"
|
|
59
|
+
],
|
|
60
|
+
builtinModules: true,
|
|
50
61
|
...options.resolve
|
|
51
62
|
});
|
|
52
63
|
const directory = path.dirname(importer || id);
|
|
@@ -61,6 +72,7 @@ const Oxc = createUnplugin((rawOptions = {}) => {
|
|
|
61
72
|
...options.transform,
|
|
62
73
|
sourcemap: options.sourcemap
|
|
63
74
|
});
|
|
75
|
+
if (result.errors.length) throw new SyntaxError(result.errors.map((error) => error.message).join("\n"));
|
|
64
76
|
return {
|
|
65
77
|
code: result.code,
|
|
66
78
|
map: result.map
|
|
@@ -69,11 +81,16 @@ const Oxc = createUnplugin((rawOptions = {}) => {
|
|
|
69
81
|
rollup: { renderChunk },
|
|
70
82
|
rolldown: { renderChunk },
|
|
71
83
|
vite: { renderChunk },
|
|
72
|
-
unloader: {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
84
|
+
unloader: {
|
|
85
|
+
options(config) {
|
|
86
|
+
config.sourcemap ||= options.sourcemap;
|
|
87
|
+
},
|
|
88
|
+
async load(id) {
|
|
89
|
+
if (!filter(id)) return;
|
|
90
|
+
const contents = await readFile(id, "utf8");
|
|
91
|
+
return contents;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
77
94
|
};
|
|
78
95
|
});
|
|
79
96
|
|
package/dist/unloader.js
CHANGED
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.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Oxc integration for unplugin.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -58,19 +58,19 @@
|
|
|
58
58
|
"unloader": "*"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"oxc-minify": "^0.
|
|
61
|
+
"oxc-minify": "^0.50.0",
|
|
62
62
|
"oxc-resolver": "^4.0.0",
|
|
63
|
-
"oxc-transform": "^0.
|
|
63
|
+
"oxc-transform": "^0.50.0",
|
|
64
64
|
"unplugin": "^2.2.0",
|
|
65
|
-
"unplugin-utils": "^0.2.
|
|
65
|
+
"unplugin-utils": "^0.2.4"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@sxzz/eslint-config": "^5.0.
|
|
68
|
+
"@sxzz/eslint-config": "^5.0.2",
|
|
69
69
|
"@sxzz/prettier-config": "^2.1.2",
|
|
70
70
|
"@sxzz/test-utils": "^0.5.1",
|
|
71
71
|
"@types/node": "^22.13.1",
|
|
72
72
|
"bumpp": "^10.0.3",
|
|
73
|
-
"eslint": "^9.20.
|
|
73
|
+
"eslint": "^9.20.1",
|
|
74
74
|
"prettier": "^3.5.0",
|
|
75
75
|
"rollup": "^4.34.6",
|
|
76
76
|
"tsdown": "^0.5.9",
|