Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeboyim/cc7c967d49bf85c52859 to your computer and use it in GitHub Desktop.
Save codeboyim/cc7c967d49bf85c52859 to your computer and use it in GitHub Desktop.
a sample Webpack configuration to include Facebook Parse JavaScript SDK for a Web project
* @file webpack.config.js
* @author codeboy<>
* @desc this gist shows the essential sections used in configuring webpack
* to make the Facebook's Parse JavaScript SDK work as other modules as expected.
* this gist is inspired by an answer to an issue reported in webpack repo
* {@link}
* disclaimer: this configuration is correct as provided and effective on Parse 1.3.0
module.exports = {
module: {
loaders: [{
//the SDK exports the APIs to an object named Parse.
//without this setting, you have to use
//var Parse = require('parse').Parse
//to access its APIs.
//after this change, you can now use something like
//var Parse = require('parse');
test: /parse-latest.js$/,
loader: 'exports?exports.Parse'
externals: [{
//this is the main trap why this SDK can't be "require"d as usual.
//the original Parse requires a "xmlhttprequest" module shimming XMLHttpRequest
//which requires "child_process" module that is unsupported in browser environment.
//this setting will force the SDK to use the native XMLHttpRequest object from the browser.
xmlhttprequest: '{XMLHttpRequest:XMLHttpRequest}'
plugins: [
//save you a bit of typing of "require('parse')" on every single module it's used.
new webpack.ProvidePlugin({
Parse: 'parse'
Copy link


I am having the exact issue you described here but when I tried to mimic your solution I am having an error of

node lib/server-production

throw err;
Error: Cannot find module '{XMLHttpRequest:XMLHttpRequest}'
I am adding the loaders and externals inside make-webpack-config.js. I also tried to install xmlhttprequest but it didn't help. Could you let me know if I missed something?


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