Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: use node: prefix to bypass require.cache call for builtins #431

Merged
merged 1 commit into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test/module/autohooks/basic.mjs
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
4 changes: 2 additions & 2 deletions test/module/autohooks/cascade.mjs
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
4 changes: 2 additions & 2 deletions test/module/autohooks/disabled.mjs
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
4 changes: 2 additions & 2 deletions test/module/autohooks/overwrite.mjs
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
6 changes: 3 additions & 3 deletions test/module/basic/app.js
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test/module/dependency/app.js
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions test/module/esm-import/app-default.js
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
4 changes: 2 additions & 2 deletions test/module/esm-import/app-named.js
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
4 changes: 2 additions & 2 deletions test/module/esm-import/app-star-default.js
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
4 changes: 2 additions & 2 deletions test/module/esm-import/app-star-named.js
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
4 changes: 2 additions & 2 deletions test/module/index-package/app.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions test/module/index-package/index.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/module/options/app.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/module/route-parameters/basic.mjs
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
4 changes: 2 additions & 2 deletions test/module/route-parameters/disabled.mjs
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
4 changes: 2 additions & 2 deletions test/typescript-esm/forceESM.ts
Original file line number Diff line number Diff line change
@@ -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 '../../'

Expand Down
2 changes: 1 addition & 1 deletion test/typescript-jest/babel-node/index.test.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/typescript-jest/basic/app.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/typescript-jest/integration/integration.test.ts
Original file line number Diff line number Diff line change
@@ -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'])(
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/basic/app.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/vitest/basic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion test/vitest/filter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading