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

Add the "type": "module" to the package.json file #327

Open
GianlucaGuarini opened this issue Nov 25, 2024 · 1 comment
Open

Add the "type": "module" to the package.json file #327

GianlucaGuarini opened this issue Nov 25, 2024 · 1 comment

Comments

@GianlucaGuarini
Copy link

What did you do?

The package.json file contains esm exports without using the "type": "module" key.
This behavior breaks bundlers like vitest due to the misleading package.json format.

What did you expect to happen?

The switch from commonjs to esm should grant that the consumers (bundlers, compilers...) will receive a specs compliant package.json file.

What happened actually?

Error displayed in vitest

Module /node_modules/react-content-loader/dist/react-content-loader.es.js:1 seems to be an ES Module but shipped in a CommonJS package. You might want to create an issue to the package "react-content-loader" asking them to ship
the file in .mjs extension or add "type": "module" in their package.json.

As a temporary workaround you can try to inline the package by updating your config:

// vitest.config.js
export default {
  test: {
    server: {
      deps: {
        inline: [
          "react-content-loader"
        ]
      }
    }
  }
}

Which versions of react-content-loader, and which browser are affected by this issue?

[email protected]

Please let me know if you need a demo project to replicate the issue 🙏

@GianlucaGuarini
Copy link
Author

The issues appears in node v18 and v20. In node >= 22 everything seems to work fine 🤦

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