unjs / unplugin

Unified plugin system for Vite, Rollup, Webpack, esbuild, Rolldown, and more
https://unplugin.unjs.io
MIT License
3.09k stars 114 forks source link

fix: undetermistic module type for virtual module #411

Closed ahabhgk closed 2 months ago

ahabhgk commented 2 months ago

https://github.com/unjs/unplugin/commit/ab51c6f9ef8822db2d3e87434f470183c760958c causes a bug about virtual module support in rspack, related https://github.com/web-infra-dev/rspack/issues/7787

Since dist/rspack/vitual.js (the placeholder module for the virtual module) is published with the unplugin package, so unplugin/package.json#type will affect the moduleType of virtual module:

Actually in rollup, it does not make such detailed distinctions for javascript, all javascript will be treated as "javascript/auto", which means all virtual modules is "javascript/auto", so this PR explicitly add type: "javascript/auto" for virtual modules

pkg-pr-new[bot] commented 2 months ago

Open in Stackblitz

pnpm add https://pkg.pr.new/unjs/unplugin@411

commit: 4d206fd