Skip to content

Commit b6bc975

Browse files
authored
fix(cli): skip protocol imports in --install (#1464)
1 parent aab8095 commit b6bc975

4 files changed

Lines changed: 10 additions & 4 deletions

File tree

.size-limit.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"build/globals.js",
3434
"build/deno.js"
3535
],
36-
"limit": "881.40 kB",
36+
"limit": "881.42 kB",
3737
"brotli": false,
3838
"gzip": false
3939
},
@@ -66,7 +66,7 @@
6666
"README.md",
6767
"LICENSE"
6868
],
69-
"limit": "944.14 kB",
69+
"limit": "944.17 kB",
7070
"brotli": false,
7171
"gzip": false
7272
}

build/deps.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function parseDeps(content) {
6262
}
6363
function parsePackageName(path) {
6464
var _a, _b;
65-
if (!path) return;
65+
if (!path || path.includes(":")) return;
6666
const name = (_b = (_a = nameRe.exec(path)) == null ? void 0 : _a.groups) == null ? void 0 : _b.name;
6767
if (name && !builtins.has(name)) return name;
6868
}

src/deps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export function parseDeps(content: string): Record<string, string> {
8686
}
8787

8888
function parsePackageName(path?: string): string | undefined {
89-
if (!path) return
89+
if (!path || path.includes(':')) return
9090

9191
const name = nameRe.exec(path)?.groups?.name
9292
if (name && !builtins.has(name)) return name

test/deps.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ describe('deps', () => {
120120
[`require('@')`, {}],
121121
[`require('@/_foo')`, {}],
122122
[`require('@foo')`, {}],
123+
// ignores protocol specifiers
124+
[`import fs from 'node:fs'`, {}],
125+
[`require('node:path')`, {}],
126+
[`import('node:crypto')`, {}],
127+
[`import { promises } from 'node:fs/promises'`, {}],
128+
[`import * as assert from 'node:assert/strict'`, {}],
123129
].forEach(([input, result]) => {
124130
assert.deepEqual(parseDeps(input), result)
125131
})

0 commit comments

Comments
 (0)