From fce0e2b47d6ec2d1ef638ae0c47acd3c38770159 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Sun, 10 Sep 2023 08:31:45 +0100 Subject: [PATCH] perf: use `node:` prefix to bypass require.cache call for builtins See https://github.com/fastify/fastify-static/pull/407 --- lib/mode/static.js | 4 ++-- lib/util/read-package-json.js | 4 ++-- test/mode/static.js | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/mode/static.js b/lib/mode/static.js index 87024946..f5ffe925 100644 --- a/lib/mode/static.js +++ b/lib/mode/static.js @@ -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 yaml = require('yaml') module.exports = function (fastify, opts, done) { diff --git a/lib/util/read-package-json.js b/lib/util/read-package-json.js index 6c32b974..01f478e4 100644 --- a/lib/util/read-package-json.js +++ b/lib/util/read-package-json.js @@ -1,7 +1,7 @@ 'use strict' -const fs = require('fs') -const path = require('path') +const fs = require('node:fs') +const path = require('node:path') function readPackageJson () { try { diff --git a/test/mode/static.js b/test/mode/static.js index 5b2ae4c0..ce8ff837 100644 --- a/test/mode/static.js +++ b/test/mode/static.js @@ -1,13 +1,13 @@ 'use strict' -const path = require('path') +const path = require('node:path') const { test } = require('tap') const Fastify = require('fastify') const fastifySwagger = require('../../index') const fastifySwaggerDynamic = require('../../lib/mode/dynamic') const Swagger = require('@apidevtools/swagger-parser') -const readFileSync = require('fs').readFileSync -const resolve = require('path').resolve +const readFileSync = require('node:fs').readFileSync +const resolve = require('node:path').resolve const yaml = require('yaml') test('specification validation check works', async (t) => {