Page MenuHomePhabricator

Change the extension of source-map files in webpack.config.js
Closed, ResolvedPublic1 Estimated Story Points

Description

We want to be able to debug bugs in Popups in production. Right now we cannot easily do that and this small change will make that possible.

.map is the default output extension for source-map files in webpack. Since that extension is not whitelisted in production the requests fail when opening devtools, see https://ca.wikipedia.org/w/extensions/Popups/resources/dist/index.js.map

In reality, there is no specific extension for source-map files, and .map is used by convention.

Let's change the extension of the source map files to a whitelisted extension like .json so that we can debug original sources in production.

Context:

AC

Details

Event Timeline

Jdlrobson triaged this task as Medium priority.Aug 18 2017, 8:07 PM
Jdlrobson awarded a token.
Jdlrobson subscribed.

Let's do it!

Jdlrobson set the point value for this task to 1.Aug 22 2017, 4:13 PM

Change 374590 had a related patch set uploaded (by Pmiazga; owner: Pmiazga):
[mediawiki/extensions/Popups@master] Store map files under .json extension

https://gerrit.wikimedia.org/r/374590

@Jdlrobson is there anything to do with your rebase script regarding this change?

Shouldn't be. All it does it run npm run build

Change 374590 merged by jenkins-bot:
[mediawiki/extensions/Popups@master] Store map files under .json extension

https://gerrit.wikimedia.org/r/374590

Jdlrobson added a subscriber: Legoktm.

As @Legoktm said in review: The /w/ path is configurable (see $wgScriptPath) and shouldn't be hardcoded." I don't see much way around this sadly, and given this is a developer only tool I think we can live with it, but I've captured it as a con of our current approach in T158980,

I can sign this off
https://en.wikipedia.beta.wmflabs.org/w/extensions/Popups/resources/dist/index.js.json is so far so good..

Visiting https://en.wikipedia.beta.wmflabs.org/wiki/Albert_Einstein?debug=true I can see the sources...

Screen Shot 2017-08-31 at 2.25.49 PM.png (976×404 px, 132 KB)

Screen Shot 2017-08-31 at 2.26.13 PM.png (951×361 px, 118 KB)

This should only work on debug=true right? If so please resolve!

Indeed. The reason is that in debug the file is loaded individually:

So the source map applies cleanly.

With debug false, all modules are sent on the same request, so the popups module ends up inside a nested object/function and the source map comment does not apply:

Why didn't we just add .map to the whitelist?