Skip to content

Commit

Permalink
move globals out and generate source maps
Browse files Browse the repository at this point in the history
  • Loading branch information
steel committed Jun 16, 2016
1 parent 1b9dcfb commit 262e4ad
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 8 deletions.
3 changes: 2 additions & 1 deletion dist/firehose.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/firehose.js.map

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion dist/firehose.vendor.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/firehose.vendor.js.map

Large diffs are not rendered by default.

20 changes: 16 additions & 4 deletions javascript/lib/globals.coffee → helpers/node.coffee
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# xhr
global.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest
# Helper used to define browser globals that our node app needs
# Defines
# - window
# - document
# - location
# - $

# jQuery dependencies
jsdom = require("jsdom")
global.document = jsdom.jsdom("<html></html>")
global.window = document.defaultView

# Node environments need this, browsers implement it themselves
global.WebSocket = require "ws"
# this needs to be attached to the jsdom window object to override
# jsdom's internal xmlhttprequest object
window.XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest

# URIjs dependencies

Expand All @@ -21,3 +26,10 @@ global.location = window.location
# You need to initialize it with a Window object
global.$ = require "jquery"
$(window)

# Node environments need this, browsers implement it themselves
global.WebSocket = require "ws"

# Current version
module.exports =
version: require("../package.json").version
5 changes: 4 additions & 1 deletion javascript/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
if ("webpack" != process.env.NODE_ENV) {
require("coffee-script/register");
__VERSION__ = require("../helpers/node").version
}
module.exports = require("./lib/firehose");

exports = module.exports = require("./lib/firehose");
exports.version = __VERSION__;
2 changes: 1 addition & 1 deletion spec/javascripts/support/spec_helper.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
global.sinon = require "sinon"
require "../../../javascript/lib/globals"
require "../../../helpers/node"
global.Firehose = require "../../../javascript/index"
1 change: 1 addition & 0 deletions webpack.config.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports =
output:
path: path.join(__dirname, "dist")
filename: "[name].js"
devtool: "source-map"
plugins: [
new webpack.DefinePlugin(
"process.env":
Expand Down

0 comments on commit 262e4ad

Please sign in to comment.