mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-10-27 02:27:18 +00:00
refactoring and tests
This commit is contained in:
1 parent
3bb553d6b5
commit
da9abbae5e
45 files changed
+3558
-1564
No files matched your search
@@ -0,0 +1,27 @@
|
||||
// Resolves the virtual modules of SvelteKit to stubs, so that the code that imports them can be
|
||||
// tested outside of the framework.
|
||||
import { fileURLToPath, pathToFileURL } from 'node:url';
|
||||
|
||||
const stubs = {
|
||||
'$app/environment': 'app-environment.ts',
|
||||
'$app/paths': 'app-paths.ts',
|
||||
'$app/state': 'app-state.ts',
|
||||
'$env/static/public': 'env-static-public.ts',
|
||||
};
|
||||
|
||||
export async function resolve(specifier, context, nextResolve) {
|
||||
const stub = stubs[specifier];
|
||||
if (stub) {
|
||||
const url = pathToFileURL(fileURLToPath(new URL(`./stubs/${stub}`, import.meta.url)));
|
||||
return nextResolve(url.href, context);
|
||||
}
|
||||
return nextResolve(specifier, context);
|
||||
}
|
||||
|
||||
// Stylesheets are for the browser: importing one gives nothing.
|
||||
export async function load(url, context, nextLoad) {
|
||||
if (url.endsWith('.css')) {
|
||||
return { format: 'module', source: '', shortCircuit: true };
|
||||
}
|
||||
return nextLoad(url, context);
|
||||
}
|
||||
Reference in new issue
Block a user