From 938f92292281ee6270a677be3ef011c90c4be4a2 Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Wed, 20 Jul 2022 11:29:07 +0800 Subject: [PATCH] review --- packages/babel-cli/src/babel/file.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/babel-cli/src/babel/file.ts b/packages/babel-cli/src/babel/file.ts index b039dcebef8f..9e604b6c0912 100644 --- a/packages/babel-cli/src/babel/file.ts +++ b/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"; @@ -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 ({ @@ -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);