Vite 4.4.10 - iife modules that import certain libraries break at runtime #14537
Closed
7 tasks done
Labels
feat: library mode
p3-minor-bug
An edge case that only affects very specific usage (priority)
regression
The issue only appears after a new release
Describe the bug
Since this commit was introduced as part of 4.4.10, iife modules that import certain libraries started breaking on runtime with exceptions such as:
Uncaught SyntaxError: Illegal return statement (at
In our case, we used the
qs
library - https://www.npmjs.com/package/qs, simply importing them into an IIFE module, and even printing the library contents reproduces the issue.In particular, the issue comes from the following manipulation on the code during build:
I guess that since
qs
compiles with commonjs might be the issue.However, we have been using this library with our IIFE modules for months now, and this issue started popping out, unfortunately on runtime, only since we upgraded to 4.4.10.
Reproduction
https://stackblitz.com/edit/vitejs-vite-su78z8?file=main.js,vite.config.ts,index.ts,index.html,package.json,node_modules%2Fvite%2Fdist%2Fnode%2Fchunks%2Fdep-3bba9c7e.js&terminal=dev
Steps to reproduce
Simply run the project.
To "fix", remove the console.log from
index.ts
System Info
Used Package Manager
yarn
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: