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

[v5 β1] cjs version of react-admin is broken as it imports an esm package #9869

Closed
smeng9 opened this issue May 23, 2024 · 3 comments
Closed
Labels

Comments

@smeng9
Copy link
Contributor

smeng9 commented May 23, 2024

What you were expecting:

I expect my project to build without errors after upgrading from v5 alpha to v5 beta

What happened instead:

There is an error when importing ra-core package in cjs mode

Steps to reproduce:

Goto https://www.npmjs.com/package/ra-core/v/5.0.0-beta.1?activeTab=code
And then go to the file /ra-core/dist/cjs/dataProvider/fetch.js

You will find var query_string_1 = __importDefault(require("query-string")); of an esm package

Related code:

This regression is introduced from #9812 This package is pure esm now

Other information:

We can revert this change or find an alternative package to do query string parsing

Environment

  • React-admin version: 5.0.0-beta.1
  • Last version that did not exhibit the issue (if applicable): 5.0.0-beta.0
  • React version: 18.3
  • Browser: Safari
  • Stack trace (in case of a JS error):
    Error: require() of ES Module /Users/home/.yarn/berry/cache/query-string-npm-9.0.0-3f8486c724-10c0.zip/node_modules/query-string/index.js from /Users/home/Developer/frontend-base/.yarn/virtual/ra-core-virtual-8c88f77e9d/3/.yarn/berry/cache/ra-core-npm-5.0.0-beta.1-6689ec2614-10c0.zip/node_modules/ra-core/dist/cjs/dataProvider/fetch.js not supported.
    Instead change the require of index.js in /Users/home/Developer/frontend-base/.yarn/virtual/ra-core-virtual-8c88f77e9d/3/.yarn/berry/cache/ra-core-npm-5.0.0-beta.1-6689ec2614-10c0.zip/node_modules/ra-core/dist/cjs/dataProvider/fetch.js to a dynamic import() which is available in all CommonJS modules.
@djhi
Copy link
Contributor

djhi commented May 23, 2024

Hi, thanks for the report. What bundler do you use?

@djhi djhi added the v5 label May 23, 2024
@smeng9
Copy link
Contributor Author

smeng9 commented May 23, 2024

Hi @djhi I use vite and vitest, the issue happens in vitest

@fzaninotto
Copy link
Member

Fixed by #9871

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants