perf: drop unneeded node imports on fast path · nuxt/cli@a642f91 · GitHub
Skip to content

Commit a642f91

Browse files
committed
perf: drop unneeded node imports on fast path
1 parent fab29e4 commit a642f91

3 files changed

Lines changed: 2 additions & 22 deletions

File tree

‎packages/nuxi/bin/nuxi.mjs‎

Lines changed: 1 addition & 2 deletions

‎packages/nuxi/src/main.ts‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import type { CommandDef } from 'citty'
22

3-
import nodeCrypto from 'node:crypto'
4-
import { builtinModules, createRequire } from 'node:module'
53
import { resolve } from 'node:path'
64
import process from 'node:process'
75

@@ -17,22 +15,6 @@ import { debug, logger } from '../../nuxt-cli/src/utils/logger'
1715
import { findInPath, withLocalBinPath } from '../../nuxt-cli/src/utils/path-env'
1816
import { description, name, version } from '../package.json'
1917

20-
// globalThis.crypto support for Node.js 18
21-
if (!globalThis.crypto) {
22-
globalThis.crypto = nodeCrypto.webcrypto as unknown as Crypto
23-
}
24-
25-
// Node.js below v22.3.0, v20.16.0
26-
if (!process.getBuiltinModule) {
27-
const _require = createRequire(import.meta.url)
28-
// @ts-expect-error we are overriding with inferior types
29-
process.getBuiltinModule = (name: string) => {
30-
if (name.startsWith('node:') || builtinModules.includes(name)) {
31-
return _require.resolve(name)
32-
}
33-
}
34-
}
35-
3618
const commands = {
3719
init: () => import('../../create-nuxt/src/init').then(m => m.default || m),
3820
} as const

‎packages/nuxt-cli/bin/nuxi.mjs‎

Lines changed: 1 addition & 2 deletions

0 commit comments

Comments
 (0)