Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: properly resolve packages with version #609

Merged
merged 1 commit into from
Oct 24, 2024
Merged
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
6 changes: 3 additions & 3 deletions packages/repl/src/lib/workers/bundler/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,14 @@ async function get_bundle(
// fetch from unpkg
self.postMessage({ type: 'status', uid, message: `resolving ${importee}` });

const match = /^((?:@[^/]+\/)?[^/]+)(\/.+)?$/.exec(importee);
const match = /^((?:@[^/]+\/)?[^/@]+)(?:@([^/]+))?(\/.+)?$/.exec(importee);
if (!match) {
return console.error(`Invalid import "${importee}"`);
}

const pkg_name = match[1];
const subpath = `.${match[2] ?? ''}`;
const version = pkg_name === 'svelte' ? svelte.VERSION : match[2] ?? 'latest';
const subpath = `.${match[3] ?? ''}`;

// if this was imported by one of our files, add it to the `imports` set
if (importer && local_files_lookup.has(importer)) {
Expand All @@ -302,7 +303,6 @@ async function get_bundle(

const fetch_package_info = async () => {
try {
const version = pkg_name === 'svelte' ? svelte.VERSION : 'latest';
const pkg_url = await follow_redirects(
`${packages_url}/${pkg_name}@${version}/package.json`,
uid
Expand Down
Loading