EvanHahn / HumanizeDuration.js

361000 becomes "6 minutes, 1 second"
https://evanhahn.github.io/HumanizeDuration.js/
The Unlicense
1.65k stars 175 forks source link

Support for direct-to-browser ESM #225

Open MagnusOxlund opened 1 month ago

MagnusOxlund commented 1 month ago

From the docs, it looks like the project installs in the browser's global namespace.

Are there any plans to distribute an ES module directly to browsers (without Node.js) that can be imported with an ES6 import declaration?

For instance:

<!DOCTYPE html>
<html lang="en">
<head>
  <link rel="modulepreload" href="https://path/to/HumanizeDuration.js">
  <script type="module">
    import humanizeDuration from 'https://path/to/HumanizeDuration.js';
    console.log(humanizeDuration(97320000));
  </script>
</head>
</html>
MagnusOxlund commented 1 month ago

For reference, Luxon is distributed in that form, with both a full and a minified version available.

EvanHahn commented 1 month ago

I'd like to add ES module support to this package, but I'm not sure how I want to do that yet.

I've added it to my to-do list. I will probably not get to this soon, apologies.

The-LukeZ commented 2 weeks ago

but I'm not sure how I want to do that yet.

Could I make PR for it?

EvanHahn commented 2 weeks ago

Yes, but please let me know how you plan to do this beforehand. There are a lot of different ways to accomplish this and I don't want you to have to do a bunch of unnecessary work.