node-semver icon indicating copy to clipboard operation
node-semver copied to clipboard

[ENHANCEMENT] Publish package as standard JS modules

Open justinfagnani opened this issue 1 month ago • 13 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current Behavior

This package is currently published as CommonJS modules only. This makes it impossible to use in browsers and other environments that don't support Common JS, without a build step.

Expected Behavior

This should just work with a suitable import map:

import semver from 'semver';

This could be done as part of a migration to standard JS modules only, or a dual-mode package, possibly as part of https://github.com/npm/node-semver/issues/498

Steps To Reproduce

  1. In a browser
  2. With dev server that can rewrite bare module specifiers to URLs (such as @web/dev-server with the --node-resolve flag)
  3. Load a module script with import semver from 'semver';
  4. See error...

Environment

  • npm:
  • Node:
  • OS:
  • platform: All browsers, Cloudflare Workers, more...

justinfagnani avatar May 08 '24 14:05 justinfagnani