diff --git a/packages/babel-core/src/transformation/file/file.js b/packages/babel-core/src/transformation/file/file.js index 2adb6e7757..1aa6070c73 100644 --- a/packages/babel-core/src/transformation/file/file.js +++ b/packages/babel-core/src/transformation/file/file.js @@ -259,8 +259,6 @@ export default class File { ): Error { let loc = node && (node.loc || node._loc); - msg = `${this.opts.filename ?? "unknown"}: ${msg}`; - if (!loc && node) { const state = { loc: null, diff --git a/packages/babel-core/test/fixtures/plugins/build-code-frame-error/exec.js b/packages/babel-core/test/fixtures/plugins/build-code-frame-error/exec.js index 3462e87a19..0b56fb9bfb 100644 --- a/packages/babel-core/test/fixtures/plugins/build-code-frame-error/exec.js +++ b/packages/babel-core/test/fixtures/plugins/build-code-frame-error/exec.js @@ -1,16 +1,18 @@ -var code = "function f() {}"; -transform(code, { - plugins: [ - function() { - return { - visitor: { - FunctionDeclaration: function(path) { - throw path.buildCodeFrameError("someMsg"); +expect(() => { + var code = "function f() {}"; + transform(code, { + plugins: [ + function() { + return { + visitor: { + FunctionDeclaration: function(path) { + throw path.buildCodeFrameError("someMsg"); + }, }, - }, - }; - }, - ], - // hard to assert on ANSI escape codes - highlightCode: false, -}); + }; + }, + ], + // hard to assert on ANSI escape codes + highlightCode: false, + }); +}).toThrow(/^unknown: someMsg\s+> 1 \| function f\(\) {}/); diff --git a/packages/babel-core/test/fixtures/plugins/build-code-frame-error/options.json b/packages/babel-core/test/fixtures/plugins/build-code-frame-error/options.json deleted file mode 100644 index 96fe5df0c4..0000000000 --- a/packages/babel-core/test/fixtures/plugins/build-code-frame-error/options.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "throws": "unknown: someMsg\n> 1 | function f() {}" -}