Request: Publish Tracker on NPM

Hi Meteor core team (@debergalis, @gschmidt, @sashko, @tmeasday),

I know you’re always busy and such, but if you could find the time to pull out Tracker from Meteor core into an NPM package more developers using other frameworks can get to use this technology, because simply it’s really clever and easy to use! <3

I don’t know if you’ve noticed what I’ve built on top of Tracker? The idea is really simple, and the implementation is straight forward on Tracker.Component (would love some comments). Here’s an example using it:

import React from 'react';
import Tracker from 'tracker-component';

Models = new Mongo.Collection('models');
if (Meteor.isServer) {
  Meteor.publish('cars', () => Models.find());
}

class Models extends Tracker.Component {
  constructor(props) {
    super(props);
    this.subscribe('cars');
    this.autorun(() => {
      this.setState({
        cars: Models.find().fetch()
      });
    });
  }
}

const Cars = ({ cars = [] }) => (
  <ul className="cars">
    {cars.map(car =>
      <li className="car">{car.brand} {car.model}</li>
    )}
  </ul>
);

if (Meteor.isClient) {
  Meteor.startup(() => {
    ReactDOM.render(<Models><Cars /></Models>, document.body);
  });
}

I think Tracker.Component clearly shows how easy it would be to go forward in a world of simple composable React and ES2015 modules.

Though, the only thing holding this back right now is a dependency on Meteor core Tracker, which I cannot get from npm, in any sort of way right now. So right now one can only use Tracker.Component with Meteor. Would it be hard to refactor Tracker and get it on npm? And do you need help with it?

https://www.npmjs.com/package/tracker-component

Cheers,
// Tim

4 Likes

Question: Isn’t Tracker, hence Tracker.Component, meteor specific? So why publish it to npm instead of using the meteor package system?

For the foreseeable future, Meteor will not be 100% package system agnostic. It’s on the roadmap to break meteor into separate repos (partially started) and in the long run published to npm. Though before that, there are more pressing issues (such as node v5 support, build tool independence etc).

If I were you, I would hold off publishing meteor dependent packages to npm (running on node v0.10.43 anyway) and do it when the whole meteor structure is shifted - with proper dependency management - to npm.

Npm support is great. But for now, meant for environment agnostic libs.

1 Like

I guess you’re right, though I can’t wait to use the many Tracker based approaches even outside of meteor.

Yes, I personally can’t wait to use meteor as npm packages in custom build tools… that will change a lot

1 Like

@mquandalle proposed build Tracker on top of mobx and make a initial commit here: https://github.com/mquandalle/tracker-mobx-bridge

I think Tracker is only Meteor-specific by association only. Personally, I would love to see this as it’s own npm package. There are already a lot of unofficial attempts at this, but an official package would be awesome. It’s a super useful package!

1 Like

It would be great if they release it on NPM (one version we can agree upon).

You can use Tracker without Meteor right now, just copy the file to your non-Meteor project and you’re good to go. It only has 2-3 references to Meteor and they’re like “if Meteor then log this way.”

3 Likes

yes, good idea so long as it can reasonably be split out. + @zoltan

3 Likes

By the way, there’s a whole bunch of discussion happening already here: https://github.com/meteor/blaze/issues/11

2 Likes

Nice! Do you know if Meteor themselves has given any input on that? Looks clean at first look

Yeah, I’ve used this before but it has tons of other dependencies that it pulls in like Meteor which I’m not sure that it needs to function.

I don´t know.

Let´s check it.

cc @zoltan @debergalis is any input on this, reimplement Tracker on top of mobx?

see @mquandalle wonderful first commit here: https://github.com/mquandalle/tracker-mobx-bridge

1 Like

That link is broken :confused:

fixed link! … thanks!

1 Like

I think it makes sense for Tracker to be the first package we get onto npm. Working on it.

7 Likes

Yeay, can’t wait! Tell me if you need help, I’d love to contribute :smiley:

1 Like

@timbrandin Our first priority is to figure out the best pattern for moving packages onto npm, especially in terms of how to replace features that Meteor’s package system has but npm doesn’t. This problem is what we’re planning on working on next (alongside fixes of course).

4 Likes

Hi, @zoltan @tmeasday

I took the liberty to work a few hours on this, please have a look, all the tests are successful but I haven’t actually tested it with Tracker.Component yet, I thought it’d fun if you guys could have a look before I move further.

I haven’t published it, so you’ll have to use npm link to try it out.

Cheers, and have a great weekend now.
// Tim

2 Likes

Hey @timbrandin - this is awesome, great work. We’re still figuring out the best strategy for moving Meteor packages themselves to npm - this may end up including our build plugin functionality. Since you’re interested, I’ll reach out once we make more progress on the strategy and perhaps you can help out with the implementation.

1 Like

Here’s a npm version of a fork of Tracker. It works.

1 Like