unplugin-isolated-decl 0.6.7 → 0.6.8
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.cjs +1 -1
- package/dist/api.js +1 -1
- package/dist/esbuild.cjs +2 -2
- package/dist/esbuild.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist/rolldown.cjs +2 -2
- package/dist/rolldown.js +2 -2
- package/dist/rollup.cjs +2 -2
- package/dist/rollup.js +2 -2
- package/dist/{src_index-jESannmB.js → src_index-2WEAOr05.js} +27 -57
- package/dist/{src_index-tVPRzUWA.cjs → src_index-NKcZyc90.cjs} +25 -55
- package/dist/{transformer-9aaNC01N.cjs → transformer-uKy0L3Za.cjs} +16 -24
- package/dist/{transformer-GSFmnEOV.js → transformer-w7XvOpWe.js} +16 -24
- package/dist/vite.cjs +2 -2
- package/dist/vite.js +2 -2
- package/package.json +11 -11
package/dist/api.cjs
CHANGED
package/dist/api.js
CHANGED
package/dist/esbuild.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const require_src_index = require('./src_index-
|
|
3
|
-
require('./transformer-
|
|
2
|
+
const require_src_index = require('./src_index-NKcZyc90.cjs');
|
|
3
|
+
require('./transformer-uKy0L3Za.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/esbuild.ts
|
|
6
6
|
var esbuild_default = require_src_index.IsolatedDecl.esbuild;
|
package/dist/esbuild.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const require_src_index = require('./src_index-
|
|
3
|
-
require('./transformer-
|
|
2
|
+
const require_src_index = require('./src_index-NKcZyc90.cjs');
|
|
3
|
+
require('./transformer-uKy0L3Za.cjs');
|
|
4
4
|
|
|
5
5
|
exports.IsolatedDecl = require_src_index.IsolatedDecl
|
|
6
6
|
exports.lowestCommonAncestor = require_src_index.lowestCommonAncestor
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./transformer-
|
|
2
|
-
import { IsolatedDecl, lowestCommonAncestor } from "./src_index-
|
|
1
|
+
import "./transformer-w7XvOpWe.js";
|
|
2
|
+
import { IsolatedDecl, lowestCommonAncestor } from "./src_index-2WEAOr05.js";
|
|
3
3
|
|
|
4
4
|
export { IsolatedDecl, lowestCommonAncestor };
|
package/dist/rolldown.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const require_src_index = require('./src_index-
|
|
3
|
-
require('./transformer-
|
|
2
|
+
const require_src_index = require('./src_index-NKcZyc90.cjs');
|
|
3
|
+
require('./transformer-uKy0L3Za.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/rolldown.ts
|
|
6
6
|
var rolldown_default = require_src_index.IsolatedDecl.rolldown;
|
package/dist/rolldown.js
CHANGED
package/dist/rollup.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const require_src_index = require('./src_index-
|
|
3
|
-
require('./transformer-
|
|
2
|
+
const require_src_index = require('./src_index-NKcZyc90.cjs');
|
|
3
|
+
require('./transformer-uKy0L3Za.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/rollup.ts
|
|
6
6
|
var rollup_default = require_src_index.IsolatedDecl.rollup;
|
package/dist/rollup.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { oxcTransform, swcTransform, tsTransform } from "./transformer-
|
|
1
|
+
import { oxcTransform, swcTransform, tsTransform } from "./transformer-w7XvOpWe.js";
|
|
2
2
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
3
|
-
import
|
|
3
|
+
import path from "node:path";
|
|
4
4
|
import { createFilter } from "@rollup/pluginutils";
|
|
5
|
-
import
|
|
5
|
+
import MagicString from "magic-string";
|
|
6
6
|
import { parseAsync } from "oxc-parser";
|
|
7
7
|
import { createUnplugin } from "unplugin";
|
|
8
8
|
|
|
@@ -34,19 +34,13 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
34
34
|
const inputMap = !Array.isArray(input) ? Object.fromEntries(Object.entries(input).map(([k, v]) => [path.resolve(stripExt(v)), k])) : undefined;
|
|
35
35
|
const normalizedInput = Array.isArray(input) ? input : Object.values(input);
|
|
36
36
|
const outBase = lowestCommonAncestor(...normalizedInput);
|
|
37
|
-
if (typeof outputOptions.entryFileNames !== "string")
|
|
38
|
-
return this.error("entryFileNames must be a string");
|
|
39
|
-
}
|
|
37
|
+
if (typeof outputOptions.entryFileNames !== "string") return this.error("entryFileNames must be a string");
|
|
40
38
|
let entryFileNames = outputOptions.entryFileNames.replace(/\.(.)?[jt]sx?$/, (_, s) => `.d.${s || ""}ts`);
|
|
41
|
-
if (options.extraOutdir)
|
|
42
|
-
entryFileNames = path.join(options.extraOutdir, entryFileNames);
|
|
43
|
-
}
|
|
39
|
+
if (options.extraOutdir) entryFileNames = path.join(options.extraOutdir, entryFileNames);
|
|
44
40
|
for (let [outname, source] of Object.entries(outputFiles)) {
|
|
45
41
|
const name = inputMap?.[outname] || path.relative(outBase, outname);
|
|
46
42
|
const fileName = entryFileNames.replace("[name]", name);
|
|
47
|
-
if (options.patchCjsDefaultExport && fileName.endsWith(".d.cts"))
|
|
48
|
-
source = patchCjsDefaultExport(source);
|
|
49
|
-
}
|
|
43
|
+
if (options.patchCjsDefaultExport && fileName.endsWith(".d.cts")) source = patchCjsDefaultExport(source);
|
|
50
44
|
this.emitFile({
|
|
51
45
|
type: "asset",
|
|
52
46
|
fileName,
|
|
@@ -74,26 +68,16 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
74
68
|
async function transform(context, code, id) {
|
|
75
69
|
let program;
|
|
76
70
|
try {
|
|
77
|
-
program =
|
|
71
|
+
program = (await parseAsync(code, { sourceFilename: id })).program;
|
|
78
72
|
} catch {}
|
|
79
73
|
if (options.autoAddExts && program) {
|
|
80
74
|
const imports = program.body.filter((node) => node.type === "ImportDeclaration" || node.type === "ExportAllDeclaration" || node.type === "ExportNamedDeclaration");
|
|
81
75
|
const s = new MagicString(code);
|
|
82
76
|
for (const i of imports) {
|
|
83
|
-
if (!i.source || path.basename(i.source.value).includes("."))
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
77
|
+
if (!i.source || path.basename(i.source.value).includes(".")) continue;
|
|
86
78
|
const resolved = await resolve(context, i.source.value, id);
|
|
87
79
|
if (!resolved || resolved.external) continue;
|
|
88
|
-
if (resolved.id.endsWith(".ts") || resolved.id.endsWith(".tsx")) {
|
|
89
|
-
s.overwrite(
|
|
90
|
-
// @ts-expect-error
|
|
91
|
-
i.source.start,
|
|
92
|
-
// @ts-expect-error
|
|
93
|
-
i.source.end,
|
|
94
|
-
JSON.stringify(`${i.source.value}.js`)
|
|
95
|
-
);
|
|
96
|
-
}
|
|
80
|
+
if (resolved.id.endsWith(".ts") || resolved.id.endsWith(".tsx")) s.overwrite(i.source.start, i.source.end, JSON.stringify(`${i.source.value}.js`));
|
|
97
81
|
}
|
|
98
82
|
code = s.toString();
|
|
99
83
|
}
|
|
@@ -108,20 +92,17 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
108
92
|
case "typescript": result = await tsTransform(id, code, options.transformOptions);
|
|
109
93
|
}
|
|
110
94
|
const { code: sourceText, errors } = result;
|
|
111
|
-
if (errors.length)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
context.error(errors[0]);
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
95
|
+
if (errors.length) if (options.ignoreErrors) context.warn(errors[0]);
|
|
96
|
+
else {
|
|
97
|
+
context.error(errors[0]);
|
|
98
|
+
return;
|
|
118
99
|
}
|
|
119
100
|
addOutput(id, sourceText);
|
|
120
101
|
if (!program) return;
|
|
121
102
|
const typeImports = program.body.filter((node) => {
|
|
122
103
|
if (node.type === "ImportDeclaration") {
|
|
123
104
|
if (node.importKind === "type") return true;
|
|
124
|
-
return node.specifiers && node.specifiers.every((spec) => spec.type === "ImportSpecifier" && spec.importKind === "type");
|
|
105
|
+
return !!node.specifiers && node.specifiers.every((spec) => spec.type === "ImportSpecifier" && spec.importKind === "type");
|
|
125
106
|
}
|
|
126
107
|
if (node.type === "ExportNamedDeclaration" || node.type === "ExportAllDeclaration") {
|
|
127
108
|
if (node.exportKind === "type") return true;
|
|
@@ -165,31 +146,23 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
165
146
|
const write = build.initialOptions.write ?? true;
|
|
166
147
|
if (write) {
|
|
167
148
|
if (!build.initialOptions.outdir) throw new Error("outdir is required when write is true");
|
|
168
|
-
} else
|
|
169
|
-
result.outputFiles ||= [];
|
|
170
|
-
}
|
|
149
|
+
} else result.outputFiles ||= [];
|
|
171
150
|
const textEncoder = new TextEncoder();
|
|
172
151
|
for (let [filename, source] of Object.entries(outputFiles)) {
|
|
173
152
|
const outDir = build.initialOptions.outdir;
|
|
174
153
|
let outFile = `${path.relative(outBase, filename)}.d.${outExt}`;
|
|
175
|
-
if (options.extraOutdir)
|
|
176
|
-
outFile = path.join(options.extraOutdir, outFile);
|
|
177
|
-
}
|
|
154
|
+
if (options.extraOutdir) outFile = path.join(options.extraOutdir, outFile);
|
|
178
155
|
const filePath = outDir ? path.resolve(outDir, outFile) : outFile;
|
|
179
|
-
if (options.patchCjsDefaultExport && filePath.endsWith(".d.cts"))
|
|
180
|
-
source = patchCjsDefaultExport(source);
|
|
181
|
-
}
|
|
156
|
+
if (options.patchCjsDefaultExport && filePath.endsWith(".d.cts")) source = patchCjsDefaultExport(source);
|
|
182
157
|
if (write) {
|
|
183
158
|
await mkdir(path.dirname(filePath), { recursive: true });
|
|
184
159
|
await writeFile(filePath, source);
|
|
185
|
-
} else {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
});
|
|
192
|
-
}
|
|
160
|
+
} else result.outputFiles.push({
|
|
161
|
+
path: filePath,
|
|
162
|
+
contents: textEncoder.encode(source),
|
|
163
|
+
hash: "",
|
|
164
|
+
text: source
|
|
165
|
+
});
|
|
193
166
|
}
|
|
194
167
|
});
|
|
195
168
|
}
|
|
@@ -229,13 +202,10 @@ function lowestCommonAncestor(...filepaths) {
|
|
|
229
202
|
for (const filepath of rest) {
|
|
230
203
|
const directories = filepath.split("/", ancestor.length);
|
|
231
204
|
let index = 0;
|
|
232
|
-
for (const directory of directories)
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
ancestor = ancestor.slice(0, index);
|
|
237
|
-
break;
|
|
238
|
-
}
|
|
205
|
+
for (const directory of directories) if (directory === ancestor[index]) index += 1;
|
|
206
|
+
else {
|
|
207
|
+
ancestor = ancestor.slice(0, index);
|
|
208
|
+
break;
|
|
239
209
|
}
|
|
240
210
|
ancestor = ancestor.slice(0, index);
|
|
241
211
|
}
|
|
@@ -22,7 +22,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
22
22
|
}) : target, mod));
|
|
23
23
|
|
|
24
24
|
//#endregion
|
|
25
|
-
const require_transformer = require('./transformer-
|
|
25
|
+
const require_transformer = require('./transformer-uKy0L3Za.cjs');
|
|
26
26
|
const { mkdir, readFile, writeFile } = __toESM(require("node:fs/promises"));
|
|
27
27
|
const { default: path } = __toESM(require("node:path"));
|
|
28
28
|
const { createFilter } = __toESM(require("@rollup/pluginutils"));
|
|
@@ -58,19 +58,13 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
58
58
|
const inputMap = !Array.isArray(input) ? Object.fromEntries(Object.entries(input).map(([k, v]) => [path.resolve(stripExt(v)), k])) : undefined;
|
|
59
59
|
const normalizedInput = Array.isArray(input) ? input : Object.values(input);
|
|
60
60
|
const outBase = lowestCommonAncestor(...normalizedInput);
|
|
61
|
-
if (typeof outputOptions.entryFileNames !== "string")
|
|
62
|
-
return this.error("entryFileNames must be a string");
|
|
63
|
-
}
|
|
61
|
+
if (typeof outputOptions.entryFileNames !== "string") return this.error("entryFileNames must be a string");
|
|
64
62
|
let entryFileNames = outputOptions.entryFileNames.replace(/\.(.)?[jt]sx?$/, (_, s) => `.d.${s || ""}ts`);
|
|
65
|
-
if (options.extraOutdir)
|
|
66
|
-
entryFileNames = path.join(options.extraOutdir, entryFileNames);
|
|
67
|
-
}
|
|
63
|
+
if (options.extraOutdir) entryFileNames = path.join(options.extraOutdir, entryFileNames);
|
|
68
64
|
for (let [outname, source] of Object.entries(outputFiles)) {
|
|
69
65
|
const name = inputMap?.[outname] || path.relative(outBase, outname);
|
|
70
66
|
const fileName = entryFileNames.replace("[name]", name);
|
|
71
|
-
if (options.patchCjsDefaultExport && fileName.endsWith(".d.cts"))
|
|
72
|
-
source = patchCjsDefaultExport(source);
|
|
73
|
-
}
|
|
67
|
+
if (options.patchCjsDefaultExport && fileName.endsWith(".d.cts")) source = patchCjsDefaultExport(source);
|
|
74
68
|
this.emitFile({
|
|
75
69
|
type: "asset",
|
|
76
70
|
fileName,
|
|
@@ -98,26 +92,16 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
98
92
|
async function transform(context, code, id) {
|
|
99
93
|
let program;
|
|
100
94
|
try {
|
|
101
|
-
program =
|
|
95
|
+
program = (await parseAsync(code, { sourceFilename: id })).program;
|
|
102
96
|
} catch {}
|
|
103
97
|
if (options.autoAddExts && program) {
|
|
104
98
|
const imports = program.body.filter((node) => node.type === "ImportDeclaration" || node.type === "ExportAllDeclaration" || node.type === "ExportNamedDeclaration");
|
|
105
99
|
const s = new MagicString(code);
|
|
106
100
|
for (const i of imports) {
|
|
107
|
-
if (!i.source || path.basename(i.source.value).includes("."))
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
101
|
+
if (!i.source || path.basename(i.source.value).includes(".")) continue;
|
|
110
102
|
const resolved = await resolve(context, i.source.value, id);
|
|
111
103
|
if (!resolved || resolved.external) continue;
|
|
112
|
-
if (resolved.id.endsWith(".ts") || resolved.id.endsWith(".tsx")) {
|
|
113
|
-
s.overwrite(
|
|
114
|
-
// @ts-expect-error
|
|
115
|
-
i.source.start,
|
|
116
|
-
// @ts-expect-error
|
|
117
|
-
i.source.end,
|
|
118
|
-
JSON.stringify(`${i.source.value}.js`)
|
|
119
|
-
);
|
|
120
|
-
}
|
|
104
|
+
if (resolved.id.endsWith(".ts") || resolved.id.endsWith(".tsx")) s.overwrite(i.source.start, i.source.end, JSON.stringify(`${i.source.value}.js`));
|
|
121
105
|
}
|
|
122
106
|
code = s.toString();
|
|
123
107
|
}
|
|
@@ -132,20 +116,17 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
132
116
|
case "typescript": result = await require_transformer.tsTransform(id, code, options.transformOptions);
|
|
133
117
|
}
|
|
134
118
|
const { code: sourceText, errors } = result;
|
|
135
|
-
if (errors.length)
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
context.error(errors[0]);
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
119
|
+
if (errors.length) if (options.ignoreErrors) context.warn(errors[0]);
|
|
120
|
+
else {
|
|
121
|
+
context.error(errors[0]);
|
|
122
|
+
return;
|
|
142
123
|
}
|
|
143
124
|
addOutput(id, sourceText);
|
|
144
125
|
if (!program) return;
|
|
145
126
|
const typeImports = program.body.filter((node) => {
|
|
146
127
|
if (node.type === "ImportDeclaration") {
|
|
147
128
|
if (node.importKind === "type") return true;
|
|
148
|
-
return node.specifiers && node.specifiers.every((spec) => spec.type === "ImportSpecifier" && spec.importKind === "type");
|
|
129
|
+
return !!node.specifiers && node.specifiers.every((spec) => spec.type === "ImportSpecifier" && spec.importKind === "type");
|
|
149
130
|
}
|
|
150
131
|
if (node.type === "ExportNamedDeclaration" || node.type === "ExportAllDeclaration") {
|
|
151
132
|
if (node.exportKind === "type") return true;
|
|
@@ -189,31 +170,23 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
189
170
|
const write = build.initialOptions.write ?? true;
|
|
190
171
|
if (write) {
|
|
191
172
|
if (!build.initialOptions.outdir) throw new Error("outdir is required when write is true");
|
|
192
|
-
} else
|
|
193
|
-
result.outputFiles ||= [];
|
|
194
|
-
}
|
|
173
|
+
} else result.outputFiles ||= [];
|
|
195
174
|
const textEncoder = new TextEncoder();
|
|
196
175
|
for (let [filename, source] of Object.entries(outputFiles)) {
|
|
197
176
|
const outDir = build.initialOptions.outdir;
|
|
198
177
|
let outFile = `${path.relative(outBase, filename)}.d.${outExt}`;
|
|
199
|
-
if (options.extraOutdir)
|
|
200
|
-
outFile = path.join(options.extraOutdir, outFile);
|
|
201
|
-
}
|
|
178
|
+
if (options.extraOutdir) outFile = path.join(options.extraOutdir, outFile);
|
|
202
179
|
const filePath = outDir ? path.resolve(outDir, outFile) : outFile;
|
|
203
|
-
if (options.patchCjsDefaultExport && filePath.endsWith(".d.cts"))
|
|
204
|
-
source = patchCjsDefaultExport(source);
|
|
205
|
-
}
|
|
180
|
+
if (options.patchCjsDefaultExport && filePath.endsWith(".d.cts")) source = patchCjsDefaultExport(source);
|
|
206
181
|
if (write) {
|
|
207
182
|
await mkdir(path.dirname(filePath), { recursive: true });
|
|
208
183
|
await writeFile(filePath, source);
|
|
209
|
-
} else {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
});
|
|
216
|
-
}
|
|
184
|
+
} else result.outputFiles.push({
|
|
185
|
+
path: filePath,
|
|
186
|
+
contents: textEncoder.encode(source),
|
|
187
|
+
hash: "",
|
|
188
|
+
text: source
|
|
189
|
+
});
|
|
217
190
|
}
|
|
218
191
|
});
|
|
219
192
|
}
|
|
@@ -253,13 +226,10 @@ function lowestCommonAncestor(...filepaths) {
|
|
|
253
226
|
for (const filepath of rest) {
|
|
254
227
|
const directories = filepath.split("/", ancestor.length);
|
|
255
228
|
let index = 0;
|
|
256
|
-
for (const directory of directories)
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
ancestor = ancestor.slice(0, index);
|
|
261
|
-
break;
|
|
262
|
-
}
|
|
229
|
+
for (const directory of directories) if (directory === ancestor[index]) index += 1;
|
|
230
|
+
else {
|
|
231
|
+
ancestor = ancestor.slice(0, index);
|
|
232
|
+
break;
|
|
263
233
|
}
|
|
264
234
|
ancestor = ancestor.slice(0, index);
|
|
265
235
|
}
|
|
@@ -10,22 +10,18 @@ function tryImport(pkg) {
|
|
|
10
10
|
}
|
|
11
11
|
async function oxcTransform(id, code) {
|
|
12
12
|
const oxc = await tryImport("oxc-transform");
|
|
13
|
-
if (!oxc) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
};
|
|
18
|
-
}
|
|
13
|
+
if (!oxc) return {
|
|
14
|
+
code: "",
|
|
15
|
+
errors: ["oxc-transform is required for transforming TypeScript, please install `oxc-transform`."]
|
|
16
|
+
};
|
|
19
17
|
return oxc.isolatedDeclaration(id, code, { sourcemap: false });
|
|
20
18
|
}
|
|
21
19
|
async function swcTransform(id, code) {
|
|
22
20
|
const swc = await tryImport("@swc/core");
|
|
23
|
-
if (!swc) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
28
|
-
}
|
|
21
|
+
if (!swc) return {
|
|
22
|
+
code: "",
|
|
23
|
+
errors: ["SWC is required for transforming TypeScript, please install `@swc/core`."]
|
|
24
|
+
};
|
|
29
25
|
try {
|
|
30
26
|
const result = await swc.transform(code, {
|
|
31
27
|
filename: id,
|
|
@@ -51,18 +47,14 @@ async function swcTransform(id, code) {
|
|
|
51
47
|
}
|
|
52
48
|
async function tsTransform(id, code, transformOptions) {
|
|
53
49
|
const ts = await tryImport("typescript");
|
|
54
|
-
if (!ts) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
code: "",
|
|
63
|
-
errors: ["TypeScript version is too low, please upgrade to TypeScript 5.5.2+."]
|
|
64
|
-
};
|
|
65
|
-
}
|
|
50
|
+
if (!ts) return {
|
|
51
|
+
code: "",
|
|
52
|
+
errors: ["TypeScript is required for transforming TypeScript, please install `typescript`."]
|
|
53
|
+
};
|
|
54
|
+
if (!ts.transpileDeclaration) return {
|
|
55
|
+
code: "",
|
|
56
|
+
errors: ["TypeScript version is too low, please upgrade to TypeScript 5.5.2+."]
|
|
57
|
+
};
|
|
66
58
|
const { outputText, diagnostics } = ts.transpileDeclaration(code, {
|
|
67
59
|
fileName: id,
|
|
68
60
|
reportDiagnostics: true,
|
|
@@ -9,22 +9,18 @@ function tryImport(pkg) {
|
|
|
9
9
|
}
|
|
10
10
|
async function oxcTransform(id, code) {
|
|
11
11
|
const oxc = await tryImport("oxc-transform");
|
|
12
|
-
if (!oxc) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
}
|
|
12
|
+
if (!oxc) return {
|
|
13
|
+
code: "",
|
|
14
|
+
errors: ["oxc-transform is required for transforming TypeScript, please install `oxc-transform`."]
|
|
15
|
+
};
|
|
18
16
|
return oxc.isolatedDeclaration(id, code, { sourcemap: false });
|
|
19
17
|
}
|
|
20
18
|
async function swcTransform(id, code) {
|
|
21
19
|
const swc = await tryImport("@swc/core");
|
|
22
|
-
if (!swc) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
}
|
|
20
|
+
if (!swc) return {
|
|
21
|
+
code: "",
|
|
22
|
+
errors: ["SWC is required for transforming TypeScript, please install `@swc/core`."]
|
|
23
|
+
};
|
|
28
24
|
try {
|
|
29
25
|
const result = await swc.transform(code, {
|
|
30
26
|
filename: id,
|
|
@@ -50,18 +46,14 @@ async function swcTransform(id, code) {
|
|
|
50
46
|
}
|
|
51
47
|
async function tsTransform(id, code, transformOptions) {
|
|
52
48
|
const ts = await tryImport("typescript");
|
|
53
|
-
if (!ts) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
code: "",
|
|
62
|
-
errors: ["TypeScript version is too low, please upgrade to TypeScript 5.5.2+."]
|
|
63
|
-
};
|
|
64
|
-
}
|
|
49
|
+
if (!ts) return {
|
|
50
|
+
code: "",
|
|
51
|
+
errors: ["TypeScript is required for transforming TypeScript, please install `typescript`."]
|
|
52
|
+
};
|
|
53
|
+
if (!ts.transpileDeclaration) return {
|
|
54
|
+
code: "",
|
|
55
|
+
errors: ["TypeScript version is too low, please upgrade to TypeScript 5.5.2+."]
|
|
56
|
+
};
|
|
65
57
|
const { outputText, diagnostics } = ts.transpileDeclaration(code, {
|
|
66
58
|
fileName: id,
|
|
67
59
|
reportDiagnostics: true,
|
package/dist/vite.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const require_src_index = require('./src_index-
|
|
3
|
-
require('./transformer-
|
|
2
|
+
const require_src_index = require('./src_index-NKcZyc90.cjs');
|
|
3
|
+
require('./transformer-uKy0L3Za.cjs');
|
|
4
4
|
|
|
5
5
|
//#region src/vite.ts
|
|
6
6
|
var vite_default = require_src_index.IsolatedDecl.vite;
|
package/dist/vite.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-isolated-decl",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.8",
|
|
4
4
|
"description": "A blazing-fast tool for generating isolated declarations.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -84,30 +84,30 @@
|
|
|
84
84
|
}
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@rollup/pluginutils": "^5.1.
|
|
87
|
+
"@rollup/pluginutils": "^5.1.3",
|
|
88
88
|
"magic-string": "^0.30.12",
|
|
89
|
-
"oxc-parser": "^0.
|
|
89
|
+
"oxc-parser": "^0.34.0",
|
|
90
90
|
"unplugin": "^1.14.1"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
|
-
"@
|
|
93
|
+
"@oxc-project/types": "^0.34.0",
|
|
94
|
+
"@swc/core": "^1.7.40",
|
|
94
95
|
"@sxzz/eslint-config": "^4.4.0",
|
|
95
96
|
"@sxzz/prettier-config": "^2.0.2",
|
|
96
|
-
"@types/node": "^22.
|
|
97
|
-
"@typescript-eslint/typescript-estree": "^8.8.1",
|
|
97
|
+
"@types/node": "^22.8.1",
|
|
98
98
|
"bumpp": "^9.7.1",
|
|
99
99
|
"esbuild": "^0.24.0",
|
|
100
|
-
"eslint": "^9.
|
|
100
|
+
"eslint": "^9.13.0",
|
|
101
101
|
"fast-glob": "^3.3.2",
|
|
102
|
-
"oxc-transform": "^0.
|
|
102
|
+
"oxc-transform": "^0.34.0",
|
|
103
103
|
"prettier": "^3.3.3",
|
|
104
104
|
"rolldown": "nightly",
|
|
105
|
-
"rollup": "^4.24.
|
|
105
|
+
"rollup": "^4.24.2",
|
|
106
106
|
"rollup-plugin-esbuild": "^6.1.1",
|
|
107
107
|
"tsdown": "^0.2.17",
|
|
108
|
-
"tsx": "^4.19.
|
|
108
|
+
"tsx": "^4.19.2",
|
|
109
109
|
"typescript": "^5.6.3",
|
|
110
|
-
"vite": "^5.4.
|
|
110
|
+
"vite": "^5.4.10",
|
|
111
111
|
"vitest": "^2.1.3"
|
|
112
112
|
},
|
|
113
113
|
"engines": {
|