countdownjs icon indicating copy to clipboard operation
countdownjs copied to clipboard

Migrate to ES6 export

Open shoonia opened this issue 4 years ago • 3 comments
trafficstars

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 };

shoonia avatar Jan 21 '21 10:01 shoonia

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 avatar Oct 05 '21 10:10 patrickbenjamin1

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

patrickbenjamin1 avatar Oct 05 '21 11:10 patrickbenjamin1

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/

shoonia avatar Oct 05 '21 11:10 shoonia