Closed aKzenT closed 4 days ago
Didn't realize that the names are required to be ending with .cjs
or .mjs
. Would just adding type
and set it to module
in package.json
work?
I cannot reproduce this issue in my Vite or Nuxt setup, is there an environment where this can be reproduced/observed?
EDIT: I can reproduce in a simple Node.js environment running .mjs
and .cjs
imports.
Should be fixed with v4.14.4
can confirm that v4.14.4 fixes the issue for us. Thank you very much for the fast response!
What happened?
The latest vee-validate version uses the exports field to declare its entry points. Our project uses ESM and loaded vee-validate as ESM with the previous version. With the latest version we get the following error however:
Named export 'configure' not found. The requested module 'vee-validate' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using: import pkg from 'vee-validate'; const { useForm, configure, defineRule, useField } = pkg;
I believe this issue is caused by a combination of various factors:
This is in contrast to the previous version, where the "module" property implicitly marks the target as being an ESM file.
I believe the correct solution is to specify a default type in the "type" field and use explicit file extensiosn (.cjs, .mjs) for the other type. This approach is also documented on the official NodeJS documentation: https://nodejs.org/api/packages.html#dual-commonjses-module-packages
Further resources: https://stackoverflow.com/a/77287842 https://nodejs.org/api/esm.html#modules-ecmascript-modules https://nodejs.org/api/packages.html#dual-commonjses-module-packages
Reproduction steps
1. 2. 3. ...
Version
Vue.js 3.x and vee-validate 4.x
What browsers are you seeing the problem on?
Relevant log output
No response
Demo link
none
Code of Conduct