mckamey / countdownjs

A simple JavaScript API for producing an accurate, intuitive description of the timespan between two Date instances.
http://countdownjs.org
MIT License
497 stars 95 forks source link

Migrate to ES6 export #38

Open shoonia opened 3 years ago

shoonia commented 3 years ago

The modern build tooling, browsers, and Nodejs support ES6 import/export.

May you migrate to ES6 export instead of a hacky way to detect the environment

export { countdown };
patrickbenjamin1 commented 2 years ago

Yeah I'm having big issues trying to get rollup to bundle this module properly because it's using outdated imports/exports

What was your hacky solution?

patrickbenjamin1 commented 2 years ago

I solved this by just copying countdown.js into my repo, removing 1346 to 1353, and adding export default countdown

I'd open a pull request but don't know much about the rest of the tooling and don't wanna break anything. If I get some time, I might fork the repo and make a more modern Typescript/ES Module version

shoonia commented 2 years ago

You can use the exports map. example: https://github.com/preactjs/preact/blob/4aaecc18d33a9f3139ddd5f30f6d7c745076795f/package.json#L12-L18

And build a few entry point for each export variant example with Rollup.js : https://github.com/shoonia/storeon-velo/blob/master/rollup.config.js#L22-L38

Playground: https://rollupjs.org/repl/