WordPress.org

Make WordPress Core

Opened 19 months ago

Last modified 32 minutes ago

#24879 new enhancement

Sourcemaps should be provided for use with minified javascript libraries

Reported by: jblz Owned by:
Milestone: 4.2 Priority: normal
Severity: normal Version:
Component: External Libraries Keywords: dev-feedback
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 (11)

comment:1 follow-up: @jblz19 months 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.

comment:2 @kadamwhite19 months ago

  • Cc kadamwhite added

comment:4 @WraithKenny18 months ago

  • Cc Ken@… added

comment:5 in reply to: ↑ 1 @hakre18 months 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 18 months ago by hakre (previous) (diff)

comment:6 @WraithKenny18 months 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.

comment:7 @WraithKenny18 months 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.

comment:8 @wonderboymusic8 weeks ago

  • Milestone changed from Awaiting Review to 4.2

We should look at our JS in 4.2

comment:9 @slackbot4 weeks ago

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

comment:10 @slackbot3 weeks ago

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

comment:11 @slackbot32 minutes ago

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

Note: See TracTickets for help on using tickets.