Source maps having wrong paths
See original GitHub issueDescribe 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:
- Created 3 years ago
- Comments:11 (6 by maintainers)
Top GitHub Comments
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.This is resolved in v3 so I will close this for now