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

Import {type Foo} Improperly handled (?) #358

Open
Caesarovich opened this issue Aug 29, 2024 · 3 comments
Open

Import {type Foo} Improperly handled (?) #358

Caesarovich opened this issue Aug 29, 2024 · 3 comments

Comments

@Caesarovich
Copy link

Hi,
This snippet results in Vinxi bundling the db package even if only the types are imported:

import { type Staff, type UserStatus } from 'db/schemas';

This caused me some issues. The 'fix' is to write it this way:

import type { Staff, UserStatus } from 'db/schemas';

Now Vinxi appropriately ignores this package during bundling. I'm unsure if this is a bug or desired because as @Brendonovich mentionned on Discord:

"[this could be because of] ...the assumption there may be side effects you care about"<

If that's intended then this issue might help someone having the same issue as me in the future.

@LexSwed
Copy link

LexSwed commented Sep 1, 2024

It might be fine to keep this behaviour if we had an easy way to scream at the browser when something we really don't want there gets bundled, like server-only, but with use server annotation that is already in place?

@Brendonovich
Copy link
Contributor

Brendonovich commented Sep 1, 2024

@LexSwed you can get the same effect as server-only by adding this in your files

import { isServer } from "solid-js/web";

if(!isServer)
  throw new Error("This module cannot be imported in the browser")

@LexSwed
Copy link

LexSwed commented Sep 1, 2024

That would work, but I mean that I already marked a file as server-only, it should automagically make anything up the dependency tree not includable in the client bundle.

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

3 participants