Skip to content

Commit 1fe60f2

Browse files
authored
Strip leading npm: modifier in imports field of deno.json
1 parent 72a6b59 commit 1fe60f2

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

server/build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ func (ctx *BuildContext) buildModule(analyzeMode bool) (meta *BuildMeta, include
477477
}
478478
if ok {
479479
if s, ok := v.(string); ok {
480-
specifier = s
480+
specifier = normalizeImportSpecifier(s)
481481
} else if m, ok := v.(map[string]interface{}); ok {
482482
targets := []string{"browser", "module", "import", "default"}
483483
if ctx.isDenoTarget() {

server/build_resolver.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1225,11 +1225,12 @@ func normalizeSavePath(zoneId string, pathname string) string {
12251225

12261226
// normalizeImportSpecifier normalizes the given specifier.
12271227
func normalizeImportSpecifier(specifier string) string {
1228-
specifier = strings.TrimPrefix(specifier, "npm:")
12291228
if specifier == "." {
12301229
specifier = "./index"
12311230
} else if specifier == ".." {
12321231
specifier = "../index"
1232+
} else {
1233+
specifier = strings.TrimPrefix(specifier, "npm:")
12331234
}
12341235
if nodeBuiltinModules[specifier] {
12351236
return "node:" + specifier

0 commit comments

Comments
 (0)