Closed EdgardLevy closed 3 years ago
Did you see the Usage section of the readme?
Also from the readme:
It assumes that your Typescript code has already been transpiled before being rolled up (if that's not the case, you should probably use rollup-plugin-typescript).
Can you be more specific with your question? In what context are you trying to use it? Is something not working?
Hi there!
I think that his question was: how to use it in a real-world example alongside the typescript
plugin. It would be nice to have that in the documentation or even better an example
folder with a real world test case.
@aminnairi it's been a long time since I used this, so I don't recall how to set it up. I also used it in a framework where everything regarding rollup and typescript was already set up, so it just worked. If you have an example, can you please share some details here and I'll add it to the readme.
It seems like https://github.com/rollup/plugins/tree/master/packages/typescript supports this already. I thought I would need this for paths, but it actually created an error, and after removing it I realized everything already worked!
@mizzao did you see the second sentence of the readme (which I already quoted in my first comment)?
It assumes that your Typescript code has already been transpiled before being rolled up (if that's not the case, you should probably use rollup-plugin-typescript).
This plugin is for specific use cases where the TS transpilation happens before you're using rollup. Lets say your build script looks like this: tsc && rollup
, and you have some paths set in your tsconfig:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@utils": ["path/to/utils"]
}
}
}
tsc
will know how to resolve import "@utils"
but it won't rewrite the import, i. e. in the transpiled JS file it'll still say @utils
.
Now you run rollup
to bundle up your code, and it sees the @utils
import, however it has no idea how to resolve it because it's not aware of the TS path mapping. Therefore this plugin, which will tell rollup
how to resolve those imports.
Now if you use rollup-plugin-typescript
, you won't transpile your code before running rollup
, which is why this plugin won't work.
Seeing how many people are trying to use this in combination with rollup-plugin-typescript
even though the readme states that's not how to use it, i'll see that I clarify that section.
Hello, how to use this module?