Skip to content

Inconsistent Dependency Optimization Behavior Between esbuild and rolldown #374

@sxzz

Description

@sxzz

Describe the bug

esbuild transforms const and let to var, whereas rolldown does not. This can lead to TDZ errors and incompatibility with vite-plugin-node-polyfills.

Image
// input
const global = globalThis || self;
export { global as default, global };
// esbuild
var global = globalThis || self;
export {
  global as default,
  global
};
// rolldown
//#region index.ts
const global = globalThis || self;

//#endregion
export { global as default, global };

Reproduction

https://bundler.sxzz.dev/#eNpFjEEKwzAMBL8idDZ9gEN/0WMvTiy3ASEVS6EBx3+vCw29zSzLNCwYG66Sab+4fVkw/j3gMnRRMYcH65wYrj+4PVeD4wAjLtNdaH9pdWjnLRlkKmljD+fUp9EjjF436j3gPNJVmbO+BfsHu98vNw==

Steps to reproduce

Try esbuild and rolldown on the reproduction

System Info

N/A

Used Package Manager

pnpm

Logs

No response

Validations

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions