Skip to content

Commit

Permalink
Move from source-map to source-map-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
7rulnik committed Feb 14, 2021
1 parent 759a82a commit 4e888d5
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/babel-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"lodash": "^4.17.19",
"make-dir": "^2.1.0",
"slash": "condition:BABEL_8_BREAKING ? ^3.0.0 : ^2.0.0",
"source-map": "^0.5.0"
"source-map-sync": "^0.8.0-beta.1"
},
"optionalDependencies": {
"@nicolo-ribaudo/chokidar-2": "condition:BABEL_8_BREAKING ? : 2.1.8-no-fsevents",
Expand Down
3 changes: 2 additions & 1 deletion packages/babel-cli/src/babel/file.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow

import convertSourceMap from "convert-source-map";
import sourceMap from "source-map";
import sourceMap from "source-map-sync";
import slash from "slash";
import path from "path";
import fs from "fs";
Expand Down Expand Up @@ -65,6 +65,7 @@ export default async function ({
}
});

consumer.destroy();
offset = code.split("\n").length - 1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"json5": "^2.1.2",
"lodash": "^4.17.19",
"semver": "^5.4.1",
"source-map": "^0.5.0"
"source-map-sync": "^0.8.0-beta.1"
},
"devDependencies": {
"@babel/helper-transform-fixture-test-runner": "workspace:*"
Expand Down
4 changes: 3 additions & 1 deletion packages/babel-core/src/transformation/file/merge-map.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow

import typeof { SourceMap } from "convert-source-map";
import sourceMap from "source-map";
import sourceMap from "source-map-sync";

export default function mergeSourceMap(
inputMap: SourceMap,
Expand Down Expand Up @@ -261,6 +261,8 @@ function buildMappingData(map: SourceMap): ResolvedMappings {
sourceMap.SourceMapConsumer.ORIGINAL_ORDER,
);

consumer.destroy();

return {
file: map.file,
sourceRoot: map.sourceRoot,
Expand Down
4 changes: 3 additions & 1 deletion packages/babel-core/test/api.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as babel from "../lib/index";
import sourceMap from "source-map";
import sourceMap from "source-map-sync";
import path from "path";
import Plugin from "../lib/config/plugin";
import generator from "@babel/generator";
Expand Down Expand Up @@ -541,6 +541,8 @@ describe("api", function () {
line: 1,
column: 6,
});

consumer.destroy();
});

it("default source map filename", function () {
Expand Down
5 changes: 2 additions & 3 deletions packages/babel-generator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@
"dependencies": {
"@babel/types": "workspace:^7.12.13",
"jsesc": "condition: BABEL_8_BREAKING ? ^3.0.2 : ^2.5.1",
"source-map": "^0.5.0"
"source-map-sync": "^0.8.0-beta.1"
},
"devDependencies": {
"@babel/helper-fixtures": "workspace:*",
"@babel/parser": "workspace:*",
"@types/jsesc": "^2.5.0",
"@types/lodash": "^4.14.150",
"@types/source-map": "^0.5.0"
"@types/lodash": "^4.14.150"
}
}
2 changes: 1 addition & 1 deletion packages/babel-generator/src/source-map.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sourceMap from "source-map";
import sourceMap from "source-map-sync";

/**
* Build a sourcemap.
Expand Down
6 changes: 5 additions & 1 deletion packages/babel-generator/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as t from "@babel/types";
import fs from "fs";
import path from "path";
import fixtures from "@babel/helper-fixtures";
import sourcemap from "source-map";
import sourcemap from "source-map-sync";

describe("generation", function () {
it("completeness", function () {
Expand Down Expand Up @@ -297,6 +297,8 @@ describe("generation", function () {
column: 0,
line: 2,
});

consumer.destroy();
});

it("newline in string literal", () => {
Expand All @@ -318,6 +320,8 @@ describe("generation", function () {
column: 0,
line: 2,
});

consumer.destroy();
});

it("lazy source map generation", function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"lodash": "^4.17.19",
"quick-lru": "5.1.0",
"regenerator-runtime": "^0.13.7",
"source-map": "^0.5.0"
"source-map-sync": "^0.8.0-beta.1"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
default as getFixtures,
resolveOptionPluginOrPreset,
} from "@babel/helper-fixtures";
import sourceMap from "source-map";
import sourceMap from "source-map-sync";
import { codeFrameColumns } from "@babel/code-frame";
import * as helpers from "./helpers";
import merge from "lodash/merge";
Expand Down Expand Up @@ -297,6 +297,8 @@ function run(task) {
const expected = consumer.originalPositionFor(mapping.generated);
expect({ line: expected.line, column: expected.column }).toEqual(actual);
});

consumer.destroy();
}

if (execCode && resultExec) {
Expand Down
52 changes: 40 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ __metadata:
make-dir: ^2.1.0
rimraf: ^3.0.0
slash: "condition:BABEL_8_BREAKING ? ^3.0.0 : ^2.0.0"
source-map: ^0.5.0
source-map-sync: ^0.8.0-beta.1
peerDependencies:
"@babel/core": ^7.0.0-0
dependenciesMeta:
Expand Down Expand Up @@ -145,7 +145,7 @@ __metadata:
json5: ^2.1.2
lodash: ^4.17.19
semver: ^5.4.1
source-map: ^0.5.0
source-map-sync: ^0.8.0-beta.1
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -255,9 +255,8 @@ __metadata:
"@babel/types": "workspace:^7.12.13"
"@types/jsesc": ^2.5.0
"@types/lodash": ^4.14.150
"@types/source-map": ^0.5.0
jsesc: "condition: BABEL_8_BREAKING ? ^3.0.2 : ^2.5.1"
source-map: ^0.5.0
source-map-sync: ^0.8.0-beta.1
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -770,7 +769,7 @@ __metadata:
lodash: ^4.17.19
quick-lru: 5.1.0
regenerator-runtime: ^0.13.7
source-map: ^0.5.0
source-map-sync: ^0.8.0-beta.1
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -3976,13 +3975,6 @@ __metadata:
languageName: node
linkType: hard

"@types/source-map@npm:^0.5.0":
version: 0.5.2
resolution: "@types/source-map@npm:0.5.2"
checksum: 228e1ef7c7f9c126cf38afdef2c3ccfb1224523c3692da6148abb9bb81095269645495773e94477e8512e1f652419b471cc8c30997f6bd222185e931f6d97acc
languageName: node
linkType: hard

"@types/stack-utils@npm:^2.0.0":
version: 2.0.0
resolution: "@types/stack-utils@npm:2.0.0"
Expand Down Expand Up @@ -12123,6 +12115,15 @@ fsevents@^1.2.7:
languageName: node
linkType: hard

"source-map-sync@npm:^0.8.0-beta.1":
version: 0.8.0-beta.1
resolution: "source-map-sync@npm:0.8.0-beta.1"
dependencies:
whatwg-url: ^7.0.0
checksum: a45bf3b3075404b80794a890f43addd75d0eb1d7c2694f6d9c60284e5942945d051e66b13de6a7f13be5e99ca8b0b775ec334aff347a8a02cd21afc8b08268c2
languageName: node
linkType: hard

"source-map-url@npm:^0.4.0":
version: 0.4.0
resolution: "source-map-url@npm:0.4.0"
Expand Down Expand Up @@ -12821,6 +12822,15 @@ fsevents@^1.2.7:
languageName: node
linkType: hard

"tr46@npm:^1.0.1":
version: 1.0.1
resolution: "tr46@npm:1.0.1"
dependencies:
punycode: ^2.1.0
checksum: 66e2e4d6799d3c2fcc56ad6084e8ab7b3e744f138babc86100e5e2bfaf011231d00d229cfccfaf338da953b96c3ea9128d182274915c1516c5189ee75b7c0ad9
languageName: node
linkType: hard

"tr46@npm:^2.0.2":
version: 2.0.2
resolution: "tr46@npm:2.0.2"
Expand Down Expand Up @@ -13347,6 +13357,13 @@ typescript@^4.1.3:
languageName: node
linkType: hard

"webidl-conversions@npm:^4.0.2":
version: 4.0.2
resolution: "webidl-conversions@npm:4.0.2"
checksum: 75c2ada4262cda41410ec898178f4f2a31419a905415a98a0bd1b93441ce4a2b942bae2d0ac6d637b749b9d3b309be5a49dbc3b06aae9d9e65280554268a2c94
languageName: node
linkType: hard

"webidl-conversions@npm:^5.0.0":
version: 5.0.0
resolution: "webidl-conversions@npm:5.0.0"
Expand Down Expand Up @@ -13377,6 +13394,17 @@ typescript@^4.1.3:
languageName: node
linkType: hard

"whatwg-url@npm:^7.0.0":
version: 7.1.0
resolution: "whatwg-url@npm:7.1.0"
dependencies:
lodash.sortby: ^4.7.0
tr46: ^1.0.1
webidl-conversions: ^4.0.2
checksum: ccbf75d3dfa6d97a7705acc250a43041dfcfa0c9695a5148cac844c39a29657d7c07b3c4533ebabb2401fedcd5eb98626256add2760403b0889c9983ea1a76aa
languageName: node
linkType: hard

"whatwg-url@npm:^8.0.0":
version: 8.4.0
resolution: "whatwg-url@npm:8.4.0"
Expand Down

0 comments on commit 4e888d5

Please sign in to comment.