diff --git a/CHANGELOG.md b/CHANGELOG.md index 267784b..425c838 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +## [4.2.3-dev.1](https://github.com/qmhc/vite-plugin-dts/compare/v4.2.3-dev.0...v4.2.3-dev.1) (2024-09-30) + ## [4.2.3-dev.0](https://github.com/qmhc/vite-plugin-dts/compare/v4.2.2...v4.2.3-dev.0) (2024-09-30) ### Bug Fixes diff --git a/package.json b/package.json index 13787db..04d8e6c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vite-plugin-dts", - "version": "4.2.3-dev.0", + "version": "4.2.3-dev.1", "type": "module", "packageManager": "pnpm@9.9.0", "license": "MIT", diff --git a/src/transform.ts b/src/transform.ts index ea7445a..fe57a0f 100644 --- a/src/transform.ts +++ b/src/transform.ts @@ -232,12 +232,16 @@ export function transformCode(options: { return false } - if (ts.isModuleDeclaration(node)) { + if (ts.isModuleDeclaration(node) && node.body && ts.isModuleBlock(node.body)) { if ( + ts.isIdentifier(node.name) && + node.name.escapedText === 'global' && + node.body.statements.some(isVLSNode) + ) { + s.remove(node.pos, node.end + 1) + } else if ( node.modifiers?.[0] && node.modifiers[0].kind === ts.SyntaxKind.DeclareKeyword && - node.body && - ts.isModuleBlock(node.body) && !node.body.statements.some( s => ts.isExportAssignment(s) || ts.isExportDeclaration(s) || ts.isImportDeclaration(s) ) @@ -247,19 +251,6 @@ export function transformCode(options: { return false } - - if ( - ts.isModuleDeclaration(node) && - node.body && - ts.isModuleBlock(node.body) && - ts.isIdentifier(node.name) && - node.name.escapedText === 'global' && - node.body.statements.some(isVLSNode) - ) { - s.remove(node.pos, node.end + 1) - - return false - } }) let prependImports = ''