Skip to content
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

Question: What do I need to change to import TS files into a Svelte component? #11

Open
SkepticMystic opened this issue Jan 25, 2022 · 1 comment

Comments

@SkepticMystic
Copy link

Thank you for making this template, it simplifies the process so much!

I have a question that may be simple to solve, or I may be misunderstanding something more fundamental.

I want to import a function from a TS file into the App svelte component from your template. The function uses the Twitter v2 API, so that might be causing an issue.
I use the following code to import the function into App:

<script lang="ts">
  import { getUserDesc } from "../electron/utils/Twitter/twitter";
  export let name: string;
</script>

Where the twitter.ts file looks like so:

import TwitterApi from 'twitter-api-v2';

const twitter = new TwitterApi()

const roClient = twitter.readOnly

export async function getUserDesc(username: string) {
    const user = await roClient.v2.userByUsername(username)
    console.log(user.data.description)
}

When running the code, I get the following error: Error: Unexpected token (Note that you need plugins to import files that are not JavaScript).

Is it that I just need a rollup-plugin? Please let me know if there is something to do differently.

Thank you for reading this :)

@fuzzc0re
Copy link
Owner

Thanks for using the template!

I see that there was an issue here rollup/plugins#287.

I cannot reproduce this on Linux or macos.

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