OverlayScrollbars: Jest with Node.js v20.11.0 does not understand overlayscrollbars-react

Hi, i noticed about “module” field in package.json is not standard way to define ESM entry point of package.

According this answer: https://github.com/jestjs/jest/issues/9430#issuecomment-1905771034

Can we update package.json of overlayscrollbars packages for to comply with the standard?

About this issue

  • Original URL
  • State: closed
  • Created 5 months ago
  • Comments: 17 (7 by maintainers)

Most upvoted comments

@krutoo I’ll continue to provide commonjs and module versions because of backwardscompatibility reasons and because some frameworks / tools simply only support one or another but not always both (or the “right” one).

@ChristophP Thank you for the input - really appreciate it!

@nickmccurdy Very useful tool, I’ll definitely use it before I publish the fixed versions - Thanks a bunch!

Regaring the extensions

  • .mjs is always interpreted as ESM (regardless of the type field of the closes package json up the file tree)
  • .cjs is always interpreted as CJS (regardless of the type field of the closes package json up the file tree)
  • .js is interpreted as ESM or CJS depending on the type field of the closest package json up the file tree.

In that sense if you have type: module set, the ESM file can be called .js the CJS file .cjs. If you have no type module set or type: commonjs you can do .mjs for ESM and .js for CJS. If you wanna be absolutely sure regardless you can use .mjs/.cjs for them respectively.

I’ve published:

Which all address this issue and should hopefully fix it properly. I’ve used https://publint.dev and https://arethetypeswrong.github.io/ to identifiy additional issues and fixed them where the error / warning was appropriate.

Please try it out and give feedback 😃

@KingSora Please also note that the order of the keys matters according to the docs

Conditional exports: https://nodejs.org/api/packages.html#conditional-exports

Node.js implements the following conditions, listed in order from most specific to least specific as conditions should be defined…

Good day @krutoo

overlayscrollbars-react package.json looks like this: https://cdn.jsdelivr.net/npm/overlayscrollbars-react@0.5.3/package.json

It defines the exports, main and module fields.