Skip to content

module render a wrong switch expression #5785

@yuzheng14

Description

@yuzheng14

Rollup Version

4.30.0

Operating System (or Browser)

MacOS 15.1

Node Version (if applicable)

bun 1.1.42 or nodejs 22

Link To Reproduction

https://stackblitz.com/edit/stackblitz-starters-v2eb36zk?file=index.html

Expected Behaviour

Bundle successfully.

Actual Behaviour

It will bundle failed when there is jspdf, because the the switch expression rendered by Module is invalid js expression.

Before the module including jspdf is render by this line, it is a valid switch expression.

const rendered = module.render(renderOptions);

But after this, it will be

switch(R){case 0:casefalse:case"fill":D=0;break;case 1:casetrue:case"stroke":D=1;break;case 2:case"fillThenStroke":D=2;break;case 3:case"invisible":D=3;break;case 4:case"fillAndAddForClipping":D=4;break;case 5:case"strokeAndAddPathForClipping":D=5;break;case 6:case"fillThenStrokeAndAddToPathForClipping":D=6;break;case 7:case"addToPathForClipping":D=7;}

The statement casefalse and casetrue in it is not a valid javascript expression so that it will cause esbuild exit after.

I tried to find out why but here is some knowledge of ast I'm not familliar and I don't have so many time so that I just debug it to here.

By the way, when I user overrides to indicate [email protected] forcely, it will be bundled successfully.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions