Skip to content

[Bug]: Bundle analyze includes assets as parts of JS chunks #6749

@andrzej-early

Description

@andrzej-early

Version

System:
    OS: Linux 6.14 Ubuntu 24.04.3 LTS 24.04.3 LTS (Noble Numbat)
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H
    Memory: 30.24 GB / 62.47 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Browsers:
    Chrome: 142.0.7444.175
    Firefox: 145.0.2
    Firefox Developer Edition: 145.0.2
  npmPackages:
    @rsbuild/core: ~1.6.14 => 1.6.14 
    @rsbuild/plugin-react: ~1.4.2 => 1.4.2 
    @rsbuild/plugin-sass: ~1.4.0 => 1.4.0 
    @rsbuild/plugin-type-check: ~1.3.2 => 1.3.2

Details

I'm running analyzer with BUNDLE_ANALYZE=true. It includes assets as a part of JS chunks, even though these assets are just pathnames to files located in separate directory. See reproduction steps below.

Reproduce link

Reproduce Steps

A basic configuration:

import { defineConfig } from '@rsbuild/core'
import { pluginReact } from '@rsbuild/plugin-react'

export default defineConfig({
  source: { entry: { main: require.resolve(`${__dirname}/index.tsx`) } },
  plugins: [pluginReact()],
})

index.tsx:

import { createRoot } from 'react-dom/client'
import image from './assets/christmas-tree.gif'

createRoot(document.getElementById('root')!).render(<img src={image} alt='' />)

I'm building my app with a flag BUNDLE_ANALYZE=true yarn rsbuild build -c rsbuild.config.mts, and it produces correct output with the GIF asset in a separate file:

File (web)                                      Size       Gzip   
dist/main.html                                  0.35 kB    0.24 kB
dist/static/js/main.23b79125.js                 1.1 kB     0.71 kB
dist/favicon.ico                                15.1 kB 
dist/static/image/christmas-tree.54b83204.gif   60.0 kB 
dist/static/js/lib-react.ea104dc4.js            140.0 kB   45.0 kB

There's only let i=t.p+"static/image/christmas-tree.54b83204.gif" in the .js file. Yet, report-web.html shows that this GIF file is a part of main chunk:

Image

When I look into my archive with output produced by Webpack, it clearly shows correct size of the assets in my chunk:

Image

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions