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

use with vite-env-only #298

Open
joprice opened this issue May 22, 2024 · 2 comments
Open

use with vite-env-only #298

joprice opened this issue May 22, 2024 · 2 comments

Comments

@joprice
Copy link

joprice commented May 22, 2024

I was attempting to use the vite-env-only plugin with a solid-start template, but found that the use of use server causes the denyFiles configurations to fail to work for transitive dependencies. An example would be client.js -> api.js -> db.js, where api.js has use server directives, and db.js is listed in the denyFiles client array in the vite config.

I'm not familiar with the internals, but since I noticed that the resulting api asset (.vinxi/build/client/_build/assets/api-....js) has the definition of db.js inlined, my guess is that the use server directive is processed first and generates a new module that no longer references db.js, so the vite-env-only plugin is no longer able to detect it the import.

It would be nice to use the vite-env-only plugin to enforce the invariant that secrets or server code do not split into the client bundle, but perhaps that functionality could be provided directly by vinxi.

@doeixd
Copy link
Contributor

doeixd commented Jun 20, 2024

Why not just use: "use server" in the first line of db.js to avoid vinxi and vite-env-only stepping on each other's feet?

@joprice
Copy link
Author

joprice commented Jun 20, 2024

I may have tried that, but I've lost context as I switched off of solid-start for now due to these issues of server code leaking into the client. Overall, I want to enforce at build time that there hasn't been any server code leaked, whether or not use server was used in the correct place. I remember trying a lot of different configurations, and all of them not getting quite what I expected. I can make a repro repo with some examples since I know it's hard to tell what the expected behavior should be and there's a lot of moving targets involved.

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