ok-computer icon indicating copy to clipboard operation
ok-computer copied to clipboard

ESM module export not used by node

Open richardscarrott opened this issue 2 years ago • 3 comments

Think it a) needs "exports" and b) needs .mjs extension, that way older versions can continue to load the cjs version.

e.g.

"module": "dist/ok-computer.esm.mjs",
  "types": "dist/ok-computer.d.ts",
  "exports": {
    ".": {
      "import": "./dist/ok-computer.esm.mjs",
      "require": "./dist/ok-computer.esm.mjs",
      "types": "./dist/ok-computer.d.ts"
    }
  },

Not sure if it's ok to have "module" with an mjs path?

richardscarrott avatar May 18 '22 07:05 richardscarrott

Additionally, current master has this

import * as parser from "ok-computer/dist/cjs/parser";

Instead of

import * as p from "ok-computer/parser";

richardscarrott avatar Sep 13 '22 19:09 richardscarrott

This Issue is still open but I'm able to successfully load ok-computer from Node CommonJS require; from Node ES6 import...from; and from Deno. What is the case that isn't supported?

unsaved avatar Oct 21 '23 06:10 unsaved

All environments are supported, however the ESM build isn't being used by Node as I had expected. It instead was pulling in the CJS build. Not really a big deal but a bug nonetheless.

richardscarrott avatar Oct 21 '23 09:10 richardscarrott