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

fix: package main should be cjs format. (fixes #869) #881

Merged
merged 1 commit into from
Jan 3, 2023

Conversation

KholdStare
Copy link
Contributor

@KholdStare KholdStare commented Dec 30, 2022

Closes #869

  • Add module entry for esm in package.json

See https://rollupjs.org/guide/en/#publishing-es-modules:

To make sure your ES modules are immediately usable by tools that work
with CommonJS such as Node.js and webpack, you can use Rollup to
compile to UMD or CommonJS format, and then point to that compiled
version with the main property in your package.json file. If your
package.json file also has a module field, ES-module-aware tools like
Rollup and webpack 2+ will import the ES module version directly.

- Add module entry for esm in package.json

See https://rollupjs.org/guide/en/#publishing-es-modules:

> To make sure your ES modules are immediately usable by tools that work
> with CommonJS such as Node.js and webpack, you can use Rollup to
> compile to UMD or CommonJS format, and then point to that compiled
> version with the main property in your package.json file. If your
> package.json file also has a module field, ES-module-aware tools like
> Rollup and webpack 2+ will import the ES module version directly.
@gabrieljablonski
Copy link
Member

I'm not the most familiar with rollup, so we'll just take a look to make sure this doesn't break anything, though this is probably fine as is.

Thanks for the contribution.

@danielbarion
Copy link
Member

hey o/

my fault, I totally forgot about this, I've worked in the past with an internal react components library for the company I worked for. This will probably work as expected.

I and @gabrieljablonski will test some use cases to double-check, thank you so much!

@danielbarion
Copy link
Member

Hi guys, version 5.3.3-beta.0 was published from this PR, let's test and give feedback please, if it's working as expected 😄

@danielbarion danielbarion merged commit d34774d into ReactTooltip:master Jan 3, 2023
@itsikcircle
Copy link
Contributor

Still have this issue since "type": "module", still exists in the package.json file

react-tooltip.cjs.min.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.

@danielbarion
Copy link
Member

@itsikcircle yeah, this is probably related like: #887

@itsikcircle itsikcircle mentioned this pull request Jan 3, 2023
@KholdStare KholdStare deleted the ak/package-json-fix branch January 3, 2023 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jest fails on standard import syntax
4 participants