From 09d4e141f0b546c135ad1d7d48ce87fea5c4cfd3 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Sun, 15 Dec 2024 16:21:20 +0000 Subject: [PATCH] perf: use `node:` prefix to bypass require.cache call for builtins --- README.md | 4 ++-- test/module/autohooks/basic.mjs | 4 ++-- test/module/autohooks/cascade.mjs | 4 ++-- test/module/autohooks/disabled.mjs | 4 ++-- test/module/autohooks/overwrite.mjs | 4 ++-- test/module/basic/app.js | 6 +++--- test/module/dependency/app.js | 4 ++-- test/module/esm-import/app-default.js | 4 ++-- test/module/esm-import/app-named.js | 4 ++-- test/module/esm-import/app-star-default.js | 4 ++-- test/module/esm-import/app-star-named.js | 4 ++-- test/module/index-package/app.js | 4 ++-- test/module/index-package/index.js | 4 ++-- test/module/options/app.js | 4 ++-- test/module/route-parameters/basic.mjs | 4 ++-- test/module/route-parameters/disabled.mjs | 4 ++-- test/typescript-esm/forceESM.ts | 4 ++-- test/typescript-jest/babel-node/index.test.ts | 2 +- test/typescript-jest/basic/app.ts | 2 +- test/typescript-jest/integration/integration.test.ts | 2 +- test/typescript/basic/app.ts | 2 +- test/vitest/basic.test.ts | 2 +- test/vitest/filter.test.ts | 2 +- 23 files changed, 41 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 4f53ed22..2768687e 100644 --- a/README.md +++ b/README.md @@ -47,8 +47,8 @@ or with ESM syntax: ```js import autoLoad from '@fastify/autoload' -import { fileURLToPath } from 'url' -import { dirname, join } from 'path' +import { fileURLToPath } from 'node:url' +import { dirname, join } from 'node:path' import fastify from 'fastify' const __filename = fileURLToPath(import.meta.url) diff --git a/test/module/autohooks/basic.mjs b/test/module/autohooks/basic.mjs index 5402aec6..e9e06499 100644 --- a/test/module/autohooks/basic.mjs +++ b/test/module/autohooks/basic.mjs @@ -1,5 +1,5 @@ -import path from 'path' -import { fileURLToPath } from 'url' +import path from 'node:path' +import { fileURLToPath } from 'node:url' import autoload from '../../../index.js' diff --git a/test/module/autohooks/cascade.mjs b/test/module/autohooks/cascade.mjs index bfa5a3db..33ac7375 100644 --- a/test/module/autohooks/cascade.mjs +++ b/test/module/autohooks/cascade.mjs @@ -1,5 +1,5 @@ -import path from 'path' -import { fileURLToPath } from 'url' +import path from 'node:path' +import { fileURLToPath } from 'node:url' import autoload from '../../../index.js' diff --git a/test/module/autohooks/disabled.mjs b/test/module/autohooks/disabled.mjs index 8a82c0cb..fc8f903e 100644 --- a/test/module/autohooks/disabled.mjs +++ b/test/module/autohooks/disabled.mjs @@ -1,5 +1,5 @@ -import path from 'path' -import { fileURLToPath } from 'url' +import path from 'node:path' +import { fileURLToPath } from 'node:url' import autoload from '../../../index.js' diff --git a/test/module/autohooks/overwrite.mjs b/test/module/autohooks/overwrite.mjs index 4f641012..da8cb659 100644 --- a/test/module/autohooks/overwrite.mjs +++ b/test/module/autohooks/overwrite.mjs @@ -1,5 +1,5 @@ -import path from 'path' -import { fileURLToPath } from 'url' +import path from 'node:path' +import { fileURLToPath } from 'node:url' import autoload from '../../../index.js' diff --git a/test/module/basic/app.js b/test/module/basic/app.js index 436dd9ab..945b7f95 100644 --- a/test/module/basic/app.js +++ b/test/module/basic/app.js @@ -1,7 +1,7 @@ -import fs from 'fs' -import path, { dirname } from 'path' +import fs from 'node:fs' +import path, { dirname } from 'node:path' import autoLoad from '../../../index.js' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' const __filename = fileURLToPath(import.meta.url) const __dirname = dirname(__filename) diff --git a/test/module/dependency/app.js b/test/module/dependency/app.js index b1a8ac56..80ad4e1e 100644 --- a/test/module/dependency/app.js +++ b/test/module/dependency/app.js @@ -1,7 +1,7 @@ -import path, { dirname } from 'path' +import path, { dirname } from 'node:path' import fastifyUrlData from '@fastify/url-data' import autoLoad from '../../../index.js' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' const __filename = fileURLToPath(import.meta.url) const __dirname = dirname(__filename) diff --git a/test/module/esm-import/app-default.js b/test/module/esm-import/app-default.js index a19ac8ec..af004c15 100644 --- a/test/module/esm-import/app-default.js +++ b/test/module/esm-import/app-default.js @@ -1,5 +1,5 @@ -import path from 'path' -import { fileURLToPath } from 'url' +import path from 'node:path' +import { fileURLToPath } from 'node:url' import fastifyAutoloadDefault from '../../../index.js' diff --git a/test/module/esm-import/app-named.js b/test/module/esm-import/app-named.js index d83f92b8..62147501 100644 --- a/test/module/esm-import/app-named.js +++ b/test/module/esm-import/app-named.js @@ -1,5 +1,5 @@ -import path from 'path' -import { fileURLToPath } from 'url' +import path from 'node:path' +import { fileURLToPath } from 'node:url' import { fastifyAutoload as fastifyAutoloadNamed } from '../../../index.js' diff --git a/test/module/esm-import/app-star-default.js b/test/module/esm-import/app-star-default.js index 988d233e..e3e38c79 100644 --- a/test/module/esm-import/app-star-default.js +++ b/test/module/esm-import/app-star-default.js @@ -1,5 +1,5 @@ -import path from 'path' -import { fileURLToPath } from 'url' +import path from 'node:path' +import { fileURLToPath } from 'node:url' import * as fastifyAutoloadStar from '../../../index.js' diff --git a/test/module/esm-import/app-star-named.js b/test/module/esm-import/app-star-named.js index 0f62e1cf..9f698203 100644 --- a/test/module/esm-import/app-star-named.js +++ b/test/module/esm-import/app-star-named.js @@ -1,5 +1,5 @@ -import path from 'path' -import { fileURLToPath } from 'url' +import path from 'node:path' +import { fileURLToPath } from 'node:url' import * as fastifyAutoloadStar from '../../../index.js' diff --git a/test/module/index-package/app.js b/test/module/index-package/app.js index f4749fcd..f5d8ce9e 100644 --- a/test/module/index-package/app.js +++ b/test/module/index-package/app.js @@ -1,5 +1,5 @@ -import url from 'url' -import path from 'path' +import url from 'node:url' +import path from 'node:path' import fastifyAutoload from '../../../index.js' export default function (fastify, opts, next) { diff --git a/test/module/index-package/index.js b/test/module/index-package/index.js index fd901d32..9b13e274 100644 --- a/test/module/index-package/index.js +++ b/test/module/index-package/index.js @@ -1,5 +1,5 @@ -import url from 'url' -import process from 'process' +import url from 'node:url' +import process from 'node:process' if (url.fileURLToPath(import.meta.url) === process.argv[1]) { // side effects diff --git a/test/module/options/app.js b/test/module/options/app.js index fba1a770..234ccef1 100644 --- a/test/module/options/app.js +++ b/test/module/options/app.js @@ -1,6 +1,6 @@ -import path from 'path' +import path from 'node:path' import fastifyUrlData from '@fastify/url-data' -import { fileURLToPath } from 'url' +import { fileURLToPath } from 'node:url' import autoLoad from '../../../index.js' const { dirname } = path diff --git a/test/module/route-parameters/basic.mjs b/test/module/route-parameters/basic.mjs index 15a2c307..a1effc64 100644 --- a/test/module/route-parameters/basic.mjs +++ b/test/module/route-parameters/basic.mjs @@ -1,5 +1,5 @@ -import path from 'path' -import { fileURLToPath } from 'url' +import path from 'node:path' +import { fileURLToPath } from 'node:url' import autoload from '../../../index.js' diff --git a/test/module/route-parameters/disabled.mjs b/test/module/route-parameters/disabled.mjs index 7a1f2405..34a24852 100644 --- a/test/module/route-parameters/disabled.mjs +++ b/test/module/route-parameters/disabled.mjs @@ -1,5 +1,5 @@ -import path from 'path' -import { fileURLToPath } from 'url' +import path from 'node:path' +import { fileURLToPath } from 'node:url' import autoload from '../../../index.js' diff --git a/test/typescript-esm/forceESM.ts b/test/typescript-esm/forceESM.ts index cc0d191e..64111034 100644 --- a/test/typescript-esm/forceESM.ts +++ b/test/typescript-esm/forceESM.ts @@ -1,6 +1,6 @@ import fastify from 'fastify' -import { dirname, resolve } from 'path' -import { fileURLToPath } from 'url' +import { dirname, resolve } from 'node:path' +import { fileURLToPath } from 'node:url' import t from 'tap' import fastifyAutoLoad from '../../' diff --git a/test/typescript-jest/babel-node/index.test.ts b/test/typescript-jest/babel-node/index.test.ts index bf5570b7..82c882af 100644 --- a/test/typescript-jest/babel-node/index.test.ts +++ b/test/typescript-jest/babel-node/index.test.ts @@ -1,5 +1,5 @@ import fastify from 'fastify' -import { join } from 'path' +import { join } from 'node:path' import AutoLoad from '../../../' describe('load typescript using babel-node', () => { diff --git a/test/typescript-jest/basic/app.ts b/test/typescript-jest/basic/app.ts index 24283632..8b382762 100644 --- a/test/typescript-jest/basic/app.ts +++ b/test/typescript-jest/basic/app.ts @@ -1,5 +1,5 @@ import { FastifyPluginCallback } from 'fastify' -import { join } from 'path' +import { join } from 'node:path' const fastifyAutoLoad = require('../../../index') const app: FastifyPluginCallback = function (fastify, opts, next): void { diff --git a/test/typescript-jest/integration/integration.test.ts b/test/typescript-jest/integration/integration.test.ts index 5d298e80..d0a1b97e 100644 --- a/test/typescript-jest/integration/integration.test.ts +++ b/test/typescript-jest/integration/integration.test.ts @@ -1,4 +1,4 @@ -import { exec } from 'child_process' +import { exec } from 'node:child_process' describe('integration test', function () { test.concurrent.each(['ts-node', 'ts-node-dev'])( diff --git a/test/typescript/basic/app.ts b/test/typescript/basic/app.ts index ac2f87bc..764f2869 100644 --- a/test/typescript/basic/app.ts +++ b/test/typescript/basic/app.ts @@ -1,5 +1,5 @@ import { FastifyPluginCallback } from 'fastify' -import { join } from 'path' +import { join } from 'node:path' import fastifyAutoLoad from '../../../' const app: FastifyPluginCallback = function (fastify, opts, next): void { diff --git a/test/vitest/basic.test.ts b/test/vitest/basic.test.ts index 496b38d6..03365cbf 100644 --- a/test/vitest/basic.test.ts +++ b/test/vitest/basic.test.ts @@ -3,7 +3,7 @@ import { describe, test, expect } from 'vitest' import Fastify from 'fastify' import AutoLoad from '../../index' -import { join } from 'path' +import { join } from 'node:path' describe.concurrent('Vitest test suite', function () { const app = Fastify() diff --git a/test/vitest/filter.test.ts b/test/vitest/filter.test.ts index 46a546f1..1dbc34ff 100644 --- a/test/vitest/filter.test.ts +++ b/test/vitest/filter.test.ts @@ -3,7 +3,7 @@ import { describe, test, expect } from 'vitest' import Fastify from 'fastify' import AutoLoad from '../../index' -import { join } from 'path' +import { join } from 'node:path' describe.concurrent('Vitest ignore filters test suite', function () { const app = Fastify()