unplugin-isolated-decl 0.9.3 → 0.9.5
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/core/ast.d.cts +1 -1
- package/dist/core/ast.d.ts +1 -1
- package/dist/core/utils.d.cts +1 -1
- package/dist/core/utils.d.ts +1 -1
- package/dist/esbuild.cjs +1 -1
- package/dist/esbuild.d.cts +1 -1
- package/dist/esbuild.d.ts +1 -1
- package/dist/esbuild.js +1 -1
- package/dist/farm.cjs +1 -1
- package/dist/farm.d.cts +1 -1
- package/dist/farm.d.ts +1 -1
- package/dist/farm.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/rolldown.cjs +1 -1
- package/dist/rolldown.d.cts +1 -1
- package/dist/rolldown.d.ts +1 -1
- package/dist/rolldown.js +1 -1
- package/dist/rollup.cjs +1 -1
- package/dist/rollup.d.cts +1 -1
- package/dist/rollup.d.ts +1 -1
- package/dist/rollup.js +1 -1
- package/dist/{src-BFve2-SZ.cjs → src-1TNLOrgN.cjs} +14 -7
- package/dist/{src-CQ91QUqv.js → src-DKq4C5zO.js} +14 -7
- package/dist/vite.cjs +1 -1
- package/dist/vite.d.cts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.js +1 -1
- package/package.json +14 -14
package/dist/core/ast.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import type * as OxcTypes from '@oxc-project/types';
|
|
|
2
2
|
import type MagicString from 'magic-string';
|
|
3
3
|
export type OxcImport = (OxcTypes.ImportDeclaration | OxcTypes.ExportAllDeclaration | OxcTypes.ExportNamedDeclaration) & {
|
|
4
4
|
source: OxcTypes.StringLiteral;
|
|
5
|
-
|
|
5
|
+
suffix?: string;
|
|
6
6
|
};
|
|
7
7
|
export declare function filterImports(program: OxcTypes.Program): OxcImport[];
|
|
8
8
|
export declare function rewriteImports(s: MagicString, imports: OxcImport[], entryMap: Record<string, string> | undefined, inputBase: string, entryFileNames: string, srcFilename: string): string;
|
package/dist/core/ast.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type * as OxcTypes from '@oxc-project/types';
|
|
|
2
2
|
import type MagicString from 'magic-string';
|
|
3
3
|
export type OxcImport = (OxcTypes.ImportDeclaration | OxcTypes.ExportAllDeclaration | OxcTypes.ExportNamedDeclaration) & {
|
|
4
4
|
source: OxcTypes.StringLiteral;
|
|
5
|
-
|
|
5
|
+
suffix?: string;
|
|
6
6
|
};
|
|
7
7
|
export declare function filterImports(program: OxcTypes.Program): OxcImport[];
|
|
8
8
|
export declare function rewriteImports(s: MagicString, imports: OxcImport[], entryMap: Record<string, string> | undefined, inputBase: string, entryFileNames: string, srcFilename: string): string;
|
package/dist/core/utils.d.cts
CHANGED
|
@@ -6,4 +6,4 @@ export declare function resolveEntry(input: string | string[] | Record<string, s
|
|
|
6
6
|
entryMap: Record<string, string> | undefined;
|
|
7
7
|
inputBase: string;
|
|
8
8
|
};
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function guessSuffix(id: string, resolved: string): string;
|
package/dist/core/utils.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ export declare function resolveEntry(input: string | string[] | Record<string, s
|
|
|
6
6
|
entryMap: Record<string, string> | undefined;
|
|
7
7
|
inputBase: string;
|
|
8
8
|
};
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function guessSuffix(id: string, resolved: string): string;
|
package/dist/esbuild.cjs
CHANGED
package/dist/esbuild.d.cts
CHANGED
package/dist/esbuild.d.ts
CHANGED
package/dist/esbuild.js
CHANGED
package/dist/farm.cjs
CHANGED
package/dist/farm.d.cts
CHANGED
package/dist/farm.d.ts
CHANGED
package/dist/farm.js
CHANGED
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
package/dist/rolldown.cjs
CHANGED
package/dist/rolldown.d.cts
CHANGED
package/dist/rolldown.d.ts
CHANGED
package/dist/rolldown.js
CHANGED
package/dist/rollup.cjs
CHANGED
package/dist/rollup.d.cts
CHANGED
package/dist/rollup.d.ts
CHANGED
package/dist/rollup.js
CHANGED
|
@@ -41,9 +41,15 @@ function resolveEntry(input, userInputBase) {
|
|
|
41
41
|
inputBase
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
function endsWithIndex(s) {
|
|
45
|
+
return /(?:^|[/\\])index\..+$/.test(s);
|
|
46
|
+
}
|
|
47
|
+
function guessSuffix(id, resolved) {
|
|
48
|
+
let suffix = "";
|
|
49
|
+
if (!endsWithIndex(id) && endsWithIndex(resolved)) suffix += "/index";
|
|
50
|
+
const ext = node_path.default.extname(resolved).slice(1).replace(/^([cm]?)ts/, (_, $1) => `${$1}js`);
|
|
51
|
+
if (ext) suffix += `.${ext}`;
|
|
52
|
+
return suffix;
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
//#endregion
|
|
@@ -73,12 +79,13 @@ function rewriteImports(s, imports, entryMap, inputBase, entryFileNames, srcFile
|
|
|
73
79
|
const resolved = stripExt(entryFileNames.replaceAll("[name]", importAlias));
|
|
74
80
|
id = pathRelative(srcDirRel, resolved);
|
|
75
81
|
} else id = stripExt(entryFileNames.replaceAll("[name]", srcIdRel));
|
|
76
|
-
const
|
|
77
|
-
if (
|
|
82
|
+
const suffix = i.suffix || guessSuffix(source.value, source.value);
|
|
83
|
+
if (suffix) id += suffix;
|
|
78
84
|
let final = node_path.default.normalize(node_path.default.join(offset, id));
|
|
79
85
|
if (final !== node_path.default.normalize(source.value)) {
|
|
80
86
|
debug$1("Patch import in", srcRel, ":", srcIdRel, "->", final);
|
|
81
87
|
final = final.replaceAll("\\", "/");
|
|
88
|
+
if (final.startsWith("/")) final = `.${final}`;
|
|
82
89
|
if (!/^\.\.?\//.test(final)) final = `./${final}`;
|
|
83
90
|
s.overwrite(i.source.start + 1, i.source.end - 1, final);
|
|
84
91
|
}
|
|
@@ -166,7 +173,7 @@ else {
|
|
|
166
173
|
context.error(errors[0]);
|
|
167
174
|
return;
|
|
168
175
|
}
|
|
169
|
-
const { program } = await (0, oxc_parser.parseAsync)(
|
|
176
|
+
const { program } = await (0, oxc_parser.parseAsync)(id, dts);
|
|
170
177
|
const imports = filterImports(program);
|
|
171
178
|
const s = new magic_string.default(dts);
|
|
172
179
|
if (options.autoAddExts || options.rewriteImports) for (const i of imports) {
|
|
@@ -182,7 +189,7 @@ else {
|
|
|
182
189
|
if (options.autoAddExts && (node_path.default.isAbsolute(value) || value[0] === ".")) {
|
|
183
190
|
const resolved = await resolve(context, value, stripExt(id));
|
|
184
191
|
if (!resolved || resolved.external) continue;
|
|
185
|
-
i.
|
|
192
|
+
i.suffix = guessSuffix(value, resolved.id);
|
|
186
193
|
}
|
|
187
194
|
}
|
|
188
195
|
addOutput(id, {
|
|
@@ -40,9 +40,15 @@ function resolveEntry(input, userInputBase) {
|
|
|
40
40
|
inputBase
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
function endsWithIndex(s) {
|
|
44
|
+
return /(?:^|[/\\])index\..+$/.test(s);
|
|
45
|
+
}
|
|
46
|
+
function guessSuffix(id, resolved) {
|
|
47
|
+
let suffix = "";
|
|
48
|
+
if (!endsWithIndex(id) && endsWithIndex(resolved)) suffix += "/index";
|
|
49
|
+
const ext = path$2.extname(resolved).slice(1).replace(/^([cm]?)ts/, (_, $1) => `${$1}js`);
|
|
50
|
+
if (ext) suffix += `.${ext}`;
|
|
51
|
+
return suffix;
|
|
46
52
|
}
|
|
47
53
|
|
|
48
54
|
//#endregion
|
|
@@ -72,12 +78,13 @@ function rewriteImports(s, imports, entryMap, inputBase, entryFileNames, srcFile
|
|
|
72
78
|
const resolved = stripExt(entryFileNames.replaceAll("[name]", importAlias));
|
|
73
79
|
id = pathRelative(srcDirRel, resolved);
|
|
74
80
|
} else id = stripExt(entryFileNames.replaceAll("[name]", srcIdRel));
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
81
|
+
const suffix = i.suffix || guessSuffix(source.value, source.value);
|
|
82
|
+
if (suffix) id += suffix;
|
|
77
83
|
let final = path$1.normalize(path$1.join(offset, id));
|
|
78
84
|
if (final !== path$1.normalize(source.value)) {
|
|
79
85
|
debug("Patch import in", srcRel, ":", srcIdRel, "->", final);
|
|
80
86
|
final = final.replaceAll("\\", "/");
|
|
87
|
+
if (final.startsWith("/")) final = `.${final}`;
|
|
81
88
|
if (!/^\.\.?\//.test(final)) final = `./${final}`;
|
|
82
89
|
s.overwrite(i.source.start + 1, i.source.end - 1, final);
|
|
83
90
|
}
|
|
@@ -165,7 +172,7 @@ else {
|
|
|
165
172
|
context.error(errors[0]);
|
|
166
173
|
return;
|
|
167
174
|
}
|
|
168
|
-
const { program } = await parseAsync(
|
|
175
|
+
const { program } = await parseAsync(id, dts);
|
|
169
176
|
const imports = filterImports(program);
|
|
170
177
|
const s = new MagicString(dts);
|
|
171
178
|
if (options.autoAddExts || options.rewriteImports) for (const i of imports) {
|
|
@@ -181,7 +188,7 @@ else {
|
|
|
181
188
|
if (options.autoAddExts && (path.isAbsolute(value) || value[0] === ".")) {
|
|
182
189
|
const resolved = await resolve(context, value, stripExt(id));
|
|
183
190
|
if (!resolved || resolved.external) continue;
|
|
184
|
-
i.
|
|
191
|
+
i.suffix = guessSuffix(value, resolved.id);
|
|
185
192
|
}
|
|
186
193
|
}
|
|
187
194
|
addOutput(id, {
|
package/dist/vite.cjs
CHANGED
package/dist/vite.d.cts
CHANGED
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.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
4
|
"description": "A blazing-fast tool for generating isolated declarations.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -89,36 +89,36 @@
|
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
91
|
"@rollup/pluginutils": "^5.1.3",
|
|
92
|
-
"debug": "^4.
|
|
92
|
+
"debug": "^4.4.0",
|
|
93
93
|
"magic-string": "^0.30.14",
|
|
94
|
-
"oxc-parser": "^0.
|
|
95
|
-
"unplugin": "^2.0.0
|
|
94
|
+
"oxc-parser": "^0.39.0",
|
|
95
|
+
"unplugin": "^2.0.0"
|
|
96
96
|
},
|
|
97
97
|
"devDependencies": {
|
|
98
|
-
"@farmfe/core": "^1.4.
|
|
99
|
-
"@oxc-project/types": "^0.
|
|
98
|
+
"@farmfe/core": "^1.4.7",
|
|
99
|
+
"@oxc-project/types": "^0.39.0",
|
|
100
100
|
"@rollup/plugin-alias": "^5.1.1",
|
|
101
|
-
"@swc/core": "^1.
|
|
101
|
+
"@swc/core": "^1.10.0",
|
|
102
102
|
"@sxzz/eslint-config": "^4.5.1",
|
|
103
103
|
"@sxzz/prettier-config": "^2.0.2",
|
|
104
104
|
"@sxzz/test-utils": "^0.3.8",
|
|
105
105
|
"@types/debug": "^4.1.12",
|
|
106
106
|
"@types/node": "^22.10.1",
|
|
107
|
-
"bumpp": "^9.
|
|
107
|
+
"bumpp": "^9.9.0",
|
|
108
108
|
"esbuild": "^0.24.0",
|
|
109
109
|
"eslint": "^9.16.0",
|
|
110
110
|
"fast-glob": "^3.3.2",
|
|
111
|
-
"oxc-transform": "^0.
|
|
112
|
-
"prettier": "^3.4.
|
|
111
|
+
"oxc-transform": "^0.39.0",
|
|
112
|
+
"prettier": "^3.4.2",
|
|
113
113
|
"rolldown": "nightly",
|
|
114
|
-
"rollup": "^4.28.
|
|
114
|
+
"rollup": "^4.28.1",
|
|
115
115
|
"rollup-plugin-esbuild": "^6.1.1",
|
|
116
116
|
"tinyglobby": "^0.2.10",
|
|
117
|
-
"tsdown": "^0.
|
|
117
|
+
"tsdown": "^0.4.4",
|
|
118
118
|
"tsx": "^4.19.2",
|
|
119
119
|
"typescript": "^5.7.2",
|
|
120
|
-
"vite": "^6.0.
|
|
121
|
-
"vitest": "^2.1.
|
|
120
|
+
"vite": "^6.0.3",
|
|
121
|
+
"vitest": "^2.1.8"
|
|
122
122
|
},
|
|
123
123
|
"engines": {
|
|
124
124
|
"node": ">=18.12.0"
|