vite-plugin-dts 4.2.2 → 4.2.3-dev.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/dist/index.cjs +18 -2
- package/dist/index.mjs +18 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -525,6 +525,20 @@ function transformAlias(importer, dir, aliases, aliasesExclude) {
|
|
|
525
525
|
}
|
|
526
526
|
return importer;
|
|
527
527
|
}
|
|
528
|
+
function isVLSNode(node) {
|
|
529
|
+
if (ts__default.isVariableStatement(node)) {
|
|
530
|
+
return node.declarationList.declarations.some(
|
|
531
|
+
(d) => ts__default.isIdentifier(d.name) && `${d.name.escapedText}`.startsWith("__VLS_")
|
|
532
|
+
);
|
|
533
|
+
}
|
|
534
|
+
if (ts__default.isTypeAliasDeclaration(node)) {
|
|
535
|
+
return `${node.name.escapedText}`.startsWith("__VLS_");
|
|
536
|
+
}
|
|
537
|
+
if (ts__default.isFunctionDeclaration(node)) {
|
|
538
|
+
return !!node.name && `${node.name.escapedText}`.startsWith("__VLS_");
|
|
539
|
+
}
|
|
540
|
+
return false;
|
|
541
|
+
}
|
|
528
542
|
function transformCode(options) {
|
|
529
543
|
const s = new MagicString__default(options.content);
|
|
530
544
|
const ast = ts__default.createSourceFile("a.ts", options.content, ts__default.ScriptTarget.Latest);
|
|
@@ -603,8 +617,10 @@ function transformCode(options) {
|
|
|
603
617
|
);
|
|
604
618
|
return false;
|
|
605
619
|
}
|
|
606
|
-
if (ts__default.isModuleDeclaration(node)) {
|
|
607
|
-
if (node.
|
|
620
|
+
if (ts__default.isModuleDeclaration(node) && node.body && ts__default.isModuleBlock(node.body)) {
|
|
621
|
+
if (ts__default.isIdentifier(node.name) && node.name.escapedText === "global" && node.body.statements.some(isVLSNode)) {
|
|
622
|
+
s.remove(node.pos, node.end + 1);
|
|
623
|
+
} else if (node.modifiers?.[0] && node.modifiers[0].kind === ts__default.SyntaxKind.DeclareKeyword && !node.body.statements.some(
|
|
608
624
|
(s2) => ts__default.isExportAssignment(s2) || ts__default.isExportDeclaration(s2) || ts__default.isImportDeclaration(s2)
|
|
609
625
|
)) {
|
|
610
626
|
declareModules.push(s.slice(node.pos, node.end + 1));
|
package/dist/index.mjs
CHANGED
|
@@ -521,6 +521,20 @@ function transformAlias(importer, dir, aliases, aliasesExclude) {
|
|
|
521
521
|
}
|
|
522
522
|
return importer;
|
|
523
523
|
}
|
|
524
|
+
function isVLSNode(node) {
|
|
525
|
+
if (ts.isVariableStatement(node)) {
|
|
526
|
+
return node.declarationList.declarations.some(
|
|
527
|
+
(d) => ts.isIdentifier(d.name) && `${d.name.escapedText}`.startsWith("__VLS_")
|
|
528
|
+
);
|
|
529
|
+
}
|
|
530
|
+
if (ts.isTypeAliasDeclaration(node)) {
|
|
531
|
+
return `${node.name.escapedText}`.startsWith("__VLS_");
|
|
532
|
+
}
|
|
533
|
+
if (ts.isFunctionDeclaration(node)) {
|
|
534
|
+
return !!node.name && `${node.name.escapedText}`.startsWith("__VLS_");
|
|
535
|
+
}
|
|
536
|
+
return false;
|
|
537
|
+
}
|
|
524
538
|
function transformCode(options) {
|
|
525
539
|
const s = new MagicString(options.content);
|
|
526
540
|
const ast = ts.createSourceFile("a.ts", options.content, ts.ScriptTarget.Latest);
|
|
@@ -599,8 +613,10 @@ function transformCode(options) {
|
|
|
599
613
|
);
|
|
600
614
|
return false;
|
|
601
615
|
}
|
|
602
|
-
if (ts.isModuleDeclaration(node)) {
|
|
603
|
-
if (node.
|
|
616
|
+
if (ts.isModuleDeclaration(node) && node.body && ts.isModuleBlock(node.body)) {
|
|
617
|
+
if (ts.isIdentifier(node.name) && node.name.escapedText === "global" && node.body.statements.some(isVLSNode)) {
|
|
618
|
+
s.remove(node.pos, node.end + 1);
|
|
619
|
+
} else if (node.modifiers?.[0] && node.modifiers[0].kind === ts.SyntaxKind.DeclareKeyword && !node.body.statements.some(
|
|
604
620
|
(s2) => ts.isExportAssignment(s2) || ts.isExportDeclaration(s2) || ts.isImportDeclaration(s2)
|
|
605
621
|
)) {
|
|
606
622
|
declareModules.push(s.slice(node.pos, node.end + 1));
|