Skip to content

Shim SvelteKit runtime import aliases / Importing $app/* fails #1485

@madeleineostoja

Description

@madeleineostoja

Describe the bug
As far as I can tell there's no way to use sveltekit runtime imports (eg: $app/navigation) outside of sveltekit dev/build. Which makes testing virtually impossible. If there is a way to shim these imports outside of the main sveltekit context I haven't found it, so perhaps documentation is needed.

My particular use-case is with Storybook, where UI components that rely on any sveltekit modules break the whole setup. I tried aliasing them with webpack (pointing to .svelte-kit/dev/...) but that didn't work either.

Another use-case is publishing components for sveltekit that would need to rely on those imports.

To Reproduce

  1. Setup storybook with Sveltekit
  2. Create a component that imports a runtime module (eg: $app/env)
  3. Run storybook and see if fail (cannot resolve module $app/env)

Severity
Not blocking, but makes building a component library with Storybook or other development/testing frameworks impossible. So, severe annoyance?

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature / enhancementNew feature or requestp1-importantSvelteKit cannot be used by a large number of people, basic functionality is missing, etc.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions