- Rollup Plugin Name: @rollup/plugin-typescript
- Rollup Plugin Version: ^5.0.2
Expected Behavior / Situation
Take an example config as followed, (also available in this reproducible link: https://repl.it/repls/FocusedAptOutsourcing#rollup.config.js):
import typescript from '@rollup/plugin-typescript';
import resolve from '@rollup/plugin-node-resolve';
export default [
// this physically present typescript file works fine, as expected
{
input: "src/main.ts",
plugins: [
resolve(),
typescript()
]
},
// this virtually loaded file doesn't work
{
input: "src/virtual.ts",
plugins: [
{
resolveId(source) {
if (source == "src/virtual.ts") return source;
return null;
},
load(id) {
if (id == "src/virtual.ts") return virtualContent;
return null;
}
},
resolve(),
typescript()
]
},
]
var virtualContent = `
interface IType {
name: string;
}
export function hello(t: IType) {
console.log(t.name);
}
`
I would assume since the custom plugin loaded the module, the typescript plugin would just transform the module without any problem.
Actual Behavior / Situation
The second config would have an error
[!] Error: The keyword 'interface' is reserved (Note that you need plugins to import files that are not JavaScript)
Modification Proposal
I believe this is because the typescript plugin is using load hook to transform the module (which I am a bit confused the reasoning).
Maybe I missed something behind, but I do think the transform hook is a better place for compiling typescript modules.
Expected Behavior / Situation
Take an example config as followed, (also available in this reproducible link: https://repl.it/repls/FocusedAptOutsourcing#rollup.config.js):
I would assume since the custom plugin loaded the module, the typescript plugin would just transform the module without any problem.
Actual Behavior / Situation
The second config would have an error
[!] Error: The keyword 'interface' is reserved (Note that you need plugins to import files that are not JavaScript)Modification Proposal
I believe this is because the typescript plugin is using
loadhook to transform the module (which I am a bit confused the reasoning).Maybe I missed something behind, but I do think the
transformhook is a better place for compiling typescript modules.