Blaze outside of Meteor

This is not exactly a meteor announcement…

A little while ago I had the desire to use blaze in a fairly simple express app that served dynamic content from mongo, but didn’t need reactivity, so I didnt want to use meteor. Much to my sadness, I couldn’t find a blaze implementation in npm, so I set about my extracting the implementation to NPM on my own (If someone knows of a working implementation, do let me know).

The project is available here: https://bitbucket.org/znewsham/meteor-blaze/src and consists of several npm packages, and a POC meteor package to show that it does indeed work. It also includes trivial reference projects for webpack and express.

All the tests included in the meteor/blaze repo https://github.com/meteor/blaze (in packages) pass.
I’ve tested it with webpack, express and in meteor and found that it works quite nicely, though I don’t think I’ve covered all the functionality yet.

Unfortunately, I’ve had to rely on some NPM packages that extract meteor functionality, which are several years out of date - I’m open to suggestions to improving this.

Let me know what you think.

9 Likes

I just realized that the readme files werent coming through on NPM so I updated

Just a random question sent from my phone, so don’t blame me for not checking the source :blush:

Did you use the actual Blaze source code and take it from there, or did you build it ”from the ground up” to have the same API and templating features, like I infered from the announcement post?

no, I used the original, I realize now that the phrase “building my own” is a little misleading, I shall edit that. It’s really just the relevant meteor code extracted - and where possible cleaned up to remove some of the dependencies on global variables.

Thanks for the clarification! Did you try to run your version with Meteor? How far is it from a drop-in replacement? What about Tracker as a dependency?

It does run with meteor, I made a dummy meteor package which basically just imports the npm package and calls the Meteor register plugin compiler method. It seems to work fine, though I haven’t tested with a complex project.

Tracker and ReactiveVar (and several other dependencies) are taken from the meteor-standalone-* npm packages, but many of those are very old - I dont know how many changes there have been to that meteor code, but some of the packages are 3-6 years old, so my guess is at least some. I’m going to open a meteor feature request for them to publish some of the packages officially under the @meteor scope, many of the packages don’t seem to rely on the Meteor global being present, and I think extracting them would be helpful. For backwards compatibility the existing meteor packages could wrap the npm package.

1 Like