esbuild icon indicating copy to clipboard operation
esbuild copied to clipboard

Incorrect source mapping pointing to a `return` token after minification

Open Andarist opened this issue 9 months ago • 1 comments

Code:

import { jsx } from "react/jsx-runtime";
import React from "react";
export function App() {
  const ref = React.useRef(null);
  React.useEffect(() => {
    console.log("ReplayAnalyze");
  }, []);
  return /* @__PURE__ */ jsx("div", { ref, children: "." });
}

Options:

--minify --sourcemap

Online repl: here

Visualized:

Image

I believe React shouldn't point to the return token here - despite that expression being inlined into the return statement after minification. This leads to weird sourcemapping issues, see my original report about this in the Vite's repo here: https://github.com/vitejs/vite/issues/19819

Andarist avatar May 10 '25 18:05 Andarist

You're saying what you think shouldn't happen, but you haven't said what you think should happen. What would you like for esbuild to do here? What's the mapping that makes Chrome Developer Tools do what you want it to?

evanw avatar May 11 '25 02:05 evanw

Closing this due to lack of a follow-up reply.

evanw avatar Jul 06 '25 23:07 evanw