v4.0.0-beta.4: Regression from v4.0.0-beta.3: ERR_UNSUPPORTED_DIR_IMPORT
Directory import '\node_modules\primevue\api' is not supported resolving ES modules when using vitest
#5821
Labels
Status: Needs Triage
Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Describe the bug
After upgrading from
v4.0.0-beta.3
tov4.0.0-beta.4
, the following error occurs when executing tests using vitest that worked previously inv4.0.0-beta.3
:It seems the issue results from this import of
primevue/api
here as this is a directory import:primevue/components/lib/config/PrimeVue.js
Line 1 in 401dd22
In the build, this directory
\node_modules\primevue\api
contains apackage.json
with the following content (changed in 1d3096d and a438dba ):This seems to cause issues as the ESM loader used by vitest does not support this.
I was guessing a potential fix could be to properly declare a proper export map instead here so ESM loaders can pick up the correct file. Something like:
(Side note: In this directory there is also a
api.esm.js
which seems to be identical to theapi.mjs
except for the sourcemap comment.)However, I could not get it running by simply changing the
package.json
in the\node_modules\primevue\api
directory.Unfortunately, this issue makes primevue v4.0.0-beta.4 impossible to be tested using vitest, therefore blocks the update in my case.
Reproducer
https://stackblitz.com/edit/primevue-create-vue-typescript-issue-template-ctejwg?file=package.json
PrimeVue version
4.0.0-beta.4
Vue version
3.x
Language
TypeScript
Build / Runtime
Vite
Browser(s)
node / vitest
Steps to reproduce the behavior
This shows the error.
Expected behavior
Primevue components can be tested using vitest as it used to work until primevue
v4.0.0-beta.3
.No error during tests.
The text was updated successfully, but these errors were encountered: