Make WordPress Core

Opened 11 years ago

Last modified 7 years ago

#24879 new enhancement

Sourcemaps should be provided for use with minified javascript libraries

Reported by: jblz's profile jblz Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: dev-feedback needs-patch
Focuses: Cc:

Description

Sourcemaps make it possible to debug minified files.

Supported in Chrome:
https://developers.google.com/chrome-developer-tools/docs/javascript-debugging#source-maps

Landing in Firefox in v23:
https://wiki.mozilla.org/DevTools/Features/SourceMap

When this feature is enabled, the Chrome console currently shows a 404 when the script specifies a sourcemap file and it isn't found.

Change History (14)

#1 follow-up: @jblz
11 years ago

jQuery provides a sourcemap:
http://blog.jquery.com/2013/01/09/jquery-1-9-rc1-and-migrate-rc1-released/#sourcemaps

But since we're customizing it ( see [24791] & #24821 ), we'd need to include our own source & sourcemap files.

#2 @kadamwhite
11 years ago

  • Cc kadamwhite added

#4 @WraithKenny
11 years ago

  • Cc Ken@… added

#5 in reply to: ↑ 1 @hakre
11 years ago

Replying to jblz:

jQuery provides a sourcemap:
http://blog.jquery.com/2013/01/09/jquery-1-9-rc1-and-migrate-rc1-released/#sourcemaps

But since we're customizing it ( see [24791] & #24821 ), we'd need to include our own source & sourcemap files.

If the sole need of an edit is to add some initialization code after the file has been enqueued, I think it's better to not touch the upstream files but just add the initialization code as data, for example see #25277.

Also according to http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/?ModPagespeed=noscript it is explained that you can use any scripts you want with such maps, it is just that your compiler/minified needs to have support for it.

So this might be something easy to fix in the build process, see [25001]

Last edited 11 years ago by hakre (previous) (diff)

#6 @WraithKenny
11 years ago

https://github.com/mishoo/UglifyJS2#source-map-options

https://github.com/gruntjs/grunt-contrib-uglify#source-maps

The grunt file looks to be using UglifyJS2, which supports source-maps, which means we can just set the proper configuration.

#7 @WraithKenny
11 years ago

Another option is to delete the sourcemap line out of the comment header at the same time the no conflict line is added, but I really believe that adding the proper source map is a better solution. For that, the removal of the production version should be reverted, and it should be minified as part of the build process, and generate the sourcemap at the same time.

#8 @wonderboymusic
10 years ago

  • Milestone changed from Awaiting Review to 4.2

We should look at our JS in 4.2

This ticket was mentioned in Slack in #core by drew. View the logs.


10 years ago

This ticket was mentioned in Slack in #core by drew. View the logs.


10 years ago

This ticket was mentioned in Slack in #core by drew. View the logs.


9 years ago

This ticket was mentioned in Slack in #core by drew. View the logs.


9 years ago

#13 @DrewAPicture
9 years ago

  • Milestone changed from 4.2 to Future Release

Doesn't seem to be much interest in pursuing this, and no activity here in about a month. Punting.

#14 @swissspidy
7 years ago

  • Component changed from External Libraries to Build/Test Tools
  • Keywords needs-patch added

I think we should extend the Grunt tasks to generate source maps when we ship both unminified and minified versions of a library.

Note: See TracTickets for help on using tickets.