Skip to content

Add ES Module Build to Support Modern Project Setups #313

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

Closed
wants to merge 2 commits into from
Closed

Add ES Module Build to Support Modern Project Setups #313

wants to merge 2 commits into from

Conversation

swiiny
Copy link

@swiiny swiiny commented May 5, 2023

Add ES Module Build to Support Modern Project Setups to fix issue #312

[x] Bug Fix

Checklist

  • Test your changes
  • Followed the build steps

Description

This pull request introduces an additional build output in ES module format for the countUp.js library. The purpose of this change is to provide better compatibility with modern project setups that use bundlers like Webpack, which are optimized for handling ES module syntax.

Previously, the library was built only in UMD format, which may have caused issues in some project setups, such as encountering "Unexpected token 'export'" errors. This update addresses this problem by adding a new build target with ES module output, allowing users to seamlessly integrate countUp.js into their projects with ES module support.

Here are the key changes made in this pull request:

  1. Updated the Rollup configuration to include an ES module build output, generating a new file countUp.esm.js.

By providing an ES module build alongside the existing UMD build, this update ensures that the library caters to a wider range of project configurations, thus enhancing its compatibility and ease of use for developers.

Does this PR introduce a breaking change?

[x] No

@inorganik
Copy link
Owner

You may have noticed that your change in the rollup config doesn't change any of the distributed files - that's because CountUp.js has been distributed as an ES6 module for about the last 4 years.

I think the change that is causing issues over on react countup is that in package.json I set "main" to point at the ES6 module. Previously it was pointed at the UMD module.

So the problem is not the module format. react-countup should update how they import countUp or pin at 2.6.0.

@inorganik inorganik closed this May 5, 2023
@inorganik
Copy link
Owner

In the meantime I would suggest using CountUp directly in react instead of the react-countup lib: https://gist.github.com/inorganik/2cf776865a4c65c12857027870e9898e

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

Successfully merging this pull request may close these issues.

2 participants