question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Move to ESM format

See original GitHub issue

Description

Encapsulating #599 and implementing https://github.com/sindresorhus/meta/discussions/15, moving to ESM is an obvious step in the right direction. I’m aware that @sindresorhus wants to “start with the lowest level packages that most of my other packages depend on”, which is A LOT in this case and I understand the intention behind that, but moving np to ESM anyway would firstly be a great way to test it out in the “sindresorhus ecosystem” and secondly a relatively easy project to do this on, since its public API is just the CLI and it has no Typescript related files.

Is the feature request related to a problem?

Not really, ESM is just better and more modern.

Possible implementation

Below is a checklist copied from the mentioned discussion post:

  • Add “type”: “module”, to package.json (below the author field)
  • Add “exports”: “./index.js”, to package.json (below the type field)
  • Update engines field in package.json to Node.js 12.
  • Update index.d.ts to use ESM imports/exports.
  • Update code examples in readme and index.d.ts to use ESM and also top-level await.
  • Remove ‘use strict’;.
  • Convert ‘.’ to ‘./index.js’.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
sindresorhuscommented, Feb 14, 2021

I would prefer to wait until the end of April for this. Mostly because a lot of people depend on np and I don’t want to bother them to upgrade until I can use the argument that Node.js 10 is obsolete.

1reaction
nnmrtscommented, May 18, 2021

@dopecodez I still neither feel able to communicate in a non emotional matter nor do I know if I have the power or time to do this right now. However, it might be a good distraction, I’ll look into it today and maybe I can make a draft PR tomorrow. Not guaranteeing anything though.

Again, I’m sorry, initially I was really motivated to start working on this (as you can see by my first post here), it’s just bad timing in this case. I’m still convinced that someone else could do the job better and quicker than me at this point in time, and I won’t be upset if someone decides to do so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migrating an NPM package to use ES Modules - Medium
... I'm going to show you the steps needed to convert an NPM package from using CommonJS (CJS) modules, to the newer ES...
Read more >
How to move to ESM - Stack Overflow
When you do decide to migrate to ESM format, in order to upgrade individual files one at a time, you can use the...
Read more >
Migrate a Node.js project to ESM - Ludovico Fischer
Next, get your own code to run as an ESM module. Either rename your files to the .mjs extension or add type: module...
Read more >
Helping Babel move to ES Modules - BigBinary Blog
Migrating from CommonJS to ESM in babel internals and the challenges ... ESM (ECMAScript modules) as the standard format for Javascript.
Read more >
Getting Started with (and Surviving) Node.js ESM
For browser and front-end application authors, the modern answer has been ECMAScript Modules ("ESM") features like import and export for quite ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found