BREAKING CHANGE: Remove the minified UMD build from the package.
Minified code is hard to audit and since this is a widely used library
it seems more appropriate nowadays to optimize for auditability than to
ship a legacy module format that, at best, serves educational purposes
nowadays.
For production browser use cases, users should be using a bundler. For
educational purposes, today's online sandboxes like replit.com offer
convenient ways to load npm modules, so the use case for UMD through
repos like UNPKG or jsDelivr has largely vanished.
Fixes#620
Jest runs browser tests in a jsdom environment which now also supports
web crypto polyfills.
Since ESM support in Jest is currently still limited, it requires a
commonJS build for browser environments, see the discussion in
https://github.com/uuidjs/uuid/pull/616 for all the details.
Co-authored-by: Christoph Tavan <[email protected]>
Co-authored-by: Simen Bekkhus <[email protected]>
While ESM support has been stable in current versions of Node.js 14.x and 16.x, support for importing JSON files is still experimental and evolving.
Since we still want to cover the fact that the package is exporting it's package.json file, this test is now extracted to only run with the updated JSON import syntax which requires import assertions and which was introduced in Node.js 16.14.0.
Fixes#619
Co-authored-by: Robert Kieffer <[email protected]>
It appears that react-native and some bundlers rely on being able to
introspect the package.json file of a npm module. After adding the
`exports` field to package.json, only the paths defined in that field
are accessible to Node.js. In order to support introspection of the
package.json file itself it has to be listed as an export as well (see:
https://github.com/ai/nanoevents/issues/44#issuecomment-602010343).
It is currently being discussed to change Node.js' behavior again, see:
https://github.com/nodejs/node/issues/33460
Until then, adding package.json to the exports field should result in
minimum breakage.
Fixes#444
* test: test imports with npm package contents
Especially for publishing CommonJS/ESM/Browser dual packages a lot can
go wrong in the actual build and release step, see:
https://medium.com/javascript-in-plain-english/is-promise-post-mortem-cab807f18dcc
In order to catch regressions with respect to the supported ways of
importing this library it makes sense to test this using `npm pack`.
Fixes#424
* chore: ignore *.tgz files
* build: run build as prepack command
This simplifies using npm pack in CI tests.
Since we have a build step now we must point the package.json file
reference to the dist folder and must explicitly list all files that we
want to be included in the npm tarball.
The initial idea was to prepare the contents of the final npm tarball
all in the dist directory (including a copy of the package.json) but
that turns out not to work particularly well with standard-version which
is used to manage the version numbers and changelog.
Unfortunately this change also required a small workaround to allow
local installation of the uuid module in the examples (see .local/).
Also instructions for relasing a new version have not yet been
documented which is finally done here.
Since we now explicitly list all files to be included in the tarball
through the files property of package.json we no longer need the
.npmignore file.