-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Define customizable protected path to prevent import to client (lib/server/ like) #12477
Comments
If I want to implement this, i guess i should add checks here: kit/packages/kit/src/exports/vite/graph_analysis/index.js Lines 18 to 22 in f3d7a3a
reading the config there and extend the logic? I'd be able to create a PR if you agree to implement this. |
Please elaborate more on the "plugins" and your intended usecase. The naming scheme is kept simple on purpose to allow users to easily recognize server-only paths by looking at the file system path (or list them with find etc). Maybe it's also worth exploring alternatives like an additional vite plugin that enforces your extra rules instead of making it part of sveltekit core. For the time being i would recommend you don't continue working on your PR until this has been discussed and agreed upon. |
edit: see below, doesn't work. |
At the moment you are not able to protect any code from node_modules beside the .server.ts / .server.js.
this doesnt work, since it checks only basename
|
Looks like you two are the same person or working together? Protecting exports from packages in node_modules is out of scope of sveltekit i think.
sveltekit is an application framework, so i'm confused why you are using |
in fact im same person, thats why I deleted and repost. the packages exports won't help. svelte does not care about it, does it? |
Still completely in the dark what kind of plugin you are building. Is this a vite plugin? a sveltekit plugin? a plugin for a custom application architecture on top of sveltekit? just sharing a few possible paths does not give a good picture. this feature would increase the complexity of sveltekit and comes with ongoing maintenance cost so we have to understand it first and agree that it beneficial for sveltekit to have or if there are ways to achieve the goal in userland. |
Its a business application (SaaS) written in sveltekit. It comes with a PluginManager. |
Isn't this already supported following this structure?
|
sure, you have to make sure every name has the .server. naming convention, but this wont help for npm modules which arent svelte exclusive. |
What you described above are plugins for a custom sveltekit application architecture. the import guards by sveltekit won't help outside of sveltekit either so npm modules that want to ensure their code is not used on the client/or want to provide different code for the client are going to have to use exports conditions to do that. |
Yes you are right. I was already thinking off plugins/module gonna distribute a also devs implementing 3rd party modules would need the freedom to manually extend the list, because the implemented module isnt even aware of svelte - like typeorm |
Any chance to get this in some way implemented? I dont see a way to do this with a plugin since SvelteKit doesnt an interface to this part. |
Describe the problem
To implement a plugin system with clean paths, I'd like to define additional pathes in sveltekit to prevent import into clientcode.
Like src/lib/plugins/myplugin/server/*
Also for node_modules shared plugins it would be good
node_modules/my-plugin-package/server/*
Describe the proposed solution
extend sveltekit config
Alternatives considered
No response
Importance
would make my life easier
Additional Information
No response
The text was updated successfully, but these errors were encountered: