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

Source maps are lost during bundling. #401

Closed
MicahZoltu opened this issue Jan 24, 2019 · 7 comments
Closed

Source maps are lost during bundling. #401

MicahZoltu opened this issue Jan 24, 2019 · 7 comments
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published.

Comments

@MicahZoltu
Copy link

The sourcemap for ethers.min.js is not the original easy-to-read TypeScript, but instead the compiled TypeScript output. The build system appears to be dropping the TypeScript sourcemap when minifying/bundling down to ethers.min.js. It would be nice if the build system kept the original TypeScript in the source map instead.

I think most major build tools know how to merge sourcemaps, so if you are generating TS source maps the bundler/minifier should be able to turn those into a single bundled source map. Of course, the process is different for every bundler.

@ricmoo
Copy link
Member

ricmoo commented Jan 24, 2019

Would love assistance on this, if you know how to get the tools to knock out the right map files. :)

@ricmoo ricmoo added help-wanted Looking for others' assistance or input. discussion Questions, feedback and general information. labels Jan 24, 2019
@MicahZoltu
Copy link
Author

It may be as simple as adding "sourceMap": true to https://github.com/ethers-io/ethers.js/blob/master/tsconfig.json#L3-L23. I would recommend trying that first and seeing if everything else "just works". If not, you'll need to illicit support from someone familiar with your particular set of build tools, which looks like browserify based on dependencies?

Either way, I recommend adding "sourceMap": true as it will make debugging in nodejs a tad better at least, even if it doesn't help with browser due to the maps getting lost during minification.

@ricmoo
Copy link
Member

ricmoo commented Jul 5, 2020

Is this still an issue in v5? If so, anyone who can demonstrate how to fix it, let me know. Otherwise I may close this soon.

Thanks! :)

@MicahZoltu
Copy link
Author

Looking at https://github.com/ethers-io/ethers.js/blob/master/tsconfig.package.json, the answer appears to be "yes this is still an issue" since that is still missing the source maps flag. I can't say whether that alone will fix it (I believe you use a bundler, which needs to do the right thing with the source TS source maps), but I can say with quite a bit of confidence that without the fix I described above, you definitely won't have functional source maps.

@ricmoo ricmoo added fixed/complete This Bug is fixed or Enhancement is complete and published. and removed help-wanted Looking for others' assistance or input. labels Nov 24, 2020
@ricmoo
Copy link
Member

ricmoo commented Nov 24, 2020

I believe this should be fixed now. Source maps are carried through the build process and with the aid of source-map-support, I even get the TypeScript location and context of errors now.

Let me know if your milage differs, otherwise I'll close this. :)

@ricmoo ricmoo added enhancement New feature or improvement. and removed discussion Questions, feedback and general information. labels Nov 24, 2020
@MicahZoltu
Copy link
Author

I'm not using ethers.js in any projects at the moment, so I cannot test myself. It may be worth also adding https://www.staging-typescript.org/tsconfig#declarationMap as well to improve developer experience (it is a relatively new addition to TS), but that is unrelated to the source map problem.

@ricmoo
Copy link
Member

ricmoo commented Feb 1, 2021

I've added declaration maps in 5.0.27.

If you have any issues, please let me know. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improvement. fixed/complete This Bug is fixed or Enhancement is complete and published.
Projects
None yet
Development

No branches or pull requests

2 participants