-
Notifications
You must be signed in to change notification settings - Fork 14
Description
In my minimal React Native setup with Vite and React Native Web, I integrated Gluestack v2 along with the AlertDialog component, which includes the @legendapp/motion dependency. However, I encountered the following error: The compilation was successful, but the console showed this error log:
SyntaxError: The requested module '/node_modules/.vite/deps/@legendapp_motion.js?v=5af80577' does not provide an export named 'AnimatePresence' (at index.tsx:12:18)
After an extensive debugging session, I found that this issue is not related to React Native, Vite, or Gluestack. The problem is that your code is being parsed as CommonJS, which isn't compatible with my setup. The root cause lies in your package.json, which doesn't fully conform to the Node.js documentation. When using the exports property, the main, module, and types fields are ignored. You need to include them as require, import, and types entries within exports.
Here's the correct structure:
"exports": {
"require": "lib/commonjs/",
"import": "lib/module/",
"types": "index.d.ts"
...
}You can either keep the old entries for Node <= 10 or remove them entirely.
I’ll be creating a PR for this, and I would appreciate it if you could review and approve it.