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:
type: "commonjs" => moduleType: "javascript/dynamic" (current behavior, which will cause an error when rspack parsing any virtual module with esm syntax)
type: "module" => moduleType: "javascript/esm"
unspecified => moduleType: "javascript/auto"
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
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, sounplugin/package.json#type
will affect the moduleType of virtual module:type: "commonjs" => moduleType: "javascript/dynamic"
(current behavior, which will cause an error when rspack parsing any virtual module with esm syntax)type: "module" => moduleType: "javascript/esm"
unspecified => moduleType: "javascript/auto"
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 addtype: "javascript/auto"
for virtual modules