diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index ab86a91..9f0b51b 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,11 @@ # @swc/cli +## 0.3.14 + +### Patch Changes + +- fe87a42: Fix dts support + ## 0.3.13 ### Patch Changes diff --git a/packages/cli/package.json b/packages/cli/package.json index 376269e..ed434bc 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@swc/cli", - "version": "0.3.13", + "version": "0.3.14", "description": "CLI for the swc project", "main": "lib/swc/index.js", "scripts": { @@ -56,7 +56,7 @@ "source-map": "^0.7.3" }, "devDependencies": { - "@swc/cli": "=0.3.12", + "@swc/cli": "=0.3.13", "@swc/core": "^1.6.4", "@swc/jest": "workspace:^", "@swc/types": "^0.1.9", diff --git a/packages/cli/src/swc/compile.ts b/packages/cli/src/swc/compile.ts index cb8d93c..7b162c8 100644 --- a/packages/cli/src/swc/compile.ts +++ b/packages/cli/src/swc/compile.ts @@ -12,9 +12,28 @@ function withSourceMap( destFile: string, destDir: string ) { + let dts: string | undefined; + + // TODO: Remove once fixed in core + if ((output as any).output) { + const json = JSON.parse((output as any).output); + + if (json.__swc_isolated_declarations__) { + dts = json.__swc_isolated_declarations__; + } + } + + let dtsPath: string | undefined; + + if (dts) { + dtsPath = join(destDir, basename(destFile) + ".d.ts"); + } + if (!output.map || options.sourceMaps === "inline") { return { sourceCode: output.code, + dts, + dtsPath, }; } // TODO: remove once fixed in core https://github.com/swc-project/swc/issues/1388 @@ -32,23 +51,6 @@ function withSourceMap( relative(destDir, sourceMapPath) )}`; - let dts: string | undefined; - - // TODO: Remove once fixed in core - if ((output as any).output) { - const json = JSON.parse((output as any).output); - - if (json.__swc_isolated_declarations__) { - dts = json.__swc_isolated_declarations__; - } - } - - let dtsPath: string | undefined; - - if (dts) { - dtsPath = join(destDir, basename(destFile) + ".d.ts"); - } - return { sourceMap: output.map, sourceMapPath, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 459c36e..46a70fa 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -64,8 +64,8 @@ importers: version: 0.7.4 devDependencies: '@swc/cli': - specifier: '=0.3.12' - version: 0.3.12(@swc/core@1.6.4)(chokidar@3.5.1) + specifier: '=0.3.13' + version: 0.3.13(@swc/core@1.6.4)(chokidar@3.5.1) '@swc/core': specifier: ^1.6.4 version: 1.6.4 @@ -2301,8 +2301,8 @@ packages: '@sinonjs/commons': 1.8.6 dev: true - /@swc/cli@0.3.12(@swc/core@1.6.4)(chokidar@3.5.1): - resolution: {integrity: sha512-h7bvxT+4+UDrLWJLFHt6V+vNAcUNii2G4aGSSotKz1ECEk4MyEh5CWxmeSscwuz5K3i+4DWTgm4+4EyMCQKn+g==} + /@swc/cli@0.3.13(@swc/core@1.6.4)(chokidar@3.5.1): + resolution: {integrity: sha512-vkgeAT6yb25+ZQXrAKYpv0ZHQRkhua/XsCJ/ksDz0Rx4W5h2Icq2qQVMtu10wvRd1al6mbot2HrJrpZsHqNyPA==} engines: {node: '>= 16.14.0'} hasBin: true peerDependencies: