Proposal: Make it easier to publish on npm with a prepublish command

Hey,

It would be great if we with meteor could use meteor to build and publish to npm, a solution would be to enable a prerelease script to build a dist/ folder that we could publish, similar to how react-mounter have done and Tracker.Component. Reducing all that boilerplate would be great for all of us to transition to npmjs.


A new meteor command for this could be added to package.json also, that would run when you type npm publish, super smart right?

Adding this functionality to Meteor would simplify and reduce the number of files we use to create an npm publication.

Cheers,
// Tim

2 Likes

Totally agree - the amount of boilerplate you need to publish a package to NPM these days is terrible. It would be awesome if there was a way to do this via Meteor. Even better if there was a way to specify the Meteor build tool as a dev dependency in an NPM package, just like Babel.

6 Likes

Yeah, just today I experienced the issue of not having the luxury of watching files in npm, I don’t want to configure this, I don’t even know how to enable some auto watching and building thing for npm.

Let’s take what was awesome with Meteor packages and give it to npm!

1 Like

@sashko, slightly OT but related, are you guys tracking publicly anywhere potential issues on migrating? I keep coming across stuff that I forget to write down, I did https://meteor.hackpad.com/Blocking-Meteor-packages-to-NPM-amw2BmWSAoJ now but it definitely isn’t covering the things I’ve actually come across.

@martijnwalraven had a document somewhere about NPM concerns, might be worth merging those!

I spent the time to make myself a boiler plate, and then I just copy it when I make a new NPM package. http://github.com/trusktr/npm-package-skeleton

All source is in src and npm publish uses Babel to compile the code into the root then publishes. Some scripts exist to build to other module formats. It is also JSPM-ready. The prepublish also builds a global.js file, for people who want a global file. npm clean will clean the build files. It works, for now. :slight_smile:

I’ve seen other ones too. Mine doesn’t have file watching yet.

May be prepublish is not the tool you want. May be if we coupled it with a yeoman generator it’s a super tool.

Recently we needed a such a tool for building React Components. So, we build a simple Yeoman generator with the ability to update build tools.

See: React CDK

This is a tool for React, but can be get some ideas from this.