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

Importing a .js typescript resource from a typescript file fails in a worker #9882

Closed
7 tasks done
Avocher opened this issue Aug 28, 2022 · 0 comments · Fixed by #10273
Closed
7 tasks done

Importing a .js typescript resource from a typescript file fails in a worker #9882

Avocher opened this issue Aug 28, 2022 · 0 comments · Fixed by #10273
Labels
feat: web workers p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@Avocher
Copy link

Avocher commented Aug 28, 2022

Describe the bug

This is the same issue that I reported previously #3040 but in a worker context. In an essence, Vite doesn't resolve typescript files if they are imported with a .js extension as following:

hello.ts

export const sayHello = () => console.log('Hello');

worker.ts

import { sayHello } from "./hello.js";

I tried my previous workaround:

import { defineConfig } from 'vite'
import resolve from '@rollup/plugin-node-resolve'

export default defineConfig({
    worker: {
        plugins: [resolve({
            extensions: ['.js', '.ts']
        })]
    }
})

but it didn't work this time.

Reproduction

https://stackblitz.com/edit/vitejs-vite-ftdhm1?file=index.html,main.ts&terminal=dev

System Info

System:
    OS: macOS 12.5.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 192.39 MB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.7.0 - /opt/homebrew/bin/node
    Yarn: 1.22.17 - /opt/homebrew/bin/yarn
    npm: 8.15.0 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 104.0.5112.101
    Safari: 15.6.1

Used Package Manager

pnpm

Logs

No response

Validations

@sapphi-red sapphi-red added p3-minor-bug An edge case that only affects very specific usage (priority) feat: web workers labels Aug 29, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Oct 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: web workers p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants