lmgonzalves/segment

Usage through NPM?

BenoitZugmeyer opened this issue · 2 comments

I would love to use this project in a small project of mine, currently built with webpack.

Using this project via NPM would require some changes, since the "main" entry point (dist/segment.js) isn't exporting any value. Would you consider either:

  • changing dist/segment.js to export the class (and then using something like webpack or browserify to build the demo website)
  • generating a new file (ex: dist/segment.node.js) by appending module.exports = Segment; at the end of segment.js, and changing the "main" entry point to this?

A new, trending way of distributing packages is to write ES6 code and add a "esnext:main" entry point in the package.json. This could be considered as well.

Also, for simplicity and visibility, it would be great to publish segment to the NPM registry.

Your suggestion is very welcome!
I chose to create a new file (segment.node.js), as you suggested.
I've also published segment to the NPM registry, so you can install it with:

npm install segment-js

I do not have much time right now, but soon I think also include support for bower. And add the instructions in the README file.
Let me know how it works for you :)

Thanks a lot, it works great. I don't have time to publish my usage of segment on github just yet though. Anyway, that's all I asked, let's close this!