unplugin-isolated-decl 0.6.6 → 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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Unit Test](https://github.com/unplugin/unplugin-isolated-decl/actions/workflows/unit-test.yml/badge.svg)](https://github.com/unplugin/unplugin-isolated-decl/actions/workflows/unit-test.yml)
4
4
 
5
- ⚡️ A blazing-fast tool for generating isolated declarations, powered by Oxc!
5
+ ⚡️ A blazing-fast tool for generating isolated declarations.
6
6
 
7
7
  ## Features
8
8
 
@@ -83,8 +83,8 @@ export interface Options {
83
83
  exclude?: FilterPattern
84
84
  enforce?: 'pre' | 'post' | undefined
85
85
  /**
86
- * If you use swc or typescript, you need to install `@swc/core` or `typescript` yourself.
87
- * @default oxc
86
+ * You need to install one of the supported transformers yourself.
87
+ * @default typescript
88
88
  */
89
89
  transformer?: 'oxc' | 'swc' | 'typescript'
90
90
  /** Only for typescript transformer */
@@ -114,6 +114,15 @@ With `autoAddExts`, it will be transformed to:
114
114
  import {} from './foo.js'
115
115
  ```
116
116
 
117
+ ### `patchCjsDefaultExport`
118
+
119
+ Patch `export default` in `.d.cts` to `export =`
120
+
121
+ ---
122
+
123
+ > [!NOTE]
124
+ > For the exhaustive set of options check [options](src/core/options.ts)
125
+
117
126
  ## Sponsors
118
127
 
119
128
  <p align="center">
@@ -125,7 +134,3 @@ import {} from './foo.js'
125
134
  ## License
126
135
 
127
136
  [MIT](./LICENSE) License © 2024-PRESENT [三咲智子](https://github.com/sxzz)
128
-
129
- ```
130
-
131
- ```
package/dist/api.cjs CHANGED
@@ -1,21 +1,6 @@
1
1
  "use strict";
2
- const require_transformer = require('./transformer-9aaNC01N.cjs');
2
+ const require_transformer = require('./transformer-uKy0L3Za.cjs');
3
3
 
4
- Object.defineProperty(exports, 'oxcTransform', {
5
- enumerable: true,
6
- get: function () {
7
- return require_transformer.oxcTransform;
8
- }
9
- });
10
- Object.defineProperty(exports, 'swcTransform', {
11
- enumerable: true,
12
- get: function () {
13
- return require_transformer.swcTransform;
14
- }
15
- });
16
- Object.defineProperty(exports, 'tsTransform', {
17
- enumerable: true,
18
- get: function () {
19
- return require_transformer.tsTransform;
20
- }
21
- });
4
+ exports.oxcTransform = require_transformer.oxcTransform
5
+ exports.swcTransform = require_transformer.swcTransform
6
+ exports.tsTransform = require_transformer.tsTransform
package/dist/api.js CHANGED
@@ -1,3 +1,3 @@
1
- import { oxcTransform, swcTransform, tsTransform } from "./transformer-GSFmnEOV.js";
1
+ import { oxcTransform, swcTransform, tsTransform } from "./transformer-w7XvOpWe.js";
2
2
 
3
3
  export { oxcTransform, swcTransform, tsTransform };
package/dist/esbuild.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- const require_src_index = require('./src_index-4YckyJ-4.cjs');
3
- require('./transformer-9aaNC01N.cjs');
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
@@ -1,5 +1,5 @@
1
- import "./transformer-GSFmnEOV.js";
2
- import { IsolatedDecl } from "./src_index-WXdz1uEu.js";
1
+ import "./transformer-w7XvOpWe.js";
2
+ import { IsolatedDecl } from "./src_index-2WEAOr05.js";
3
3
 
4
4
  //#region src/esbuild.ts
5
5
  var esbuild_default = IsolatedDecl.esbuild;
package/dist/index.cjs CHANGED
@@ -1,16 +1,6 @@
1
1
  "use strict";
2
- const require_src_index = require('./src_index-4YckyJ-4.cjs');
3
- require('./transformer-9aaNC01N.cjs');
2
+ const require_src_index = require('./src_index-NKcZyc90.cjs');
3
+ require('./transformer-uKy0L3Za.cjs');
4
4
 
5
- Object.defineProperty(exports, 'IsolatedDecl', {
6
- enumerable: true,
7
- get: function () {
8
- return require_src_index.IsolatedDecl;
9
- }
10
- });
11
- Object.defineProperty(exports, 'lowestCommonAncestor', {
12
- enumerable: true,
13
- get: function () {
14
- return require_src_index.lowestCommonAncestor;
15
- }
16
- });
5
+ exports.IsolatedDecl = require_src_index.IsolatedDecl
6
+ exports.lowestCommonAncestor = require_src_index.lowestCommonAncestor
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import "./transformer-GSFmnEOV.js";
2
- import { IsolatedDecl, lowestCommonAncestor } from "./src_index-WXdz1uEu.js";
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-4YckyJ-4.cjs');
3
- require('./transformer-9aaNC01N.cjs');
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
@@ -1,5 +1,5 @@
1
- import "./transformer-GSFmnEOV.js";
2
- import { IsolatedDecl } from "./src_index-WXdz1uEu.js";
1
+ import "./transformer-w7XvOpWe.js";
2
+ import { IsolatedDecl } from "./src_index-2WEAOr05.js";
3
3
 
4
4
  //#region src/rolldown.ts
5
5
  var rolldown_default = IsolatedDecl.rolldown;
package/dist/rollup.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
- const require_src_index = require('./src_index-4YckyJ-4.cjs');
3
- require('./transformer-9aaNC01N.cjs');
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,5 +1,5 @@
1
- import "./transformer-GSFmnEOV.js";
2
- import { IsolatedDecl } from "./src_index-WXdz1uEu.js";
1
+ import "./transformer-w7XvOpWe.js";
2
+ import { IsolatedDecl } from "./src_index-2WEAOr05.js";
3
3
 
4
4
  //#region src/rollup.ts
5
5
  var rollup_default = IsolatedDecl.rollup;
@@ -1,8 +1,8 @@
1
- import { oxcTransform, swcTransform, tsTransform } from "./transformer-GSFmnEOV.js";
1
+ import { oxcTransform, swcTransform, tsTransform } from "./transformer-w7XvOpWe.js";
2
2
  import { mkdir, readFile, writeFile } from "node:fs/promises";
3
- import { default as path } from "node:path";
3
+ import path from "node:path";
4
4
  import { createFilter } from "@rollup/pluginutils";
5
- import { default as MagicString } from "magic-string";
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,20 +68,16 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
74
68
  async function transform(context, code, id) {
75
69
  let program;
76
70
  try {
77
- program = JSON.parse((await parseAsync(code, { sourceFilename: id })).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(i.source.start, i.source.end, JSON.stringify(`${i.source.value}.js`));
90
- }
80
+ if (resolved.id.endsWith(".ts") || resolved.id.endsWith(".tsx")) s.overwrite(i.source.start, i.source.end, JSON.stringify(`${i.source.value}.js`));
91
81
  }
92
82
  code = s.toString();
93
83
  }
@@ -102,20 +92,17 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
102
92
  case "typescript": result = await tsTransform(id, code, options.transformOptions);
103
93
  }
104
94
  const { code: sourceText, errors } = result;
105
- if (errors.length) {
106
- if (options.ignoreErrors) {
107
- context.warn(errors[0]);
108
- } else {
109
- context.error(errors[0]);
110
- return;
111
- }
95
+ if (errors.length) if (options.ignoreErrors) context.warn(errors[0]);
96
+ else {
97
+ context.error(errors[0]);
98
+ return;
112
99
  }
113
100
  addOutput(id, sourceText);
114
101
  if (!program) return;
115
102
  const typeImports = program.body.filter((node) => {
116
103
  if (node.type === "ImportDeclaration") {
117
104
  if (node.importKind === "type") return true;
118
- 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");
119
106
  }
120
107
  if (node.type === "ExportNamedDeclaration" || node.type === "ExportAllDeclaration") {
121
108
  if (node.exportKind === "type") return true;
@@ -159,31 +146,23 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
159
146
  const write = build.initialOptions.write ?? true;
160
147
  if (write) {
161
148
  if (!build.initialOptions.outdir) throw new Error("outdir is required when write is true");
162
- } else {
163
- result.outputFiles ||= [];
164
- }
149
+ } else result.outputFiles ||= [];
165
150
  const textEncoder = new TextEncoder();
166
151
  for (let [filename, source] of Object.entries(outputFiles)) {
167
152
  const outDir = build.initialOptions.outdir;
168
153
  let outFile = `${path.relative(outBase, filename)}.d.${outExt}`;
169
- if (options.extraOutdir) {
170
- outFile = path.join(options.extraOutdir, outFile);
171
- }
154
+ if (options.extraOutdir) outFile = path.join(options.extraOutdir, outFile);
172
155
  const filePath = outDir ? path.resolve(outDir, outFile) : outFile;
173
- if (options.patchCjsDefaultExport && filePath.endsWith(".d.cts")) {
174
- source = patchCjsDefaultExport(source);
175
- }
156
+ if (options.patchCjsDefaultExport && filePath.endsWith(".d.cts")) source = patchCjsDefaultExport(source);
176
157
  if (write) {
177
158
  await mkdir(path.dirname(filePath), { recursive: true });
178
159
  await writeFile(filePath, source);
179
- } else {
180
- result.outputFiles.push({
181
- path: filePath,
182
- contents: textEncoder.encode(source),
183
- hash: "",
184
- text: source
185
- });
186
- }
160
+ } else result.outputFiles.push({
161
+ path: filePath,
162
+ contents: textEncoder.encode(source),
163
+ hash: "",
164
+ text: source
165
+ });
187
166
  }
188
167
  });
189
168
  }
@@ -223,13 +202,10 @@ function lowestCommonAncestor(...filepaths) {
223
202
  for (const filepath of rest) {
224
203
  const directories = filepath.split("/", ancestor.length);
225
204
  let index = 0;
226
- for (const directory of directories) {
227
- if (directory === ancestor[index]) {
228
- index += 1;
229
- } else {
230
- ancestor = ancestor.slice(0, index);
231
- break;
232
- }
205
+ for (const directory of directories) if (directory === ancestor[index]) index += 1;
206
+ else {
207
+ ancestor = ancestor.slice(0, index);
208
+ break;
233
209
  }
234
210
  ancestor = ancestor.slice(0, index);
235
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-9aaNC01N.cjs');
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,20 +92,16 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
98
92
  async function transform(context, code, id) {
99
93
  let program;
100
94
  try {
101
- program = JSON.parse((await parseAsync(code, { sourceFilename: id })).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(i.source.start, i.source.end, JSON.stringify(`${i.source.value}.js`));
114
- }
104
+ if (resolved.id.endsWith(".ts") || resolved.id.endsWith(".tsx")) s.overwrite(i.source.start, i.source.end, JSON.stringify(`${i.source.value}.js`));
115
105
  }
116
106
  code = s.toString();
117
107
  }
@@ -126,20 +116,17 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
126
116
  case "typescript": result = await require_transformer.tsTransform(id, code, options.transformOptions);
127
117
  }
128
118
  const { code: sourceText, errors } = result;
129
- if (errors.length) {
130
- if (options.ignoreErrors) {
131
- context.warn(errors[0]);
132
- } else {
133
- context.error(errors[0]);
134
- return;
135
- }
119
+ if (errors.length) if (options.ignoreErrors) context.warn(errors[0]);
120
+ else {
121
+ context.error(errors[0]);
122
+ return;
136
123
  }
137
124
  addOutput(id, sourceText);
138
125
  if (!program) return;
139
126
  const typeImports = program.body.filter((node) => {
140
127
  if (node.type === "ImportDeclaration") {
141
128
  if (node.importKind === "type") return true;
142
- 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");
143
130
  }
144
131
  if (node.type === "ExportNamedDeclaration" || node.type === "ExportAllDeclaration") {
145
132
  if (node.exportKind === "type") return true;
@@ -183,31 +170,23 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
183
170
  const write = build.initialOptions.write ?? true;
184
171
  if (write) {
185
172
  if (!build.initialOptions.outdir) throw new Error("outdir is required when write is true");
186
- } else {
187
- result.outputFiles ||= [];
188
- }
173
+ } else result.outputFiles ||= [];
189
174
  const textEncoder = new TextEncoder();
190
175
  for (let [filename, source] of Object.entries(outputFiles)) {
191
176
  const outDir = build.initialOptions.outdir;
192
177
  let outFile = `${path.relative(outBase, filename)}.d.${outExt}`;
193
- if (options.extraOutdir) {
194
- outFile = path.join(options.extraOutdir, outFile);
195
- }
178
+ if (options.extraOutdir) outFile = path.join(options.extraOutdir, outFile);
196
179
  const filePath = outDir ? path.resolve(outDir, outFile) : outFile;
197
- if (options.patchCjsDefaultExport && filePath.endsWith(".d.cts")) {
198
- source = patchCjsDefaultExport(source);
199
- }
180
+ if (options.patchCjsDefaultExport && filePath.endsWith(".d.cts")) source = patchCjsDefaultExport(source);
200
181
  if (write) {
201
182
  await mkdir(path.dirname(filePath), { recursive: true });
202
183
  await writeFile(filePath, source);
203
- } else {
204
- result.outputFiles.push({
205
- path: filePath,
206
- contents: textEncoder.encode(source),
207
- hash: "",
208
- text: source
209
- });
210
- }
184
+ } else result.outputFiles.push({
185
+ path: filePath,
186
+ contents: textEncoder.encode(source),
187
+ hash: "",
188
+ text: source
189
+ });
211
190
  }
212
191
  });
213
192
  }
@@ -247,13 +226,10 @@ function lowestCommonAncestor(...filepaths) {
247
226
  for (const filepath of rest) {
248
227
  const directories = filepath.split("/", ancestor.length);
249
228
  let index = 0;
250
- for (const directory of directories) {
251
- if (directory === ancestor[index]) {
252
- index += 1;
253
- } else {
254
- ancestor = ancestor.slice(0, index);
255
- break;
256
- }
229
+ for (const directory of directories) if (directory === ancestor[index]) index += 1;
230
+ else {
231
+ ancestor = ancestor.slice(0, index);
232
+ break;
257
233
  }
258
234
  ancestor = ancestor.slice(0, index);
259
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
- return {
15
- code: "",
16
- errors: ["oxc-transform is required for transforming TypeScript, please install `oxc-transform`."]
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
- return {
25
- code: "",
26
- errors: ["SWC is required for transforming TypeScript, please install `@swc/core`."]
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
- return {
56
- code: "",
57
- errors: ["TypeScript is required for transforming TypeScript, please install `typescript`."]
58
- };
59
- }
60
- if (!ts.transpileDeclaration) {
61
- return {
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
- return {
14
- code: "",
15
- errors: ["oxc-transform is required for transforming TypeScript, please install `oxc-transform`."]
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
- return {
24
- code: "",
25
- errors: ["SWC is required for transforming TypeScript, please install `@swc/core`."]
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
- return {
55
- code: "",
56
- errors: ["TypeScript is required for transforming TypeScript, please install `typescript`."]
57
- };
58
- }
59
- if (!ts.transpileDeclaration) {
60
- return {
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-4YckyJ-4.cjs');
3
- require('./transformer-9aaNC01N.cjs');
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
@@ -1,5 +1,5 @@
1
- import "./transformer-GSFmnEOV.js";
2
- import { IsolatedDecl } from "./src_index-WXdz1uEu.js";
1
+ import "./transformer-w7XvOpWe.js";
2
+ import { IsolatedDecl } from "./src_index-2WEAOr05.js";
3
3
 
4
4
  //#region src/vite.ts
5
5
  var vite_default = IsolatedDecl.vite;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unplugin-isolated-decl",
3
- "version": "0.6.6",
4
- "description": "A blazing-fast tool for generating isolated declarations, powered by Oxc.",
3
+ "version": "0.6.8",
4
+ "description": "A blazing-fast tool for generating isolated declarations.",
5
5
  "type": "module",
6
6
  "keywords": [
7
7
  "unplugin",
@@ -69,7 +69,7 @@
69
69
  },
70
70
  "peerDependencies": {
71
71
  "@swc/core": "^1.6.6",
72
- "oxc-transform": "^0.28.0",
72
+ "oxc-transform": ">=0.28.0",
73
73
  "typescript": "^5.5.2"
74
74
  },
75
75
  "peerDependenciesMeta": {
@@ -84,31 +84,31 @@
84
84
  }
85
85
  },
86
86
  "dependencies": {
87
- "@rollup/pluginutils": "^5.1.2",
88
- "magic-string": "^0.30.11",
89
- "oxc-parser": "^0.30.5",
87
+ "@rollup/pluginutils": "^5.1.3",
88
+ "magic-string": "^0.30.12",
89
+ "oxc-parser": "^0.34.0",
90
90
  "unplugin": "^1.14.1"
91
91
  },
92
92
  "devDependencies": {
93
- "@swc/core": "^1.7.26",
94
- "@sxzz/eslint-config": "^4.2.0",
93
+ "@oxc-project/types": "^0.34.0",
94
+ "@swc/core": "^1.7.40",
95
+ "@sxzz/eslint-config": "^4.4.0",
95
96
  "@sxzz/prettier-config": "^2.0.2",
96
- "@types/node": "^22.7.4",
97
- "@typescript-eslint/typescript-estree": "^8.7.0",
98
- "bumpp": "^9.6.1",
97
+ "@types/node": "^22.8.1",
98
+ "bumpp": "^9.7.1",
99
99
  "esbuild": "^0.24.0",
100
- "eslint": "^9.11.1",
100
+ "eslint": "^9.13.0",
101
101
  "fast-glob": "^3.3.2",
102
- "oxc-transform": "^0.30.5",
102
+ "oxc-transform": "^0.34.0",
103
103
  "prettier": "^3.3.3",
104
104
  "rolldown": "nightly",
105
- "rollup": "^4.22.5",
105
+ "rollup": "^4.24.2",
106
106
  "rollup-plugin-esbuild": "^6.1.1",
107
107
  "tsdown": "^0.2.17",
108
- "tsx": "^4.19.1",
109
- "typescript": "^5.6.2",
110
- "vite": "^5.4.8",
111
- "vitest": "^2.1.1"
108
+ "tsx": "^4.19.2",
109
+ "typescript": "^5.6.3",
110
+ "vite": "^5.4.10",
111
+ "vitest": "^2.1.3"
112
112
  },
113
113
  "engines": {
114
114
  "node": ">=18.12.0"