Skip to content

Aliases #58

@Rich-Harris

Description

@Rich-Harris

Snowpack doesn't let you use the src/node_modules trick, so we have to use aliases if we're to avoid ../.../../../ hell.

At present in the config there's a $components alias that maps to src/components. We need something that maps to runtime functions like goto etc (which don't live in a package Snowpack can install because they rely on the generated manifest), because at present the way to do it is gross:

import { goto, prefetch, prefetchRoutes, stores } from '/_app/main/client.js';

There's lots wrong with this — importing from an 'internal' URL like /_app is ugly, the main (to differentiate it from the other generated paths, like the /_app/components that $components aliases to) is awkward, and client.js is inaccurate since stores can be instantiated on the server.

Here's what I propose instead:

import { goto, prefetch, prefetchRoutes } from '$app/navigation';
import { getStores } from '$app/stores';

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions