[BUG] ReferenceError: exports is not defined
Bug Description
I wanted to sign a transaction directly on postman. It seems it should be possible to dynamically load a library as shown below but it is not working
Steps to Reproduce
-
In postman create a dummy request with the following Pre-request script pm.sendRequest("https://unpkg.com/@bsv/sdk", (err, res) => { //convert the response to text and save it as an environment variable pm.collectionVariables.set("bsv", res.text());
// eval will evaluate the JavaScript code and initialize the min.js eval(pm.collectionVariables.get("bsv"));
//use the library to sign a transaction and broadcast it via ARC })
- Send
Expected Behavior
Library is loaded and you can use it to sign, broadcast via ARC, etc.
Actual Behavior
Reference error: exports is not defined
Stack Traces or Screenshots
Environment
- OS: Windows
- Node version: n/a
@bsv/sdkversion: 1.0.18
Additional Information
Not sure if this is actually a bug as this is a very specific use case
More an environment incompatibility. Definitely worth investigating how to use the library in such an environment.
@domingotaal you should be able to access the TS SDK modules from the unpkg cdn in a non-standard environment, such as Postman, once the above PR is merged and published to npmjs.
Currently the main entry point is set to commonJS, so you'll have to reference this bundled JS file: https://unpkg.com/@bsv/[email protected]/dist/umd/bundle.js
Tested creating an instance of the PrivateKey class with a throwaway hex private key: