question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Source maps having wrong paths

See original GitHub issue

Describe the bug I am developing a cross-platform application, and part of that is using @capacitor-community/electron for desktop. The build and export itself works fine, and the electron application is functioning, but I cannot get the source maps to work.

I am updating the electron build like this: ionic cap sync

And then run it by going to the electron directory and: npm run build && electron ./

It seems to me that the .map files are just blindly copied from root/build/static/js to root/electron/app/static/js. Naturally, the paths inside of the .map files won’t work in that location, as an additional “…/” (or even “…/…/”?) would be required.

The errors all look like this:

devtools failed to load sourcemap could not load content for “capacitor-electron://-/static/js/16.45739f90.chunk.js.map”

Is there a way to tell ionic (or capacitor) to change the paths so that the source maps will work with the electron target? I’m not entirely sure if this is a bug or something additional I’d need to do to make it work properly.

Desktop (please complete the following information):

  • OS: Manjaro Linux

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
TheSHEEEPcommented, Jul 31, 2020

I think there might be a misunderstanding here.

The error message doesn’t say that the .map file cannot be found. The path capacitor-electron://-/static/js/27.f5e6c67c.chunk.js.map is correct (assuming that capacitor-electron://-/ leads to root/electron/app). However, the path inside of the .map file is incorrect.

For example, one of my .map files begins like this:
{"version":3,"sources":["../node_modules/@ionic/core/dist/esm-es5/swipe-back-0a6a44c8.js"] ... That path, "../node_modules/@ionic/core/dist/esm-es5/swipe-back-0a6a44c8.js", works if you assume root/build to be the working directory (or the directory where whatever resolves the path starts looking). However, it does not work if the working directory is root/electron/app, as that would require the path to become "../../node_modules/@ionic...".

The error says could not load content for ... - it doesn’t say that it cannot find the file itself.

0reactions
IT-MikeScommented, May 4, 2021

This is resolved in v3 so I will close this for now

Read more comments on GitHub >

github_iconTop Results From Across the Web

gulp - Sourcemaps are in wrong location or have incorrect paths
Outcome: writes a separate sourcemap, but the sourceRoot says '/sources/' (WTF is that?!, it doesn't exist and I never configured it) and the ......
Read more >
4 Reasons Why Your Source Maps are Broken - Sentry Blog
Missing or incorrect source map directive ... If it is a relative URL, it is relative to the path location of the bundled...
Read more >
Source Map & Webpack file path issues - Roots Discourse
Does anyone have an explanation for this? Sourcemaps not working correctly // wrong paths in dev tools. Source Map Webpack 5 pointing to...
Read more >
Easy JavaScript error investigation with Source Maps - Elastic
One issue you may have experienced is the challenge of finding the source of errors for minified JavaScript files.
Read more >
Source Maps - Rollbar Docs
For the full details of stack traces to appear we need to have information about column numbers in the error object. You'll get...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found