Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a regression for multiple __self & __source props with classic runtime #12475

Merged
merged 3 commits into from Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -862,18 +862,15 @@ You can set \`throwIfNamespace: false\` to bypass this warning.`,

let props = [];
const objs = [];
const found = Object.create(null);

for (const attr of attribs) {
const name =
t.isJSXAttribute(attr) &&
t.isJSXIdentifier(attr.name) &&
attr.name.name;

if (name === "__source" || name === "__self") {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is part of the code that will be removed in Babel 8 anyway, so I didn't have to provide any extra TODO comments or anything here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I follow: why would this be removed? I think we'll keep the classic runtime, and just make the automatic one the default.

@Andarist explained me on Slack that this is for the !useSpread case, that we are removing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah - this is just in the compat path that handles useSpread and useBuiltIns options. It's OK to still throw this error when one uses automatic runtime.

if (found[name]) throw sourceSelfError(path, name);
found[name] = true;
if (!options.development) continue;
if (!options.development && (name === "__source" || name === "__self")) {
continue;
}

if (useSpread || !t.isJSXSpreadAttribute(attr)) {
Expand Down
@@ -0,0 +1 @@
<div/>
@@ -0,0 +1,3 @@
module.exports = () => ({
presets: [["@babel/preset-react", { development: true }]],
});
@@ -0,0 +1,4 @@
{
"presets": [["@babel/preset-react", { "development": true }], "./my-preset"],
"os": ["linux", "darwin"]
}
@@ -0,0 +1,18 @@
var _jsxFileName = "<CWD>/packages/babel-preset-react/test/fixtures/regression/runtime-classic-allow-multiple-source-self/input.mjs",
_jsxFileName2 = "<CWD>/packages/babel-preset-react/test/fixtures/regression/runtime-classic-allow-multiple-source-self/input.mjs";

/*#__PURE__*/
React.createElement("div", {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 1,
columnNumber: 1
},
__self: this,
__source: {
fileName: _jsxFileName2,
lineNumber: 1,
columnNumber: 1
}
});