Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
liuxingbaoyu committed Jul 20, 2022
1 parent 017b6da commit 938f922
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/babel-cli/src/babel/file.ts
@@ -1,6 +1,5 @@
import convertSourceMap from "convert-source-map";
import { AnyMap, encodedMap } from "@jridgewell/trace-mapping";
import type { Section } from "@jridgewell/trace-mapping/dist/types/types";
import slash from "slash";
import path from "path";
import fs from "fs";
Expand All @@ -9,9 +8,17 @@ import * as util from "./util";
import type { CmdOptions } from "./options";
import * as watcher from "./watcher";

import type {
SectionedSourceMap,
SourceMapInput,
TraceMap,
} from "@jridgewell/trace-mapping";

type Section = SectionedSourceMap["sections"][0];

type CompilationOutput = {
code: string;
map: any;
map: SourceMapInput;
};

export default async function ({
Expand Down Expand Up @@ -90,7 +97,10 @@ export default async function ({
if (babelOptions.sourceMaps && babelOptions.sourceMaps !== "inline") {
const mapLoc = cliOptions.outFile + ".map";
result.code = util.addSourceMappingUrl(result.code, mapLoc);
fs.writeFileSync(mapLoc, JSON.stringify(encodedMap(result.map)));
fs.writeFileSync(
mapLoc,
JSON.stringify(encodedMap(result.map as TraceMap)),
);
}

fs.writeFileSync(cliOptions.outFile, result.code);
Expand Down

0 comments on commit 938f922

Please sign in to comment.