Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Jun 22, 2024
1 parent bf04342 commit 87862ab
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions packages/cli/src/swc/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit 87862ab

Please sign in to comment.