unplugin-isolated-decl 0.6.0 → 0.6.2
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 +22 -0
- package/dist/api.d.cts +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/core/options.d.cts +4 -0
- package/dist/core/options.d.ts +4 -0
- package/dist/esbuild.cjs +1 -1
- package/dist/esbuild.d.cts +2 -2
- package/dist/esbuild.d.ts +1 -1
- package/dist/esbuild.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/rolldown.cjs +1 -1
- package/dist/rolldown.d.cts +2 -2
- package/dist/rolldown.d.ts +1 -1
- package/dist/rolldown.js +1 -1
- package/dist/rollup.cjs +1 -1
- package/dist/rollup.d.cts +2 -2
- package/dist/rollup.d.ts +1 -1
- package/dist/rollup.js +1 -1
- package/dist/{src_index--m5BPU5W.cjs → src_index-94OZIa2J.cjs} +62 -19
- package/dist/{src_index-pbl3XXPp.js → src_index-_h3SFnKA.js} +62 -19
- package/dist/vite.cjs +1 -1
- package/dist/vite.d.cts +2 -2
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +1 -1
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -93,9 +93,27 @@ export interface Options {
|
|
|
93
93
|
|
|
94
94
|
/** An extra directory layer for output files. */
|
|
95
95
|
extraOutdir?: string
|
|
96
|
+
/** Automatically add `.js` extension to resolve in `Node16` + ESM mode. */
|
|
97
|
+
autoAddExts?: boolean
|
|
96
98
|
}
|
|
97
99
|
```
|
|
98
100
|
|
|
101
|
+
### `autoAddExts`
|
|
102
|
+
|
|
103
|
+
Automatically add `.js` extension to resolve in Node 16+ ESM mode.
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
// index.d.ts
|
|
107
|
+
import {} from './foo'
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
With `autoAddExts`, it will be transformed to:
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
// index.d.ts
|
|
114
|
+
import {} from './foo.js'
|
|
115
|
+
```
|
|
116
|
+
|
|
99
117
|
## Sponsors
|
|
100
118
|
|
|
101
119
|
<p align="center">
|
|
@@ -107,3 +125,7 @@ export interface Options {
|
|
|
107
125
|
## License
|
|
108
126
|
|
|
109
127
|
[MIT](./LICENSE) License © 2024-PRESENT [三咲智子](https://github.com/sxzz)
|
|
128
|
+
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
```
|
package/dist/api.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { oxcTransform, swcTransform, tsTransform } from
|
|
1
|
+
export { oxcTransform, swcTransform, tsTransform } from "./core/transformer.js";
|
package/dist/api.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { oxcTransform, swcTransform, tsTransform } from
|
|
1
|
+
export { oxcTransform, swcTransform, tsTransform } from "./core/transformer.js";
|
package/dist/core/options.d.cts
CHANGED
|
@@ -7,6 +7,10 @@ export type Options = {
|
|
|
7
7
|
ignoreErrors?: boolean;
|
|
8
8
|
/** An extra directory layer for output files. */
|
|
9
9
|
extraOutdir?: string;
|
|
10
|
+
/** Automatically add `.js` extension to resolve in `Node16` + ESM mode. */
|
|
11
|
+
autoAddExts?: boolean;
|
|
12
|
+
/** Patch `export default` in `.d.cts` to `export = ` */
|
|
13
|
+
patchCjsDefaultExport?: boolean;
|
|
10
14
|
} & ({
|
|
11
15
|
/**
|
|
12
16
|
* `oxc-transform` or `@swc/core` should be installed yourself
|
package/dist/core/options.d.ts
CHANGED
|
@@ -7,6 +7,10 @@ export type Options = {
|
|
|
7
7
|
ignoreErrors?: boolean;
|
|
8
8
|
/** An extra directory layer for output files. */
|
|
9
9
|
extraOutdir?: string;
|
|
10
|
+
/** Automatically add `.js` extension to resolve in `Node16` + ESM mode. */
|
|
11
|
+
autoAddExts?: boolean;
|
|
12
|
+
/** Patch `export default` in `.d.cts` to `export = ` */
|
|
13
|
+
patchCjsDefaultExport?: boolean;
|
|
10
14
|
} & ({
|
|
11
15
|
/**
|
|
12
16
|
* `oxc-transform` or `@swc/core` should be installed yourself
|
package/dist/esbuild.cjs
CHANGED
package/dist/esbuild.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IsolatedDecl } from
|
|
1
|
+
import { IsolatedDecl } from "./index.js";
|
|
2
2
|
declare const _default: typeof IsolatedDecl.esbuild;
|
|
3
|
-
export
|
|
3
|
+
export = _default;
|
package/dist/esbuild.d.ts
CHANGED
package/dist/esbuild.js
CHANGED
package/dist/index.cjs
CHANGED
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type UnpluginInstance } from 'unplugin';
|
|
2
|
-
import { type Options } from
|
|
2
|
+
import { type Options } from "./core/options.js";
|
|
3
3
|
export type { Options };
|
|
4
4
|
export declare const IsolatedDecl: UnpluginInstance<Options | undefined, false>;
|
|
5
5
|
export declare function lowestCommonAncestor(...filepaths: string[]): string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type UnpluginInstance } from 'unplugin';
|
|
2
|
-
import { type Options } from
|
|
2
|
+
import { type Options } from "./core/options.js";
|
|
3
3
|
export type { Options };
|
|
4
4
|
export declare const IsolatedDecl: UnpluginInstance<Options | undefined, false>;
|
|
5
5
|
export declare function lowestCommonAncestor(...filepaths: string[]): string;
|
package/dist/index.js
CHANGED
package/dist/rolldown.cjs
CHANGED
package/dist/rolldown.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IsolatedDecl } from
|
|
1
|
+
import { IsolatedDecl } from "./index.js";
|
|
2
2
|
declare const _default: typeof IsolatedDecl.rolldown;
|
|
3
|
-
export
|
|
3
|
+
export = _default;
|
package/dist/rolldown.d.ts
CHANGED
package/dist/rolldown.js
CHANGED
package/dist/rollup.cjs
CHANGED
package/dist/rollup.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IsolatedDecl } from
|
|
1
|
+
import { IsolatedDecl } from "./index.js";
|
|
2
2
|
declare const _default: typeof IsolatedDecl.rollup;
|
|
3
|
-
export
|
|
3
|
+
export = _default;
|
package/dist/rollup.d.ts
CHANGED
package/dist/rollup.js
CHANGED
|
@@ -26,6 +26,7 @@ const require_transformer = require('./transformer-ZHFQTLaY.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"));
|
|
29
|
+
const { default: MagicString } = __toESM(require("magic-string"));
|
|
29
30
|
const { parseAsync } = __toESM(require("oxc-parser"));
|
|
30
31
|
const { createUnplugin } = __toESM(require("unplugin"));
|
|
31
32
|
|
|
@@ -37,7 +38,9 @@ function resolveOptions(options) {
|
|
|
37
38
|
enforce: "enforce" in options ? options.enforce : "pre",
|
|
38
39
|
transformer: options.transformer || "typescript",
|
|
39
40
|
ignoreErrors: options.ignoreErrors || false,
|
|
40
|
-
extraOutdir: options.extraOutdir
|
|
41
|
+
extraOutdir: options.extraOutdir,
|
|
42
|
+
autoAddExts: options.autoAddExts || false,
|
|
43
|
+
patchCjsDefaultExport: options.patchCjsDefaultExport || false
|
|
41
44
|
};
|
|
42
45
|
}
|
|
43
46
|
|
|
@@ -64,10 +67,14 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
64
67
|
if (options.extraOutdir) {
|
|
65
68
|
entryFileNames = path.join(options.extraOutdir, entryFileNames);
|
|
66
69
|
}
|
|
67
|
-
for (
|
|
70
|
+
for (let [outname, source] of Object.entries(outputFiles)) {
|
|
71
|
+
const fileName = entryFileNames.replace("[name]", path.relative(outBase, outname));
|
|
72
|
+
if (options.patchCjsDefaultExport && fileName.endsWith(".d.cts")) {
|
|
73
|
+
source = patchCjsDefaultExport(source);
|
|
74
|
+
}
|
|
68
75
|
this.emitFile({
|
|
69
76
|
type: "asset",
|
|
70
|
-
fileName
|
|
77
|
+
fileName,
|
|
71
78
|
source
|
|
72
79
|
});
|
|
73
80
|
}
|
|
@@ -90,6 +97,25 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
90
97
|
}
|
|
91
98
|
};
|
|
92
99
|
async function transform(context, code, id) {
|
|
100
|
+
let program;
|
|
101
|
+
try {
|
|
102
|
+
program = JSON.parse((await parseAsync(code, { sourceFilename: id })).program);
|
|
103
|
+
} catch {}
|
|
104
|
+
if (options.autoAddExts && program) {
|
|
105
|
+
const imports = program.body.filter((node) => node.type === "ImportDeclaration" || node.type === "ExportAllDeclaration" || node.type === "ExportNamedDeclaration");
|
|
106
|
+
const s = new MagicString(code);
|
|
107
|
+
for (const i of imports) {
|
|
108
|
+
if (!i.source || path.basename(i.source.value).includes(".")) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
const resolved = await resolve(context, i.source.value, id);
|
|
112
|
+
if (!resolved || resolved.external) continue;
|
|
113
|
+
if (resolved.id.endsWith(".ts")) {
|
|
114
|
+
s.overwrite(i.source.start, i.source.end, JSON.stringify(`${i.source.value}.js`));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
code = s.toString();
|
|
118
|
+
}
|
|
93
119
|
let result;
|
|
94
120
|
switch (options.transformer) {
|
|
95
121
|
case "oxc":
|
|
@@ -110,19 +136,21 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
110
136
|
}
|
|
111
137
|
}
|
|
112
138
|
addOutput(id, sourceText);
|
|
113
|
-
|
|
114
|
-
try {
|
|
115
|
-
program = JSON.parse((await parseAsync(code, { sourceFilename: id })).program);
|
|
116
|
-
} catch {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
139
|
+
if (!program) return;
|
|
119
140
|
const typeImports = program.body.filter((node) => {
|
|
120
|
-
if (node.type
|
|
121
|
-
|
|
122
|
-
|
|
141
|
+
if (node.type === "ImportDeclaration") {
|
|
142
|
+
if (node.importKind === "type") return true;
|
|
143
|
+
return node.specifiers && node.specifiers.every((spec) => spec.type === "ImportSpecifier" && spec.importKind === "type");
|
|
144
|
+
}
|
|
145
|
+
if (node.type === "ExportNamedDeclaration" || node.type === "ExportAllDeclaration") {
|
|
146
|
+
if (node.exportKind === "type") return true;
|
|
147
|
+
return node.type === "ExportNamedDeclaration" && node.specifiers && node.specifiers.every((spec) => spec.type === "ExportSpecifier" && spec.exportKind === "type");
|
|
148
|
+
}
|
|
149
|
+
return false;
|
|
123
150
|
});
|
|
124
151
|
for (const i of typeImports) {
|
|
125
|
-
|
|
152
|
+
if (!i.source) continue;
|
|
153
|
+
const resolved = (await resolve(context, i.source.value, id))?.id;
|
|
126
154
|
if (resolved && filter(resolved) && !outputFiles[stripExt(resolved)]) {
|
|
127
155
|
let source;
|
|
128
156
|
try {
|
|
@@ -160,13 +188,16 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
160
188
|
result.outputFiles ||= [];
|
|
161
189
|
}
|
|
162
190
|
const textEncoder = new TextEncoder();
|
|
163
|
-
for (
|
|
191
|
+
for (let [filename, source] of Object.entries(outputFiles)) {
|
|
164
192
|
const outDir = build.initialOptions.outdir;
|
|
165
193
|
let outFile = `${path.relative(outBase, filename)}.d.${outExt}`;
|
|
166
194
|
if (options.extraOutdir) {
|
|
167
195
|
outFile = path.join(options.extraOutdir, outFile);
|
|
168
196
|
}
|
|
169
197
|
const filePath = outDir ? path.resolve(outDir, outFile) : outFile;
|
|
198
|
+
if (options.patchCjsDefaultExport && filePath.endsWith(".d.cts")) {
|
|
199
|
+
source = patchCjsDefaultExport(source);
|
|
200
|
+
}
|
|
170
201
|
if (write) {
|
|
171
202
|
await mkdir(path.dirname(filePath), { recursive: true });
|
|
172
203
|
await writeFile(filePath, source);
|
|
@@ -182,20 +213,32 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
182
213
|
});
|
|
183
214
|
}
|
|
184
215
|
});
|
|
185
|
-
|
|
216
|
+
async function resolve(context, id, importer) {
|
|
186
217
|
const nativeContext = context.getNativeBuildContext?.();
|
|
187
218
|
if (nativeContext?.framework === "esbuild") {
|
|
188
|
-
|
|
219
|
+
const resolved$1 = await nativeContext.build.resolve(id, {
|
|
189
220
|
importer,
|
|
190
221
|
resolveDir: path.dirname(importer),
|
|
191
222
|
kind: "import-statement"
|
|
192
|
-
})
|
|
223
|
+
});
|
|
224
|
+
return {
|
|
225
|
+
id: resolved$1.path,
|
|
226
|
+
external: resolved$1.external
|
|
227
|
+
};
|
|
193
228
|
}
|
|
194
|
-
|
|
195
|
-
|
|
229
|
+
const resolved = await context.resolve(id, importer);
|
|
230
|
+
if (!resolved) return;
|
|
231
|
+
return {
|
|
232
|
+
id: resolved.id,
|
|
233
|
+
external: !!resolved.external
|
|
234
|
+
};
|
|
235
|
+
}
|
|
196
236
|
function stripExt(filename) {
|
|
197
237
|
return filename.replace(/\.(.?)[jt]s$/, "");
|
|
198
238
|
}
|
|
239
|
+
function patchCjsDefaultExport(source) {
|
|
240
|
+
return source.replace(/(?<=(?:[;}]|^)\s*export\s*)(?:\{\s*([\w$]+)\s*as\s+default\s*\}|default\s+([\w$]+))/, (_, s1, s2) => `= ${s1 || s2}`);
|
|
241
|
+
}
|
|
199
242
|
function lowestCommonAncestor(...filepaths) {
|
|
200
243
|
if (filepaths.length === 0) return "";
|
|
201
244
|
if (filepaths.length === 1) return path.dirname(filepaths[0]);
|
|
@@ -2,6 +2,7 @@ import { oxcTransform, swcTransform, tsTransform } from "./transformer-YxBC7dLI.
|
|
|
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";
|
|
5
|
+
import { default as MagicString } from "magic-string";
|
|
5
6
|
import { parseAsync } from "oxc-parser";
|
|
6
7
|
import { createUnplugin } from "unplugin";
|
|
7
8
|
|
|
@@ -13,7 +14,9 @@ function resolveOptions(options) {
|
|
|
13
14
|
enforce: "enforce" in options ? options.enforce : "pre",
|
|
14
15
|
transformer: options.transformer || "typescript",
|
|
15
16
|
ignoreErrors: options.ignoreErrors || false,
|
|
16
|
-
extraOutdir: options.extraOutdir
|
|
17
|
+
extraOutdir: options.extraOutdir,
|
|
18
|
+
autoAddExts: options.autoAddExts || false,
|
|
19
|
+
patchCjsDefaultExport: options.patchCjsDefaultExport || false
|
|
17
20
|
};
|
|
18
21
|
}
|
|
19
22
|
|
|
@@ -40,10 +43,14 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
40
43
|
if (options.extraOutdir) {
|
|
41
44
|
entryFileNames = path.join(options.extraOutdir, entryFileNames);
|
|
42
45
|
}
|
|
43
|
-
for (
|
|
46
|
+
for (let [outname, source] of Object.entries(outputFiles)) {
|
|
47
|
+
const fileName = entryFileNames.replace("[name]", path.relative(outBase, outname));
|
|
48
|
+
if (options.patchCjsDefaultExport && fileName.endsWith(".d.cts")) {
|
|
49
|
+
source = patchCjsDefaultExport(source);
|
|
50
|
+
}
|
|
44
51
|
this.emitFile({
|
|
45
52
|
type: "asset",
|
|
46
|
-
fileName
|
|
53
|
+
fileName,
|
|
47
54
|
source
|
|
48
55
|
});
|
|
49
56
|
}
|
|
@@ -66,6 +73,25 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
66
73
|
}
|
|
67
74
|
};
|
|
68
75
|
async function transform(context, code, id) {
|
|
76
|
+
let program;
|
|
77
|
+
try {
|
|
78
|
+
program = JSON.parse((await parseAsync(code, { sourceFilename: id })).program);
|
|
79
|
+
} catch {}
|
|
80
|
+
if (options.autoAddExts && program) {
|
|
81
|
+
const imports = program.body.filter((node) => node.type === "ImportDeclaration" || node.type === "ExportAllDeclaration" || node.type === "ExportNamedDeclaration");
|
|
82
|
+
const s = new MagicString(code);
|
|
83
|
+
for (const i of imports) {
|
|
84
|
+
if (!i.source || path.basename(i.source.value).includes(".")) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
const resolved = await resolve(context, i.source.value, id);
|
|
88
|
+
if (!resolved || resolved.external) continue;
|
|
89
|
+
if (resolved.id.endsWith(".ts")) {
|
|
90
|
+
s.overwrite(i.source.start, i.source.end, JSON.stringify(`${i.source.value}.js`));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
code = s.toString();
|
|
94
|
+
}
|
|
69
95
|
let result;
|
|
70
96
|
switch (options.transformer) {
|
|
71
97
|
case "oxc":
|
|
@@ -86,19 +112,21 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
86
112
|
}
|
|
87
113
|
}
|
|
88
114
|
addOutput(id, sourceText);
|
|
89
|
-
|
|
90
|
-
try {
|
|
91
|
-
program = JSON.parse((await parseAsync(code, { sourceFilename: id })).program);
|
|
92
|
-
} catch {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
115
|
+
if (!program) return;
|
|
95
116
|
const typeImports = program.body.filter((node) => {
|
|
96
|
-
if (node.type
|
|
97
|
-
|
|
98
|
-
|
|
117
|
+
if (node.type === "ImportDeclaration") {
|
|
118
|
+
if (node.importKind === "type") return true;
|
|
119
|
+
return node.specifiers && node.specifiers.every((spec) => spec.type === "ImportSpecifier" && spec.importKind === "type");
|
|
120
|
+
}
|
|
121
|
+
if (node.type === "ExportNamedDeclaration" || node.type === "ExportAllDeclaration") {
|
|
122
|
+
if (node.exportKind === "type") return true;
|
|
123
|
+
return node.type === "ExportNamedDeclaration" && node.specifiers && node.specifiers.every((spec) => spec.type === "ExportSpecifier" && spec.exportKind === "type");
|
|
124
|
+
}
|
|
125
|
+
return false;
|
|
99
126
|
});
|
|
100
127
|
for (const i of typeImports) {
|
|
101
|
-
|
|
128
|
+
if (!i.source) continue;
|
|
129
|
+
const resolved = (await resolve(context, i.source.value, id))?.id;
|
|
102
130
|
if (resolved && filter(resolved) && !outputFiles[stripExt(resolved)]) {
|
|
103
131
|
let source;
|
|
104
132
|
try {
|
|
@@ -136,13 +164,16 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
136
164
|
result.outputFiles ||= [];
|
|
137
165
|
}
|
|
138
166
|
const textEncoder = new TextEncoder();
|
|
139
|
-
for (
|
|
167
|
+
for (let [filename, source] of Object.entries(outputFiles)) {
|
|
140
168
|
const outDir = build.initialOptions.outdir;
|
|
141
169
|
let outFile = `${path.relative(outBase, filename)}.d.${outExt}`;
|
|
142
170
|
if (options.extraOutdir) {
|
|
143
171
|
outFile = path.join(options.extraOutdir, outFile);
|
|
144
172
|
}
|
|
145
173
|
const filePath = outDir ? path.resolve(outDir, outFile) : outFile;
|
|
174
|
+
if (options.patchCjsDefaultExport && filePath.endsWith(".d.cts")) {
|
|
175
|
+
source = patchCjsDefaultExport(source);
|
|
176
|
+
}
|
|
146
177
|
if (write) {
|
|
147
178
|
await mkdir(path.dirname(filePath), { recursive: true });
|
|
148
179
|
await writeFile(filePath, source);
|
|
@@ -158,20 +189,32 @@ const IsolatedDecl = createUnplugin((rawOptions = {}) => {
|
|
|
158
189
|
});
|
|
159
190
|
}
|
|
160
191
|
});
|
|
161
|
-
|
|
192
|
+
async function resolve(context, id, importer) {
|
|
162
193
|
const nativeContext = context.getNativeBuildContext?.();
|
|
163
194
|
if (nativeContext?.framework === "esbuild") {
|
|
164
|
-
|
|
195
|
+
const resolved$1 = await nativeContext.build.resolve(id, {
|
|
165
196
|
importer,
|
|
166
197
|
resolveDir: path.dirname(importer),
|
|
167
198
|
kind: "import-statement"
|
|
168
|
-
})
|
|
199
|
+
});
|
|
200
|
+
return {
|
|
201
|
+
id: resolved$1.path,
|
|
202
|
+
external: resolved$1.external
|
|
203
|
+
};
|
|
169
204
|
}
|
|
170
|
-
|
|
171
|
-
|
|
205
|
+
const resolved = await context.resolve(id, importer);
|
|
206
|
+
if (!resolved) return;
|
|
207
|
+
return {
|
|
208
|
+
id: resolved.id,
|
|
209
|
+
external: !!resolved.external
|
|
210
|
+
};
|
|
211
|
+
}
|
|
172
212
|
function stripExt(filename) {
|
|
173
213
|
return filename.replace(/\.(.?)[jt]s$/, "");
|
|
174
214
|
}
|
|
215
|
+
function patchCjsDefaultExport(source) {
|
|
216
|
+
return source.replace(/(?<=(?:[;}]|^)\s*export\s*)(?:\{\s*([\w$]+)\s*as\s+default\s*\}|default\s+([\w$]+))/, (_, s1, s2) => `= ${s1 || s2}`);
|
|
217
|
+
}
|
|
175
218
|
function lowestCommonAncestor(...filepaths) {
|
|
176
219
|
if (filepaths.length === 0) return "";
|
|
177
220
|
if (filepaths.length === 1) return path.dirname(filepaths[0]);
|
package/dist/vite.cjs
CHANGED
package/dist/vite.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IsolatedDecl } from
|
|
1
|
+
import { IsolatedDecl } from "./index.js";
|
|
2
2
|
declare const _default: typeof IsolatedDecl.vite;
|
|
3
|
-
export
|
|
3
|
+
export = _default;
|
package/dist/vite.d.ts
CHANGED
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.2",
|
|
4
4
|
"description": "A blazing-fast tool for generating isolated declarations, powered by Oxc.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -85,6 +85,7 @@
|
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
87
|
"@rollup/pluginutils": "^5.1.0",
|
|
88
|
+
"magic-string": "^0.30.11",
|
|
88
89
|
"oxc-parser": "^0.27.0",
|
|
89
90
|
"unplugin": "^1.14.0"
|
|
90
91
|
},
|
|
@@ -93,6 +94,7 @@
|
|
|
93
94
|
"@sxzz/eslint-config": "^4.2.0",
|
|
94
95
|
"@sxzz/prettier-config": "^2.0.2",
|
|
95
96
|
"@types/node": "^22.5.4",
|
|
97
|
+
"@typescript-eslint/typescript-estree": "^8.5.0",
|
|
96
98
|
"bumpp": "^9.5.2",
|
|
97
99
|
"esbuild": "^0.23.1",
|
|
98
100
|
"eslint": "^9.10.0",
|