Replies: 2 comments 7 replies
-
fwiw I’ve been working on npmjs.com/list-exports which can help with this, and after an upcoming overhaul I’ll be working on a package to achieve exactly this behavior. |
Beta Was this translation helpful? Give feedback.
-
I don't think this check should be enabled in npm by default. While npm packages are expected to follow SemVer, this isn't a requirement, and some popular packages like TypeScript and Prettier don't adhere fully. Seeing a warning that you're not following SemVer when it's intentional could be confusing. I think this is more of an education issue, so I'd prefer clarifications in docs and other messaging. A general tool or opt-in check (possibly part of |
Beta Was this translation helpful? Give feedback.
-
Many people don't seem to realize that changes in a package's exports are usually (if not always?) a breaking change. Today we had a team unsuspectingly change their package exports from:
to:
Where the former will only allow imports like:
import 'my-package';
, and the latter only allows imports like:import 'my-package/index.js';
, (and thus breaking any existing imports for'my-package'
)And this is something I've seen many packages do as well; changing and/or adding package exports in a minor or patch version, and frankly, has become a bit of a pain to deal with over time.
It feels like NPM could be doing more to educate and or warn about these things. I'm not sure if any of these are viable solutions, but I'd just like to create this post as a point of feedback and starting point for discussion to see if this can't be improved in any way:
npm publish
, if the publish is a minor or patch version, detect if the publish contains breaking changes in the package exports by comparing to the previous published version, and warn the user publishing about thisnpm install
, if a package is installed with a higher minor or patch version contains a breaking change in the package exports, log a warning to the terminalI'd be happy to discuss other options, by in any case it would be great to see if we could somehow improve on this 🙂
Beta Was this translation helpful? Give feedback.
All reactions