torchlight-api / torchlight-cli

Node CLI for Torchlight
15 stars 2 forks source link

fix: add `"type": "module"`, use `exports` field & bump version #3

Closed N0tExisting closed 2 years ago

N0tExisting commented 2 years ago

This PR correctly makes the package an ESModule

ShivanshVij commented 2 years ago

Any updates on this PR?

aarondfrancis commented 2 years ago

I merged and tagged this, and then tried to use the CLI locally and got this error:

file:///Users/aaron/Code/torchlight/torchlight-cli-test/node_modules/@torchlight-api/torchlight-cli/lib/bin/torchlight.js:4
var _cli = require("../cli.js");
           ^

ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/Users/aaron/Code/torchlight/torchlight-cli-test/node_modules/@torchlight-api/torchlight-cli/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.

which is what I was afraid of. Going to revert now and see if I can figure out to make it work.

aarondfrancis commented 2 years ago

Ok I think I got this fixed, now publishing both CJS and ESM.