Skip to content

Unable to import TS file from Svelte file #15

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

Closed
tomasbonco opened this issue Oct 5, 2019 · 2 comments
Closed

Unable to import TS file from Svelte file #15

tomasbonco opened this issue Oct 5, 2019 · 2 comments

Comments

@tomasbonco
Copy link

Describe the bug
The path of .ts dependency can't be resolved by .svelte file.

To Reproduce
Steps to reproduce the behavior:

  1. Create a store.ts file, with content:
import { writable } from 'svelte/store'
export const something = writable( 10 )
  1. In App.svelte add following line:
import {something} from './store'

And you'll get:

[!] Error: Could not resolve './store' from src\App.svelte
Error: Could not resolve './store' from src\App.svelte
    at error (d:\node\bug-repro\node_modules\rollup\dist\rollup.js:10162:30)
    at ModuleLoader.handleMissingImports (d:\node\bug-repro\node_modules\rollup\dist\rollup.js:17237:17)
    at ModuleLoader.<anonymous> (d:\node\bug-repro\node_modules\rollup\dist\rollup.js:17288:26)
    at Generator.next (<anonymous>)
    at fulfilled (d:\node\bug-repro\node_modules\rollup\dist\rollup.js:40:28)
    at <anonymous>

Expected behavior
Everything should be awesome, no errors reported.

Additional context
During filling of this bug I found out that import {something} from './store.ts' does work, but throws error into console:

src/App.svelte:4:27 - error TS2691: An import path cannot end with a '.ts' extension. Consider importing './store' instead.
@tomasbonco
Copy link
Author

Even thou ignoring the error and using import .. from './store.ts' might look like a solution, there is an issue. Reference of store.ts imported in main.ts is different than the one imported inside App.svelte (each of them creates its own store). It makes the whole concept useless.

@pyoner
Copy link
Owner

pyoner commented Oct 8, 2019

@tomasbonco
The problem in rollup-plugin-typescript2 ezolenko/rollup-plugin-typescript2#172
To quick fix I recommend downgrading the rollup-plugin-typescript2 to version "0.21.0"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants