(#4700) - fix and test Webpack #4701

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
@nolanlawson
Member

nolanlawson commented Dec 25, 2015

This fixes Webpack support, and additionally it tests Webpack in CI.

There were (surprisingly) quite a few changes that needed to be made to support this:

  • require('request') needed to be isolated to its own file and then swapped with the -browser version at that level
  • browserify-versionify wasn't working at all with Webpack and was breaking the tests, since Webpack just left the '__VERSION__' string in there as-is. So I swapped it out for a new Browserify transform that I wrote - package-json-versionify, which simply removes everything from package.json except for "version". Webpack will ignore this transform, meaning that Webpack users are punished with a larger bundle size, but it still works.
  • Unfortunately, once you start doing require('../package.json'), Webpack loses its mind and you suddenly need a json-loader. AFAICT from this discussion, this is expected behavior and they intend for end-users to include custom loaders to deal with this stuff. So unfortunately our users are going to have to do that. Hopefully they've run into it enough times before that it won't surprise them. (WTF, why can't you just require() a JSON file without any additional configuration?)

I think moving forward it is super important that we test Webpack in CI, because I cannot believe how much bending over backwards you have to do to support it and Browserify simultaneously.

- "./lib/deps/env/isChromeApp.js": "./lib/deps/env/isChromeApp-browser.js",
+ "./lib/deps/ajax/explainError.js": "./lib/deps/ajax/explainError-browser.js",
+ "./lib/deps/ajax/prequest.js": "./lib/deps/ajax/prequest-browser.js",
+ "./lib/deps/ajax/request.js": "./lib/deps/ajax/request-browser.js",

This comment has been minimized.

@nolanlawson

nolanlawson Dec 25, 2015

Member

I sorted these alphabetically; the only true change is the above line.

@nolanlawson

nolanlawson Dec 25, 2015

Member

I sorted these alphabetically; the only true change is the above line.

@daleharvey

This comment has been minimized.

Show comment
Hide comment
@daleharvey

daleharvey Dec 26, 2015

Member

👍 this is awesome, thanks, merry christmas :)

Member

daleharvey commented Dec 26, 2015

👍 this is awesome, thanks, merry christmas :)

@daleharvey

This comment has been minimized.

Show comment
Hide comment
@daleharvey

daleharvey Dec 26, 2015

Member

Merged in e586068

Member

daleharvey commented Dec 26, 2015

Merged in e586068

@daleharvey daleharvey closed this Dec 26, 2015

@nolanlawson

This comment has been minimized.

Show comment
Hide comment
@nolanlawson

nolanlawson Dec 27, 2015

Member

Heh, Merry Christmas to you too. :)

Member

nolanlawson commented Dec 27, 2015

Heh, Merry Christmas to you too. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment