-
Notifications
You must be signed in to change notification settings - Fork 304
Sourcemaps appear to be broken when uglify/--prod task is used. #1235
Comments
This bug makes it impossible for us to upload source map files to sentry. Is this something you're going to fix or do we have to create a workaround for this? I'm asking because we have a product launch within the next couple of weeks. @kensodemann An official comment would be appreciated here. Cheers |
Is this resolved now? We have made changes to the source maps. Not sure if they'll fix the issue with Sentry or not. I know the changes we made improved our own error tracking service. Thanks, |
Hey @danbucholtz , the source maps are correctly generated when I'm using the --aot flag but it's still not working when I'm running it with the --prod flag. There's something going on with the minification .... |
Thanks for your work in this. I haven't been able to successfully test this yet as upgrading has caused other project related problems (not related to app scripts itself). I should be able to test in a few days time. |
Any news on this? Trying to get sourcemaps working with the |
Hi @danbucholtz, Apologies in the delay getting my app tested with v3. Unfortunately all the issues I have are still present:
Is there anything I can do to help? Thanks. EDIT: Formatting fixes. |
Anyone found a workaround for building production apps while App-Scripts v3.0.0 is in place? I want to upgrade ionic framework to latest v3.7.1 which uses app-scripts v3.0.0 but this bug is a show-stopper. Right now I'm in ionic v3.6.1 and using App-scripts v2.0.1. |
I've updated everything on my app and got --prod builds to work with the latest and greatest ionic tools. I'm not sure if it's ionic-angular or the ionic-cli that resolved the issue. I didn't test the sourcemaps but they were generated and no errors were shown with @killerchip I found a workaround using app-scripts 3.0 and ionic-angular 3.7.1 (I actually tested with a snapshot build, specified as My --prod build did take some time (approximately 12 minutes), they worked for both Android and iOS. My ionic info:
|
It seems that it has something to do with my environment in Mac. I have tested compiling in a Windows host and it works fine even with not the latest and greatest npm/node, etc. |
I nuked everything. ionic, cordova, npm, node. I re-installed them from scratch to their latest versions...
The behavior remains the same. Next thing I'm thinking... I may even nuke my whole MacOS. Return it to factory default update to latest and see how this goes. It's getting pretty weird this issue. |
Hi, In regards to my original issue (the sourcemaps not being correct), has there been any progress on this? Has it been assigned to anyone on the Ionic side to look at? Apologies for asking again but I need to update Ionic to 3.8.0 to support iPhone X for next week but that will break my error logging so it's not an ideal situation either way as it stands. Pinging @danbucholtz who initially responded to this. Thanks. |
Hi,
After building (via One problem is the Below are the versions I'm using:
|
@ttphi88 Dude, you've just saved me a ton of time! Your solution works like a charm 👍 👍 👍 Thanks for posting it!!! |
Is anyone able to get automatic |
Having same problem as @doender. This has been going on for months. A solution forthcoming from the Ionic team would be appreciated. |
@c0bra I agree. Until then I call the following node script after every build to add the source mapping URLs.
|
Thanks @c0bra for the snippet! For my use case I've modified it a bit and can share here too (TypeScript): to be executed like this: import * as fs from 'fs-extra'
import * as path from 'path'
import { wwwDir } from '../cnst/paths.cnst'
import * as yargs from 'yargs'
const argv = yargs.argv
const buildDir = argv.dir || wwwDir + '/build'
if (!fs.existsSync(buildDir)) {
console.warn('Dir does not exist: ' + buildDir)
process.exit(-1)
}
doWork()
.then(() => console.log('done'))
.catch(err => {
console.error(err)
process.exit(1)
})
async function doWork () {
let saved = 0
fs.readdirSync(buildDir)
.filter(f => f.endsWith('.js'))
.forEach(fileName => {
const filePath = path.join(buildDir, fileName)
const mapPath = filePath + '.map'
if (!fs.existsSync(mapPath)) return
let content = fs.readFileSync(filePath).toString('utf8')
if (content.endsWith('.js.map')) return // make idempotent
content += `\n//# sourceMappingURL=${fileName}.map`;
fs.writeFileSync(filePath, content)
saved++
})
console.log(`${saved} files saved in ${buildDir}`)
} |
Thanks @c0bra! Just want to add for those of us wanting to run this as a Cordova hook:
|
Note: the snippet is from @doender :) Credit where credit is due. |
Short description of the problem:
For info, the below behaviour of generating production sourcemaps worked correctly in v1.3.12 so I feel like this is a potential regression or bug.
When setting
ionic_generate_source_map
to true and runningionic build --prod
, the sourcemaps produced seem to be broken as they are significantly different when compared toionic build
based sourcemaps with several base64 chunks and random blocks of code seemingly in the wrong position. When checking the sourcemaps with Raygun The same part of the sourcemap always returns when querying different lines/columns. ThesourceMappingURL
is also missing on main.js & vendor.jsI believe the problem occurs when the uglifyjs task is ran as it doesn't occur on
ionic build
for example. I tried to provide my own config based on a modified default config to uglifyjs with sourcemaps set to true to no effect.Also, when setting
ionic_generate_source_map
to true, vendor.js.map isn't copied over to the sourcemaps folder.The reason for needing sourcemaps based on --prod code is for error tracking.
I've spent a few hours looking at the app-scripts workflow but couldn't quite work out where the uglifyjs sourcemap options were getting added but I'd be happy to look more into this if I could get some guidance and help as to where to look.
There are some similar-ish tickets to my one but they refer to different aspects of sourcemaps, eg the mappingurl being an absolute path, not completely missing so I don't think this is a duplicate.
Thanks.
What behavior are you expecting?
To summarise, I'd expect when running the build task with
--prod
flag://# sourceMappingURL=main.js.map
to be present in main.js,//# sourceMappingURL=vendor.js.map
to be present in vendor.js,vendor.js.map
should be copied into the.sourcemaps
directory,Steps to reproduce:
ionic build
and save sourcemaps somewhere,ionic build --prod
and compare sourcemaps.Which @ionic/app-scripts version are you using?
2.1.4
The text was updated successfully, but these errors were encountered: