Skip to content

Feature request: add "require" to package.json exports list #94

Open
@flyon

Description

@flyon

This package is made as an ESM module.

However, it is possible to use ESM modules in a CJS environment by using dynamic imports.

But when I tried to import this package with a dynamic import I got this error:

Module not found: Error: Package path . is not exported from package /web/workspace/node_modules/@material/material-color-utilities (see exports field in /web/workspace/node_modules/@material/material-color-utilities/package.json)

This is because "require" (what CJS environments look for) is not listed in the exports of package.json (currently there's only "types" and "import").

I suggest to add "require" to the "exports" field in package.json so this library can work in CJS environments for those that are not quite ready to switch everything over to ESM yet.

package.json

  "exports": {
    ".": {
      "types": "./index.d.ts",
      "import": "./index.js",
      "require" : "./index.js"
    }
  },

With that in place it runs perfectly on node.js and in the browser in my CJS setup. I'm getting color schemes etc.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions