ronantakizawa/codereview-bench huggingface dataset:
Repository: vitejs/vite
File: packages/vite/src/node/server/index.ts (TypeScript)

Code before:
    server: ViteDevServer,
    hmr: (environment: DevEnvironment) => Promise<void>,
  ) => Promise<void>
}

export interface ResolvedServerOptions
  extends Omit<
    RequiredExceptFor<
      ServerOptions,
      | 'host'
      | 'https'
      | 'proxy'
      | 'hmr'
      | 'ws'
      | 'watch'
      | 'origin'
      | 'hotUpdateEnvironments'
    >,
    'fs' | 'middlewareMode' | 'sourcemapIgnoreList'
  > {
  fs: Required<FileSystemServeOptions>
  middlewareMode: NonNullable<ServerOptions['middlewareMode']>
  hostname: Hostname
  sourcemapIgnoreList: Exclude<
    ServerOptions['sourcemapIgnoreList'],
    false | undefined
  >
}

export interface FileSystemServeOptions {
  /**
   * Strictly restrict file accessing outside of allowing paths.
   *
   * Set to `false` to disable the warning
   *
   * @default true
   */
  strict?: boolean

  /**
   * Restrict accessing files outside the allowed directories.
   *
   * Accepts absolute path or a path relative to project root.
   * Will try to search up for workspace root by default.
   */
  allow?: string[]

