unplugin-isolated-decl 0.4.6 → 0.5.0
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/core/transformer.d.cts +1 -1
- package/dist/core/transformer.d.ts +1 -1
- package/dist/esbuild.cjs +2 -2
- package/dist/esbuild.js +2 -2
- package/dist/index.cjs +8 -2
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -3
- 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-yIG2muej.cjs → src_index-2j2jy32a.cjs} +14 -8
- package/dist/{src_index-CysF8PH2.js → src_index-GOBsoA4f.js} +10 -9
- package/dist/{transformer-69vts78l.js → transformer-2hVUBpkW.js} +7 -7
- package/dist/{transformer-wFl7-Qrk.cjs → transformer-ZZscAG9G.cjs} +7 -7
- package/dist/vite.cjs +2 -2
- package/dist/vite.js +2 -2
- package/package.json +14 -14
package/dist/api.cjs
CHANGED
package/dist/api.js
CHANGED
package/dist/esbuild.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
require('./transformer-
|
|
3
|
-
const require_src_index = require('./src_index-
|
|
2
|
+
require('./transformer-ZZscAG9G.cjs');
|
|
3
|
+
const require_src_index = require('./src_index-2j2jy32a.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,10 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
require('./transformer-
|
|
3
|
-
const require_src_index = require('./src_index-
|
|
2
|
+
require('./transformer-ZZscAG9G.cjs');
|
|
3
|
+
const require_src_index = require('./src_index-2j2jy32a.cjs');
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, 'IsolatedDecl', {
|
|
6
6
|
enumerable: true,
|
|
7
7
|
get: function () {
|
|
8
8
|
return require_src_index.IsolatedDecl;
|
|
9
9
|
}
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, 'lowestCommonAncestor', {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () {
|
|
14
|
+
return require_src_index.lowestCommonAncestor;
|
|
15
|
+
}
|
|
10
16
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -2,3 +2,4 @@ import { type UnpluginInstance } from "unplugin";
|
|
|
2
2
|
import { type Options } from "./core/options";
|
|
3
3
|
export type { Options };
|
|
4
4
|
export declare const IsolatedDecl: UnpluginInstance<Options | undefined, false>;
|
|
5
|
+
export declare function lowestCommonAncestor(...filepaths: string[]): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,3 +2,4 @@ import { type UnpluginInstance } from "unplugin";
|
|
|
2
2
|
import { type Options } from "./core/options";
|
|
3
3
|
export type { Options };
|
|
4
4
|
export declare const IsolatedDecl: UnpluginInstance<Options | undefined, false>;
|
|
5
|
+
export declare function lowestCommonAncestor(...filepaths: string[]): string;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./transformer-
|
|
2
|
-
import { IsolatedDecl } from "./src_index-
|
|
1
|
+
import "./transformer-2hVUBpkW.js";
|
|
2
|
+
import { IsolatedDecl, lowestCommonAncestor } from "./src_index-GOBsoA4f.js";
|
|
3
3
|
|
|
4
|
-
export { IsolatedDecl };
|
|
4
|
+
export { IsolatedDecl, lowestCommonAncestor };
|
package/dist/rolldown.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
require('./transformer-
|
|
3
|
-
const require_src_index = require('./src_index-
|
|
2
|
+
require('./transformer-ZZscAG9G.cjs');
|
|
3
|
+
const require_src_index = require('./src_index-2j2jy32a.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
|
-
require('./transformer-
|
|
3
|
-
const require_src_index = require('./src_index-
|
|
2
|
+
require('./transformer-ZZscAG9G.cjs');
|
|
3
|
+
const require_src_index = require('./src_index-2j2jy32a.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
1
|
"use strict";
|
|
2
|
-
const require_transformer = require('./transformer-
|
|
2
|
+
const require_transformer = require('./transformer-ZZscAG9G.cjs');
|
|
3
3
|
const { mkdir, readFile, writeFile } = __toESM(require("node:fs/promises"));
|
|
4
4
|
const { default: path } = __toESM(require("node:path"));
|
|
5
5
|
const { createFilter } = __toESM(require("@rollup/pluginutils"));
|
|
@@ -23,9 +23,6 @@ const IsolatedDecl = createUnplugin((rawOptions = {}, meta) => {
|
|
|
23
23
|
const options = resolveOptions(rawOptions);
|
|
24
24
|
const filter = createFilter(options.include, options.exclude);
|
|
25
25
|
const outputFiles = {};
|
|
26
|
-
function stripExt(filename) {
|
|
27
|
-
return filename.replace(/\.(.?)[jt]s$/, "");
|
|
28
|
-
}
|
|
29
26
|
function addOutput(filename, source) {
|
|
30
27
|
outputFiles[stripExt(filename)] = source;
|
|
31
28
|
}
|
|
@@ -119,7 +116,7 @@ const IsolatedDecl = createUnplugin((rawOptions = {}, meta) => {
|
|
|
119
116
|
break;
|
|
120
117
|
case "typescript": result = await require_transformer.tsTransform(id, code, options.transformOptions);
|
|
121
118
|
}
|
|
122
|
-
const { sourceText, errors } = result;
|
|
119
|
+
const { code: sourceText, errors } = result;
|
|
123
120
|
if (errors.length) {
|
|
124
121
|
if (options.ignoreErrors) {
|
|
125
122
|
this.warn(errors[0]);
|
|
@@ -164,13 +161,17 @@ const IsolatedDecl = createUnplugin((rawOptions = {}, meta) => {
|
|
|
164
161
|
}
|
|
165
162
|
}
|
|
166
163
|
});
|
|
164
|
+
function stripExt(filename) {
|
|
165
|
+
return filename.replace(/\.(.?)[jt]s$/, "");
|
|
166
|
+
}
|
|
167
167
|
function lowestCommonAncestor(...filepaths) {
|
|
168
168
|
if (filepaths.length === 0) return "";
|
|
169
169
|
if (filepaths.length === 1) return path.dirname(filepaths[0]);
|
|
170
|
+
filepaths = filepaths.map((p) => p.replaceAll("\\", "/"));
|
|
170
171
|
const [first, ...rest] = filepaths;
|
|
171
|
-
let ancestor = first.split(
|
|
172
|
+
let ancestor = first.split("/");
|
|
172
173
|
for (const filepath of rest) {
|
|
173
|
-
const directories = filepath.split(
|
|
174
|
+
const directories = filepath.split("/", ancestor.length);
|
|
174
175
|
let index = 0;
|
|
175
176
|
for (const directory of directories) {
|
|
176
177
|
if (directory === ancestor[index]) {
|
|
@@ -182,7 +183,7 @@ function lowestCommonAncestor(...filepaths) {
|
|
|
182
183
|
}
|
|
183
184
|
ancestor = ancestor.slice(0, index);
|
|
184
185
|
}
|
|
185
|
-
return ancestor.length <= 1 && ancestor[0] === "" ?
|
|
186
|
+
return ancestor.length <= 1 && ancestor[0] === "" ? `/${ancestor[0]}` : ancestor.join("/");
|
|
186
187
|
}
|
|
187
188
|
|
|
188
189
|
//#endregion
|
|
@@ -191,4 +192,9 @@ Object.defineProperty(exports, 'IsolatedDecl', {
|
|
|
191
192
|
get: function () {
|
|
192
193
|
return IsolatedDecl;
|
|
193
194
|
}
|
|
195
|
+
});Object.defineProperty(exports, 'lowestCommonAncestor', {
|
|
196
|
+
enumerable: true,
|
|
197
|
+
get: function () {
|
|
198
|
+
return lowestCommonAncestor;
|
|
199
|
+
}
|
|
194
200
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { oxcTransform, swcTransform, tsTransform } from "./transformer-
|
|
1
|
+
import { oxcTransform, swcTransform, tsTransform } from "./transformer-2hVUBpkW.js";
|
|
2
2
|
import { mkdir, readFile, writeFile } from "node:fs/promises";
|
|
3
3
|
import { default as path } from "node:path";
|
|
4
4
|
import { createFilter } from "@rollup/pluginutils";
|
|
@@ -22,9 +22,6 @@ const IsolatedDecl = createUnplugin((rawOptions = {}, meta) => {
|
|
|
22
22
|
const options = resolveOptions(rawOptions);
|
|
23
23
|
const filter = createFilter(options.include, options.exclude);
|
|
24
24
|
const outputFiles = {};
|
|
25
|
-
function stripExt(filename) {
|
|
26
|
-
return filename.replace(/\.(.?)[jt]s$/, "");
|
|
27
|
-
}
|
|
28
25
|
function addOutput(filename, source) {
|
|
29
26
|
outputFiles[stripExt(filename)] = source;
|
|
30
27
|
}
|
|
@@ -118,7 +115,7 @@ const IsolatedDecl = createUnplugin((rawOptions = {}, meta) => {
|
|
|
118
115
|
break;
|
|
119
116
|
case "typescript": result = await tsTransform(id, code, options.transformOptions);
|
|
120
117
|
}
|
|
121
|
-
const { sourceText, errors } = result;
|
|
118
|
+
const { code: sourceText, errors } = result;
|
|
122
119
|
if (errors.length) {
|
|
123
120
|
if (options.ignoreErrors) {
|
|
124
121
|
this.warn(errors[0]);
|
|
@@ -163,13 +160,17 @@ const IsolatedDecl = createUnplugin((rawOptions = {}, meta) => {
|
|
|
163
160
|
}
|
|
164
161
|
}
|
|
165
162
|
});
|
|
163
|
+
function stripExt(filename) {
|
|
164
|
+
return filename.replace(/\.(.?)[jt]s$/, "");
|
|
165
|
+
}
|
|
166
166
|
function lowestCommonAncestor(...filepaths) {
|
|
167
167
|
if (filepaths.length === 0) return "";
|
|
168
168
|
if (filepaths.length === 1) return path.dirname(filepaths[0]);
|
|
169
|
+
filepaths = filepaths.map((p) => p.replaceAll("\\", "/"));
|
|
169
170
|
const [first, ...rest] = filepaths;
|
|
170
|
-
let ancestor = first.split(
|
|
171
|
+
let ancestor = first.split("/");
|
|
171
172
|
for (const filepath of rest) {
|
|
172
|
-
const directories = filepath.split(
|
|
173
|
+
const directories = filepath.split("/", ancestor.length);
|
|
173
174
|
let index = 0;
|
|
174
175
|
for (const directory of directories) {
|
|
175
176
|
if (directory === ancestor[index]) {
|
|
@@ -181,8 +182,8 @@ function lowestCommonAncestor(...filepaths) {
|
|
|
181
182
|
}
|
|
182
183
|
ancestor = ancestor.slice(0, index);
|
|
183
184
|
}
|
|
184
|
-
return ancestor.length <= 1 && ancestor[0] === "" ?
|
|
185
|
+
return ancestor.length <= 1 && ancestor[0] === "" ? `/${ancestor[0]}` : ancestor.join("/");
|
|
185
186
|
}
|
|
186
187
|
|
|
187
188
|
//#endregion
|
|
188
|
-
export { IsolatedDecl };
|
|
189
|
+
export { IsolatedDecl, lowestCommonAncestor };
|
|
@@ -2,7 +2,7 @@ import { isolatedDeclaration } from "oxc-transform";
|
|
|
2
2
|
|
|
3
3
|
//#region src/core/transformer.ts
|
|
4
4
|
function oxcTransform(id, code) {
|
|
5
|
-
return isolatedDeclaration(id, code);
|
|
5
|
+
return isolatedDeclaration(id, code, { sourcemap: false });
|
|
6
6
|
}
|
|
7
7
|
async function swcTransform(id, code) {
|
|
8
8
|
let swc;
|
|
@@ -10,7 +10,7 @@ async function swcTransform(id, code) {
|
|
|
10
10
|
swc = await import("@swc/core");
|
|
11
11
|
} catch {
|
|
12
12
|
return {
|
|
13
|
-
|
|
13
|
+
code: "",
|
|
14
14
|
errors: ["SWC is required for transforming TypeScript, please install `@swc/core`.",]
|
|
15
15
|
};
|
|
16
16
|
}
|
|
@@ -27,12 +27,12 @@ async function swcTransform(id, code) {
|
|
|
27
27
|
});
|
|
28
28
|
const output = JSON.parse(result.output);
|
|
29
29
|
return {
|
|
30
|
-
|
|
30
|
+
code: output.__swc_isolated_declarations__,
|
|
31
31
|
errors: []
|
|
32
32
|
};
|
|
33
33
|
} catch (error) {
|
|
34
34
|
return {
|
|
35
|
-
|
|
35
|
+
code: "",
|
|
36
36
|
errors: [error.toString()]
|
|
37
37
|
};
|
|
38
38
|
}
|
|
@@ -43,13 +43,13 @@ async function tsTransform(id, code, transformOptions) {
|
|
|
43
43
|
ts = await import("typescript");
|
|
44
44
|
} catch {
|
|
45
45
|
return {
|
|
46
|
-
|
|
46
|
+
code: "",
|
|
47
47
|
errors: ["TypeScript is required for transforming TypeScript, please install `typescript`.",]
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
if (!ts.transpileDeclaration) {
|
|
51
51
|
return {
|
|
52
|
-
|
|
52
|
+
code: "",
|
|
53
53
|
errors: ["TypeScript version is too low, please upgrade to TypeScript 5.5.2+.",]
|
|
54
54
|
};
|
|
55
55
|
}
|
|
@@ -64,7 +64,7 @@ async function tsTransform(id, code, transformOptions) {
|
|
|
64
64
|
getNewLine: () => ts.sys.newLine
|
|
65
65
|
}),] : [];
|
|
66
66
|
return {
|
|
67
|
-
|
|
67
|
+
code: outputText,
|
|
68
68
|
errors
|
|
69
69
|
};
|
|
70
70
|
}
|
|
@@ -26,7 +26,7 @@ const { isolatedDeclaration } = __toESM(require("oxc-transform"));
|
|
|
26
26
|
|
|
27
27
|
//#region src/core/transformer.ts
|
|
28
28
|
function oxcTransform(id, code) {
|
|
29
|
-
return isolatedDeclaration(id, code);
|
|
29
|
+
return isolatedDeclaration(id, code, { sourcemap: false });
|
|
30
30
|
}
|
|
31
31
|
async function swcTransform(id, code) {
|
|
32
32
|
let swc;
|
|
@@ -34,7 +34,7 @@ async function swcTransform(id, code) {
|
|
|
34
34
|
swc = await import("@swc/core");
|
|
35
35
|
} catch {
|
|
36
36
|
return {
|
|
37
|
-
|
|
37
|
+
code: "",
|
|
38
38
|
errors: ["SWC is required for transforming TypeScript, please install `@swc/core`.",]
|
|
39
39
|
};
|
|
40
40
|
}
|
|
@@ -51,12 +51,12 @@ async function swcTransform(id, code) {
|
|
|
51
51
|
});
|
|
52
52
|
const output = JSON.parse(result.output);
|
|
53
53
|
return {
|
|
54
|
-
|
|
54
|
+
code: output.__swc_isolated_declarations__,
|
|
55
55
|
errors: []
|
|
56
56
|
};
|
|
57
57
|
} catch (error) {
|
|
58
58
|
return {
|
|
59
|
-
|
|
59
|
+
code: "",
|
|
60
60
|
errors: [error.toString()]
|
|
61
61
|
};
|
|
62
62
|
}
|
|
@@ -67,13 +67,13 @@ async function tsTransform(id, code, transformOptions) {
|
|
|
67
67
|
ts = await import("typescript");
|
|
68
68
|
} catch {
|
|
69
69
|
return {
|
|
70
|
-
|
|
70
|
+
code: "",
|
|
71
71
|
errors: ["TypeScript is required for transforming TypeScript, please install `typescript`.",]
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
if (!ts.transpileDeclaration) {
|
|
75
75
|
return {
|
|
76
|
-
|
|
76
|
+
code: "",
|
|
77
77
|
errors: ["TypeScript version is too low, please upgrade to TypeScript 5.5.2+.",]
|
|
78
78
|
};
|
|
79
79
|
}
|
|
@@ -88,7 +88,7 @@ async function tsTransform(id, code, transformOptions) {
|
|
|
88
88
|
getNewLine: () => ts.sys.newLine
|
|
89
89
|
}),] : [];
|
|
90
90
|
return {
|
|
91
|
-
|
|
91
|
+
code: outputText,
|
|
92
92
|
errors
|
|
93
93
|
};
|
|
94
94
|
}
|
package/dist/vite.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
require('./transformer-
|
|
3
|
-
const require_src_index = require('./src_index-
|
|
2
|
+
require('./transformer-ZZscAG9G.cjs');
|
|
3
|
+
const require_src_index = require('./src_index-2j2jy32a.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.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "A blazing-fast tool for generating isolated declarations, powered by Oxc.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -81,27 +81,27 @@
|
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
83
|
"@rollup/pluginutils": "^5.1.0",
|
|
84
|
-
"oxc-parser": "^0.
|
|
85
|
-
"oxc-transform": "^0.
|
|
86
|
-
"unplugin": "^1.
|
|
84
|
+
"oxc-parser": "^0.27.0",
|
|
85
|
+
"oxc-transform": "^0.27.0",
|
|
86
|
+
"unplugin": "^1.14.0"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
|
-
"@swc/core": "^1.7.
|
|
90
|
-
"@sxzz/eslint-config": "^
|
|
89
|
+
"@swc/core": "^1.7.24",
|
|
90
|
+
"@sxzz/eslint-config": "^4.2.0",
|
|
91
91
|
"@sxzz/prettier-config": "^2.0.2",
|
|
92
|
-
"@types/node": "^
|
|
93
|
-
"bumpp": "^9.5.
|
|
92
|
+
"@types/node": "^22.5.4",
|
|
93
|
+
"bumpp": "^9.5.2",
|
|
94
94
|
"esbuild": "^0.23.1",
|
|
95
|
-
"eslint": "^9.
|
|
95
|
+
"eslint": "^9.10.0",
|
|
96
96
|
"fast-glob": "^3.3.2",
|
|
97
97
|
"prettier": "^3.3.3",
|
|
98
98
|
"rolldown": "nightly",
|
|
99
|
-
"rollup": "^4.21.
|
|
99
|
+
"rollup": "^4.21.2",
|
|
100
100
|
"rollup-plugin-esbuild": "^6.1.1",
|
|
101
|
-
"tsdown": "^0.2.
|
|
102
|
-
"tsx": "^4.
|
|
103
|
-
"typescript": "^5.
|
|
104
|
-
"vite": "^5.4.
|
|
101
|
+
"tsdown": "^0.2.15",
|
|
102
|
+
"tsx": "^4.19.0",
|
|
103
|
+
"typescript": "^5.6.2",
|
|
104
|
+
"vite": "^5.4.3",
|
|
105
105
|
"vitest": "^2.0.5"
|
|
106
106
|
},
|
|
107
107
|
"engines": {
|