unplugin-oxc 0.4.2 → 0.4.4
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.js +1 -1
- package/dist/rolldown.js +1 -1
- package/dist/rollup.js +1 -1
- package/dist/rspack.js +1 -1
- package/dist/{src-BdV4nB7N.js → src-VARAeVoC.js} +77 -60
- package/dist/unloader.js +1 -1
- package/dist/vite.js +1 -1
- package/dist/webpack.js +1 -1
- package/package.json +12 -12
package/dist/esbuild.js
CHANGED
package/dist/farm.js
CHANGED
package/dist/index.js
CHANGED
package/dist/rolldown.js
CHANGED
package/dist/rollup.js
CHANGED
package/dist/rspack.js
CHANGED
|
@@ -38,6 +38,56 @@ function getModuleFormat(id) {
|
|
|
38
38
|
const Oxc = createUnplugin((rawOptions = {}, { framework }) => {
|
|
39
39
|
const options = resolveOptions(rawOptions, framework);
|
|
40
40
|
const filter = createFilter(options.include, options.exclude);
|
|
41
|
+
const resolveId = options.resolve !== false ? (id, importer, resolveOptions$1) => {
|
|
42
|
+
if (!options.resolveNodeModules && id[0] !== "." && !path.isAbsolute(id)) return;
|
|
43
|
+
const resolver = new ResolverFactory({
|
|
44
|
+
extensions: [
|
|
45
|
+
".mjs",
|
|
46
|
+
".js",
|
|
47
|
+
".ts",
|
|
48
|
+
".jsx",
|
|
49
|
+
".tsx",
|
|
50
|
+
".json",
|
|
51
|
+
".node"
|
|
52
|
+
],
|
|
53
|
+
conditionNames: resolveOptions$1?.conditions ? Array.from(resolveOptions$1.conditions) : [
|
|
54
|
+
"import",
|
|
55
|
+
"require",
|
|
56
|
+
"browser",
|
|
57
|
+
"node",
|
|
58
|
+
"default"
|
|
59
|
+
],
|
|
60
|
+
builtinModules: true,
|
|
61
|
+
...options.resolve
|
|
62
|
+
});
|
|
63
|
+
const directory = importer ? path.dirname(importer) : process.cwd();
|
|
64
|
+
const resolved = resolver.sync(directory, id);
|
|
65
|
+
if (resolved.error?.startsWith("Builtin module")) return {
|
|
66
|
+
id,
|
|
67
|
+
external: true,
|
|
68
|
+
moduleSideEffects: false
|
|
69
|
+
};
|
|
70
|
+
if (resolved.path) {
|
|
71
|
+
const format = getModuleFormat(resolved.path) || resolved.moduleType || "commonjs";
|
|
72
|
+
return {
|
|
73
|
+
id: resolved.path,
|
|
74
|
+
format
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
} : void 0;
|
|
78
|
+
const transform$1 = options.transform !== false ? (code, id, ...args) => {
|
|
79
|
+
const [transformOptions] = args;
|
|
80
|
+
const result = transform(id, code, {
|
|
81
|
+
...options.transform,
|
|
82
|
+
sourceType: guessSourceType(id, transformOptions?.format),
|
|
83
|
+
sourcemap: options.sourcemap
|
|
84
|
+
});
|
|
85
|
+
if (result.errors.length) throw new SyntaxError(result.errors.map((error) => error.message).join("\n"));
|
|
86
|
+
return {
|
|
87
|
+
code: result.code,
|
|
88
|
+
map: result.map
|
|
89
|
+
};
|
|
90
|
+
} : void 0;
|
|
41
91
|
const renderChunk = options.minify !== false ? async (code, chunk) => {
|
|
42
92
|
const { minify } = await import("oxc-minify");
|
|
43
93
|
const result = minify(chunk.fileName, code, {
|
|
@@ -49,75 +99,42 @@ const Oxc = createUnplugin((rawOptions = {}, { framework }) => {
|
|
|
49
99
|
map: result.map
|
|
50
100
|
};
|
|
51
101
|
} : void 0;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
],
|
|
67
|
-
conditionNames: resolveOptions$1?.conditions ? Array.from(resolveOptions$1.conditions) : [
|
|
68
|
-
"import",
|
|
69
|
-
"require",
|
|
70
|
-
"browser",
|
|
71
|
-
"node",
|
|
72
|
-
"default"
|
|
73
|
-
],
|
|
74
|
-
builtinModules: true,
|
|
75
|
-
...options.resolve
|
|
76
|
-
});
|
|
77
|
-
const directory = importer ? path.dirname(importer) : process.cwd();
|
|
78
|
-
const resolved = resolver.sync(directory, id);
|
|
79
|
-
if (resolved.error?.startsWith("Builtin module")) return {
|
|
80
|
-
id,
|
|
81
|
-
external: true,
|
|
82
|
-
moduleSideEffects: false
|
|
83
|
-
};
|
|
84
|
-
if (resolved.path) {
|
|
85
|
-
const format = getModuleFormat(resolved.path) || resolved.moduleType || "commonjs";
|
|
102
|
+
const unloader = {
|
|
103
|
+
options(config) {
|
|
104
|
+
config.sourcemap ||= options.sourcemap;
|
|
105
|
+
},
|
|
106
|
+
load(id) {
|
|
107
|
+
if (id.endsWith(".json")) {
|
|
108
|
+
let code = readFileSync(id, "utf8");
|
|
109
|
+
const json = JSON.parse(code);
|
|
110
|
+
code = `const json = ${code}\nexport default json\n`;
|
|
111
|
+
const i = 0;
|
|
112
|
+
for (const key of Object.keys(json)) {
|
|
113
|
+
const sanitizedKey = `_${key.replaceAll(/\W/g, "_")}${i}`;
|
|
114
|
+
code += `\nconst ${sanitizedKey} = json[${JSON.stringify(key)}]\nexport { ${sanitizedKey} as ${JSON.stringify(key)} }\n`;
|
|
115
|
+
}
|
|
86
116
|
return {
|
|
87
|
-
|
|
88
|
-
format
|
|
117
|
+
code,
|
|
118
|
+
format: "module"
|
|
89
119
|
};
|
|
90
120
|
}
|
|
91
|
-
|
|
121
|
+
if (!filter(id)) return;
|
|
122
|
+
const contents = readFileSync(id, "utf8");
|
|
123
|
+
return contents;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
return {
|
|
127
|
+
name: "unplugin-oxc",
|
|
128
|
+
enforce: options.enforce,
|
|
129
|
+
resolveId,
|
|
92
130
|
transformInclude(id) {
|
|
93
131
|
return filter(id);
|
|
94
132
|
},
|
|
95
|
-
transform:
|
|
96
|
-
const [transformOptions] = args;
|
|
97
|
-
const result = transform(id, code, {
|
|
98
|
-
...options.transform,
|
|
99
|
-
sourceType: guessSourceType(id, transformOptions?.format),
|
|
100
|
-
sourcemap: options.sourcemap
|
|
101
|
-
});
|
|
102
|
-
if (result.errors.length) throw new SyntaxError(result.errors.map((error) => error.message).join("\n"));
|
|
103
|
-
return {
|
|
104
|
-
code: result.code,
|
|
105
|
-
map: result.map
|
|
106
|
-
};
|
|
107
|
-
} : void 0,
|
|
133
|
+
transform: transform$1,
|
|
108
134
|
rollup: { renderChunk },
|
|
109
135
|
rolldown: { renderChunk },
|
|
110
136
|
vite: { renderChunk },
|
|
111
|
-
unloader
|
|
112
|
-
options(config) {
|
|
113
|
-
config.sourcemap ||= options.sourcemap;
|
|
114
|
-
},
|
|
115
|
-
load(id) {
|
|
116
|
-
if (!filter(id)) return;
|
|
117
|
-
const contents = readFileSync(id, "utf8");
|
|
118
|
-
return contents;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
137
|
+
unloader
|
|
121
138
|
};
|
|
122
139
|
});
|
|
123
140
|
function guessSourceType(id, format) {
|
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.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "Oxc integration for unplugin.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -63,28 +63,28 @@
|
|
|
63
63
|
}
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"oxc-minify": "^0.
|
|
67
|
-
"oxc-resolver": "^9.0.
|
|
68
|
-
"oxc-transform": "^0.
|
|
69
|
-
"unplugin": "^2.3.
|
|
66
|
+
"oxc-minify": "^0.70.0",
|
|
67
|
+
"oxc-resolver": "^9.0.2",
|
|
68
|
+
"oxc-transform": "^0.70.0",
|
|
69
|
+
"unplugin": "^2.3.4",
|
|
70
70
|
"unplugin-utils": "^0.2.4"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@sxzz/eslint-config": "^7.0.1",
|
|
74
74
|
"@sxzz/prettier-config": "^2.2.1",
|
|
75
75
|
"@sxzz/test-utils": "^0.5.6",
|
|
76
|
-
"@types/node": "^22.15.
|
|
77
|
-
"bumpp": "^10.1.
|
|
78
|
-
"eslint": "^9.
|
|
76
|
+
"@types/node": "^22.15.19",
|
|
77
|
+
"bumpp": "^10.1.1",
|
|
78
|
+
"eslint": "^9.27.0",
|
|
79
79
|
"prettier": "^3.5.3",
|
|
80
|
-
"rollup": "^4.
|
|
80
|
+
"rollup": "^4.41.0",
|
|
81
81
|
"tinyexec": "^1.0.1",
|
|
82
|
-
"tsdown": "^0.11.
|
|
82
|
+
"tsdown": "^0.11.12",
|
|
83
83
|
"tsx": "^4.19.4",
|
|
84
84
|
"typescript": "^5.8.3",
|
|
85
|
-
"unloader": "^0.4.
|
|
85
|
+
"unloader": "^0.4.5",
|
|
86
86
|
"vite": "^6.3.5",
|
|
87
|
-
"vitest": "^3.1.
|
|
87
|
+
"vitest": "^3.1.4"
|
|
88
88
|
},
|
|
89
89
|
"engines": {
|
|
90
90
|
"node": ">=20.18.0"
|