Closed
Description
- Rollup Plugin Name: plugin-virtual
Feature Use Case
Whenever a virtual script is created .js
is always assumed.
So for example this throws an error:
export default {
entry: 'entry.svelte',
// ...
plugins: [
virtual({
'entry.svelte': `
<script>
const message = "Hello virtual!";
</script>
<h1>{message}</h1>
`
})
]
};
Error:
[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
Feature Proposal
It would be great to be able to produce virtual modules in other languages other than the assumed .js
. This would allow to produce anything from .svelte
components to dynamic .scss
files.
The API wouldn't need to change. The plugin already allows to pass a path with an extension as a module name. The plugin would only need to check the file extension and "tell" Rollup which type of file it is so that Rollup would use the appropriate plugin. Eg: use the Svelte plugin for .svelte
.