- Rollup Plugin Name: virtual
- Rollup Plugin Version: 3.0.2
- Rollup Version: 4.11.0
- Link to reproduction:
const bundle = await rollup({
input: "virtual_main.js",
plugins: [
virtual({ "virtual_main.js": "console.log(1);" }),
strip()
],
});
Expected Behavior
strip() runs on the code passed.
Actual Behavior
This looks like very legitimate code (rollup will output the content of virtual_main eventually). But strip() (or SWC, Terser, Babel, or any other plugin that relies on CreateFilter) will be silently ignored, because virtual appends a \x00virtual: prefix to all files, that then always returns false on CreateFilter.
See also bug #749.
Additional Information
As the previous bug suggests, removing the \x00 on CreateFilter may cause regressions, as well as removing it from virtual (although I'd assume it's a much more reasonable change). If both those ideas are bad, then could I suggest allowing a prefix option to virtual, that allows folks to change this?
virtual seems to be the only official way to support rollup being called with a string (instead of a file), and it's completely broken as is. Without regressing anything, adding a prefix option to virtual and having some documentation that calls out that any filter that has include/exclude doesn't work with the default option sounds better.
Expected Behavior
strip()runs on the code passed.Actual Behavior
This looks like very legitimate code (rollup will output the content of virtual_main eventually). But
strip()(or SWC, Terser, Babel, or any other plugin that relies on CreateFilter) will be silently ignored, becausevirtualappends a\x00virtual:prefix to all files, that then always returns false on CreateFilter.See also bug #749.
Additional Information
As the previous bug suggests, removing the
\x00on CreateFilter may cause regressions, as well as removing it from virtual (although I'd assume it's a much more reasonable change). If both those ideas are bad, then could I suggest allowing a prefix option to virtual, that allows folks to change this?virtualseems to be the only official way to support rollup being called with a string (instead of a file), and it's completely broken as is. Without regressing anything, adding a prefix option to virtual and having some documentation that calls out that any filter that has include/exclude doesn't work with the default option sounds better.