Skip to content

Commit

Permalink
Update convert-source-map (#15909)
Browse files Browse the repository at this point in the history
Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com>
  • Loading branch information
nicolo-ribaudo and liuxingbaoyu committed Sep 18, 2023
1 parent 4f02d4a commit 4bf5932
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 22 deletions.
2 changes: 1 addition & 1 deletion packages/babel-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"dependencies": {
"@jridgewell/trace-mapping": "^0.3.17",
"commander": "^4.0.1",
"convert-source-map": "^1.1.0",
"convert-source-map": "^2.0.0",
"fs-readdir-recursive": "^1.1.0",
"glob": "^7.2.0",
"make-dir": "condition:BABEL_8_BREAKING ? : ^2.1.0",
Expand Down
1 change: 0 additions & 1 deletion packages/babel-cli/src/babel/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ if (!process.env.BABEL_8_BREAKING) {
// Config params for certain module output formats.
commander.option(
"--module-root [filename]",
// eslint-disable-next-line max-len
"Optional prefix for the AMD module formatter that will be prepended to the filename on module definitions.",
);
commander.option("-M, --module-ids", "Insert an explicit id for modules.");
Expand Down
4 changes: 2 additions & 2 deletions packages/babel-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"@babel/template": "workspace:^",
"@babel/traverse": "workspace:^",
"@babel/types": "workspace:^",
"convert-source-map": "^1.7.0",
"convert-source-map": "^2.0.0",
"debug": "^4.1.0",
"gensync": "^1.0.0-beta.2",
"json5": "^2.2.3",
Expand All @@ -70,7 +70,7 @@
"@babel/preset-env": "workspace:^",
"@babel/preset-typescript": "workspace:^",
"@jridgewell/trace-mapping": "^0.3.17",
"@types/convert-source-map": "^1.5.1",
"@types/convert-source-map": "^2.0.0",
"@types/debug": "^4.1.0",
"@types/gensync": "^1.0.0",
"@types/resolve": "^1.3.2",
Expand Down
1 change: 0 additions & 1 deletion packages/babel-core/src/config/validation/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ function throwUnknownError(loc: OptionPath) {
`Using removed Babel ${version} option: ${msg(loc)} - ${message}`,
);
} else {
// eslint-disable-next-line max-len
const unknownOptErr = new Error(
`Unknown option: ${msg(
loc,
Expand Down
13 changes: 10 additions & 3 deletions packages/babel-core/src/transformation/normalize-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const debug = buildDebug("babel:transform:file");
// These regexps are copied from the convert-source-map package,
// but without // or /* at the beginning of the comment.

// eslint-disable-next-line max-len
const INLINE_SOURCEMAP_REGEX =
/^[@#]\s+sourceMappingURL=data:(?:application|text)\/json;(?:charset[:=]\S+?;)?base64,(?:.*)$/;
const EXTERNAL_SOURCEMAP_REGEX =
Expand Down Expand Up @@ -63,9 +62,17 @@ export default function* normalizeFile(
const lastComment = extractComments(INLINE_SOURCEMAP_REGEX, ast);
if (lastComment) {
try {
inputMap = convertSourceMap.fromComment(lastComment);
inputMap = convertSourceMap.fromComment("//" + lastComment);
} catch (err) {
debug("discarding unknown inline input sourcemap", err);
if (process.env.BABEL_8_BREAKING) {
console.warn(
"discarding unknown inline input sourcemap",
options.filename,
err,
);
} else {
debug("discarding unknown inline input sourcemap");
}
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions packages/babel-core/test/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,15 +605,13 @@ describe("api", function () {
it("source map merging", function () {
const result = transformSync(
[
/* eslint-disable max-len */
'function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }',
"",
"let Foo = function Foo() {",
" _classCallCheck(this, Foo);",
"};",
"",
"//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInN0ZG91dCJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztJQUFNLEdBQUcsWUFBSCxHQUFHO3dCQUFILEdBQUciLCJmaWxlIjoidW5kZWZpbmVkIiwic291cmNlc0NvbnRlbnQiOlsiY2xhc3MgRm9vIHt9XG4iXX0=",
/* eslint-enable max-len */
].join("\n"),
{
sourceMap: true,
Expand Down
1 change: 0 additions & 1 deletion packages/babel-core/test/option-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ describe("option-manager", () => {
blacklist: true,
});
}).toThrow(
// eslint-disable-next-line max-len
/Using removed Babel 5 option: .auxiliaryComment - Use `auxiliaryCommentBefore` or `auxiliaryCommentAfter`/,
);
});
Expand Down
2 changes: 0 additions & 2 deletions packages/babel-parser/src/util/identifier.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint max-len: 0 */

import * as charCodes from "charcodes";
import { isIdentifierStart } from "@babel/helper-validator-identifier";

Expand Down
2 changes: 0 additions & 2 deletions packages/babel-standalone/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
* plugins, instead explicitly registering all the available plugins and
* presets, and requiring custom ones to be registered through `registerPlugin`
* and `registerPreset` respectively.
* @flow
*/

/* global VERSION */
/* eslint-disable max-len */
/// <reference lib="dom" />

import {
Expand Down
14 changes: 7 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ __metadata:
"@types/glob": ^7.2.0
chokidar: ^3.4.0
commander: ^4.0.1
convert-source-map: ^1.1.0
convert-source-map: ^2.0.0
fs-readdir-recursive: ^1.1.0
glob: ^7.2.0
make-dir: "condition:BABEL_8_BREAKING ? : ^2.1.0"
Expand Down Expand Up @@ -415,12 +415,12 @@ __metadata:
"@babel/traverse": "workspace:^"
"@babel/types": "workspace:^"
"@jridgewell/trace-mapping": ^0.3.17
"@types/convert-source-map": ^1.5.1
"@types/convert-source-map": ^2.0.0
"@types/debug": ^4.1.0
"@types/gensync": ^1.0.0
"@types/resolve": ^1.3.2
"@types/semver": ^5.4.0
convert-source-map: ^1.7.0
convert-source-map: ^2.0.0
debug: ^4.1.0
gensync: ^1.0.0-beta.2
json5: ^2.2.3
Expand Down Expand Up @@ -5088,10 +5088,10 @@ __metadata:
languageName: node
linkType: hard

"@types/convert-source-map@npm:^1.5.1":
version: 1.5.1
resolution: "@types/convert-source-map@npm:1.5.1"
checksum: f201025a8078a0f80172a7b0b93253368ab00603aa656ac093d79257b7b78dca0b7b011bc3d19d20b1275e7ba0dea76528f6873b528338f44c34dda221fa58d9
"@types/convert-source-map@npm:^2.0.0":
version: 2.0.0
resolution: "@types/convert-source-map@npm:2.0.0"
checksum: 012497f7495d67204950eeebe10e94b7ab3508bf8659214ad430b527514e0611260d3ac41c47b88212b9de55aa7a9ee18b2fad2d03eb16234b66101150f74017
languageName: node
linkType: hard

Expand Down

0 comments on commit 4bf5932

Please sign in to comment.