Make it easier to identify the format of a package #128405
Replies: 0 comments 17 replies
This comment was marked as off-topic.
This comment was marked as off-topic.
-
@Ethan-Arrowood have you seen this? npm/rfcs#126 |
Beta Was this translation helpful? Give feedback.
-
As a first step, it would be great to surface descriptive information about a package's exports in the npm website's sidebar. Rather than listing permutations of entry points and mainFields, something higher-level:
The "ES Modules" criteria could be that all non-bare import specifiers are directly resolvable to filepaths. That would help drive folks to using ESM as-specified, rather than "transpile-only" or "bundler-only" ESM with intermixed CommonJS semantics. |
Beta Was this translation helpful? Give feedback.
-
What would be the behavior for packages that have multiple entry points?
I'd presume it is a sum of some sorts. |
Beta Was this translation helpful? Give feedback.
-
(continuing from npm/feedback#634) What about providing a badge for "requireable" and "importable"? "main" and/or "exports" can indicate whether a package is requireable and/or importable. Any ESM-only package would be only importable, any CJS-only or dual package would be both, a package with C++ entry points would be only requireable, any package that has no entry points would be neither. That would map neatly to what node supports, and what bundlers expect. |
Beta Was this translation helpful? Give feedback.
-
Use case I’m having right now: For testing, I’m using an ESM loader hook to replace the built-in Thus, I think both is useful information:
In a way, these are different degrees of ESM support. |
Beta Was this translation helpful? Give feedback.
-
Problem Statement
While individuals can use keywords to help sort / identify a package it is not an exact or reliable way of identifying the format of a package or the runtime it is expected to be executed in. I've heard feedback from those new to the JavaScript ecosystem that sometimes it can be very hard to know where they can run something once they've
npm install
'd it.Some example identification includes:
Potential Solutions
There are a couple of different ways this could be solved on the backend ranging from static analysis of the source text to examining fields in the
package.json
includingpackage.exports
,package.module
, andpackage.main
.As a consumer of packages it would be nice to have a way of surfacing these details in both the cli and the website. This information could also be useful when searching for modules.
Beta Was this translation helpful? Give feedback.
All reactions