Skip to content
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

Publish to npm for browserify support #197

Closed
twolfson opened this issue Apr 3, 2014 · 24 comments
Closed

Publish to npm for browserify support #197

twolfson opened this issue Apr 3, 2014 · 24 comments

Comments

@twolfson
Copy link
Contributor

twolfson commented Apr 3, 2014

In order to support browserify, a JS compiler that resolves dependencies as if they were npm dependencies, we should publish raven-js to npm.

https://github.com/substack/node-browserify

The changes that we need to make this happen:

  • Rename package.json to raven-browser or similar
  • Remove private property from package.json
  • Get approval from maintainers

If you are concerned about the task of adding 2 more tasks when you release (i.e. bumping package.json version and running npm publish), then you might want to consider using foundry:

https://github.com/twolfson/foundry

@bobbyrenwick
Copy link

👍

@christophercliff
Copy link

👍

FYI, there is a fork published to npm, but it's rather out of date: https://www.npmjs.org/package/raven-js

@mattrobenolt Any interest in losing the fork and making the main repo CommonJS compatible and publishing releases to npm?

@mattrobenolt
Copy link
Contributor

@christophercliff I'm ok with doing that, I just need someone to hand hold this and support it since I don't use browserify.

@clayzermk1
Copy link
Contributor

👍 for browserify support

@moretti
Copy link
Contributor

moretti commented Nov 3, 2014

Any update? Essentially you just have to merge the PR that @clayzermk1 submitted (#261), remove "private": true from package.json and update the npm package.

@mattrobenolt
Copy link
Contributor

Just merged #261. I think there are a few other issues/PR's to address, then I'll cut a release and try to get this onto npm.

Anyone here willing to test when I publish? Or want to give me instructions to test on my own? I don't want to break the public package that others depend on.

mattrobenolt added a commit that referenced this issue Nov 3, 2014
@mattrobenolt
Copy link
Contributor

This is going to be awkward now having a package called raven and one called raven-js both in npm. 😞

I need to figure out a way to combine these two or something into something that can be used in both places.

@moretti
Copy link
Contributor

moretti commented Nov 3, 2014

Yeah I agree, it's confusing, it would be nice to figure out a way to combine them! 😃
I can test the package once it's published, I think it should work fine, though.

@mattrobenolt
Copy link
Contributor

@moretti Thanks. I'm going through my backlog of issues and pull requests today so I'll try and cut a new version this afternoon unless there's a major reason I can't.

@clayzermk1
Copy link
Contributor

@mattrobenolt

I need to figure out a way to combine these two or something into something that can be used in both places.

CommonJS 😉. I think it all boils down to whether raven's dependencies would work browser-side (I don't think they do currently).

Anyone here willing to test when I publish? Or want to give me instructions to test on my own? I don't want to break the public package that others depend on.

I would be more than happy to give it a go! 😄 Testing is easy, npm install raven-js should pull it down, check the package.json that the version matches the code base (make sure you tag the release in git before doing an npm publish).

@moretti
Copy link
Contributor

moretti commented Nov 3, 2014

The simplest way for combining these projects would be to define two different entry points: one for node.js and another one for browsers. This can be done by editing the "main" and the "browser" field in package.json:
https://github.com/substack/node-browserify#browser-field

Have a look, for example, at superagent's package.json:
https://github.com/visionmedia/superagent/blob/master/package.json

@tommoor
Copy link

tommoor commented Jan 16, 2015

This would be lovely.

@twolfson
Copy link
Contributor Author

For what it's worth, since the opening of this issue I now prefer to always separate raven from the rest of my JS. If there is anything that would cause the compiled JS to fail and block raven from getting set up, then that is bad. As a result, I usually put it in its own script tag and initialize it before the other JS.

<script src="raven-with-init.js"></script>
<script src="index.min.js"></script>

@piuccio
Copy link

piuccio commented Feb 13, 2015

@mattrobenolt any update on this?

All you need to do is
git checkout 1.1.16 npm publish ./

This will publish 1.1.16 on npm, the code will be exactly the same as the github tag.

You are already a maintainer of raven-js it should work even if the repository is different.

