Skip to content

Commit

Permalink
perf: use node: prefix to bypass require.cache call for builtins
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Oct 18, 2023
1 parent 75d2901 commit 9520865
Show file tree
Hide file tree
Showing 24 changed files with 63 additions and 63 deletions.
2 changes: 1 addition & 1 deletion cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

'use strict'

const path = require('path')
const path = require('node:path')
const commist = require('commist')()
const argv = require('yargs-parser')(process.argv)
const help = require('help-me')({
Expand Down
2 changes: 1 addition & 1 deletion eject.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const path = require('path')
const path = require('node:path')
const generify = require('generify')
const argv = require('yargs-parser')
const log = require('./log')
Expand Down
10 changes: 5 additions & 5 deletions generate-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
const {
readFile,
writeFile
} = require('fs').promises
const { existsSync } = require('fs')
const path = require('path')
} = require('node:fs').promises
const { existsSync } = require('node:fs')
const path = require('node:path')
const chalk = require('chalk')
const generify = require('generify')
const argv = require('yargs-parser')
const cliPkg = require('./package')
const { execSync } = require('child_process')
const { promisify } = require('util')
const { execSync } = require('node:child_process')
const { promisify } = require('node:util')
const log = require('./log')

const pluginTemplate = {
Expand Down
6 changes: 3 additions & 3 deletions generate-readme.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict'

const { readFileSync, existsSync } = require('fs')
const path = require('path')
const { readFileSync, existsSync } = require('node:fs')
const path = require('node:path')
const generify = require('generify')
const argv = require('yargs-parser')
const { execSync } = require('child_process')
const { execSync } = require('node:child_process')
const log = require('./log')

function toMarkdownList (a) {
Expand Down
6 changes: 3 additions & 3 deletions generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ const {
readFile,
writeFile,
existsSync
} = require('fs')
const path = require('path')
} = require('node:fs')
const path = require('node:path')
const chalk = require('chalk')
const generify = require('generify')
const argv = require('yargs-parser')
const cliPkg = require('./package')
const { execSync } = require('child_process')
const { execSync } = require('node:child_process')
const log = require('./log')

const javascriptTemplate = {
Expand Down
6 changes: 3 additions & 3 deletions lib/watch/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict'

const path = require('path')
const cp = require('child_process')
const path = require('node:path')
const cp = require('node:child_process')
const chalk = require('chalk')
const { arrayToRegExp, logWatchVerbose } = require('./utils')
const { GRACEFUL_SHUT } = require('./constants.js')

const EventEmitter = require('events')
const EventEmitter = require('node:events')
const chokidar = require('chokidar')
const forkPath = path.join(__dirname, './fork.js')

Expand Down
2 changes: 1 addition & 1 deletion lib/watch/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const chalk = require('chalk')
const path = require('path')
const path = require('node:path')

const arrayToRegExp = (arr) => {
const reg = arr.map((file) => {
Expand Down
2 changes: 1 addition & 1 deletion start.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ async function runFastify (args, additionalOptions, serverOptions) {
if (process.version.match(/v[0-6]\..*/g)) {
stop('Fastify debug mode not compatible with Node.js version < 6')
} else {
require('inspector').open(
require('node:inspector').open(
opts.debugPort,
opts.debugHost || isDocker() || isKubernetes() ? listenAddressDocker : undefined
)
Expand Down
2 changes: 1 addition & 1 deletion templates/app/app.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

const path = require('path')
const path = require('node:path')
const AutoLoad = require('@fastify/autoload')

// Pass --options via CLI arguments in command to enable these options.
Expand Down
2 changes: 1 addition & 1 deletion templates/app/test/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// between our tests.

const { build: buildApplication } = require('fastify-cli/helper')
const path = require('path')
const path = require('node:path')
const AppPath = path.join(__dirname, '..', 'app.js')

// Fill in this config with all the configurations
Expand Down
6 changes: 3 additions & 3 deletions test/cli.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict'

const t = require('tap')
const { execSync } = require('child_process')
const { mkdirSync, readFileSync } = require('fs')
const path = require('path')
const { execSync } = require('node:child_process')
const { mkdirSync, readFileSync } = require('node:fs')
const path = require('node:path')
const rimraf = require('rimraf')

t.test('generate', async (t) => {
Expand Down
4 changes: 2 additions & 2 deletions test/eject-esm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const {
mkdirSync,
readFileSync,
readFile
} = require('fs')
const path = require('path')
} = require('node:fs')
const path = require('node:path')
const rimraf = require('rimraf')
const walker = require('walker')
const workdir = path.join(__dirname, 'workdir')
Expand Down
4 changes: 2 additions & 2 deletions test/eject-ts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
process.env.TAP_BAIL = true

const t = require('tap')
const { mkdirSync, readFileSync, readFile } = require('fs')
const path = require('path')
const { mkdirSync, readFileSync, readFile } = require('node:fs')
const path = require('node:path')
const rimraf = require('rimraf')
const walker = require('walker')
const workdir = path.join(__dirname, 'workdir')
Expand Down
4 changes: 2 additions & 2 deletions test/eject.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ const {
mkdirSync,
readFileSync,
readFile
} = require('fs')
const path = require('path')
} = require('node:fs')
const path = require('node:path')
const rimraf = require('rimraf')
const walker = require('walker')
const workdir = path.join(__dirname, 'workdir')
Expand Down
8 changes: 4 additions & 4 deletions test/generate-esm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ const {
readFile,
promises: fsPromises,
unlink
} = require('fs')
const path = require('path')
const { promisify } = require('util')
} = require('node:fs')
const path = require('node:path')
const { promisify } = require('node:util')
const rimraf = require('rimraf')
const walker = require('walker')
const { generate, javascriptTemplate } = require('../generate')
const workdir = path.join(__dirname, 'workdir')
const appTemplateDir = path.join(__dirname, '..', 'templates', 'app-esm')
const cliPkg = require('../package')
const { exec, execSync } = require('child_process')
const { exec, execSync } = require('node:child_process')
const pExec = promisify(exec)
const pUnlink = promisify(unlink)
const minimatch = require('minimatch')
Expand Down
6 changes: 3 additions & 3 deletions test/generate-plugin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const {
mkdirSync,
readFileSync,
readFile
} = require('fs')
const path = require('path')
} = require('node:fs')
const path = require('node:path')
const rimraf = require('rimraf')
const walker = require('walker')
const { generate, pluginTemplate } = require('../generate-plugin')
const workdir = path.join(__dirname, 'workdir')
const templateDir = path.join(__dirname, '..', 'templates', 'plugin')
const cliPkg = require('../package')
const { exec, execSync } = require('child_process')
const { exec, execSync } = require('node:child_process')
const minimatch = require('minimatch')
const strip = require('strip-ansi')
const expected = {}
Expand Down
4 changes: 2 additions & 2 deletions test/generate-readme.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const path = require('path')
const fs = require('fs')
const path = require('node:path')
const fs = require('node:fs')
const t = require('tap')
const rimraf = require('rimraf')
const { generate } = require('../generate-readme')
Expand Down
2 changes: 1 addition & 1 deletion test/generate-swagger.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path')
const path = require('node:path')
const t = require('tap')
const { test } = t
const { generateSwagger } = require('../generate-swagger')
Expand Down
6 changes: 3 additions & 3 deletions test/generate-typescript-esm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const {
mkdirSync,
readFileSync,
readFile
} = require('fs')
const path = require('path')
} = require('node:fs')
const path = require('node:path')
const rimraf = require('rimraf')
const walker = require('walker')
const { generate, typescriptTemplate } = require('../generate')
const workdir = path.join(__dirname, 'workdir')
const appTemplateDir = path.join(__dirname, '..', 'templates', 'app-ts')
const cliPkg = require('../package')
const { exec, execSync } = require('child_process')
const { exec, execSync } = require('node:child_process')
const minimatch = require('minimatch')
const strip = require('strip-ansi')
const expected = {}
Expand Down
6 changes: 3 additions & 3 deletions test/generate-typescript.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ const {
mkdirSync,
readFileSync,
readFile
} = require('fs')
const path = require('path')
} = require('node:fs')
const path = require('node:path')
const rimraf = require('rimraf')
const walker = require('walker')
const { generate, typescriptTemplate } = require('../generate')
const workdir = path.join(__dirname, 'workdir')
const appTemplateDir = path.join(__dirname, '..', 'templates', 'app-ts')
const cliPkg = require('../package')
const { exec, execSync } = require('child_process')
const { exec, execSync } = require('node:child_process')
const minimatch = require('minimatch')
const strip = require('strip-ansi')
const expected = {}
Expand Down
8 changes: 4 additions & 4 deletions test/generate.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ const {
readFile,
promises: fsPromises,
unlink
} = require('fs')
const path = require('path')
const { promisify } = require('util')
} = require('node:fs')
const path = require('node:path')
const { promisify } = require('node:util')
const rimraf = require('rimraf')
const walker = require('walker')
const { generate, javascriptTemplate } = require('../generate')
const workdir = path.join(__dirname, 'workdir')
const appTemplateDir = path.join(__dirname, '..', 'templates', 'app')
const cliPkg = require('../package')
const { exec, execSync } = require('child_process')
const { exec, execSync } = require('node:child_process')
const pExec = promisify(exec)
const pUnlink = promisify(unlink)
const minimatch = require('minimatch')
Expand Down
8 changes: 4 additions & 4 deletions test/helper.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict'

const util = require('util')
const fs = require('fs')
const path = require('path')
const util = require('node:util')
const fs = require('node:fs')
const path = require('node:path')
const { test } = require('tap')
const stream = require('stream')
const stream = require('node:stream')

const helper = require('../helper')

Expand Down
14 changes: 7 additions & 7 deletions test/start.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* global GLOBAL_MODULE_1, GLOBAL_MODULE_2 */
'use strict'

const util = require('util')
const { once } = require('events')
const fs = require('fs')
const path = require('path')
const crypto = require('crypto')
const util = require('node:util')
const { once } = require('node:events')
const fs = require('node:fs')
const path = require('node:path')
const crypto = require('node:crypto')
const semver = require('semver')
const baseFilename = path.join(__dirname, 'fixtures', `test_${crypto.randomBytes(16).toString('hex')}`)
const { fork } = require('child_process')
const { fork } = require('node:child_process')
const moduleSupport = semver.satisfies(process.version, '>= 14 || >= 12.17.0 < 13.0.0')

const t = require('tap')
Expand Down Expand Up @@ -226,7 +226,7 @@ test('should start fastify at given socket path', { skip: process.platform === '
const fastify = await start.start(argv)

await new Promise((resolve, reject) => {
const request = require('http').request({
const request = require('node:http').request({
method: 'GET',
path: '/',
socketPath: sockFile
Expand Down
6 changes: 3 additions & 3 deletions util.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require('fs')
const path = require('path')
const url = require('url')
const fs = require('node:fs')
const path = require('node:path')
const url = require('node:url')
const semver = require('semver')
const pkgUp = require('pkg-up')
const resolveFrom = require('resolve-from')
Expand Down

0 comments on commit 9520865

Please sign in to comment.