question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Question] Aliasing SvelteKit paths

See original GitHub issue

I’d like to use Svelte component testing feature in order to sort of unit test some ts libraries used across my SvelteKit application. This way I could use Playwright for everything.

The problem I currently stumbled upon is as follows: path import convention $app/stores doesn’t seem to resolve correctly, despite overriding config as suggested here:

...
ctViteConfig: {
	resolve: {
		alias: {
			$app: resolve('playwright/mocks/app')
		}
	}
}

and ./playwright/mocks/app containing stores.ts:

import { readable } from 'svelte/store';

export const page = readable({});

What I’m getting is Error: Cannot find package '$app', and, while $lib and other aliases are resolving correctly, my guess is that $app cannot not be overwritten.

I’ve also tried to move mocks to other directory and resolving with a __dirname with no avail so far. Any ideas?

Issue Analytics

  • State:open
  • Created 9 months ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
pooledgecommented, Dec 15, 2022

Oh, didn’t you ask for a repo, did you? Minimum repro @ GH.

Thanks!

1reaction
yury-scommented, Dec 12, 2022

See this comment https://github.com/microsoft/playwright/issues/16787#issuecomment-1230857867 We may add better support once SvelteKit becomes stable (at least 1.0.0 release is published).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Make Pathing Easier with Aliases in SvelteKit - CodingCat.dev
Out of the box SvelteKit provides a $lib alias setup for the src/lib folder and a number of modules are available from $app...
Read more >
Configuration • Docs • SvelteKit
An object containing zero or more aliases used to replace values in import ... The directory relative to paths.assets where the built JS...
Read more >
How to import enum using path alias in Svelte Kit?
I have an interface that I can export and use without problem through the path alias. Importing an enum throws an error: Cannot...
Read more >
Path aliases don't work in basic svelte-kit app : WEB-55303
Path aliases don't work in basic svelte-kit app · Open the attached project, npm i · Open file: src/lib/header/Header.svelte , try to import...
Read more >
How do I have import file path aliases in svelte? : r/sveltejs
rollup alias is not working like I want it to I need a simple tutorial ... https://stackoverflow.com/questions/43281741/how-to-use-paths-in- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found