-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
bug: source maps are not loaded when debugging with chrome dev tools on device #16455
Comments
I have this problem too. I am only able to debug by putting in |
@manucorporat it here any way to add source maps to Android, too? I can confirm this issue |
Same problem. This occurs with either of Capacitor or Cordova wrapper. Tried adding Debugging the TypeScript when running on an emulator (or device) is still very essential when the app replies on plugin(s) |
Actually, I did get it working by following the above, but I needed to add the Would still be a lot better if we did not have to edit the Angular build file, as this we could forget and lose this if node_modules refreshed. |
Thanks for your investigation! Can you maybe open a feature request at https://github.com/ionic-team/ionic-cli/issues and link this issue here? |
Are you sure that you run the build with --eval-source-map param (as suggested in my original post)? What is @angular/cli version? 7.0.0? |
There are some options to enable this without editing angular sources - see angular/angular-cli#13543 (comment) |
To whom it may concern, here is the approach I implemented to enable debugging with source maps support on Android devices
This is a better approach then changing angular/cli source :) |
I have the same issue. @IonicProSupport I need to debug android devices and for now I am not able, I hope you find a fix soon |
Yes. It is described above and works fine for me. |
@ryaa I tried your solution but didn't work for me.
I hope the @IonicProSupport team find an official solution |
Any updates on this? It is very annoying |
I've done a script to work around this while we wait for the fix, just execute it with node: const fs = require('fs');
const path = 'node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js';
let file = fs.readFileSync(path, { encoding: 'utf8' });
file = file.replace('source-map', 'inline-source-map');
fs.writeFileSync(path, file, 'utf8'); |
@ElianCordoba which version of |
@amb-jarek I'm using |
Same issue here when using
|
在angular.json 添加 evalSourceMap ,plugin 配置 |
Having this too, just bumping the issue...
Added to my
Running Running |
I've successfully got source maps on my device with following workaround: add following to your
Then create let fs = require('fs');
let path = require('path');
const TARGET_DIR = 'www';
module.exports = function (ctx) {
console.log('=====================');
console.log('attaching source maps');
console.log('=====================');
let files = fs.readdirSync(TARGET_DIR);
files.forEach(file => {
let mapFile = path.join(TARGET_DIR, file + '.map');
let targetFile = path.join(TARGET_DIR, file);
if (path.extname(file) === '.js' && fs.existsSync(mapFile)) {
let bufMap = fs.readFileSync(mapFile).toString('base64');
let bufFile = fs.readFileSync(targetFile, "utf8");
let result = bufFile.replace('sourceMappingURL=' + file + '.map', 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + bufMap);
fs.writeFileSync(targetFile, result);
}
});
}; At the end adjust script to your needs - eg disable it for prod build |
@amb-jarek can you give some more information? What is your |
provided hook is working for me when I execute:
or
|
Angular CLI will never allow devtools options for inline-source-maps. Search the Angular CLI issues. I cannot understand this decision. Anyway... The problem with the DevTools in Chromium (device inspect) is that the url of source maps refer to "localhost". The localhost of the device. But the DevTools does not know the url of the device. So it is trying to fetch from the localhost of the computer. So, what can we do?
Conclusion: Sadly the Angular CLI team will not provide a inline source map option. See issue Life would be a lot easier with this option. ... That is disappointing. |
Serving the files from the computer is exatly what is happening with livereload as i mentioned here. You need to set the url to use by using the |
Is official Live Reload support planned? A full rebuild for every small change is the worst way to work. I'm on Cordova + Angular 9 + Ionic stack, any kind of fast dev-work seems impossible. ionic-team/ionic-app-scripts#822 I hope this issue doesn't get closed without a fix like the previous threads. |
The above does not work for the latest angular cli (@angular-devkit/* with version 0.1000.0 and above) To enable this workaround again please update
All the rest is the same |
I'm on Ionic 6, with angular 13 and I can't debug my project on android.... because there are no source-maps Funny thing is: I can debug on iOS because safari's inspect does have the source |
I’m not sure if it’s changed recently, but using Capacitor with Live Reload will result in source maps working on Android (at least it does for us). I know that doesn’t help if the app is using Cordova or there’s a desire to not use Live Reload though. Hope that could help! |
Works for me too. Regarding the "not wanting live reload" aspect: When I was using live reload, Capacitor just set the App-URL in capacitor.config.json to the host IP I handed using the CLI flag. I'm not sure whether that's the only thing that happened, but I guess with a bit of effort one could connect the app to the remote dev server but disable the live reloading. |
No longer working on ionic 6 and Angular 13, is there any updated workaround for this? |
This one works #16455 (comment) |
Indeed, it works, for some reason if I run the commands individually:
doesn't work, but if I add:
Thanks. |
How can I disable this for prod builds? I've been struggling trying to import the environment .ts file into this attach-source-maps.js file, and I can also only use a .js file in the hook. I've also tried the live-reload option but can't get that to work either, we test mostly on emulators and physical devices connected via a cable - does this methods require a device connected via Wi-Fi? It's not a huge problem but just a bit annoying to have to enable and disable the hook manually for prod vs dev builds all the time. Ionic 6 / Angular 13 / Capacitor 3 |
The livereload option definitely worked over cable too. However, the host and the device need to be on the same network and able to reach each other. |
I think that you can:
For example, here is the excerpt for scripts section in my package.json
You will run the dev build as you do now but for the production build issue npm run release:android OR
|
manually attaching the source code is a pain in nx monorepos :/ |
In Capacitor 4.1.0 there is now an option that allows debugging the Android Web View in Chrome/Edge. You run: The argument --inline makes sure the source maps are inlined and you can use chrome://inspect/ or edge://inspect/ to debug into your Typescript code (under the webpack:// tree). |
Hi everyone, As @dtarnawsky mentioned in #16455 (comment), Capacitor 4.1.0 added a new option to inline all source maps when syncing. This makes it possible to get the latest source maps when debugging in a Chromium-based browser. As a result, I am going to close this issue. See Damian's comment above for more information. |
@liamdebeasi liamdebeasi |
Hi there, I do not work on the Capacitor project, so I am unable to assist with this feature request. I recommend opening a feature request on the Capacitor repo. |
@itziksha : thank-you for bringing that up. I 100% agree with you and started discussing that with the Capacitor team this morning. They have asked me to open an internal Jira ticket for them to track. If you do create a feature request as @liamdebeasi suggested, please let me know and I will attach it to the internal Jira ticket. |
I opened a feature request here - ionic-team/capacitor#5900 Thanks. |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Bug Report
Ionic Info
Describe the Bug
TypeScript source maps are not present when debugging on an Android device/emulator.
Steps to Reproduce
Steps to reproduce the behavior:
ionic start sourcemaps blank --type=angular
.ionic cordova prepare android
. SayY
to the prompt to install the Android platform.ionic cordova prepare android
again. It will download/install the Cordova plugins that are part of the template.ionic cordova run android
. This will build the app and deploy it to an Android emulator. You could also choose to deploy to a device by connecting a device configured for debugging and passing the--device
flag to this command.chrome://inspect/#devices
and inspect the Ionic app.Sources
useCmd + P
to search for the source filehome.page.ts
. It will not be found.Related Code
If you are able to illustrate the bug with an example, please provide a sample application via an online code collaborator such as StackBlitz, or GitHub.
Expected Behavior
I expected the TypeScript source files to be present and debuggable with breakpoints in the Chrome DevTools.
Additional Context
This is the same issue as #15152 which has since been closed and locked. While the OP of that issue decided to use Ionic DevApp as a workaround, our application uses a number of additional and different Cordova plugins that make using DevApp unsuitable. I would expect the browser dev tools to work like they have previously in Ionic 3 and like they currently do with iOS.
The text was updated successfully, but these errors were encountered: