Issue 1:
Bug Report

Input Code

const path = require('path');
const {transformSync} = require('@babel/core');

transformSync('', {
filename: path.resolve('filename.js'),
plugins: [
() => ({
visitor: {
Program(path) {
throw path.buildCodeFrameError('example error');
}
}
})
]
});

Expected behavior/code

The first line of error.message should be /path/to/filename.js: example error

Current Behavior

The first line of error.message is /path/to/filename.js: /path/to/filename.js: example error

Babel Configuration (.babelrc, package.json, cli command)

None / see code.

Environment

Babel version(s): 7.6.3

Node/npm version: node 8+

OS: all

Monorepo: no

How you are using Babel: API

Possible Solution

Since packages/babel-core/src/transformation/index.js now prepends the error with the message maybe path.buildCodeFrameError should not do the same.

Additional context/Screenshots

Introduced by #10511. CC @JLHwung

Issue 2:
Bug Report

I would like to work on a fix!

Current behavior

https://unpkg.com/@babel/runtime@7.13.2/helpers/createSuper/_index.mjs

import getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import isNativeReflectConstruct from "@babel/runtime/helpers/isNativeReflectConstruct";
import possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
export default function _createSuper(Derived) {
var hasNativeReflectConstruct = isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = getPrototypeOf(Derived),
result;

if (hasNativeReflectConstruct) {
var NewTarget = getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}

return possibleConstructorReturn(this, result);
};
}

Expected behavior

Should it be?

```js
- import getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
- import isNativeReflectConstruct from "@babel/runtime/helpers/isNativeReflectConstruct";
- import possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
+ import getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
+ import isNativeReflectConstruct from "@babel/runtime/helpers/esm/isNativeReflectConstruct";
+ import possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
export default function _createSuper(Derived) {
var hasNativeReflectConstruct = isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = getPrototypeOf(Derived),
result;

if (hasNativeReflectConstruct) {
var NewTarget = getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}

return possibleConstructorReturn(this, result);
};
}

like: https://unpkg.com/browse/@babel/runtime@7.12.0/helpers/esm/createSuper.js

Environment

System:
OS: macOS 10.15.7
Binaries:
Node: 15.3.0 - ~/.nvm/versions/node/v15.3.0/bin/node
Yarn: 1.22.10 - ~/.nvm/versions/node/v15.3.0/bin/yarn
npm: 7.0.14 - ~/.nvm/versions/node/v15.3.0/bin/npm
npmPackages:
@babel/runtime: ^7.12.5 => 7.13.2
babel-plugin-add-react-displayname: ^0.0.5 => 0.0.5
eslint: ^7.9.0 => 7.20.0
eslint-plugin-babel: ^5.3.0 => 5.3.1
jest: ^26.0.0 => 26.6.3

Babel version(s): 7.13.3

Node/npm version: 15.3.0

OS: [e.g. macOS 10.15.4, Windows 10]

Monorepo: [e.g. yes/no/Lerna]

How you are using Babel: [e.g. webpack, rollup, parcel, babel-register]

Possible Solution

Additional context