rsbuild icon indicating copy to clipboard operation
rsbuild copied to clipboard

[Bug]: The sideEffects package is not working with namespace import.

Open Fitz6 opened this issue 1 year ago • 4 comments

Version

Browsers:
    Chrome: 126.0.6478.127
    Edge: Chromium (126.0.2592.87)
  npmPackages:
    @rsbuild/core: 1.0.0-alpha.6 => 1.0.0-alpha.6

Details

// test.js
export const doSomething = () => {
  console.log('It works.')
}
window.doSomething = doSomething
// index.js with namespace import
import * as something from './test.js'

window.doSomething() // TypeError: window.doSomething is not a function
// index.js with side effect import
import './test.js'

window.doSomething() // It works.

Reproduce link

https://rsbuild.dev/guide/start/quick-start

Reproduce Steps

  1. execute rsbuild dev
  2. find the error message in the console

Fitz6 avatar Jul 09 '24 16:07 Fitz6