Skip to content

Commit 332dd52

Browse files
authored
Merge branch 'main' into feat-622
2 parents 6fe6f2b + d2a44c9 commit 332dd52

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
@@ -234,9 +234,12 @@ async function get_bundle(
234234
}
235235

236236
// importing a file from the same package via pkg.imports
237-
if (importee[0] === '#' && current) {
238-
const subpath = resolve_subpath(current, importee);
239-
return normalize_path(current, subpath.slice(2));
237+
if (importee[0] === '#') {
238+
if (current) {
239+
const subpath = resolve_subpath(current, importee);
240+
return normalize_path(current, subpath.slice(2));
241+
}
242+
return await resolve_local(importee);
240243
}
241244

242245
// 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
@@ -223,9 +223,14 @@ let local_svelte_pkg: Promise<any>;
223223
export async function resolve_local(specifier: string) {
224224
const pkg = await (local_svelte_pkg ??= fetch(LOCAL_PKG_URL).then((r) => r.json()));
225225

226-
const subpath = resolve.exports(pkg, specifier.replace('svelte', '.'), {
227-
browser: true
228-
})![0] as string;
226+
const subpath =
227+
specifier[0] === '#'
228+
? (resolve.imports(pkg, specifier, {
229+
browser: true
230+
})![0] as string)
231+
: (resolve.exports(pkg, specifier.replace('svelte', '.'), {
232+
browser: true
233+
})![0] as string);
229234

230235
return new URL(subpath, LOCAL_PKG_URL).href;
231236
}

0 commit comments

Comments
 (0)