New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@rollup/plugin-virtual does not work #1471
Comments
Note: only the null byte needed to be fixed. The |
Sorry for that second non-issue, and thanks for the null byte fix 🙌🏼 Updated @rollup/plugin-virtual to compatible in http://vite-rollup-plugins.patak.dev |
Im trying to use virtual plugin set it in vitejs.dev but i dont know how it have to works, I put that plugin in my vite.config.js function myPlugin() {
const virtualFileId = '@my-virtual-file'
return {
name: 'my-plugin', // required, will show up in warnings and errors
resolveId(id) {
console.log('resolveId', id);
if (id === virtualFileId) {
return virtualFileId
}
},
load(id) {
if (id === virtualFileId) {
return `export const msg = "from virtual file"`
}
}
}
}
export default {
// build: {
// rollupOptions: {
// input: 'entry'
// }
// },
entry: 'src/main.js',
plugins: [
vuePlugin(),
{
enforce: 'pre',
...myPlugin({
batman: `export default 'na na na na na'`,
})
},
]
} Even I tried to set a different input like rollup docs, but does not works Vite version: 2.0.0-beta.30
|
@kasec, given that you commented in this issue, if you are trying to use @rollup/plugin-virtual, there are instructions for it in http://vite-rollup-plugins.patak.dev. There is no need to use enforce pre with it. The page is using this plugin, configured here, and the virtual files are used here. But I see that you are defining your own plugin, following the example in Vite plugin docs. To use that particular example, you need to |
Ok, thank you buddy, I really misunderstood about how to implement it, and yesterday before my comment https://vite-rollup-plugins.patak.dev had not the implementation code in virtual-code. Excellent job! |
Opening this issue as an enhancement following the relabelling of #1428
Is your feature request related to a problem? Please describe.
@rollup/plugin-virtual is currently not working. Checking the implementation, it looks like it may be workable.
I create a repro for this issue starting from the vanilla create app:
https://github.com/matias-capeletto/vite-rollup-plugin-virtual
It is using the example from the plugin docs (batman and robin are from there)
I am also using it with
{ enforce: 'pre', plugin }
so it is applied before the rest of vite core plugins:Additional context
It looks like there are two unrelated issues. Vite doesn't like the
When removing this line, the other virtual file also fails. I think it is related to the prefix used by the plugin
In Dev the error reads:
During build it correctly compiles and runs through.
System Info
vite version: 2.0.0-beta.19
Operating System: Windows 10 Home, 10.0.18363 N/A Build 18363
Node version: v15.5.0
Package manager and version: yarn v1.22.10
The text was updated successfully, but these errors were encountered: