Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

complete 1.js file is being displayed in the terminal if ganache used programatically #2289

Open
aniketpcsync opened this issue Feb 5, 2022 · 6 comments

Comments

@aniketpcsync
Copy link

In my project i was using ganache programatically and passing options as an argument to the provider. If any error occurs it should show only error but it prints complete 1.js file in the terminal in my node project.
We can handle the issue with, 1. Prettifying minified 1.js file and other is to use try catch whenever using ganache instance.
This problem is similar to solidity's solcjson.js error.
var ganache = require('ganache');
options = { miner: { blockGasLimit: "5F5E100" }, }
provider = ganache.provider(options);
Here gaslimit should be in hex but i have put this without 0x to recreate the errror.
It would be great if this problem is solved.

@davidmurdoch
Copy link
Member

Can you try loading the source-map-support package before ganache and let me know if that works? https://www.npmjs.com/package/source-map-support

@davidmurdoch
Copy link
Member

Dev note: We should probably reconsider our minification approach for our node bundle, as I doubt it doesn't anything to decrease bundle size since we ship the source maps anyway. We should keep it for the browser bundle since the browser won't download and parse it unless needed, whereas node's source-map-support eagerly loads and parses it immediately (or maybe we should ship the browser bundle as a separate package 🤔).

@aniketpcsync
Copy link
Author

aniketpcsync commented Feb 5, 2022

Can you try loading the source-map-support package before ganache and let me know if that works? https://www.npmjs.com/package/source-map-support

Thank you for the solution ! It is working, can you explain a little about this package and why is this type of error occuring.
Does it have any downsides? is it good for production level code?

Dev note: We should probably reconsider our minification approach for our node bundle, as I doubt it doesn't anything to decrease bundle size since we ship the source maps anyway. We should keep it for the browser bundle since the browser won't download and parse it unless needed, whereas node's source-map-support eagerly loads and parses it immediately (or maybe we should ship the browser bundle as a separate package thinking).

there 200kb size difference from minified version but in solc case there was none.

@davidmurdoch
Copy link
Member

We bundle our packages to reduce installation time, and at the same time we minify it all. In doing so we generate source maps, files that can map characters in the minified file to their original source.

Node.js doesn't automatically read these source map files (but browsers do, in certain situations), so you have to use source-map-support to add support.

The downside to using source-map-support for you is that this will slow down the initialization of your application (i'm not sure how slow ganache's source map loading can be). There is also a downside for everyone, even if they don't use source-map-support, since it increases our bundle size, which defeats the purpose of minifying in the first place!

@aniketpcsync
Copy link
Author

We bundle our packages to reduce installation time, and at the same time we minify it all. In doing so we generate source maps, files that can map characters in the minified file to their original source.

Node.js doesn't automatically read these source map files (but browsers do, in certain situations), so you have to use source-map-support to add support.

The downside to using source-map-support for you is that this will slow down the initialization of your application (i'm not sure how slow ganache's source map loading can be). There is also a downside for everyone, even if they don't use source-map-support, since it increases our bundle size, which defeats the purpose of minifying in the first place!

Thank you so much for the answer !

@martinheidegger
Copy link

Just to add user story: I tried upgrading a bunch of dependencies including ganache and the tests stopped passing, triage using sourcemaps is one thing, but by deploying ganache as minimized blob its really hard to add log statements to figure out where/how things fail.

@davidmurdoch davidmurdoch moved this to Inbox in Ganache Jul 19, 2022
@davidmurdoch davidmurdoch moved this from Inbox to Backlog in Ganache Jul 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Status: Backlog
Development

No branches or pull requests

4 participants