Skip to content

Commit

Permalink
refactor: use nanoid instead of copying it (#17864)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Aug 19, 2024
1 parent 177a853 commit c5365d1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
"micromatch": "^4.0.7",
"mlly": "^1.7.1",
"mrmime": "^2.0.0",
"nanoid": "^5.0.7",
"open": "^8.4.2",
"parse5": "^7.1.2",
"pathe": "^1.1.2",
Expand Down
12 changes: 1 addition & 11 deletions packages/vite/src/module-runner/runnerTransport.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { nanoid } from 'nanoid/non-secure'
import type { FetchFunction, FetchResult } from './types'

export interface RunnerTransport {
Expand Down Expand Up @@ -70,14 +71,3 @@ export class RemoteRunnerTransport implements RunnerTransport {
return this.resolve<FetchResult>('fetchModule', id, importer)
}
}

// port from nanoid
// https://github.com/ai/nanoid
const urlAlphabet =
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
function nanoid(size = 21) {
let id = ''
let i = size
while (i--) id += urlAlphabet[(Math.random() * 64) | 0]
return id
}
16 changes: 15 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c5365d1

Please sign in to comment.