diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-11-22 20:09:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-22 20:09:30 +0100 |
commit | b70f520ebc59d123c114b76013a233c4250227e6 (patch) | |
tree | 44476e016d44a167d7020a8257098651e5f4d25c /cli/tsc | |
parent | f077c4f248ab96c1ba67dd24d6573cc9f9a0a1ad (diff) |
fix: Make npm packages works with import maps (#16754)
Co-authored-by: David Sherret <dsherret@gmail.com>
Diffstat (limited to 'cli/tsc')
-rw-r--r-- | cli/tsc/00_typescript.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/cli/tsc/00_typescript.js b/cli/tsc/00_typescript.js index 01377c8b5..4f2a0c467 100644 --- a/cli/tsc/00_typescript.js +++ b/cli/tsc/00_typescript.js @@ -90846,7 +90846,7 @@ var ts; if (!text.startsWith("npm:")) { throw new Error("Not an npm specifier: ".concat(text)); } - text = text.replace(/^npm:/, ""); + text = text.replace(/^npm:\/?/, ""); var parts = text.split("/"); var namePartLen = text.startsWith("@") ? 2 : 1; if (parts.length < namePartLen) { @@ -90860,8 +90860,12 @@ var ts; versionReq = lastNamePart.substring(lastAtIndex + 1); nameParts[nameParts.length - 1] = lastNamePart.substring(0, lastAtIndex); } + var name = nameParts.join("/"); + if (name.length === 0) { + throw new Error("Npm specifier did not have a name: ".concat(text)); + } return { - name: nameParts.join("/"), + name: name, versionReq: versionReq, subPath: parts.length > nameParts.length ? parts.slice(nameParts.length).join("/") : undefined, }; |