  /**
   * Restrict accessing files that matches the patterns.
   *
   * This will have higher priority than `allow`.

Review comment (suggestion):
```suggestion
  /** @internal */
  hostname: Hostname
```
I'd like to mark this as a internal type.

Code after:
   */
  hotUpdateEnvironments?: (
    server: ViteDevServer,
    hmr: (environment: DevEnvironment) => Promise<void>,
  ) => Promise<void>
}

export interface ResolvedServerOptions
  extends Omit<
    RequiredExceptFor<
      ServerOptions,
      | 'host'
      | 'https'
      | 'proxy'
      | 'hmr'
      | 'ws'
      | 'watch'
      | 'origin'
      | 'hotUpdateEnvironments'
    >,
    'fs' | 'middlewareMode' | 'sourcemapIgnoreList'
  > {
  fs: Required<FileSystemServeOptions>
  middlewareMode: NonNullable<ServerOptions['middlewareMode']>
  /** @internal */
  hostname: Hostname
  sourcemapIgnoreList: Exclude<
    ServerOptions['sourcemapIgnoreList'],
    false | undefined
  >
}

export interface FileSystemServeOptions {
  /**
   * Strictly restrict file accessing outside of allowing paths.
   *
   * Set to `false` to disable the warning
   *
   * @default true
   */
  strict?: boolean

  /**
   * Restrict accessing files outside the allowed directories.
   *
   * Accepts absolute path or a path relative to project root.
   * Will try to search up for workspace root by default.
   */
  allow?: string[]

  /**
Repository: vitejs/vite
File: packages/vite/src/node/__tests__/dev.spec.ts (TypeScript)

Code before:
    const { promise, resolve } =
      promiseWithResolvers<ResolvedServerUrls | null>()
    server = await createServer({
      root: __dirname,
      logLevel: 'error',
      server: {
        strictPort: true,
        ws: false,
        ...options,
      },
      plugins: [
        {
          name: 'test',
          configureServer(server) {
            server.httpServer?.on('listening', () => {
              resolve(server.resolvedUrls)
            })
          },
        },
      ],
    })

    await server.listen()
    const urls = await promise

    expect(urls).toMatchObject(expectation)
  })
})


Review comment (suggestion):
```suggestion
    expect(urls).toStrictEqual(expectation)
```
If `.toStrictEquals` works here, would you replace with it? Because [`toMatchObject`](https://vitest.dev/api/expect.html#tomatchobject) is a bit loose.

Code after:
import { afterEach, describe, expect, test } from 'vitest'
import type { ResolvedServerUrls } from 'vite'
import { createServer, resolveConfig } from '..'
import type { ViteDevServer } from '..'
import { promiseWithResolvers } from '../../shared/utils'

describe('resolveBuildEnvironmentOptions in dev', () => {
  test('build.rollupOptions should not have input in lib', async () => {
    const config = await resolveConfig(
      {
        build: {
          lib: {
            entry: './index.js',
          },
        },
      },
      'serve',
    )

    expect(config.build.rollupOptions).not.toHaveProperty('input')
  })
})

describe('the dev server', () => {
  let server: ViteDevServer

  afterEach(() => {
    server?.close()
  })

  test('resolves the server URLs before the httpServer listening events are called', async () => {
    expect.assertions(1)

    const options = {
      port: 5013, // make sure the port is unique
    }

    const { promise, resolve } =
      promiseWithResolvers<ResolvedServerUrls | null>()
    server = await createServer({
      root: __dirname,
      logLevel: 'error',
      server: {
        strictPort: true,
        ws: false,
        ...options,
      },
      plugins: [
        {
          name: 'test',
          configureServer(server) {
            server.httpServer?.on('listening', () => {
              resolve(server.resolvedUrls)
            })
          },
        },
      ],
    })

    await server.listen()
    const urls = await promise

    expect(urls).toStrictEqual({
      local: ['http://localhost:5013/'],
      network: [],
    })
  })
})
Repository: vitejs/vite
File: packages/vite/src/node/__tests__/dev.spec.ts (TypeScript)

Code before:
      {
        build: {
          lib: {
            entry: './index.js',
          },
        },
      },
      'serve',
    )

    expect(config.build.rollupOptions).not.toHaveProperty('input')
  })
})

describe('the dev server', () => {
  let server: ViteDevServer

  afterEach(() => {
    server?.close()
  })

  test('resolves the server URLs before the httpServer listening events are called', async () => {
    expect.assertions(1)

    const options = {
      port: 5013,
    }

    const { promise, resolve } =
      promiseWithResolvers<ResolvedServerUrls | null>()
    server = await createServer({
      root: __dirname,
      logLevel: 'error',
      server: {
        strictPort: true,
        ws: false,
        ...options,
      },
      plugins: [
        {
          name: 'test',
          configureServer(server) {
            server.httpServer?.on('listening', () => {
              resolve(server.resolvedUrls)
            })
          },
        },
      ],
    })

    await server.listen()

Review comment (suggestion):
```suggestion
      port: 5013, // make sure the port is unique
```

Code after:
      {
        build: {
          lib: {
            entry: './index.js',
          },
        },
      },
      'serve',
    )

    expect(config.build.rollupOptions).not.toHaveProperty('input')
  })
})

describe('the dev server', () => {
  let server: ViteDevServer

  afterEach(() => {
    server?.close()
  })

  test('resolves the server URLs before the httpServer listening events are called', async () => {
    expect.assertions(1)

    const options = {
      port: 5013, // make sure the port is unique
    }

    const { promise, resolve } =
      promiseWithResolvers<ResolvedServerUrls | null>()
    server = await createServer({
      root: __dirname,
      logLevel: 'error',
      server: {
        strictPort: true,
        ws: false,
        ...options,
      },
      plugins: [
        {
          name: 'test',
          configureServer(server) {
            server.httpServer?.on('listening', () => {
              resolve(server.resolvedUrls)
            })
          },
        },
      ],
    })

    await server.listen()
Repository: vitejs/vite
File: packages/vite/src/node/optimizer/esbuildDepPlugin.ts (TypeScript)

Code before:

      build.onResolve({ filter }, (args) => {
        // preserve `require` for node because it's more accurate than converting it to import
        if (args.kind === 'require-call' && platform !== 'node') {
          return {
            path: args.path,
            namespace: cjsExternalFacadeNamespace,
          }
        }

        return {
          path: args.path,
          external: true,
        }
      })

      build.onLoad(
        { filter: /.*/, namespace: cjsExternalFacadeNamespace },
        (args) => ({
          contents: `\
import * as m from ${JSON.stringify(nonFacadePrefix + args.path)};
if (typeof m.default === 'function') {
  module.exports = m.default;
} else {
  module.exports = { ...m };
}`,
        }),
      )
    },
  }
}


Review comment (suggestion):
Thanks for the change! I realize my earlier comment might have been misleading, sorry about that. What I had in mind was to apply the change _only_ for Node builtins. So the change I was thinking of looks like this:
```suggestion
          contents:  isNodeBuiltin(args.path) ? `\
import * as m from ${JSON.stringify(nonFacadePrefix + args.path)};
if (typeof m.default === 'function') {
  module.exports = m.default;
} else {
  module.exports = { ...m };
}` : `\
import * as m from ${JSON.stringify(
  nonFacadePrefix + args.path,
)};` + `module.exports = { ...m };`,
```

Code after:
        }
      })

      build.onResolve({ filter }, (args) => {
        // preserve `require` for node because it's more accurate than converting it to import
        if (args.kind === 'require-call' && platform !== 'node') {
          return {
            path: args.path,
            namespace: cjsExternalFacadeNamespace,
          }
        }

        return {
          path: args.path,
          external: true,
        }
      })

      build.onLoad(
        { filter: /.*/, namespace: cjsExternalFacadeNamespace },
        (args) => ({
          contents: `\
import * as m from ${JSON.stringify(nonFacadePrefix + args.path)};
module.exports = ${isNodeBuiltin(args.path) ? 'm.default' : '{ ...m }'};
`,
        }),
      )
    },
  }
}
Repository: vitejs/vite
File: packages/create-vite/src/index.ts (TypeScript)

Code before:
      {
        name: 'solid-ts',
        display: 'TypeScript',
        color: blue,
      },
      {
        name: 'solid',
        display: 'JavaScript',
        color: yellow,
      },
      {
        name: 'custom-tanstack-router',
        display: 'TanStack Router ↗',
        color: cyan,
        customCommand:
          'npm create -- tsrouter-app@latest TARGET_DIR --framework solid --interactive',
      },
    ],
  },
  {
    name: 'ember',
    display: 'Ember',
    color: redBright,
    variants: [
      {
        name: 'ember app',
        display: 'Production-ready App',
        color: redBright,
        customCommand:
          'npx ember-cli@latest new TARGET_DIR --blueprint @ember/app-blueprint --pnpm --lang en',
      },
      {
        name: 'ember app (ts)',
        display: 'Production-ready App (TypeScript)',
        color: blueBright,
        customCommand:
          'npx ember-cli@latest new TARGET_DIR --blueprint @ember/app-blueprint --pnpm --lang en --typescript',
      },
      {
        name: 'ember library',
        display: 'Production and OSS ready Library',
        color: redBright,
        customCommand:
          'npx ember-cli@latest addon TARGET_DIR --blueprint @ember/addon-blueprint --pnpm --typescript',
      },
      {
        name: 'ember library (ts)',
        display: 'Production and OSS ready Library (TypeScript)',
        color: blueBright,
        customCommand:
          'npx ember-cli@latest addon TARGET_DIR --blueprint @ember/addon-blueprint --pnpm --typescript',

Review comment (suggestion):
the names should probably follow the pattern set by other templates eg `ember` or `ember-app

Code after:
        name: 'lit',
        display: 'JavaScript',
        color: yellow,
      },
    ],
  },
  {
    name: 'svelte',
    display: 'Svelte',
    color: red,
    variants: [
      {
        name: 'svelte-ts',
        display: 'TypeScript',
        color: blue,
      },
      {
        name: 'svelte',
        display: 'JavaScript',
        color: yellow,
      },
      {
        name: 'custom-svelte-kit',
        display: 'SvelteKit ↗',
        color: red,
        customCommand: 'npm exec sv create TARGET_DIR',
      },
    ],
  },
  {
    name: 'solid',
    display: 'Solid',
    color: blue,
    variants: [
      {
        name: 'solid-ts',
        display: 'TypeScript',
        color: blue,
      },
      {
        name: 'solid',
        display: 'JavaScript',
        color: yellow,
      },
      {
        name: 'custom-tanstack-router-solid',
        display: 'TanStack Router ↗',
        color: cyan,
        customCommand:
          'npm create -- tsrouter-app@latest TARGET_DIR --framework Solid --interactive',
      },
Repository: vitejs/vite
File: packages/create-vite/src/index.ts (TypeScript)

Code before:
      },
      {
        name: 'solid',
        display: 'JavaScript',
        color: yellow,
      },
      {
        name: 'custom-tanstack-router',
        display: 'TanStack Router ↗',
        color: cyan,
        customCommand:
          'npm create -- tsrouter-app@latest TARGET_DIR --framework solid --interactive',
      },
    ],
  },
  {
    name: 'ember',
    display: 'Ember',
    color: redBright,
    variants: [
      {
        name: 'ember app',
        display: 'Production-ready App',
        color: redBright,
        customCommand:
          'npx ember-cli@latest new TARGET_DIR --blueprint @ember/app-blueprint --pnpm --lang en',
      },
      {
        name: 'ember app (ts)',
        display: 'Production-ready App (TypeScript)',
        color: blueBright,
        customCommand:
          'npx ember-cli@latest new TARGET_DIR --blueprint @ember/app-blueprint --pnpm --lang en --typescript',
      },
      {
        name: 'ember library',
        display: 'Production and OSS ready Library',
        color: redBright,
        customCommand:
          'npx ember-cli@latest addon TARGET_DIR --blueprint @ember/addon-blueprint --pnpm --typescript',
      },
      {
        name: 'ember library (ts)',
        display: 'Production and OSS ready Library (TypeScript)',
        color: blueBright,
        customCommand:
          'npx ember-cli@latest addon TARGET_DIR --blueprint @ember/addon-blueprint --pnpm --typescript',
      },
    ],
  },
  {

Review comment (suggestion):
--pnpm and --lang en are opinionated choices, does ember-cli come with an interactive mode that allows users to pick them? or maybe investigate reusing the detected package manager from create-vite cli

Code after:
    ],
  },
  {
    name: 'svelte',
    display: 'Svelte',
    color: red,
    variants: [
      {
        name: 'svelte-ts',
        display: 'TypeScript',
        color: blue,
      },
      {
        name: 'svelte',
        display: 'JavaScript',
        color: yellow,
      },
      {
        name: 'custom-svelte-kit',
        display: 'SvelteKit ↗',
        color: red,
        customCommand: 'npm exec sv create TARGET_DIR',
      },
    ],
  },
  {
    name: 'solid',
    display: 'Solid',
    color: blue,
    variants: [
      {
        name: 'solid-ts',
        display: 'TypeScript',
        color: blue,
      },
      {
        name: 'solid',
        display: 'JavaScript',
        color: yellow,
      },
      {
        name: 'custom-tanstack-router-solid',
        display: 'TanStack Router ↗',
        color: cyan,
        customCommand:
          'npm create -- tsrouter-app@latest TARGET_DIR --framework Solid --interactive',
      },
      {
        name: 'custom-vike-solid',
        display: 'Vike ↗',
        color: cyan,
Repository: vitejs/vite
File: packages/create-vite/src/index.ts (TypeScript)

Code before:
  },
  {
    name: 'ember',
    display: 'Ember',
    color: redBright,
    variants: [
      {
        name: 'ember app',
        display: 'Production-ready App',
        color: redBright,
        customCommand:
          'npx ember-cli@latest new TARGET_DIR --blueprint @ember/app-blueprint --pnpm --lang en',
      },
      {
        name: 'ember app (ts)',
        display: 'Production-ready App (TypeScript)',
        color: blueBright,
        customCommand:
          'npx ember-cli@latest new TARGET_DIR --blueprint @ember/app-blueprint --pnpm --lang en --typescript',
      },
      {
        name: 'ember library',
        display: 'Production and OSS ready Library',
        color: redBright,
        customCommand:
          'npx ember-cli@latest addon TARGET_DIR --blueprint @ember/addon-blueprint --pnpm --typescript',
      },
      {
        name: 'ember library (ts)',
        display: 'Production and OSS ready Library (TypeScript)',
        color: blueBright,
        customCommand:
          'npx ember-cli@latest addon TARGET_DIR --blueprint @ember/addon-blueprint --pnpm --typescript',
      },
    ],
  },
  {
    name: 'qwik',
    display: 'Qwik',
    color: blueBright,
    variants: [
      {
        name: 'qwik-ts',
        display: 'TypeScript',
        color: blueBright,
      },
      {
        name: 'qwik',
        display: 'JavaScript',
        color: yellow,
      },

Review comment (suggestion):
do ember libraries leverage vite during their build process? (vite library mode?)  create-vite is primarily used for creating applications using vite, i don't think we have explicit library support for any other option

Code after:
        display: 'JavaScript',
        color: yellow,
      },
      {
        name: 'custom-svelte-kit',
        display: 'SvelteKit ↗',
        color: red,
        customCommand: 'npm exec sv create TARGET_DIR',
      },
    ],
  },
  {
    name: 'solid',
    display: 'Solid',
    color: blue,
    variants: [
      {
        name: 'solid-ts',
        display: 'TypeScript',
        color: blue,
      },
      {
        name: 'solid',
        display: 'JavaScript',
        color: yellow,
      },
      {
        name: 'custom-tanstack-router-solid',
        display: 'TanStack Router ↗',
        color: cyan,
        customCommand:
          'npm create -- tsrouter-app@latest TARGET_DIR --framework Solid --interactive',
      },
      {
        name: 'custom-vike-solid',
        display: 'Vike ↗',
        color: cyan,
        customCommand: 'npm create -- vike@latest --solid TARGET_DIR',
      },
    ],
  },
  {
    name: 'ember',
    display: 'Ember',
    color: redBright,
    variants: [
      {
        name: 'ember-app-ts',
        display: 'TypeScript ↗',
        color: blueBright,
        customCommand:
Repository: vitejs/vite
File: packages/create-vite/src/index.ts (TypeScript)

Code before:
        customCommand:
          'npm create -- tsrouter-app@latest TARGET_DIR --framework solid --interactive',
      },
    ],
  },
  {
    name: 'ember',
    display: 'Ember',
    color: redBright,
    variants: [
      {
        name: 'ember app',
        display: 'Production-ready App',
        color: redBright,
        customCommand:
          'npx ember-cli@latest new TARGET_DIR --blueprint @ember/app-blueprint --pnpm --lang en',
      },
      {
        name: 'ember app (ts)',
        display: 'Production-ready App (TypeScript)',
        color: blueBright,
        customCommand:
          'npx ember-cli@latest new TARGET_DIR --blueprint @ember/app-blueprint --pnpm --lang en --typescript',
      },
      {
        name: 'ember library',
        display: 'Production and OSS ready Library',
        color: redBright,
        customCommand:
          'npx ember-cli@latest addon TARGET_DIR --blueprint @ember/addon-blueprint --pnpm --typescript',
      },
      {
        name: 'ember library (ts)',
        display: 'Production and OSS ready Library (TypeScript)',
        color: blueBright,
        customCommand:
          'npx ember-cli@latest addon TARGET_DIR --blueprint @ember/addon-blueprint --pnpm --typescript',
      },
    ],
  },
  {
    name: 'qwik',
    display: 'Qwik',
    color: blueBright,
    variants: [
      {
        name: 'qwik-ts',
        display: 'TypeScript',
        color: blueBright,
      },
      {

Review comment (suggestion):
```suggestion
        name: 'ember-library',
```

Code after:
        color: blue,
      },
      {
        name: 'svelte',
        display: 'JavaScript',
        color: yellow,
      },
      {
        name: 'custom-svelte-kit',
        display: 'SvelteKit ↗',
        color: red,
        customCommand: 'npm exec sv create TARGET_DIR',
      },
    ],
  },
  {
    name: 'solid',
    display: 'Solid',
    color: blue,
    variants: [
      {
        name: 'solid-ts',
        display: 'TypeScript',
        color: blue,
      },
      {
        name: 'solid',
        display: 'JavaScript',
        color: yellow,
      },
      {
        name: 'custom-tanstack-router-solid',
        display: 'TanStack Router ↗',
        color: cyan,
        customCommand:
          'npm create -- tsrouter-app@latest TARGET_DIR --framework Solid --interactive',
      },
      {
        name: 'custom-vike-solid',
        display: 'Vike ↗',
        color: cyan,
        customCommand: 'npm create -- vike@latest --solid TARGET_DIR',
      },
    ],
  },
  {
    name: 'ember',
    display: 'Ember',
    color: redBright,
    variants: [
      {
Repository: vitejs/vite
File: packages/create-vite/src/index.ts (TypeScript)

Code before:
    display: 'Ember',
    color: redBright,
    variants: [
      {
        name: 'ember app',
        display: 'Production-ready App',
        color: redBright,
        customCommand:
          'npx ember-cli@latest new TARGET_DIR --blueprint @ember/app-blueprint --pnpm --lang en',
      },
      {
        name: 'ember app (ts)',
        display: 'Production-ready App (TypeScript)',
        color: blueBright,
        customCommand:
          'npx ember-cli@latest new TARGET_DIR --blueprint @ember/app-blueprint --pnpm --lang en --typescript',
      },
      {
        name: 'ember library',
        display: 'Production and OSS ready Library',
        color: redBright,
        customCommand:
          'npx ember-cli@latest addon TARGET_DIR --blueprint @ember/addon-blueprint --pnpm --typescript',
      },
      {
        name: 'ember library (ts)',
        display: 'Production and OSS ready Library (TypeScript)',
        color: blueBright,
        customCommand:
          'npx ember-cli@latest addon TARGET_DIR --blueprint @ember/addon-blueprint --pnpm --typescript',
      },
    ],
  },
  {
    name: 'qwik',
    display: 'Qwik',
    color: blueBright,
    variants: [
      {
        name: 'qwik-ts',
        display: 'TypeScript',
        color: blueBright,
      },
      {
        name: 'qwik',
        display: 'JavaScript',
        color: yellow,
      },
      {
        name: 'custom-qwik-city',
        display: 'QwikCity ↗',

Review comment (suggestion):
```suggestion
        name: 'ember-library-ts',
```

Code after:
      {
        name: 'custom-svelte-kit',
        display: 'SvelteKit ↗',
        color: red,
        customCommand: 'npm exec sv create TARGET_DIR',
      },
    ],
  },
  {
    name: 'solid',
    display: 'Solid',
    color: blue,
    variants: [
      {
        name: 'solid-ts',
        display: 'TypeScript',
        color: blue,
      },
      {
        name: 'solid',
        display: 'JavaScript',
        color: yellow,
      },
      {
        name: 'custom-tanstack-router-solid',
        display: 'TanStack Router ↗',
        color: cyan,
        customCommand:
          'npm create -- tsrouter-app@latest TARGET_DIR --framework Solid --interactive',
      },
      {
        name: 'custom-vike-solid',
        display: 'Vike ↗',
        color: cyan,
        customCommand: 'npm create -- vike@latest --solid TARGET_DIR',
      },
    ],
  },
  {
    name: 'ember',
    display: 'Ember',
    color: redBright,
    variants: [
      {
        name: 'ember-app-ts',
        display: 'TypeScript ↗',
        color: blueBright,
        customCommand:
          'npm exec -- ember-cli@latest new TARGET_DIR --typescript',
      },
      {