sindresorhus / ora

Elegant terminal spinner
MIT License
9.08k stars 269 forks source link

Can we please add commonjs to "exports" in 'package.json'?sometimes" ES Module not supported" #199

Closed Yancy1028 closed 2 years ago

Yancy1028 commented 2 years ago

question

my project use "ts-node", now, when i import 'ora' ,it tell me "ES Module not supported", so,i add type:module to package and change module:ESNEXT to tsconfig.json ,then run node --loader ts-node/esm --experimental-specifier-resolution=node src\*.ts, it's work ok ! but when i convert code to "cjs",and run it with node, it tell me "ES Module not supported", i don't think so it.

why not add export like this?

the code from ava's 'package.json'

    "exports": {
        ".": {
            "import": "./entrypoints/main.mjs", // this is ES Module,when my project is ESModule, it's auto import
            "require": "./entrypoints/main.cjs" // this is Commonjs , when my project is Commonjs, it's auto import
        },
    },
    "type": "module",

another way

ora@5.x is commonjs

npm i -S ora@5
sindresorhus commented 2 years ago

Duplicate of #189