unplugin-oxc 0.2.8 → 0.3.1
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/api.d.ts +1 -1
- package/dist/esbuild.d.ts +1 -1
- package/dist/esbuild.js +1 -1
- package/dist/farm.d.ts +1 -1
- package/dist/farm.js +1 -1
- package/dist/index.d.ts +14 -5
- package/dist/index.js +1 -1
- package/dist/rolldown.d.ts +1 -1
- package/dist/rolldown.js +1 -1
- package/dist/rollup.d.ts +1 -1
- package/dist/rollup.js +1 -1
- package/dist/rspack.d.ts +1 -1
- package/dist/rspack.js +1 -1
- package/dist/{src-CE68RyH8.js → src-Bw_izk11.js} +35 -9
- package/dist/unloader.d.ts +1 -1
- package/dist/unloader.js +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +1 -1
- package/dist/webpack.d.ts +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +12 -12
package/dist/api.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
|
|
2
|
-
export {
|
|
2
|
+
export { };
|
package/dist/esbuild.d.ts
CHANGED
package/dist/esbuild.js
CHANGED
package/dist/farm.d.ts
CHANGED
package/dist/farm.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
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';
|
|
1
|
+
import type { UnpluginInstance } from 'unplugin';
|
|
2
|
+
import type { MinifyOptions } from 'oxc-minify';
|
|
3
|
+
import type { NapiResolveOptions } from 'oxc-resolver';
|
|
4
|
+
import type { TransformOptions } from 'oxc-transform';
|
|
5
|
+
import type { FilterPattern } from 'unplugin-utils';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
6
12
|
|
|
7
13
|
interface Options {
|
|
8
14
|
/**
|
|
@@ -38,6 +44,9 @@ interface Options {
|
|
|
38
44
|
sourcemap?: boolean;
|
|
39
45
|
}
|
|
40
46
|
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
41
50
|
declare const Oxc: UnpluginInstance<Options | undefined, false>;
|
|
42
51
|
|
|
43
52
|
export { Oxc };
|
package/dist/index.js
CHANGED
package/dist/rolldown.d.ts
CHANGED
package/dist/rolldown.js
CHANGED
package/dist/rollup.d.ts
CHANGED
package/dist/rollup.js
CHANGED
package/dist/rspack.d.ts
CHANGED
package/dist/rspack.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import { ResolverFactory } from "oxc-resolver";
|
|
@@ -20,6 +20,18 @@ function resolveOptions(options, framework) {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/core/utils.ts
|
|
25
|
+
function getModuleFormat(id) {
|
|
26
|
+
const ext = path.extname(id);
|
|
27
|
+
switch (ext) {
|
|
28
|
+
case ".mjs":
|
|
29
|
+
case ".mts": return "module";
|
|
30
|
+
case ".cjs":
|
|
31
|
+
case ".cts": return "commonjs";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
23
35
|
//#endregion
|
|
24
36
|
//#region src/index.ts
|
|
25
37
|
const Oxc = createUnplugin((rawOptions = {}, { framework }) => {
|
|
@@ -39,8 +51,8 @@ const Oxc = createUnplugin((rawOptions = {}, { framework }) => {
|
|
|
39
51
|
return {
|
|
40
52
|
name: "unplugin-oxc",
|
|
41
53
|
enforce: options.enforce,
|
|
42
|
-
resolveId: options.resolve !== false ?
|
|
43
|
-
if (!options.resolveNodeModules && id[0] !== "." && id
|
|
54
|
+
resolveId: options.resolve !== false ? (id, importer, resolveOptions$1) => {
|
|
55
|
+
if (!options.resolveNodeModules && id[0] !== "." && !path.isAbsolute(id)) return;
|
|
44
56
|
const resolver = new ResolverFactory({
|
|
45
57
|
extensions: [
|
|
46
58
|
".mjs",
|
|
@@ -51,7 +63,7 @@ const Oxc = createUnplugin((rawOptions = {}, { framework }) => {
|
|
|
51
63
|
".json",
|
|
52
64
|
".node"
|
|
53
65
|
],
|
|
54
|
-
conditionNames: [
|
|
66
|
+
conditionNames: resolveOptions$1?.conditions ? Array.from(resolveOptions$1.conditions) : [
|
|
55
67
|
"import",
|
|
56
68
|
"require",
|
|
57
69
|
"browser",
|
|
@@ -62,20 +74,28 @@ const Oxc = createUnplugin((rawOptions = {}, { framework }) => {
|
|
|
62
74
|
...options.resolve
|
|
63
75
|
});
|
|
64
76
|
const directory = importer ? path.dirname(importer) : process.cwd();
|
|
65
|
-
const resolved =
|
|
77
|
+
const resolved = resolver.sync(directory, id);
|
|
66
78
|
if (resolved.error?.startsWith("Builtin module")) return {
|
|
67
79
|
id,
|
|
68
80
|
external: true,
|
|
69
81
|
moduleSideEffects: false
|
|
70
82
|
};
|
|
71
|
-
if (resolved.path)
|
|
83
|
+
if (resolved.path) {
|
|
84
|
+
const format = getModuleFormat(resolved.path) || resolved.moduleType || "commonjs";
|
|
85
|
+
return {
|
|
86
|
+
id: resolved.path,
|
|
87
|
+
format
|
|
88
|
+
};
|
|
89
|
+
}
|
|
72
90
|
} : void 0,
|
|
73
91
|
transformInclude(id) {
|
|
74
92
|
return filter(id);
|
|
75
93
|
},
|
|
76
|
-
transform: options.transform !== false ? (code, id) => {
|
|
94
|
+
transform: options.transform !== false ? (code, id, ...args) => {
|
|
95
|
+
const [transformOptions] = args;
|
|
77
96
|
const result = transform(id, code, {
|
|
78
97
|
...options.transform,
|
|
98
|
+
sourceType: guessSourceType(id, transformOptions?.format),
|
|
79
99
|
sourcemap: options.sourcemap
|
|
80
100
|
});
|
|
81
101
|
if (result.errors.length) throw new SyntaxError(result.errors.map((error) => error.message).join("\n"));
|
|
@@ -91,14 +111,20 @@ const Oxc = createUnplugin((rawOptions = {}, { framework }) => {
|
|
|
91
111
|
options(config) {
|
|
92
112
|
config.sourcemap ||= options.sourcemap;
|
|
93
113
|
},
|
|
94
|
-
|
|
114
|
+
load(id) {
|
|
95
115
|
if (!filter(id)) return;
|
|
96
|
-
const contents =
|
|
116
|
+
const contents = readFileSync(id, "utf8");
|
|
97
117
|
return contents;
|
|
98
118
|
}
|
|
99
119
|
}
|
|
100
120
|
};
|
|
101
121
|
});
|
|
122
|
+
function guessSourceType(id, format) {
|
|
123
|
+
if (format === "module" || format === "module-typescript") return "module";
|
|
124
|
+
else if (format === "commonjs" || format === "commonjs-typescript") return "script";
|
|
125
|
+
const moduleFormat = getModuleFormat(id);
|
|
126
|
+
if (moduleFormat) return moduleFormat === "module" ? "module" : "script";
|
|
127
|
+
}
|
|
102
128
|
|
|
103
129
|
//#endregion
|
|
104
130
|
export { Oxc };
|
package/dist/unloader.d.ts
CHANGED
package/dist/unloader.js
CHANGED
package/dist/vite.d.ts
CHANGED
package/dist/vite.js
CHANGED
package/dist/webpack.d.ts
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.3.1",
|
|
4
4
|
"description": "Oxc integration for unplugin.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"oxc-minify": "^0.
|
|
67
|
-
"oxc-resolver": "^5.0.
|
|
68
|
-
"oxc-transform": "^0.
|
|
69
|
-
"unplugin": "^2.2.
|
|
66
|
+
"oxc-minify": "^0.60.0",
|
|
67
|
+
"oxc-resolver": "^5.0.1",
|
|
68
|
+
"oxc-transform": "^0.60.0",
|
|
69
|
+
"unplugin": "^2.2.1",
|
|
70
70
|
"unplugin-utils": "^0.2.4"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
@@ -74,17 +74,17 @@
|
|
|
74
74
|
"@sxzz/prettier-config": "^2.2.1",
|
|
75
75
|
"@sxzz/test-utils": "^0.5.2",
|
|
76
76
|
"@types/node": "^22.13.10",
|
|
77
|
-
"bumpp": "^10.0
|
|
77
|
+
"bumpp": "^10.1.0",
|
|
78
78
|
"eslint": "^9.22.0",
|
|
79
79
|
"prettier": "^3.5.3",
|
|
80
|
-
"rollup": "^4.
|
|
81
|
-
"tinyexec": "^0.
|
|
82
|
-
"tsdown": "^0.6.
|
|
80
|
+
"rollup": "^4.36.0",
|
|
81
|
+
"tinyexec": "^1.0.0",
|
|
82
|
+
"tsdown": "^0.6.9",
|
|
83
83
|
"tsx": "^4.19.3",
|
|
84
84
|
"typescript": "^5.8.2",
|
|
85
|
-
"unloader": "^0.
|
|
86
|
-
"vite": "^6.2.
|
|
87
|
-
"vitest": "^3.0.
|
|
85
|
+
"unloader": "^0.4.1",
|
|
86
|
+
"vite": "^6.2.2",
|
|
87
|
+
"vitest": "^3.0.9"
|
|
88
88
|
},
|
|
89
89
|
"engines": {
|
|
90
90
|
"node": ">=18.12.0"
|