Fixed issue with skipping over self & source generated by another instance (#12495)

This commit is contained in:
Mateusz Burzyński 2020-12-12 17:39:25 +01:00 committed by GitHub
parent fc82169b4e
commit 01ab1e3e7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 10 deletions

View File

@ -837,7 +837,6 @@ You can set \`throwIfNamespace: false\` to bypass this warning.`,
if (name === "__source" || name === "__self") { if (name === "__source" || name === "__self") {
if (found[name]) throw sourceSelfError(path, name); if (found[name]) throw sourceSelfError(path, name);
found[name] = true; found[name] = true;
if (!options.development) continue;
} }
props.push(convertAttribute(attr)); props.push(convertAttribute(attr));
@ -850,15 +849,6 @@ You can set \`throwIfNamespace: false\` to bypass this warning.`,
const objs = []; const objs = [];
for (const attr of attribs) { for (const attr of attribs) {
const name =
t.isJSXAttribute(attr) &&
t.isJSXIdentifier(attr.name) &&
attr.name.name;
if (!options.development && (name === "__source" || name === "__self")) {
continue;
}
if (useSpread || !t.isJSXSpreadAttribute(attr)) { if (useSpread || !t.isJSXSpreadAttribute(attr)) {
props.push(convertAttribute(attr)); props.push(convertAttribute(attr));
} else { } else {

View File

@ -0,0 +1,3 @@
module.exports = () => ({
plugins: [["@babel/plugin-transform-react-jsx", { pragma: "___EmotionJSX" }]],
});

View File

@ -0,0 +1,5 @@
import * as React from "react";
export default function Foo() {
return <div />;
}

View File

@ -0,0 +1,7 @@
{
"presets": [
["@babel/preset-react", { "development": true }],
"./emotion-css-prop-preset.js"
],
"os": ["linux", "darwin"]
}

View File

@ -0,0 +1,12 @@
var _jsxFileName = "<CWD>/packages/babel-preset-react/test/fixtures/regression/another-preset-with-custom-jsx-keep-source-self/input.mjs";
import * as React from "react";
export default function Foo() {
return ___EmotionJSX("div", {
__self: this,
__source: {
fileName: _jsxFileName,
lineNumber: 4,
columnNumber: 10
}
});
}