Skip to content

@svgr/webpack with jsxRuntime: 'classic-preact' emits React namespace usageΒ #1018

@jet2jet

Description

@jet2jet

πŸ› Bug Report

When using jsxRuntime: 'classic-preact' option in @svgr/webpack, emitted module includes React namespace reference which is not defined by default.

To Reproduce

  1. Use @svgr/webpack
  2. Configure webpack.config for .svg file to use @svgr/webpack with jsxRuntime: 'classic-preact':
    rules: [
      {
        test: /\.svg$/i,
        use: {
          loader: '@svgr/webpack',
          options: {
            jsxRuntime: 'classic-preact',
          }
        }
      }
    ]
  1. Build files

Expected behavior

svg modules uses preact-related API only

(Actual behavior: svg modules uses React.createElement instead of preact API)

Link to repl or repo (highly encouraged)

https://github.com/jet2jet/svgr-preact-test

Run npx envinfo --system --binaries --npmPackages @svgr/core,@svgr/cli,@svgr/webpack,@svgr/rollup --markdown --clipboard

Paste the results here:

## System:
 - OS: Linux 6.6 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
 - CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
 - Memory: 5.30 GB / 7.58 GB
 - Container: Yes
 - Shell: 5.1.16 - /bin/bash
## Binaries:
 - Node: 20.19.3 - /home/user/.asdf/installs/nodejs/v20.19.3/bin/node
 - npm: 11.5.1 - /home/user/.asdf/installs/nodejs/v20.19.3/bin/npm
 - pnpm: 8.7.1 - /home/user/.local/share/pnpm/pnpm
## npmPackages:
 - @svgr/core: ^8.1.0 => 8.1.0 
 - @svgr/webpack: ^8.1.0 => 8.1.0 

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