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

vee validate cannot be used with SSR #4339

Closed
userquin opened this issue Jun 29, 2023 · 1 comment · Fixed by #4340
Closed

vee validate cannot be used with SSR #4339

userquin opened this issue Jun 29, 2023 · 1 comment · Fixed by #4340

Comments

@userquin
Copy link
Contributor

userquin commented Jun 29, 2023

Is your feature request related to a problem? Please describe.
I'm using vee-validate (with zod via Nuxt module) with Vuetify 3 in a Nuxt 3 layer: when generating the project (via nuxi generate), Nuxt will use SSR and the generation fails, there are some window references.

imagen

Describe the solution you'd like

Just remove window, for example, there are no references to window in throttle function.

Describe alternatives you've considered
Apply a pnpm patch to dist/vee-validate.esm.js, a tedious task since we need to apply the patch every time a new version is released:

package.json

"pnpm": {
    "patchedDependencies": {
      "vee-validate@4.10.2": "patches/vee-validate@4.10.2.patch"
    }
  }

patches/vee-validate@4.10.2.patch

diff --git a/dist/vee-validate.esm.js b/dist/vee-validate.esm.js
index 776d29d91f6d100bb7f973c8487b8bc375aaf476..fffd15c82e81a9736e5fb6b3fbd8a7ca019eac5d 100644
--- a/dist/vee-validate.esm.js
+++ b/dist/vee-validate.esm.js
@@ -460,9 +460,9 @@ function debounceAsync(inner, ms = 0) {
     return function (...args) {
         // Run the function after a certain amount of time
         if (timer) {
-            window.clearTimeout(timer);
+            clearTimeout(timer);
         }
-        timer = window.setTimeout(() => {
+        timer = setTimeout(() => {
             // Get the result of the inner function, then apply it to the resolve function of
             // each promise that has been created since the last time the inner function was run
             const result = inner(...args);
@userquin
Copy link
Contributor Author

I'll send a PR but on my Windows laptop running pnpm build fails; you should also review the contributing guide, instructions using yarn/npm instead pnpm:

pnpm build script output
D:\work\projects\userquin\GitHub\userquin\vee-validate>nr build

> vee-validate-monorepo@ build D:\work\projects\userquin\GitHub\userquin\vee-validate
> node scripts/build.mjs

(node:16676) ExperimentalWarning: Import assertions are not a stable feature of the JavaScript language. Avoid relying on their current behavior and syntax as th
ose might change in a future version of Node.js.
(Use `node --trace-warnings ...` to show where the warning was created)
(node:16676) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
Generating bundle for vee-validate
node:internal/errors:490
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file and data are supported by the default ESM loader. On Windows, absolute paths must be val
id file:// URLs. Received protocol 'd:'
    at new NodeError (node:internal/errors:399:5)
    at throwIfUnsupportedURLScheme (node:internal/modules/esm/resolve:1059:11)
    at defaultResolve (node:internal/modules/esm/resolve:1135:3)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:838:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ESMLoader.import (node:internal/modules/esm/loader:525:22)
    at importModuleDynamically (node:internal/modules/esm/translators:110:35)
    at importModuleDynamicallyCallback (node:internal/process/esm_loader:35:14)
    at createConfig (file:///D:/work/projects/userquin/GitHub/userquin/vee-validate/scripts/config.mjs:38:47) {
  code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
}

Running test script on my local, 3 tests are failing (Node 18):

imagen

imagen

imagen

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 a pull request may close this issue.

1 participant