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

fix: Emit correct sourcemap ranges for JSXText #15233

Merged
merged 1 commit into from Dec 5, 2022
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
@@ -0,0 +1,11 @@
import React from 'react';

export default function App() {
return (
<div className="App">
<h1>Welcome to my application!</h1>
This is my app!
<strong>MINE.</strong>
</div>
)
}
@@ -0,0 +1,5 @@
{
"sourceType": "module",
"plugins": [["transform-react-jsx", { "runtime": "classic" }]],
"sourceMap": true
}
@@ -0,0 +1,6 @@
import React from 'react';
export default function App() {
return /*#__PURE__*/React.createElement("div", {
className: "App"
}, /*#__PURE__*/React.createElement("h1", null, "Welcome to my application!"), "This is my app!", /*#__PURE__*/React.createElement("strong", null, "MINE."));
}
@@ -0,0 +1,14 @@
{
"version": 3,
"names": [
"React",
"App"
],
"sources": [
"sourcemaps/JSXText/input.js"
],
"sourcesContent": [
"import React from 'react';\n\nexport default function App() {\n return (\n <div className=\"App\">\n <h1>Welcome to my application!</h1>\n This is my app!\n <strong>MINE.</strong>\n </div>\n )\n}"
],
"mappings": "AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,eAAe,SAASC,GAAG,GAAG;EAC5B,oBACE;IAAK,SAAS,EAAC;EAAK,gBAClB,gCAAI,4BAA0B,CAAK,mBAEnC,mDAAQ,OAAK,CAAS,CAClB;AAEV"
}
@@ -1,10 +1,9 @@
import { stringLiteral } from "../../builders/generated";
import type * as t from "../..";
import { inherits } from "../..";

export default function cleanJSXElementLiteralChild(
child: {
value: string;
},
child: t.JSXText,
args: Array<t.Node>,
) {
const lines = child.value.split(/\r\n|\n|\r/);
Expand Down Expand Up @@ -48,5 +47,5 @@ export default function cleanJSXElementLiteralChild(
}
}

if (str) args.push(stringLiteral(str));
if (str) args.push(inherits(stringLiteral(str), child));
}