Skip to content

Commit d2a44c9

Browse files
fix: resolve imports for local version (#1318)
1 parent 923674d commit d2a44c9

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

packages/repl/src/lib/workers/bundler/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,12 @@ async function get_bundle(
219219
}
220220

221221
// importing a file from the same package via pkg.imports
222-
if (importee[0] === '#' && current) {
223-
const subpath = resolve_subpath(current, importee);
224-
return normalize_path(current, subpath.slice(2));
222+
if (importee[0] === '#') {
223+
if (current) {
224+
const subpath = resolve_subpath(current, importee);
225+
return normalize_path(current, subpath.slice(2));
226+
}
227+
return await resolve_local(importee);
225228
}
226229

227230
// importing an external package -> `npm://$/<name>@<version>/<path>`

packages/repl/src/lib/workers/npm.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,14 @@ let local_svelte_pkg: Promise<any>;
219219
export async function resolve_local(specifier: string) {
220220
const pkg = await (local_svelte_pkg ??= fetch(LOCAL_PKG_URL).then((r) => r.json()));
221221

222-
const subpath = resolve.exports(pkg, specifier.replace('svelte', '.'), {
223-
browser: true
224-
})![0] as string;
222+
const subpath =
223+
specifier[0] === '#'
224+
? (resolve.imports(pkg, specifier, {
225+
browser: true
226+
})![0] as string)
227+
: (resolve.exports(pkg, specifier.replace('svelte', '.'), {
228+
browser: true
229+
})![0] as string);
225230

226231
return new URL(subpath, LOCAL_PKG_URL).href;
227232
}

0 commit comments

Comments
 (0)