Skip to content

Commit 4073e5b

Browse files
authored
perf: use node: prefix to bypass require.cache call for builtins (#644)
* perf: use `node:` prefix to bypass require.cache call for builtins See fastify/fastify-static#407 * docs: use `node:` prefix to bypass require.cache call for builtins
1 parent a3e4618 commit 4073e5b

File tree

9 files changed

+12
-12
lines changed

9 files changed

+12
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ The standalone mode is used to compile the code that can be directly run by `nod
692692
itself. You need to have `fast-json-stringify` installed for the standalone code to work.
693693

694694
```js
695-
const fs = require('fs')
695+
const fs = require('node:fs')
696696
const code = fastJson({
697697
title: 'default string',
698698
type: 'object',

benchmark/bench-cmp-branch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const { spawn } = require('child_process')
3+
const { spawn } = require('node:child_process')
44

55
const cliSelect = require('cli-select')
66
const simpleGit = require('simple-git')

benchmark/bench-thread.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const { workerData: benchmark, parentPort } = require('worker_threads')
3+
const { workerData: benchmark, parentPort } = require('node:worker_threads')
44

55
const Benchmark = require('benchmark')
66
Benchmark.options.minSamples = 100

benchmark/bench.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

3-
const path = require('path')
4-
const { Worker } = require('worker_threads')
3+
const path = require('node:path')
4+
const { Worker } = require('node:worker_threads')
55

66
const BENCH_THREAD_PATH = path.join(__dirname, 'bench-thread.js')
77

build/build-schema-validator.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
const Ajv = require('ajv')
44
const standaloneCode = require('ajv/dist/standalone').default
55
const ajvFormats = require('ajv-formats')
6-
const fs = require('fs')
7-
const path = require('path')
6+
const fs = require('node:fs')
7+
const path = require('node:path')
88

99
const ajv = new Ajv({
1010
addUsedSchema: false,

examples/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const http = require('http')
3+
const http = require('node:http')
44

55
const stringify = require('fast-json-stringify')({
66
type: 'object',

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
const merge = require('@fastify/deepmerge')()
66
const clone = require('rfdc')({ proto: true })
7-
const { randomUUID } = require('crypto')
7+
const { randomUUID } = require('node:crypto')
88

99
const validate = require('./lib/schema-validator')
1010
const Serializer = require('./lib/serializer')

test/standalone-mode.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
const test = require('tap').test
44
const fjs = require('..')
5-
const fs = require('fs')
6-
const path = require('path')
5+
const fs = require('node:fs')
6+
const path = require('node:path')
77

88
function build (opts, schema) {
99
return fjs(schema || {

test/webpack.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const test = require('tap').test
44
const webpack = require('webpack')
5-
const path = require('path')
5+
const path = require('node:path')
66

77
test('the library should work with webpack', async (t) => {
88
t.plan(1)

0 commit comments

Comments
 (0)