-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
move kit runtime, expose via $app alias #75
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
Conversation
|
Added something new. Having to do this, or its Sapper equivalent... import { getStores } from '$app/stores';
const { page, preloading, session } = getStores();...has always been a nuisance. The reason we have to do it is that stores are necessarily contextual, so that you don't get the same store as someone else hitting the same server, potentially leaking information. But it occurs to me that you could expose facade stores... import { page, preloading, session } from '$app/stores';...that 'link' to the real ones as soon as you subscribe. The only constraint is that you do in fact subscribe, and that you do so when context is discoverable (i.e. during component initialisation), but that covers 99% of cases, because Svelte subscribes automatically when it sees this: The We can't safely Now I'm wondering if there's a smart way to make your own custom stores that have similar behaviour to |
|
If the import of the runtime code does not start with We can of course point to an ambient type definition in a It might be possible to auto-generate the typings and then search-and-replace the module names (or maybe there is a plugin of some kind that does this transformation). |
|
I'm going to merge this anyway, as changing the aliases is a single line whereas this PR is really more about the code organisation. We have other problems with aliases anyway: This happens because TypeScript doesn't understand that "compilerOptions": {
// ...
"baseUrl": ".",
"paths": {
"$components/*": ["./src/components/*"],
"$app/*": [".svelte/main/runtime/*"]
}
},...but I don't think my brain has the necessary wiring to configure a TypeScript project. My understanding was that solving this sort of thing (and the |
|
Yeah, the TS configuration is driving my slightly crazy too. The I suspect the error you get is because for whatever reason you don't have these typings that I have in |
|
Let's continue this in #82 |


Ref #58. Adds a
$appalias for importing stuff specific to your app:Currently involves a bit of a funky workaround for FredKSchott/snowpack#1395.