Would be nice if you could publish 1.1.16 and then work on next versions or merging with raven-node. It would be very useful for many of us.

@grrowl
Copy link

grrowl commented Mar 2, 2015

+1 would be great if npm could be updated. We just pushed some code using .setUserContext(), a function which isn't documented against a version, but is unavailable while relying on the npm published version.

@mattrobenolt
Copy link
Contributor

So allow me to explain the problem and why it's not so simple:

This module was never intended to be published to npm in the first place. The project was forked and published without our permission. This fork even diverged from master. That's the version 1.1.11 that you see there today, which does not match the 1.1.11 release tagged in this repo.

After that confusion, I've acquired ownership of the repository. I'm hesitant to just publish 1.1.16 to npm since I'm not super familiar with this space and how people use npm for client side dependencies.

With that said, @dcramer and I are going to get this sorted out soon and fix this so we can move forward with our version and nor a forked version that we don't support.

So again, I apologize for the confusion, but I'm trying really hard not to make people more upset by breaking compatibility.

@grrowl
Copy link

grrowl commented Mar 2, 2015

Understandably. Basically it should be CommonJS (the fork has removed noConflict support but this isn't neccessary -- jquery has both noConflict and AMD/CommonJS support), and will require some changes to package.json.

I appreciate not breaking compatibility and measuring twice, cutting once. Good luck, hopefully a contributor can kick in some time if you need it.

@dcramer
Copy link
Member

dcramer commented Mar 2, 2015

See also #323

@dcramer dcramer closed this as completed Mar 2, 2015
@dcramer dcramer reopened this Mar 2, 2015
@fson
Copy link

fson commented Mar 2, 2015

@dcramer @mattrobenolt I'm currently using Raven.js installed from npm with webpack, so I could chime in with some experiences. I installed Raven.js 1.1.16 directly from GitHub (so I'm not using the fork published in npm, which is outdated).

Issues I had to work around:

  • Latest release didn't have the main field in package.json and the name field was raven.This has been fixed in master since then, but a new release is needed.
  • webpack understands even AMD modules, so this was not really an issue with it, but you'll want something like UMD wrapper to ensure compatibility with CommonJS, AMD and globals.
  • Make sure that Raven.js doesn't set any globals, when CommonJS or AMD is used. UMD wrapper should take care of this. I had to resort to noConflict as a workaround.
  • Expecting this at the root scope to be window. This does not work when using a module system. Because Raven.js depends on the actual window global, that could fixed by removing this this wrapper and referencing window directly. The issue is caused by this wrapper:
;(function(window, undefined){
  // ...
})(this);

Workarounds for using with webpack

These issues are quite easily fix. In the meanwhile, it's already possible to use the current version Raven.js with webpack and npm:

  • install from GitHub:
npm install getsentry/raven-js#1.1.16 --save
  • use imports-loader to define this – put this in module.loaders:
{
  test: require.resolve('raven/dist/raven.js'),
  loader: 'imports-loader?this=>window'
}
  • if you are using the latest release version (1.1.16) from GitHub, you'll need to add an alias to compensate for the missing main field and name being raven and not raven-js:
  resolve:
    alias: {
      'raven-js': 'raven/dist/raven.js'
    }
  }
  • call noConflict so you don't expose Raven as a global:
require('raven-js').noConflict();

@mattrobenolt
Copy link
Contributor

1.1.17 was published to npm. I have no idea if this really works, so some confirmation would be great. :)

@piuccio
Copy link

piuccio commented Mar 8, 2015

Thanks @mattrobenolt

@clayzermk1
Copy link
Contributor

@mattrobenolt Thank you for publishing this! I just upgraded to it and have had no problems building or running it yet.

@mattrobenolt
Copy link
Contributor

Awesome, good to know. I'll be keeping the npm version up to date now as well. :)

@chromakode
Copy link

Works great, thank you.

matghaleb pushed a commit to matghaleb/raven-js that referenced this issue Sep 9, 2015
kamilogorek pushed a commit that referenced this issue Jun 12, 2018
* rm -rf udp

This has been gone for years
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.