-
Notifications
You must be signed in to change notification settings - Fork 71
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 error Could not resolve
TS files without extension (.ts
) from Svelte files
#283
Comments
I have same problem, how did you solve it? |
Switched to SvelteKit and rollup-plugin-ts |
With |
Here's a permalink to OP's old commit that was referenced, as the Looking at the Rollup config, the ordering of Above comment suggests resolving
But it's a great plugin in any case! It was too complicated for me to contribute to in any short time period, so that's why I ended up contributing here a bunch instead over the years. rpt2 is significantly simpler, which has its trade-offs of course. |
Could not resolve
TS files without extension (.ts
) from Svelte files
So I investigated this issue and came up with a handful of different things: clarificationsThe error that OP was receiving wasn't from rpt2, but from Rollup itself. That is, Rollup and none of the plugins were able to resolve the file without extension. workarounds
One can just add This workaround resolves the issue because it means seems like this is caused by a regressionThe root cause is because rpt2 has some very specific code to not resolve anything imported by a file that isn't in the This was a bit of a doozy to track down why this even existed. I eventually traced it to this commit, which was meant to be an optimization / potential bugfix for #162 (which never actually got a response). Can see a deeper investigation in #347 (comment) . Writing up a PR to fix this shortly (EDIT: see #365). In the meantime, until the fix is released, please use the workaround listed above if you're facing this. |
Oh boy this regression really goes back.... #172 (comment) mentions this exact same problem (importing TS files from Svelte files) and the suggested fix was to add That issue / comment is also linked to in a Svelte library's issues pyoner/svelte-typescript#15 (comment), which was subsequently linked to the official Anyway... I've written a PR for this in #365, though it's really quite unfortunate how many regressions came out of #162 and how many years those have lasted for (and the additional confusion, frustration, breakage, etc caused by that) 😕 😕 |
Wow, really forgot about this issue but I'm impressed by the depth of your investigation! Glad you found the root cause and squashed that nasty bug. Big thumbs up 👍. Great work |
What happens and why it is wrong
I am trying to bundle a Svelte project that uses TypeScript and while importing TS files from other TS files works well, importing TS files inside Svelte project requires setting the extension eg
utils.ts
which then causes linting errors. This works in other TS rollup bundlers, like rollup-plugin-ts, but since they have other issues I am hoping this gets fixed so I can keep using this plugin instead.Environment
It's exactly this project https://github.com/TeemuKoivisto/svelte-tree-view/tree/master/core
Versions
Running the command didn't work but I extracted the versions manually.
rollup.config.js
`rollup.config.js`:
tsconfig.json
`tsconfig.json`:
package.json
`package.json`:
plugin output with verbosity 3
plugin output with verbosity 3:
The text was updated successfully, but these errors were encountered: