Make vite.config.ts
support pure esm modules without setting type: "module"
#6623
Closed
4 tasks done
Labels
Clear and concise description of the problem
In a cjs project (i.e. without
type: 'module'
in package.json), if you import a package written in pure esm invite.config.ts
, it will panic:Since Vite will bundle
vite.config.ts
in cjs format.Suggested solution
Switching to https://github.com/egoist/bundle-require:
It outputs the bundled config as
.mjs
with a random filename (to get rid of import cache) and loaded with dynamic import by default.// Not sure if this would break existing behavior tho.
Alternative
Just adding
type: 'module'
to yourpackage.json
would also fix this.Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: