WordPress.org

Make WordPress Core

Opened 9 months ago

Last modified 7 months ago

#24879 new enhancement

Sourcemaps should be provided for use with minified javascript libraries

Reported by: jblz Owned by:
Milestone: Awaiting Review 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 (7)

comment:1 follow-up: jblz9 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 kadamwhite9 months ago

  • Cc kadamwhite added

comment:4 WraithKenny8 months ago

  • Cc Ken@… added

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

comment:6 WraithKenny7 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 WraithKenny7 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.

Note: See TracTickets for help on using tickets.