Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/repl/src/lib/workers/bundler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,12 @@ async function get_bundle(
}

// importing a file from the same package via pkg.imports
if (importee[0] === '#' && current) {
const subpath = resolve_subpath(current, importee);
return normalize_path(current, subpath.slice(2));
if (importee[0] === '#') {
if (current) {
const subpath = resolve_subpath(current, importee);
return normalize_path(current, subpath.slice(2));
}
return await resolve_local(importee);
}

// importing an external package -> `npm://$/<name>@<version>/<path>`
Expand Down
11 changes: 8 additions & 3 deletions packages/repl/src/lib/workers/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,14 @@ let local_svelte_pkg: Promise<any>;
export async function resolve_local(specifier: string) {
const pkg = await (local_svelte_pkg ??= fetch(LOCAL_PKG_URL).then((r) => r.json()));

const subpath = resolve.exports(pkg, specifier.replace('svelte', '.'), {
browser: true
})![0] as string;
const subpath =
specifier[0] === '#'
? (resolve.imports(pkg, specifier, {
browser: true
})![0] as string)
: (resolve.exports(pkg, specifier.replace('svelte', '.'), {
browser: true
})![0] as string);

return new URL(subpath, LOCAL_PKG_URL).href;
}
Expand Down