Skip to content

React Project With Custom JSX Factory #832

@n1xx1

Description

@n1xx1

I'm trying to get the css prop of emotion to work correctly, so as far I understood I can use the inject option and then specify the jsxFactory and jsxFragment.

My config looks like this:

require("esbuild")
  .build({
    // ...
    jsxFactory: "__jsx",
    jsxFragment: "__Fragment",
    inject: [path.join(__dirname, "./react-shim.js")],
    // ...
  )}

And the react-shim.js is this:

const {
  jsx: __jsx,
  Fragment: __Fragment,
} = require("@emotion/react/jsx-runtime");

However the in generated code the import names get renamed:

  // scripts/react-shim.js
  var {
    jsx: __jsx2,
    Fragment: __Fragment
  } = require_emotion_react_jsx_runtime_browser_cjs();
  // ....
  var MotionCard = import_react12.memo(import_react12.forwardRef(function MotionCard2({card, onDragEnd}, ref) {
    return /* @__PURE__ */ __jsx(motion.div, {
      css: {width: "10%"},
      ref,
  // ...

Why are the names changed? How can I make it work?

Thank you and great work with the project!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions