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

package.json needs some mandatory fields in exports #19

Open
artzuk opened this issue Sep 17, 2024 · 0 comments
Open

package.json needs some mandatory fields in exports #19

artzuk opened this issue Sep 17, 2024 · 0 comments

Comments

@artzuk
Copy link

artzuk commented Sep 17, 2024

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.

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

No branches or pull requests

1 participant