Svgr: Can't make @svgr/rollup work with Preact?

Created on 5 Dec 2019  路  1Comment  路  Source: gregberge/svgr

馃挰 Questions and Help

I am trying to add SVG support to a Preact project. Here is my minimal rollup config:

{
  plugins: [
    alias({
      resolve: extensions,
      entries: {
        react: path.resolve("./node_modules/preact/compat/src/index.js")
      }
    }),
    svgr({ babel: false }),
    resolve({
      extensions
    }),
    babel({
      extensions,
      babelrc: false,
      presets: ["@babel/env", ["@babel/typescript", { jsxPragma: "h" }]],
      plugins: [
        [
          "@babel/plugin-transform-react-jsx",
          {
            pragma: "h",
            pragmaFrag: "Fragment"
          }
        ]
      ]
    })
  ]
}

Everything works good, except the h function which is added by this plugin is literally outputted as h in the bundle file. but the other h functions are converted to h$1, then I got this Uncaught ReferenceError: h is not defined error only for SVGs.

Could anyone give me a clue to solve this issue? Thanks!

>All comments

Hello @P233, Preact support is not a goal for now. If the Preact community want to help and make it possible, then its welcome. Until that I am sorry but I will not give support about Preact.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

runeh picture runeh  路  4Comments

Kosai106 picture Kosai106  路  4Comments

rj-coding picture rj-coding  路  5Comments

gregberge picture gregberge  路  6Comments

lm93547 picture lm93547  路  3Comments