unplugin-oxc 0.2.0 → 0.2.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/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-C7AaF2B_.js} +15 -9
- package/dist/unloader.js +1 -1
- package/dist/vite.js +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +2 -2
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, {
|
|
@@ -61,6 +61,7 @@ const Oxc = createUnplugin((rawOptions = {}) => {
|
|
|
61
61
|
...options.transform,
|
|
62
62
|
sourcemap: options.sourcemap
|
|
63
63
|
});
|
|
64
|
+
if (result.errors.length) throw new SyntaxError(result.errors.map((error) => error.message).join("\n"));
|
|
64
65
|
return {
|
|
65
66
|
code: result.code,
|
|
66
67
|
map: result.map
|
|
@@ -69,11 +70,16 @@ const Oxc = createUnplugin((rawOptions = {}) => {
|
|
|
69
70
|
rollup: { renderChunk },
|
|
70
71
|
rolldown: { renderChunk },
|
|
71
72
|
vite: { renderChunk },
|
|
72
|
-
unloader: {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
73
|
+
unloader: {
|
|
74
|
+
options(config) {
|
|
75
|
+
config.sourcemap ||= options.sourcemap;
|
|
76
|
+
},
|
|
77
|
+
async load(id) {
|
|
78
|
+
if (!filter(id)) return;
|
|
79
|
+
const contents = await readFile(id, "utf8");
|
|
80
|
+
return contents;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
77
83
|
};
|
|
78
84
|
});
|
|
79
85
|
|
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.1",
|
|
4
4
|
"description": "Oxc integration for unplugin.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"unplugin-utils": "^0.2.3"
|
|
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",
|