starknet.js
starknet.js copied to clipboard
starknet.js is not working from CDN
I want to use starknet.js in a simple web app built with vanilla HTML/CSS/JS with nothing like npm, yarn, webpack, react ....
The first way that come to mind is to use a complied and minified Javascript hosted on some CDN which I did and got the following error in the browser console:
Uncaught ReferenceError: exports is not defined
at index.js:28:23
Reproduction
Create an HTML file with the following content and open it in the browser, open the console in the developer tools to see the error
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/index.min.js"></script>
</head>
<body>
<p>This is an example of a simple HTML page with one paragraph.</p>
</body>
</html>
Notices the same Issue when doing local npm link and run in browser js app. I suppose it is a build module type issue but didn't had time jet to tackle it.
Notices the same Issue when doing local npm link and run in browser js app. I suppose it is a build module type issue but didn't had time jet to tackle it.
Yes. Same for me, I tried to build the npm package and use the the resulted index.js file and had the exact same problem. I also think this could be solved with some tsconfig.json tweaking, this is literally blocking the development of our project, do you have an idea about when could we expect a solution for it ?
this is literally blocking the development of our project
as an open source project, we‘re always happy about contributions!
this is literally blocking the development of our project
as an open source project, we‘re always happy about contributions!
Sure, although I'm not a Javascript/Typescript dev myself I tried to solve the problem by Googling, Stackoverflow without success, I also reached out to some Frontend devs I know to see if they have anything to suggest, nothing worth sharing for the moment but I'll definitely contribute the solution If I found any
I'm also open for your directions and suggestions on what you suspect could be the issue or what I should learn/know to be able to debug it and fix it myself.
+1
If you need this feature ASAP there is a draft PR linked to this issue that can help you get unblocked. If you switch to the corresponding branch and execute npm run build -- --platform browser it should result in a dist/index.global.js file that can be used in the way described in the opening comment.