PeculiarVentures / x509

@peculiar/x509 is an easy to use TypeScript/Javascript library based on @peculiar/asn1-schema that makes generating X.509 Certificates and Certificate Requests as well as validating certificate chains easy
https://peculiarventures.github.io/x509/
MIT License
78 stars 10 forks source link

Package import is empty #13

Closed donskov closed 2 years ago

donskov commented 2 years ago

Package version

@peculiar/x509@1.4.1

Usage example

import * as x509 from '@peculiar/x509';

console.log(x509); // -> {default: {}}

Usage environment

Project created using https://create-react-app.dev/.

Problem description

If your module is meant to be used client-side the browser field should be used instead of the main field. This is helpful to hint users that it might rely on primitives that aren't available in Node.js modules. (e.g. window)

Based on https://docs.npmjs.com/cli/v7/configuring-npm/package-json#browser.

Solution

Use:

"unpkg": "build/x509.js",

Instead of:

"browser": "build/x509.js",

https://github.com/PeculiarVentures/x509/blob/master/package.json#L7

ThibsG commented 2 years ago

Hi, we just hit the same issue. For what it's worth, we found a workaround by importing from '@peculiar/x509/build/x509.es.js' instead of just '@peculiar/x509' (see this answer: https://stackoverflow.com/a/68722155).

microshine commented 2 years ago

I published the new version @peculiar/x509@1.5.0. It includes unpkg field instead of browser

Please try it

donskov commented 2 years ago

@microshine Thank you. It works for me.