cacjs / cac

Simple yet powerful framework for building command-line apps.
MIT License
2.65k stars 104 forks source link

Native ESM (Node 13+) Support #85

Closed talentlessguy closed 4 years ago

talentlessguy commented 4 years ago

Issue Type

Expected

ESM support so we can do this:

import cac from 'cac'

const cli = cac()

// ...

Actual

No ESM support for Node.js

Possible Solutions

Adding these fields to package.json

"type": "module",
"module: "...",
"exports": {
    ".": {
      "import": "./dist/index.js",
      "require": "./dist/index.cjs"
    },
    "./package.json": "./package.json",
    "./": "./"
  }

Note that CJS will still work as before, here's an example of such module: https://github.com/talentlessguy/es-mime-types

Because this project already uses Rollup, it will be very easy to add a module target.

Info

if needed, I can make a pull request

egoist commented 4 years ago

Nice, I guess pointing import to ./mod.js would just work then 👌

egoist commented 4 years ago

:tada: This issue has been resolved in version 6.6.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: