Skip to content

perf: remove schema-utils dependency and validation#12

Merged
chenjiahan merged 1 commit intomainfrom
schema_remove_0314
Mar 14, 2026
Merged

perf: remove schema-utils dependency and validation#12
chenjiahan merged 1 commit intomainfrom
schema_remove_0314

Conversation

@chenjiahan
Copy link
Copy Markdown
Member

The commit removes the schema-utils dependency and all related validation code, including:

  • Deleted options.json schema file
  • Removed validation logic from index.js
  • Removed validation test file and snapshots
  • Updated type definitions to remove Schema references
  • Removed schema-utils from package.json dependencies

Copilot AI review requested due to automatic review settings March 14, 2026 12:34
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on a performance improvement by eliminating the 'schema-utils' dependency and all related option validation infrastructure. This change aims to reduce the bundle size and runtime overhead, making the middleware more lightweight and efficient. The removal encompasses the schema definition, validation calls, and corresponding test files, simplifying the codebase.

Highlights

  • Dependency Removal: The 'schema-utils' dependency has been completely removed from the project, reducing the overall package footprint.
  • Validation Logic Elimination: All code related to options validation, including the 'options.json' schema file and its usage in 'src/index.js', has been deleted.
  • Test Cleanup: Associated validation test files and their snapshots have been removed, streamlining the test suite.
  • Type Definition Update: TypeScript type definitions were updated to remove any references to the 'Schema' type, reflecting the removal of 'schema-utils'.
  • Build Configuration: The 'pnpm-lock.yaml' file was added to '.prettierignore' to prevent formatting conflicts.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .prettierignore
    • Added 'pnpm-lock.yaml' to the ignore list.
  • package.json
    • Removed 'schema-utils' from production dependencies.
  • src/index.js
    • Removed imports for 'validate' and 'schema'.
    • Deleted the 'validate' function call for options.
    • Removed the 'Schema' JSDoc typedef.
  • src/options.json
    • File deleted.
  • test/snapshots/validation-options.test.js.snap.webpack5
    • File deleted.
  • test/validation-options.test.js
    • File deleted.
  • tsconfig.json
    • Removed the 'resolveJsonModule' compiler option.
  • types/index.d.ts
    • Removed 'Schema' type definition.
    • Removed 'Schema' from the exported types.
Activity
  • No specific activity (comments, reviews, or progress updates) has been recorded for this pull request.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@chenjiahan chenjiahan merged commit fb6f3d6 into main Mar 14, 2026
2 of 7 checks passed
@chenjiahan chenjiahan deleted the schema_remove_0314 branch March 14, 2026 12:34
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request successfully removes the schema-utils dependency and its associated validation logic to improve performance. The changes are applied consistently across the codebase, including updates to dependencies, removal of schema and test files, and adjustments to type definitions.

However, the complete removal of option validation is a significant concern. It makes the middleware less robust and can lead to a poor developer experience due to cryptic runtime errors on invalid configuration. I have left a comment in src/index.js suggesting the addition of basic, manual validation for options. This would provide a good compromise, maintaining most of the performance gains while preventing hard-to-debug issues for users.

@@ -198,11 +195,6 @@ const noop = () => {};
* @returns {API<RequestInternal, ResponseInternal>} webpack dev middleware
*/
function wdm(compiler, options = {}) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Removing options validation entirely may lead to cryptic runtime errors and a poor developer experience when invalid options are provided. For instance, if a user passes a non-object value for mimeTypes, it will result in an unhelpful TypeError when the options are used.

While removing the schema-utils dependency is beneficial for performance, I recommend adding basic manual checks for the options. This would provide clear error messages for common misconfigurations and strike a better balance between performance and robustness.

For example:

if (options.mimeTypes && (typeof options.mimeTypes !== 'object' || Array.isArray(options.mimeTypes))) {
  throw new Error('The "mimeTypes" option must be an object.');
}

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the schema-utils dependency and all associated validation logic from webpack-dev-middleware. This eliminates runtime schema validation of options passed to the middleware, reducing bundle size and startup overhead at the cost of losing developer-friendly validation error messages for invalid configuration.

Changes:

  • Removed schema-utils from dependencies and deleted the options.json schema definition
  • Removed the validate() call in the wdm() entry point and cleaned up related type definitions
  • Deleted the validation test file and its snapshots, and added pnpm-lock.yaml to .prettierignore

Reviewed changes

Copilot reviewed 6 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/index.js Removed schema-utils import, schema import, and validate() call
src/options.json Deleted JSON schema definition file
types/index.d.ts Removed Schema type references
tsconfig.json Removed resolveJsonModule (no longer needed without options.json)
package.json Removed schema-utils from dependencies
test/validation-options.test.js Deleted validation test suite
test/snapshots/validation-options.test.js.snap.webpack5 Deleted validation test snapshots
.prettierignore Added pnpm-lock.yaml to ignore list

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 028fabdb6d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@@ -198,11 +195,6 @@ const noop = () => {};
* @returns {API<RequestInternal, ResponseInternal>} webpack dev middleware
*/
function wdm(compiler, options = {}) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restore option validation before middleware setup

Removing the validation step in wdm lets malformed options reach request-time code paths that assume validated types, which now causes hard runtime failures instead of an immediate config error. For example, passing methods: true will now initialize successfully but throw on the first request when acceptedMethods.includes(...) is executed in src/middleware.js (line 169), and modifyResponseData: true will be invoked as a function in src/middleware.js (lines 814-817). This is a regression from startup ValidationError behavior and can crash production traffic on misconfiguration.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants