-
-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
|
||
| lastCapturedException, | ||
| lastEventId, | ||
| globalServer, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,13 @@ | ||
| // Expose Raven to the world | ||
| window.Raven = Raven; | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is being done on purpose. We need to globally expose
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line was moved to the I also needed to move it as I'm using this in a firefox add-on, which will barf if you try to modify the window object... so Raven.noConflict() doesn't work. (Yes.. firefox has their own commonjs implementation which does end up keepin the window object as |
||
| // AMD | ||
| if (typeof define === 'function' && define.amd) { | ||
| define('raven', [], function() { return Raven; }); | ||
| } | ||
|
|
||
| else if (typeof module == 'object') { | ||
| module.exports = Raven; | ||
| } | ||
| else { | ||
| window.Raven = Raven; | ||
| } | ||
| })(this); | ||
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.JSONhere?windowis referring tothis. Which you can see in the_footer.jsending 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?)
thisrefers to the module, not the window.. so in this casewindowis 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:
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.