Skip to content

Commit c76f9a0

Browse files
dodok8claude
andcommitted
Fix Deno import map generation for npm deps
Fix joinDepsReg to properly handle dependencies that already contain registry prefixes. When a dependency value included a prefix like "npm:elysia@^1.3.6", the function was incorrectly prepending the name again, creating invalid specifiers like "jsr:elysia@npm:elysia@^1.3.6" in deno.json imports. Now checks if version already starts with "npm:" or "jsr:" and uses it as-is, otherwise constructs the spec from name and version. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 6033f71 commit c76f9a0

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

  • packages/cli/src/init/action

packages/cli/src/init/action/deps.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,15 @@ export const joinDepsReg = (pm: PackageManager) => //
127127
pipe(
128128
dependencies,
129129
entries,
130-
map(([name, version]): [string, string] => [
131-
name.substring(4),
132-
`${name}@${getPackageVersion(pm, version)}`,
133-
]),
130+
map(([name, version]): [string, string] => {
131+
const cleanName = name.substring(4);
132+
// If version already contains a registry prefix (npm: or jsr:), use it as-is
133+
// Otherwise, construct the full spec from the name and version
134+
const fullSpec = version.startsWith("npm:") || version.startsWith("jsr:")
135+
? version
136+
: `${name}@${getPackageVersion(pm, version)}`;
137+
return [cleanName, fullSpec];
138+
}),
134139
fromEntries,
135140
);
136141

0 commit comments

Comments
 (0)