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

Could not resolve .js import from ts svelte component #323

Closed
shir0u opened this issue May 4, 2022 · 1 comment · Fixed by #324
Closed

Could not resolve .js import from ts svelte component #323

shir0u opened this issue May 4, 2022 · 1 comment · Fixed by #324
Labels
bug Something isn't working

Comments

@shir0u
Copy link

shir0u commented May 4, 2022

Describe the bug

When type: module is used in package.json, the specification says that any import should have an extension. Following convention, if we add .js import for a typescript file, it is not able to resolve.

Reproduction

<script lang="ts">
import foo from './some-typescript-file.js';
console.log(foo);
</script>

This works with a regular .ts file, but not a svelte file using ts context.

Logs

Errors:

Could not resolve './some-typescript-file.js' from App.svelte


### System Info

```shell
System:
    OS: macOS 10.15.7
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 48.13 GB / 64.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node
    Yarn: 1.22.18 - /usr/local/bin/yarn
    npm: 8.5.5 - ~/.nvm/versions/node/v16.15.0/bin/npm
  Browsers:
    Chrome: 100.0.4896.127
    Firefox: 98.0.2
    Safari: 15.4
  npmPackages:
    @sveltejs/vite-plugin-svelte: 1.0.0-next.42 => 1.0.0-next.42 
    svelte: 3.48.0 => 3.48.0 
    vite-system:  2.9.6

Severity

blocking all usage of vite-plugin-svelte

@shir0u shir0u added bug Something isn't working triage Awaiting triage by a project member labels May 4, 2022
@bluwy
Copy link
Member

bluwy commented May 4, 2022

Was just looking at this yesterday: vitejs/vite#7998. Got a fix for Vue but will port the fix here too once that's merged.

@bluwy bluwy removed the triage Awaiting triage by a project member label May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants