refactor: use deno_graph for npm specifiers (#17858)

This changes npm specifiers to be handled by deno_graph and resolved to
an npm package name and version when the specifier is encountered. It
also slightly changes how npm specifier resolution occurs—previously it
would collect all the npm specifiers and resolve them all at once, but
now it resolves them on the fly as they are encountered in the module
graph.

https://github.com/denoland/deno_graph/pull/232

---------

Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
David Sherret 2023-02-22 14:15:25 -05:00 committed by GitHub
parent 0f9daaeacb
commit a6ca4d0d61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
55 changed files with 1340 additions and 1731 deletions

View file

@ -1,4 +1,2 @@
error: Error getting response at http://localhost:4545/npm/registry/chalk for package "chalk"
Caused by:
An npm specifier not found in cache: "chalk", --cached-only is specified.
error: Error getting response at http://localhost:4545/npm/registry/chalk for package "chalk": An npm specifier not found in cache: "chalk", --cached-only is specified.
at file:///[WILDCARD]/testdata/npm/cached_only/main.ts:1:19

View file

@ -1,5 +1,7 @@
Download http://localhost:4545/npm/registry/chai
Download http://localhost:4545/npm/registry/chalk
Download http://localhost:4545/npm/registry/chai
Download http://localhost:4545/npm/registry/ansi-styles
Download http://localhost:4545/npm/registry/supports-color
Download http://localhost:4545/npm/registry/assertion-error
Download http://localhost:4545/npm/registry/check-error
Download http://localhost:4545/npm/registry/deep-eql
@ -7,8 +9,6 @@ Download http://localhost:4545/npm/registry/get-func-name
Download http://localhost:4545/npm/registry/loupe
Download http://localhost:4545/npm/registry/pathval
Download http://localhost:4545/npm/registry/type-detect
Download http://localhost:4545/npm/registry/ansi-styles
Download http://localhost:4545/npm/registry/supports-color
Download http://localhost:4545/npm/registry/color-convert
Download http://localhost:4545/npm/registry/has-flag
Download http://localhost:4545/npm/registry/color-name

View file

@ -4,19 +4,19 @@ dependencies: 14 unique
size: [WILDCARD]
file:///[WILDCARD]/npm/cjs_with_deps/main.js ([WILDCARD])
├─┬ npm:chai@4.3 - 4.3.6 ([WILDCARD])
│ ├── npm:assertion-error@1.1.0 ([WILDCARD])
├── npm:check-error@1.0.2 ([WILDCARD])
├─┬ npm:deep-eql@3.0.1 ([WILDCARD])
│ └── npm:type-detect@4.0.8 ([WILDCARD])
├── npm:get-func-name@2.0.0 ([WILDCARD])
│ ├─┬ npm:loupe@2.3.4 ([WILDCARD])
│ │ └── npm:get-func-name@2.0.0 ([WILDCARD])
│ ├── npm:pathval@1.1.1 ([WILDCARD])
│ └── npm:type-detect@4.0.8 ([WILDCARD])
└─┬ npm:chalk@4 - 4.1.2 ([WILDCARD])
├─┬ npm:ansi-styles@4.3.0 ([WILDCARD])
│ └─┬ npm:color-convert@2.0.1 ([WILDCARD])
└── npm:color-name@1.1.4 ([WILDCARD])
└─┬ npm:supports-color@7.2.0 ([WILDCARD])
└── npm:has-flag@4.0.0 ([WILDCARD])
├─┬ npm:chalk@4.1.2 ([WILDCARD])
│ ├─┬ npm:ansi-styles@4.3.0 ([WILDCARD])
│ └─┬ npm:color-convert@2.0.1 ([WILDCARD])
│ └── npm:color-name@1.1.4 ([WILDCARD])
└─┬ npm:supports-color@7.2.0 ([WILDCARD])
└── npm:has-flag@4.0.0 ([WILDCARD])
└─┬ npm:chai@4.3.6 ([WILDCARD])
├── npm:assertion-error@1.1.0 ([WILDCARD])
├── npm:check-error@1.0.2 ([WILDCARD])
├─┬ npm:deep-eql@3.0.1 ([WILDCARD])
│ └── npm:type-detect@4.0.8 ([WILDCARD])
├── npm:get-func-name@2.0.0 ([WILDCARD])
├─┬ npm:loupe@2.3.4 ([WILDCARD])
└── npm:get-func-name@2.0.0 ([WILDCARD])
├── npm:pathval@1.1.1 ([WILDCARD])
└── npm:type-detect@4.0.8 ([WILDCARD])

View file

@ -4,24 +4,8 @@
],
"modules": [
{
"kind": "esm",
"dependencies": [
{
"specifier": "npm:chai@4.3",
"code": {
"specifier": "npm:chai@4.3",
"span": {
"start": {
"line": 1,
"character": 23
},
"end": {
"line": 1,
"character": 37
}
}
},
"npmPackage": "chai@4.3.6"
},
{
"specifier": "npm:chalk@4",
"code": {
@ -38,9 +22,25 @@
}
},
"npmPackage": "chalk@4.1.2"
},
{
"specifier": "npm:chai@4.3",
"code": {
"specifier": "npm:chai@4.3",
"span": {
"start": {
"line": 1,
"character": 23
},
"end": {
"line": 1,
"character": 37
}
}
},
"npmPackage": "chai@4.3.6"
}
],
"kind": "esm",
"local": "[WILDCARD]main.js",
"emit": null,
"map": null,
@ -49,7 +49,10 @@
"specifier": "[WILDCARD]/main.js"
}
],
"redirects": {},
"redirects": {
"npm:chai@4.3": "npm:chai@4.3.6",
"npm:chalk@4": "npm:chalk@4.1.2"
},
"npmPackages": {
"ansi-styles@4.3.0": {
"name": "ansi-styles",

View file

@ -1,5 +1,5 @@
Download http://localhost:4545/npm/registry/@denotest/globals
Download http://localhost:4545/npm/registry/@types/node
Download http://localhost:4545/npm/registry/@denotest/globals
Download http://localhost:4545/npm/registry/@denotest/globals/1.0.0.tgz
Download http://localhost:4545/npm/registry/@types/node/node-18.8.2.tgz
Check file:///[WILDCARD]/npm/compare_globals/main.ts

View file

@ -1,5 +1,5 @@
Download http://localhost:4545/npm/registry/@denotest/dual-cjs-esm
Download http://localhost:4545/npm/registry/chalk
Download http://localhost:4545/npm/registry/@denotest/dual-cjs-esm
Download http://localhost:4545/npm/registry/@denotest/dual-cjs-esm/1.0.0.tgz
Download http://localhost:4545/npm/registry/chalk/chalk-5.0.1.tgz
chalk import map loads

View file

@ -1,8 +1,7 @@
type: Unknown
dependencies: 5 unique
size: [WILDCARD]
npm:chalk@4 - 4.1.2 ([WILDCARD])
npm:chalk@4.1.2 ([WILDCARD])
├─┬ npm:ansi-styles@4.3.0 ([WILDCARD])
│ └─┬ npm:color-convert@2.0.1 ([WILDCARD])
│ └── npm:color-name@1.1.4 ([WILDCARD])

View file

@ -5,11 +5,13 @@
"modules": [
{
"kind": "npm",
"specifier": "npm:chalk@4",
"specifier": "npm:chalk@4.1.2",
"npmPackage": "chalk@4.1.2"
}
],
"redirects": {},
"redirects": {
"npm:chalk@4": "npm:chalk@4.1.2"
},
"npmPackages": {
"ansi-styles@4.3.0": {
"name": "ansi-styles",

View file

@ -4,11 +4,11 @@ dependencies: 6 unique
size: [WILDCARD]
file:///[WILDCARD]/testdata/npm/peer_deps_with_copied_folders/main.ts (171B)
├─┬ npm:@denotest/peer-dep-test-child@1 - 1.0.0 ([WILDCARD])
├─┬ npm:@denotest/peer-dep-test-child@1.0.0 ([WILDCARD])
│ ├─┬ npm:@denotest/peer-dep-test-grandchild@1.0.0_@denotest+peer-dep-test-peer@1.0.0 ([WILDCARD])
│ │ └── npm:@denotest/peer-dep-test-peer@1.0.0 ([WILDCARD])
│ └── npm:@denotest/peer-dep-test-peer@1.0.0 ([WILDCARD])
└─┬ npm:@denotest/peer-dep-test-child@2 - 2.0.0 ([WILDCARD])
└─┬ npm:@denotest/peer-dep-test-child@2.0.0 ([WILDCARD])
├─┬ npm:@denotest/peer-dep-test-grandchild@1.0.0_@denotest+peer-dep-test-peer@2.0.0 ([WILDCARD])
│ └── npm:@denotest/peer-dep-test-peer@2.0.0 ([WILDCARD])
└── npm:@denotest/peer-dep-test-peer@2.0.0 ([WILDCARD])

View file

@ -4,6 +4,7 @@
],
"modules": [
{
"kind": "esm",
"dependencies": [
{
"specifier": "npm:@denotest/peer-dep-test-child@1",
@ -40,7 +41,6 @@
"npmPackage": "@denotest/peer-dep-test-child@2.0.0_@denotest+peer-dep-test-peer@2.0.0"
}
],
"kind": "esm",
"local": "[WILDCARD]main.ts",
"emit": null,
"map": null,
@ -49,7 +49,10 @@
"specifier": "file://[WILDCARD]/main.ts"
}
],
"redirects": {},
"redirects": {
"npm:@denotest/peer-dep-test-child@1": "npm:@denotest/peer-dep-test-child@1.0.0",
"npm:@denotest/peer-dep-test-child@2": "npm:@denotest/peer-dep-test-child@2.0.0"
},
"npmPackages": {
"@denotest/peer-dep-test-child@1.0.0_@denotest+peer-dep-test-peer@1.0.0": {
"name": "@denotest/peer-dep-test-child",

View file

@ -1,6 +1,6 @@
Download http://localhost:4545/npm/registry/@denotest/typescript-file
Download http://localhost:4545/npm/registry/@denotest/typescript-file/1.0.0.tgz
error: Could not resolve 'npm:@denotest/typescript-file'.
error: Could not resolve 'npm:@denotest/typescript-file@1.0.0'.
Caused by:
TypeScript files are not supported in npm packages: file:///[WILDCARD]/@denotest/typescript-file/1.0.0/index.ts