-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
added support for commonjs modules #206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -4,7 +4,7 @@ | |||
// If there is no JSON, we no-op the core features of Raven | |||
// since JSON is required to encode the payload | |||
var _Raven = window.Raven, | |||
hasJSON = !!(window.JSON && window.JSON.stringify), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's wrong with window.JSON
here? window
is referring to this
. Which you can see in the _footer.js
ending closure. Wouldn't that context be correct in your case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In browserify (and commonjs in general i think?) this
refers to the module, not the window.. so in this case window
is just an empty object. removing the window qualifier seemed like a much less invasive change than renaming the initial function parameter..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fyi, here's the browserify require code:
require = (function e(t, n, r) {
function s(o, u) {
if (!n[o]) {
if (!t[o]) {
var a = typeof require == "function" && require;
if (!u && a) return a(o, !0);
if (i) return i(o, !0);
throw new Error("Cannot find module '" + o + "'")
}
var f = n[o] = {
exports: {}
};
t[o][0].call(f.exports, function(e) {
var n = t[o][1][e];
return s(n ? n : e)
}, f, f.exports, e, t, n, r)
}
return n[o].exports
}
var i = typeof require == "function" && require;
for (var o = 0; o < r.length; o++) s(r[o]);
return s
})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 can confirm that this is necessary to get this working.
Definitely remove the changes in |
This reverts commit 8ed8ccc.
👍 This patch got browserify working for me. |
@@ -4,7 +4,7 @@ | |||
// If there is no JSON, we no-op the core features of Raven | |||
// since JSON is required to encode the payload | |||
var _Raven = window.Raven, | |||
hasJSON = !!(window.JSON && window.JSON.stringify), | |||
hasJSON = !!(JSON && JSON.stringify), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't make this change. This is very significantly different in behavior.
(JSON && JSON.stringify)
will now raise a ReferenceError
instead of returning undefined
as window.JSON
would.
Superseded by #261 |
Hey there,
This PR adds support for commonjs modules, browserify etc, sometimes used in environments where the 'window' object isn't available, but JSON is.
Steve