unplugin-isolated-decl 0.8.1 → 0.8.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/dist/core/ast.d.cts +1 -1
- package/dist/core/ast.d.ts +1 -1
- package/dist/core/utils.d.cts +1 -0
- package/dist/core/utils.d.ts +1 -0
- package/dist/esbuild.cjs +1 -1
- package/dist/esbuild.js +1 -1
- package/dist/farm.cjs +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.js +1 -1
- package/dist/rollup.cjs +1 -1
- package/dist/rollup.js +1 -1
- package/dist/{src-D3Z1XJCx.cjs → src-CUBv8HDT.cjs} +9 -5
- package/dist/{src-BiFhTk02.js → src-DF97Tiay.js} +9 -5
- package/dist/vite.cjs +1 -1
- package/dist/vite.js +1 -1
- package/package.json +1 -1
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
|
+
ext?: 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
|
+
ext?: 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
package/dist/core/utils.d.ts
CHANGED
package/dist/esbuild.cjs
CHANGED
package/dist/esbuild.js
CHANGED
package/dist/farm.cjs
CHANGED
package/dist/farm.js
CHANGED
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
package/dist/rolldown.cjs
CHANGED
package/dist/rolldown.js
CHANGED
package/dist/rollup.cjs
CHANGED
package/dist/rollup.js
CHANGED
|
@@ -64,6 +64,10 @@ function resolveEntry(input) {
|
|
|
64
64
|
inputBase
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
+
function guessExt(filename) {
|
|
68
|
+
const ext = node_path.default.extname(filename).slice(1);
|
|
69
|
+
return ext.replace(/^([cm]?)ts/, (_, $1) => `${$1}js`);
|
|
70
|
+
}
|
|
67
71
|
|
|
68
72
|
//#endregion
|
|
69
73
|
//#region src/core/ast.ts
|
|
@@ -92,9 +96,10 @@ function rewriteImports(s, imports, entryMap, inputBase, entryFileNames, srcFile
|
|
|
92
96
|
const resolved = stripExt(entryFileNames.replaceAll("[name]", importAlias));
|
|
93
97
|
id = pathRelative(srcDirRel, resolved);
|
|
94
98
|
} else id = stripExt(entryFileNames.replaceAll("[name]", srcIdRel));
|
|
95
|
-
|
|
99
|
+
const ext = i.ext || guessExt(source.value);
|
|
100
|
+
if (ext) id += `.${ext}`;
|
|
96
101
|
let final = node_path.default.normalize(node_path.default.join(offset, id));
|
|
97
|
-
if (final !== source.value) {
|
|
102
|
+
if (final !== node_path.default.normalize(source.value)) {
|
|
98
103
|
debug$1("Patch import in", srcRel, ":", srcIdRel, "->", final);
|
|
99
104
|
final = final.replaceAll("\\", "/");
|
|
100
105
|
if (!/^\.\.?\//.test(final)) final = `./${final}`;
|
|
@@ -192,7 +197,7 @@ else {
|
|
|
192
197
|
if (options.autoAddExts && (node_path.default.isAbsolute(value) || value[0] === ".")) {
|
|
193
198
|
const resolved = await resolve(context, value, stripExt(id));
|
|
194
199
|
if (!resolved || resolved.external) continue;
|
|
195
|
-
|
|
200
|
+
i.ext = guessExt(resolved.id);
|
|
196
201
|
}
|
|
197
202
|
}
|
|
198
203
|
addOutput(id, {
|
|
@@ -206,8 +211,7 @@ else {
|
|
|
206
211
|
if (node.type === "ImportDeclaration") return !!node.specifiers && node.specifiers.every((spec) => spec.type === "ImportSpecifier" && spec.importKind === "type");
|
|
207
212
|
return node.type === "ExportNamedDeclaration" && node.specifiers && node.specifiers.every((spec) => spec.exportKind === "type");
|
|
208
213
|
});
|
|
209
|
-
for (const
|
|
210
|
-
const { source } = i;
|
|
214
|
+
for (const { source } of typeImports) {
|
|
211
215
|
const resolved = (await resolve(context, source.value, id))?.id;
|
|
212
216
|
if (resolved && filter(resolved) && !outputFiles[stripExt(resolved)]) {
|
|
213
217
|
let source$1;
|
|
@@ -40,6 +40,10 @@ function resolveEntry(input) {
|
|
|
40
40
|
inputBase
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
+
function guessExt(filename) {
|
|
44
|
+
const ext = path$2.extname(filename).slice(1);
|
|
45
|
+
return ext.replace(/^([cm]?)ts/, (_, $1) => `${$1}js`);
|
|
46
|
+
}
|
|
43
47
|
|
|
44
48
|
//#endregion
|
|
45
49
|
//#region src/core/ast.ts
|
|
@@ -68,9 +72,10 @@ function rewriteImports(s, imports, entryMap, inputBase, entryFileNames, srcFile
|
|
|
68
72
|
const resolved = stripExt(entryFileNames.replaceAll("[name]", importAlias));
|
|
69
73
|
id = pathRelative(srcDirRel, resolved);
|
|
70
74
|
} else id = stripExt(entryFileNames.replaceAll("[name]", srcIdRel));
|
|
71
|
-
|
|
75
|
+
const ext = i.ext || guessExt(source.value);
|
|
76
|
+
if (ext) id += `.${ext}`;
|
|
72
77
|
let final = path$1.normalize(path$1.join(offset, id));
|
|
73
|
-
if (final !== source.value) {
|
|
78
|
+
if (final !== path$1.normalize(source.value)) {
|
|
74
79
|
debug("Patch import in", srcRel, ":", srcIdRel, "->", final);
|
|
75
80
|
final = final.replaceAll("\\", "/");
|
|
76
81
|
if (!/^\.\.?\//.test(final)) final = `./${final}`;
|
|
@@ -168,7 +173,7 @@ else {
|
|
|
168
173
|
if (options.autoAddExts && (path.isAbsolute(value) || value[0] === ".")) {
|
|
169
174
|
const resolved = await resolve(context, value, stripExt(id));
|
|
170
175
|
if (!resolved || resolved.external) continue;
|
|
171
|
-
|
|
176
|
+
i.ext = guessExt(resolved.id);
|
|
172
177
|
}
|
|
173
178
|
}
|
|
174
179
|
addOutput(id, {
|
|
@@ -182,8 +187,7 @@ else {
|
|
|
182
187
|
if (node.type === "ImportDeclaration") return !!node.specifiers && node.specifiers.every((spec) => spec.type === "ImportSpecifier" && spec.importKind === "type");
|
|
183
188
|
return node.type === "ExportNamedDeclaration" && node.specifiers && node.specifiers.every((spec) => spec.exportKind === "type");
|
|
184
189
|
});
|
|
185
|
-
for (const
|
|
186
|
-
const { source } = i;
|
|
190
|
+
for (const { source } of typeImports) {
|
|
187
191
|
const resolved = (await resolve(context, source.value, id))?.id;
|
|
188
192
|
if (resolved && filter(resolved) && !outputFiles[stripExt(resolved)]) {
|
|
189
193
|
let source$1;
|
package/dist/vite.cjs
CHANGED
package/dist/vite.js
CHANGED