Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unpkg.com browser Error: Uncaught RefereceError: exports is not defined #75

Closed
cmdruid opened this issue Oct 19, 2022 · 5 comments
Closed

Comments

@cmdruid
Copy link

cmdruid commented Oct 19, 2022

secp256k1@1.7.0:3 Uncaught ReferenceError: exports is not defined
    at secp256k1@1.7.0:3:23
(anonymous) @ secp256k1@1.7.0:3

Hello. I am getting this error when trying to import the library into the browser, from the following URL: https://unpkg.com/@noble/secp256k1@1.7.0

I do not get this problem when I import the file from the github releases page, or locally from my machine.

I think there may be a mis-configuration somewhere (package.json?), as unpkg.com is not properly hosting a browser version of the file , even though it seems to work fine when I import the file from other sources.

This is not a critical issue. I thought to bring it up since unpkg.com is useful as a CDN, and it would be nice to pull a working version from there.

@paulmillr
Copy link
Owner

You should report this to unpkg. I am not familiar with their build system, it could be their error.

We support deno, webpack, browserify, rollup, standalone file, etc -- hard to ensure everything works properly.

@cmdruid
Copy link
Author

cmdruid commented Oct 19, 2022

unpkg.com is run by npmjs.com and is their automated CDN service.

NPM supports a "unpkg" keyword in package.json to point towards a browser-compatible build. It tells NPM specifically which file in your package to make available on their unpkg CDN.

I think something like "unpkg": "lib/index.js" would work as an example. If you have any questions about it, please let me know!

I do not mean to make a big deal out of it, just I would like to import using unpkg.com/@noble/libsecp256k1 versus github.com/paulmillr/noble-secp256k1/releases/download/1.7.0/noble-secp256k1.js (also not deal with CORS issues from github imports). Thank you for responding!

@paulmillr
Copy link
Owner

I can change package.json, but did you actually test the change? I don't want to do a broken release

@cmdruid
Copy link
Author

cmdruid commented Oct 19, 2022

I did a test deployment and submitted a PR. No need to merge, just demonstrating the minor changes to get it working with NPM's unpkg CDN. See here:

#76

@paulmillr
Copy link
Owner

v2.0 will be unpkg-friendly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants