unplugin-isolated-decl 0.3.0 → 0.4.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/README.md +19 -1
- package/dist/api.cjs +8 -2
- package/dist/api.d.cts +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.js +3 -0
- package/dist/core/options.d.cts +8 -4
- package/dist/core/options.d.ts +8 -4
- package/dist/core/transformer.d.cts +8 -0
- package/dist/core/transformer.d.ts +8 -0
- package/dist/esbuild.cjs +2 -2
- package/dist/esbuild.js +2 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/rolldown.cjs +2 -2
- package/dist/rolldown.js +2 -1
- package/dist/rollup.cjs +2 -2
- package/dist/rollup.js +2 -1
- package/dist/{src_index-1GProTgq.cjs → src_index-JrSKjSmw.cjs} +15 -5
- package/dist/{src_index--o4926Ps.js → src_index-OeLmVd0z.js} +15 -4
- package/dist/transformer-ZIY9xt38.cjs +110 -0
- package/dist/transformer-m4c_uotZ.js +73 -0
- package/dist/vite.cjs +2 -2
- package/dist/vite.js +2 -1
- package/package.json +21 -8
- package/dist/chunk-J8LkbbVi.cjs +0 -36
package/README.md
CHANGED
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
9
|
- 🚀 **Fast**: Blazing-fast `.d.ts` generator, powered by Oxc.
|
|
10
|
-
-
|
|
10
|
+
- 🎨 **Transformer**: Support Oxc, SWC, and TypeScript transformer.
|
|
11
|
+
- 📦 **Zero Config**: No configuration required, works out of the box.
|
|
11
12
|
- ✨ **Bundler Support**: Works with Vite, Rollup, and esbuild.
|
|
12
13
|
|
|
13
14
|
## Installation
|
|
@@ -74,6 +75,23 @@ build({
|
|
|
74
75
|
|
|
75
76
|
<br></details>
|
|
76
77
|
|
|
78
|
+
## Options
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
export interface Options {
|
|
82
|
+
include?: FilterPattern
|
|
83
|
+
exclude?: FilterPattern
|
|
84
|
+
enforce?: 'pre' | 'post' | undefined
|
|
85
|
+
/**
|
|
86
|
+
* If you use swc or typescript, you need to install `@swc/core` or `typescript` yourself.
|
|
87
|
+
* @default oxc
|
|
88
|
+
*/
|
|
89
|
+
transformer?: 'oxc' | 'swc' | 'typescript'
|
|
90
|
+
/** Only for typescript transformer */
|
|
91
|
+
transformOptions?: TranspileOptions
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
77
95
|
## Sponsors
|
|
78
96
|
|
|
79
97
|
<p align="center">
|
package/dist/api.cjs
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const { __toCommonJS } = require("./
|
|
3
|
+
const { __export, __toCommonJS, oxcTransform, swcTransform, tsTransform } = require("./transformer-ZIY9xt38.cjs");
|
|
4
4
|
|
|
5
5
|
//#region src/api.ts
|
|
6
6
|
var api_ns = {};
|
|
7
|
+
__export(api_ns, {
|
|
8
|
+
oxcTransform: () => oxcTransform,
|
|
9
|
+
swcTransform: () => swcTransform,
|
|
10
|
+
tsTransform: () => tsTransform
|
|
11
|
+
});
|
|
7
12
|
|
|
8
|
-
//#endregion
|
|
13
|
+
//#endregion
|
|
14
|
+
module.exports = __toCommonJS(api_ns)
|
package/dist/api.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { oxcTransform, swcTransform, tsTransform } from './core/transformer';
|
package/dist/api.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { oxcTransform, swcTransform, tsTransform } from './core/transformer';
|
package/dist/api.js
CHANGED
package/dist/core/options.d.cts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import type { TranspileOptions } from 'typescript';
|
|
1
2
|
import type { FilterPattern } from '@rollup/pluginutils';
|
|
2
|
-
export
|
|
3
|
+
export type Options = {
|
|
3
4
|
include?: FilterPattern;
|
|
4
5
|
exclude?: FilterPattern;
|
|
5
|
-
enforce?:
|
|
6
|
-
}
|
|
7
|
-
|
|
6
|
+
enforce?: 'pre' | 'post' | undefined;
|
|
7
|
+
} & ({transformer?: 'oxc' | 'swc'} | {
|
|
8
|
+
transformer: 'typescript';
|
|
9
|
+
transformOptions?: TranspileOptions;
|
|
10
|
+
});
|
|
11
|
+
type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
|
|
8
12
|
export type OptionsResolved = Overwrite<Required<Options>, Pick<Options, 'enforce'>>;
|
|
9
13
|
export declare function resolveOptions(options: Options): OptionsResolved;
|
|
10
14
|
export {};
|
package/dist/core/options.d.ts
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import type { TranspileOptions } from 'typescript';
|
|
1
2
|
import type { FilterPattern } from '@rollup/pluginutils';
|
|
2
|
-
export
|
|
3
|
+
export type Options = {
|
|
3
4
|
include?: FilterPattern;
|
|
4
5
|
exclude?: FilterPattern;
|
|
5
|
-
enforce?:
|
|
6
|
-
}
|
|
7
|
-
|
|
6
|
+
enforce?: 'pre' | 'post' | undefined;
|
|
7
|
+
} & ({transformer?: 'oxc' | 'swc'} | {
|
|
8
|
+
transformer: 'typescript';
|
|
9
|
+
transformOptions?: TranspileOptions;
|
|
10
|
+
});
|
|
11
|
+
type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
|
|
8
12
|
export type OptionsResolved = Overwrite<Required<Options>, Pick<Options, 'enforce'>>;
|
|
9
13
|
export declare function resolveOptions(options: Options): OptionsResolved;
|
|
10
14
|
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TranspileOptions } from 'typescript';
|
|
2
|
+
export interface TransformResult {
|
|
3
|
+
sourceText: string;
|
|
4
|
+
errors: Array<string>;
|
|
5
|
+
}
|
|
6
|
+
export declare function oxcTransform(id: string, code: string): TransformResult;
|
|
7
|
+
export declare function swcTransform(id: string, code: string): Promise<TransformResult>;
|
|
8
|
+
export declare function tsTransform(id: string, code: string, transformOptions?: TranspileOptions): Promise<TransformResult>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TranspileOptions } from 'typescript';
|
|
2
|
+
export interface TransformResult {
|
|
3
|
+
sourceText: string;
|
|
4
|
+
errors: Array<string>;
|
|
5
|
+
}
|
|
6
|
+
export declare function oxcTransform(id: string, code: string): TransformResult;
|
|
7
|
+
export declare function swcTransform(id: string, code: string): Promise<TransformResult>;
|
|
8
|
+
export declare function tsTransform(id: string, code: string, transformOptions?: TranspileOptions): Promise<TransformResult>;
|
package/dist/esbuild.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const { __export, __toCommonJS } = require("./
|
|
4
|
-
const { IsolatedDecl } = require("./src_index-
|
|
3
|
+
const { __export, __toCommonJS } = require("./transformer-ZIY9xt38.cjs");
|
|
4
|
+
const { IsolatedDecl } = require("./src_index-JrSKjSmw.cjs");
|
|
5
5
|
|
|
6
6
|
//#region src/esbuild.ts
|
|
7
7
|
var esbuild_ns = {};
|
package/dist/esbuild.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const { __toCommonJS } = require("./
|
|
4
|
-
const { IsolatedDecl, src_index_ns } = require("./src_index-
|
|
3
|
+
const { __toCommonJS } = require("./transformer-ZIY9xt38.cjs");
|
|
4
|
+
const { IsolatedDecl, src_index_ns } = require("./src_index-JrSKjSmw.cjs");
|
|
5
5
|
|
|
6
6
|
module.exports = __toCommonJS(src_index_ns)
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type UnpluginInstance } from 'unplugin';
|
|
2
2
|
import { type Options } from './core/options';
|
|
3
3
|
export type { Options };
|
|
4
|
-
export declare const IsolatedDecl: UnpluginInstance<
|
|
4
|
+
export declare const IsolatedDecl: UnpluginInstance<Options | undefined, false>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type UnpluginInstance } from 'unplugin';
|
|
2
2
|
import { type Options } from './core/options';
|
|
3
3
|
export type { Options };
|
|
4
|
-
export declare const IsolatedDecl: UnpluginInstance<
|
|
4
|
+
export declare const IsolatedDecl: UnpluginInstance<Options | undefined, false>;
|
package/dist/index.js
CHANGED
package/dist/rolldown.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const { __export, __toCommonJS } = require("./
|
|
4
|
-
const { IsolatedDecl } = require("./src_index-
|
|
3
|
+
const { __export, __toCommonJS } = require("./transformer-ZIY9xt38.cjs");
|
|
4
|
+
const { IsolatedDecl } = require("./src_index-JrSKjSmw.cjs");
|
|
5
5
|
|
|
6
6
|
//#region src/rolldown.ts
|
|
7
7
|
var rolldown_ns = {};
|
package/dist/rolldown.js
CHANGED
package/dist/rollup.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const { __export, __toCommonJS } = require("./
|
|
4
|
-
const { IsolatedDecl } = require("./src_index-
|
|
3
|
+
const { __export, __toCommonJS } = require("./transformer-ZIY9xt38.cjs");
|
|
4
|
+
const { IsolatedDecl } = require("./src_index-JrSKjSmw.cjs");
|
|
5
5
|
|
|
6
6
|
//#region src/rollup.ts
|
|
7
7
|
var rollup_ns = {};
|
package/dist/rollup.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const { __export, __toESM } = require("./
|
|
3
|
+
const { __export, __toESM, oxcTransform, swcTransform, tsTransform } = require("./transformer-ZIY9xt38.cjs");
|
|
4
4
|
const { default: path } = __toESM(require("node:path"));
|
|
5
5
|
const { mkdir, writeFile } = __toESM(require("node:fs/promises"));
|
|
6
6
|
const { createUnplugin } = __toESM(require("unplugin"));
|
|
7
|
-
const { isolatedDeclaration } = __toESM(require("oxc-transform"));
|
|
8
7
|
const { createFilter } = __toESM(require("@rollup/pluginutils"));
|
|
9
8
|
|
|
10
9
|
//#region src/core/options.ts
|
|
@@ -12,7 +11,8 @@ function resolveOptions(options) {
|
|
|
12
11
|
return {
|
|
13
12
|
include: options.include || [/\.[cm]?ts$/],
|
|
14
13
|
exclude: options.exclude || [/node_modules/],
|
|
15
|
-
enforce: 'enforce'in options ? options.enforce : 'pre'
|
|
14
|
+
enforce: 'enforce'in options ? options.enforce : 'pre',
|
|
15
|
+
transformer: options.transformer || 'oxc'
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -51,8 +51,18 @@ const IsolatedDecl = createUnplugin((rawOptions = {}, meta) => {
|
|
|
51
51
|
transformInclude(id) {
|
|
52
52
|
return filter(id);
|
|
53
53
|
},
|
|
54
|
-
transform(code, id) {
|
|
55
|
-
|
|
54
|
+
async transform(code, id) {
|
|
55
|
+
let result;
|
|
56
|
+
switch (options.transformer) {
|
|
57
|
+
case 'oxc':
|
|
58
|
+
result = oxcTransform(id, code);
|
|
59
|
+
break;
|
|
60
|
+
case 'swc':
|
|
61
|
+
result = await swcTransform(id, code);
|
|
62
|
+
break;
|
|
63
|
+
case 'typescript': result = await tsTransform(id, code, options.transformOptions);
|
|
64
|
+
}
|
|
65
|
+
const { sourceText, errors } = result;
|
|
56
66
|
if (errors.length) {
|
|
57
67
|
this.error(errors[0]);
|
|
58
68
|
return;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { oxcTransform, swcTransform, tsTransform } from "./transformer-m4c_uotZ.js";
|
|
1
2
|
import { default as path } from "node:path";
|
|
2
3
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
4
|
import { createUnplugin } from "unplugin";
|
|
4
|
-
import { isolatedDeclaration } from "oxc-transform";
|
|
5
5
|
import { createFilter } from "@rollup/pluginutils";
|
|
6
6
|
|
|
7
7
|
//#region src/core/options.ts
|
|
@@ -9,7 +9,8 @@ function resolveOptions(options) {
|
|
|
9
9
|
return {
|
|
10
10
|
include: options.include || [/\.[cm]?ts$/],
|
|
11
11
|
exclude: options.exclude || [/node_modules/],
|
|
12
|
-
enforce: 'enforce'in options ? options.enforce : 'pre'
|
|
12
|
+
enforce: 'enforce'in options ? options.enforce : 'pre',
|
|
13
|
+
transformer: options.transformer || 'oxc'
|
|
13
14
|
};
|
|
14
15
|
}
|
|
15
16
|
|
|
@@ -46,8 +47,18 @@ const IsolatedDecl = createUnplugin((rawOptions = {}, meta) => {
|
|
|
46
47
|
transformInclude(id) {
|
|
47
48
|
return filter(id);
|
|
48
49
|
},
|
|
49
|
-
transform(code, id) {
|
|
50
|
-
|
|
50
|
+
async transform(code, id) {
|
|
51
|
+
let result;
|
|
52
|
+
switch (options.transformer) {
|
|
53
|
+
case 'oxc':
|
|
54
|
+
result = oxcTransform(id, code);
|
|
55
|
+
break;
|
|
56
|
+
case 'swc':
|
|
57
|
+
result = await swcTransform(id, code);
|
|
58
|
+
break;
|
|
59
|
+
case 'typescript': result = await tsTransform(id, code, options.transformOptions);
|
|
60
|
+
}
|
|
61
|
+
const { sourceText, errors } = result;
|
|
51
62
|
if (errors.length) {
|
|
52
63
|
this.error(errors[0]);
|
|
53
64
|
return;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
//#region rolldown:runtime
|
|
4
|
+
var __create = Object.create;
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __export = (target, all) => {
|
|
11
|
+
for (var name in all) __defProp(target, name, {
|
|
12
|
+
get: all[name],
|
|
13
|
+
enumerable: true
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === 'object' || typeof from === 'function') for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
18
|
+
key = keys[i];
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
20
|
+
get: ((k) => from[k]).bind(null, key),
|
|
21
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, 'default', {
|
|
27
|
+
value: mod,
|
|
28
|
+
enumerable: true
|
|
29
|
+
}) : target, mod));
|
|
30
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, '__esModule', {value: true}), mod);
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
const { isolatedDeclaration } = __toESM(require("oxc-transform"));
|
|
34
|
+
|
|
35
|
+
//#region src/core/transformer.ts
|
|
36
|
+
function oxcTransform(id, code) {
|
|
37
|
+
return isolatedDeclaration(id, code);
|
|
38
|
+
}
|
|
39
|
+
async function swcTransform(id, code) {
|
|
40
|
+
let swc;
|
|
41
|
+
try {
|
|
42
|
+
swc = await import('@swc/core');
|
|
43
|
+
} catch {
|
|
44
|
+
return {
|
|
45
|
+
sourceText: '',
|
|
46
|
+
errors: ['SWC is required for transforming TypeScript, please install `@swc/core`.',]
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
const result = await swc.transform(code, {
|
|
51
|
+
filename: id,
|
|
52
|
+
jsc: {
|
|
53
|
+
parser: {
|
|
54
|
+
syntax: 'typescript',
|
|
55
|
+
tsx: false
|
|
56
|
+
},
|
|
57
|
+
experimental: {emitIsolatedDts: true}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
const output = JSON.parse(result.output);
|
|
61
|
+
return {
|
|
62
|
+
sourceText: output.__swc_isolated_declarations__,
|
|
63
|
+
errors: []
|
|
64
|
+
};
|
|
65
|
+
} catch (error) {
|
|
66
|
+
return {
|
|
67
|
+
sourceText: '',
|
|
68
|
+
errors: [error.toString()]
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async function tsTransform(id, code, transformOptions) {
|
|
73
|
+
let ts;
|
|
74
|
+
try {
|
|
75
|
+
ts = await import('typescript');
|
|
76
|
+
} catch {
|
|
77
|
+
return {
|
|
78
|
+
sourceText: '',
|
|
79
|
+
errors: ['TypeScript is required for transforming TypeScript, please install `typescript`.',]
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
if (!ts.transpileDeclaration) {
|
|
83
|
+
return {
|
|
84
|
+
sourceText: '',
|
|
85
|
+
errors: ['TypeScript version is too low, please upgrade to TypeScript 5.5.2+.',]
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const { outputText, diagnostics } = ts.transpileDeclaration(code, {
|
|
89
|
+
fileName: id,
|
|
90
|
+
reportDiagnostics: true,
|
|
91
|
+
...transformOptions
|
|
92
|
+
});
|
|
93
|
+
const errors = diagnostics?.length ? [ts.formatDiagnostics(diagnostics, {
|
|
94
|
+
getCanonicalFileName: (fileName) => ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(),
|
|
95
|
+
getCurrentDirectory: () => ts.sys.getCurrentDirectory(),
|
|
96
|
+
getNewLine: () => ts.sys.newLine
|
|
97
|
+
}),] : [];
|
|
98
|
+
return {
|
|
99
|
+
sourceText: outputText,
|
|
100
|
+
errors
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
//#endregion
|
|
105
|
+
exports.__export = __export;
|
|
106
|
+
exports.__toCommonJS = __toCommonJS;
|
|
107
|
+
exports.__toESM = __toESM;
|
|
108
|
+
exports.oxcTransform = oxcTransform;
|
|
109
|
+
exports.swcTransform = swcTransform;
|
|
110
|
+
exports.tsTransform = tsTransform;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { isolatedDeclaration } from "oxc-transform";
|
|
2
|
+
|
|
3
|
+
//#region src/core/transformer.ts
|
|
4
|
+
function oxcTransform(id, code) {
|
|
5
|
+
return isolatedDeclaration(id, code);
|
|
6
|
+
}
|
|
7
|
+
async function swcTransform(id, code) {
|
|
8
|
+
let swc;
|
|
9
|
+
try {
|
|
10
|
+
swc = await import('@swc/core');
|
|
11
|
+
} catch {
|
|
12
|
+
return {
|
|
13
|
+
sourceText: '',
|
|
14
|
+
errors: ['SWC is required for transforming TypeScript, please install `@swc/core`.',]
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
const result = await swc.transform(code, {
|
|
19
|
+
filename: id,
|
|
20
|
+
jsc: {
|
|
21
|
+
parser: {
|
|
22
|
+
syntax: 'typescript',
|
|
23
|
+
tsx: false
|
|
24
|
+
},
|
|
25
|
+
experimental: {emitIsolatedDts: true}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const output = JSON.parse(result.output);
|
|
29
|
+
return {
|
|
30
|
+
sourceText: output.__swc_isolated_declarations__,
|
|
31
|
+
errors: []
|
|
32
|
+
};
|
|
33
|
+
} catch (error) {
|
|
34
|
+
return {
|
|
35
|
+
sourceText: '',
|
|
36
|
+
errors: [error.toString()]
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async function tsTransform(id, code, transformOptions) {
|
|
41
|
+
let ts;
|
|
42
|
+
try {
|
|
43
|
+
ts = await import('typescript');
|
|
44
|
+
} catch {
|
|
45
|
+
return {
|
|
46
|
+
sourceText: '',
|
|
47
|
+
errors: ['TypeScript is required for transforming TypeScript, please install `typescript`.',]
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
if (!ts.transpileDeclaration) {
|
|
51
|
+
return {
|
|
52
|
+
sourceText: '',
|
|
53
|
+
errors: ['TypeScript version is too low, please upgrade to TypeScript 5.5.2+.',]
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const { outputText, diagnostics } = ts.transpileDeclaration(code, {
|
|
57
|
+
fileName: id,
|
|
58
|
+
reportDiagnostics: true,
|
|
59
|
+
...transformOptions
|
|
60
|
+
});
|
|
61
|
+
const errors = diagnostics?.length ? [ts.formatDiagnostics(diagnostics, {
|
|
62
|
+
getCanonicalFileName: (fileName) => ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(),
|
|
63
|
+
getCurrentDirectory: () => ts.sys.getCurrentDirectory(),
|
|
64
|
+
getNewLine: () => ts.sys.newLine
|
|
65
|
+
}),] : [];
|
|
66
|
+
return {
|
|
67
|
+
sourceText: outputText,
|
|
68
|
+
errors
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
export { oxcTransform, swcTransform, tsTransform };
|
package/dist/vite.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
const { __export, __toCommonJS } = require("./
|
|
4
|
-
const { IsolatedDecl } = require("./src_index-
|
|
3
|
+
const { __export, __toCommonJS } = require("./transformer-ZIY9xt38.cjs");
|
|
4
|
+
const { IsolatedDecl } = require("./src_index-JrSKjSmw.cjs");
|
|
5
5
|
|
|
6
6
|
//#region src/vite.ts
|
|
7
7
|
var vite_ns = {};
|
package/dist/vite.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unplugin-isolated-decl",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "A blazing-fast tool for generating isolated declarations, powered by Oxc.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -67,24 +67,37 @@
|
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|
|
69
69
|
},
|
|
70
|
+
"peerDependencies": {
|
|
71
|
+
"@swc/core": "^1.6.6",
|
|
72
|
+
"typescript": "^5.5.2"
|
|
73
|
+
},
|
|
74
|
+
"peerDependenciesMeta": {
|
|
75
|
+
"@swc/core": {
|
|
76
|
+
"optional": true
|
|
77
|
+
},
|
|
78
|
+
"typescript": {
|
|
79
|
+
"optional": true
|
|
80
|
+
}
|
|
81
|
+
},
|
|
70
82
|
"dependencies": {
|
|
71
83
|
"@rollup/pluginutils": "^5.1.0",
|
|
72
|
-
"oxc-transform": "^0.
|
|
73
|
-
"unplugin": "^1.
|
|
84
|
+
"oxc-transform": "^0.16.3",
|
|
85
|
+
"unplugin": "^1.11.0"
|
|
74
86
|
},
|
|
75
87
|
"devDependencies": {
|
|
88
|
+
"@swc/core": "^1.6.6",
|
|
76
89
|
"@sxzz/eslint-config": "^3.13.0",
|
|
77
90
|
"@sxzz/prettier-config": "^2.0.2",
|
|
78
91
|
"@types/node": "^20.14.9",
|
|
79
92
|
"bumpp": "^9.4.1",
|
|
80
|
-
"esbuild": "^0.
|
|
81
|
-
"eslint": "^9.
|
|
93
|
+
"esbuild": "^0.23.0",
|
|
94
|
+
"eslint": "^9.6.0",
|
|
82
95
|
"fast-glob": "^3.3.2",
|
|
83
96
|
"prettier": "^3.3.2",
|
|
84
97
|
"rollup": "^4.18.0",
|
|
85
|
-
"tsdown": "^0.2.
|
|
86
|
-
"tsx": "^4.
|
|
87
|
-
"typescript": "^5.5.
|
|
98
|
+
"tsdown": "^0.2.3",
|
|
99
|
+
"tsx": "^4.16.0",
|
|
100
|
+
"typescript": "^5.5.3",
|
|
88
101
|
"vite": "^5.3.2",
|
|
89
102
|
"vitest": "^1.6.0"
|
|
90
103
|
},
|
package/dist/chunk-J8LkbbVi.cjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
//#region rolldown:runtime
|
|
4
|
-
var __create = Object.create;
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __export = (target, all) => {
|
|
11
|
-
for (var name in all) __defProp(target, name, {
|
|
12
|
-
get: all[name],
|
|
13
|
-
enumerable: true
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
var __copyProps = (to, from, except, desc) => {
|
|
17
|
-
if (from && typeof from === 'object' || typeof from === 'function') for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
18
|
-
key = keys[i];
|
|
19
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
20
|
-
get: ((k) => from[k]).bind(null, key),
|
|
21
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
return to;
|
|
25
|
-
};
|
|
26
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, 'default', {
|
|
27
|
-
value: mod,
|
|
28
|
-
enumerable: true
|
|
29
|
-
}) : target, mod));
|
|
30
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, '__esModule', {value: true}), mod);
|
|
31
|
-
|
|
32
|
-
//#endregion
|
|
33
|
-
|
|
34
|
-
exports.__export = __export;
|
|
35
|
-
exports.__toCommonJS = __toCommonJS;
|
|
36
|
-
exports.__toESM = __toESM;
|