Skip to content

TypeError: Unknown file extension ".svelte" when testing component using shared package with indirect bits-ui dependency #430

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

Open
LeoDoby opened this issue Apr 18, 2025 · 1 comment

Comments

@LeoDoby
Copy link

LeoDoby commented Apr 18, 2025

Hello, I'm encountering the following error when running tests in project1 for a component that imports another component from a local shared package (package/):

TypeError: Unknown file extension ".svelte" for C:\Users\user\WebstormProjects\project1\node_modules\bits-ui\dist\bits\utilities\portal\portal.svelte
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:219:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:245:36)
    at defaultLoad (node:internal/modules/esm/load:120:22)
    at ModuleLoader.loadAndTranslate (node:internal/modules/esm/loader:514:32)
/
│
├── package/
│   └── my-shared-component/       # Uses bits-ui internally
│       └── CardWrapper.svelte     # This uses bits-ui components
│
├── project1/
│   └── src/routes/page.svelte     # Imports CardWrapper from package/ (work perfectly)
│   └── tests/page.test.ts         # Crashes here
│
└── bits-ui/ (installed in package/, NOT in project1/)
@mcous
Copy link
Collaborator

mcous commented Apr 18, 2025

Hi @LeoDoby, this seems like some sort of misconfiguration issue with your monorepo. I can't tell what tools you're using, but a good first step would be to make sure all your package.json files properly spec their internal workspace dependencies, since it seems like whatever Svelte compiler toolchain you're using isn't picking up that bits-ui needs to be compiled.

Are you able to share a complete, minimal repository showing the issue?

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