Skip to content

Commit

Permalink
fix: properly resolve packages with version (#609)
Browse files Browse the repository at this point in the history
adjusts the regex for this
Fixes #605
  • Loading branch information
dummdidumm authored Oct 24, 2024
1 parent 32c4d26 commit fcbeaae
Showing 1 changed file with 3 additions and 3 deletions.
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

0 comments on commit fcbeaae

Please sign in to comment.