ui: Allow disabling of sourcemaps via env var #10491
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The rebuild of the Consul UI used very minimal ES6 features for 2 reasons:
Sets
andMaps
in handlebars templates for example)We had a period of time that we were we started moving to use more ES6 style syntax, but pretty soon after that we reduced our browser support (#9729) by not supporting anything older than ~2016. This brought us back to being able transpile as little as possible (decorators are so necessary for ember work we can't really avoid having to transpile those until they are native), and thus removing extra layers again. This means that sourcemaps aren't that much of a necessity again (depending on what your preference is)
Additionally, for a good while now I've noticed that since we enabled sourcemaps, they don't really work correctly in Ember. I often find myself debugging something and the stack trace line numbers are completely wrong, often reporting line numbers of over 1000 when the file where the error is is only a few lines long, it even sometimes gives me minus numbers. This can sometimes make chasing down errors a little frustrating as it is essentially saying 'the error is....umm I dunno, somewhere in this file but I'm not sure where'.
Here's one I noticed today which points me to line 1336 in a file of only 85 lines.
And another from a few days ago telling me the error was in a comment
I've also heard both online and offline that there are problems with sourcemaps and ember, potentially related to ember-auto-import, and this might be the root of the problem. Its a strange one, as you don't notice at first, and the line numbers seem fine to begin with, but as time goes on the line numbers seem to get wildly out of kilter.
I've experimented a little with turning sourcemaps off again and I no longer seem to have problems with line numbers and my browser points me to exactly where the error is within the file. As we aren't really doing much transpilation, this is much easier for me to read and figure out what is happening.
Therefore (for the moment at least) I personally prefer not to have sourcemaps enabled, but I understand other folks might not. This PR makes enabling/disabling sourcemaps possible via a local environment variable, so I can choose what is best for me whilst not affecting anyone else and not have to remember to not commit change in our config files that I use just for myself.
We can revisit this when the new ember build tooling is ready for prime time, but if you don't set the environment variable then there is no real change here.