You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We received a bug report (see: preactjs/preset-vite#75) for the Preact vite preset that there is an issue with importing react-datetime. Upon further inspection this issue isn't related to Preact and can be reproduced with the React preset too. I was able to narrow it down to a difference in how default exports from commonjs modules are treated.
importDateTimefrom'react-datetime';if(typeofDateTime!=='function'){// We hit this path only in prod buildsthrownewError('This is a bug');}console.log('it works');
In development mode everything works as expected. But in production mode the default export is wrapped into an object: { default: ... } with a default property which contains the expected value. This additional indirection causes production builds to be incorrect.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
Describe the bug
We received a bug report (see: preactjs/preset-vite#75) for the Preact vite preset that there is an issue with importing
react-datetime
. Upon further inspection this issue isn't related to Preact and can be reproduced with the React preset too. I was able to narrow it down to a difference in how default exports from commonjs modules are treated.In development mode everything works as expected. But in production mode the default export is wrapped into an object:
{ default: ... }
with adefault
property which contains the expected value. This additional indirection causes production builds to be incorrect.Reproduction
https://stackblitz.com/edit/vitejs-vite-k6uuun?file=main.js
Steps to reproduce
npm install
npm run build
npm run preview
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: