three-stdlib icon indicating copy to clipboard operation
three-stdlib copied to clipboard

Project doesn't use proper ESM & CJS file extensions

Open jasontheiler opened this issue 3 years ago • 0 comments

  • three version: 0.140.0
  • @types/three version: 0.139.0
  • three-stdlib version: 2.10.1

Problem description:

The currently used file extensions for ESM and CJS (.js for ESM and .cjs.js for CJS`) can cause problems in certain environments that rely on them (e.g. Nuxt3), because they are non-standard in Node.js.

Relevant code:

package.json

{
  "main": "index.cjs.js",
  "module": "index.js"
}

Suggested solution:

The file extensions should follow the Node.js convention to provide the best compatibility across all environments.

For example: .js for CJS and .mjs for ESM

I recommend reading up on the native ESM guide written by the creators of Nuxt3, especially the library author guide part should be of interest.

jasontheiler avatar Apr 30 '22 21:04 jasontheiler