sites icon indicating copy to clipboard operation
sites copied to clipboard

Getting `$app` module not found error for component which is using `sveltkit` in REPL

Open thecodejack opened this issue 3 years ago • 7 comments

Can we add support for some of sveltekit internal API especially $app (https://kit.svelte.dev/docs#modules-$app-env) ?

thecodejack avatar Jan 05 '22 14:01 thecodejack

Getting SvelteKit to work in the REPL is its own (quite large) project which we haven't begun to tackle yet, and in the meantime, I don't see much value in implementing various little pieces of it.

Conduitry avatar Jan 05 '22 14:01 Conduitry

I am not saying we need add support sveltekit as a whole. Would prefer to have some of sveltekit modules available. https://kit.svelte.dev/docs#modules

Slowly when third party libs starts supporting sveltekit, they may end up using some of sveltekit modules. So if those modules are available directly in REPL, can be help for the community.

thecodejack avatar Jan 05 '22 14:01 thecodejack

SvelteKit's modules aren't independent in the sense that we can extract parts of it out. They are tightly integrated with the framework, so the most we can do is to shim it, which doesn't feel right. And implementing only parts of it would be confusing. Not to mention that the modules API can have breaking changes, which can break existing REPLs.

bluwy avatar Jan 05 '22 14:01 bluwy

agreed. So what should be right way to handle those? Should there be an exposed node module as a shim?

thecodejack avatar Jan 05 '22 15:01 thecodejack

I think we should just not shim anything and keep the REPL vanilla. I'm not sure if it's worth the effort and instead could open a can of worms.

bluwy avatar Jan 05 '22 15:01 bluwy

yea..not saying to add in REPL. was just thinking out loud if we can have a shim node module which will expose $app as a module available for import. That node module can be imported in REPL code wherever required.

thecodejack avatar Jan 05 '22 16:01 thecodejack

Related SvelteKit issue: https://github.com/sveltejs/kit/issues/1485

benmccann avatar Jan 05 '22 16:01 benmccann