-
Notifications
You must be signed in to change notification settings - Fork 48
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
Importing as ES module, DevTool is included in production build #175
Comments
+1 I just came across this as well (building a React app with Vite) Made a quick demo to showcase the problem - https://stackblitz.com/edit/github-ei8jpp?file=src/Home/index.tsx |
Is this going to be addressed or should we use the work around? |
this isn't removed in production builds refs react-hook-form/devtools#175
Any updates on this issue? |
+1 |
A workaround (that could turn into a solution) inspired by react-query-devtools that worked for me is to create the following file and always import the hookform-devtools.ts import * as hookFormDevTools from "@hookform/devtools";
export const DevTool: (typeof hookFormDevTools)["DevTool"] =
process.env.NODE_ENV !== "development"
? function () {
return null;
}
: hookFormDevTools.DevTool; then change your import from - import { DevTool } from "@hookform/devtools";
+ import { DevTool } from "../hookform-devtools"; |
+1 any updates? |
My workaround: edit: it's not working 😕 |
+1 Any Update? |
As the title says, when a project by default imports and builds everything from ES modules, hookform's DevTool import returns the entire code even in production builds, instead of the noop of the default import.
Depending on the environment, a quick workaround may be to import from /dist/index for now, which returns either the CommonJS-version or a noop DevTool.
The text was updated successfully, but these errors were encountered: