Skip to content

[Bug]: @rsbuild/plugin-svgr implementing ?raw query uncorrectly #4976

@tiny-ant

Description

@tiny-ant

Version

System:
    OS: Linux 5.4 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
    CPU: (32) x64 AMD EPYC 9Y24 96-Core Processor
    Memory: 37.57 GB / 61.56 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  npmPackages:
    @rsbuild/core: ^1.3.1 => 1.3.1 
    @rsbuild/plugin-less: ^1.1.1 => 1.2.1 
    @rsbuild/plugin-react: ^1.1.1 => 1.1.1 
    @rsbuild/plugin-svgr: ^1.1.0 => 1.1.0

Details

Hi @chenjiahan , This is a reopened issue coresponding to #4936 , I just updated to the latest version of svgr plugin and found that nothing changed to my demo result here: https://github.com/tiny-ant/rsbuild-issues.

Adding some options like following is still going wrong:

    pluginSvgr({
      // mixedImport: true,
      exclude: /\?raw/,
    })

one more thing, some build error throws if I open the mixedImport flag:

error   Build error: 
File: /cloudide/workspace/rsbuild-issues/common/assets/symbols.svg?raw:1:1
  × Module build failed:
  ╰─▶   × Error: Unexpected end of input (0:0). If this is valid SVG, it's probably a bug in svg-parser. Please raise an issue at https://github.com/Rich-Harris/svg-parser/issues – thanks!

There may be some processes handled by svg-parser that are not intercepted. I can only disable this plugin for now, in which case .svg?raw works fine.

Reproduce link

https://github.com/tiny-ant/rsbuild-issues

Reproduce Steps

  1. pnpm install
  2. pnpm run dev

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions