Try out a preview of batch build plugins (and other 1.2 features)!

We’ve been working hard over the past few months on a number of features for Meteor 1.2. @slava and I have been focused on adding new capabilities to build plugins, and we have a preview release ready! Try it out with meteor --release PLUGINS-PREVIEW@1.

This release adds new plugin APIs: Plugin.registerCompiler, Plugin.registerLinter, and Plugin.registerMinifier.

registerCompiler is a replacement for the now-deprecated registerSourceHandler feature. Compilers are like source handlers, but they always run when you’re building your app instead of when packages are published, and they have access to all of the relevant files in your app and its packages at once. This lets us implement things like CSS preprocessor @imports that work across package boundaries.

registerLinter allows you to write linters that handle different file types and show warnings when you run your app or publish a package (or run the new meteor lint command).

registerMinifier allows you to define your own minifiers to use instead of the standard minifiers, which are no longer baked into the tool but now can be replaced.

The new APIs are documented at

Some notes:

  • You’ll need to add the standard-minifiers package to your app when testing this. (When this is released for real as Meteor 1.2, meteor update will add that to your app automatically.)
  • The less and stylus packages now support cross-package imports! If you specify a file like @import "{package}/file.js" (with the curly braces), it will load the file from that package. Use @import "{}/file.js" to load a file from your app.
  • There’s a new core jshint package which is a linter for js files using JSHint.
  • We’ve made one backwards-incompatible change to packages. To include static assets in packages, you now need to explicitly specify {isAsset: true} in your api.addFiles call. This is not necessary for static assets in apps, and doesn’t affect published packages, just package sources.
  • Because of this change to these packages, we’ve bumped their major version numbers. Packages that include less files will need to publish a new version using this preview (or an RC) before you can use them.
  • We’ve improved rebuild time in meteor run in various ways, including via new caches and new APIs that allow plugins to define their own caches.
  • There’s a lot of other stuff in here too! For example, there’s a new core ecmascript package which uses Babel to let you write Meteor code in ES2015 (similar to grigio:babel). There’s automatic compression on the wire for DDP. There’s some improvements to Livequery oplog tailing performance. There are several months worth of incremental bugfixes. Pretty exciting!

Were not quite ready for the formal 1.2 release candidate process, but we’d love to hear how this release works for your apps! And plugin authors (or those interested in becoming plugin authors), we’d love to see how the new APIs work for you!

Feedback on or here!


Started trying coffeescript today, 2 hrs later, reached the conclusion it’s better to wait for meteor-babel, one sweaty jog later and this. Trying it out now.

EDIT: Unable to get it running

meteor --release PLUGINS-PREVIEW@1                                              
=> Using PLUGINS-PREVIEW@1 as requested (overriding Meteor                          
[[[[[ c:\code\odo2 ]]]]]                                                                     
=> Started proxy.                                                                            
=> Started MongoDB.                                                                          
=> Errors prevented startup:                                                                 
   While selecting package versions:                                                         
   error: Conflict: Constraint less@1.0.11 is not satisfied by less 2.5.0-plugins.0_1.       
   Constraints on package "less":                                                            
   * less@=2.5.0-plugins.0_1 <- top level                                                    
   * less@2.5.0-plugins.0_1 <- accounts-ui 1.1.6-plugins.0                                   
   * less@2.5.0-plugins.0_1 <- accounts-ui-unstyled 1.1.8-plugins.0 <- accounts-ui           
   * less@1.0.11 <- useraccounts:bootstrap 1.11.1                                            
   * less@1.0.11 <- yogiben:admin 1.2.2                                                      
=> Your application has errors. Waiting for file change.                                     

Yeah, this is like I said: packages using less will need to put out new versions.

@glasser were you thinking of creating a central Github issue for this preview release? I got some stuff I ran into.

I have some difficulties with the package.js for the buildplugin, anyone could show a sample ?

The less package uses it for example:

1 Like

Good call.

Thank you very much Sanjo :slight_smile:

@glasser on linux, console.log() output in the console comes corrupted. End of lines have character added each time the plugin restart (after a plugin code modification).
The characters seems to come from a platform description (as if there was some sort of buffer overflow), i get things like “owser” (end of browser) or “ux.x86_64” (end of linux.x86_64) if that can help.

Any idea what this error means that I encountered trying PLUGINS-PREVIEW@1 compared to METEOR@ I’m not sure how to debug this:

I20150724-15:56:32.498(-5)? Exception in Mongo write: Error: fence has already activated -- too late to add a callback
I20150724-15:56:32.498(-5)?     at [object Object]._.extend.onBeforeFire (packages/ddp-server/writefence.js:69:1)
I20150724-15:56:32.498(-5)?     at Object.callback (packages/mongo/oplog_observe_driver.js:154:1)
I20150724-15:56:32.498(-5)?     at packages/ddp-server/crossbar.js:109:1
I20150724-15:56:32.499(-5)?     at Array.forEach (native)
I20150724-15:56:32.499(-5)?     at Function._.each._.forEach (packages/underscore/underscore.js:105:1)
I20150724-15:56:32.499(-5)?     at [object Object] (packages/ddp-server/crossbar.js:107:1)
I20150724-15:56:32.499(-5)?     at [object Object].kadira_Crossbar_fire [as fire] (packages/meteorhacks_kadira/packages/meteorhacks_kadira.js:3348:1)
I20150724-15:56:32.499(-5)?     at Object.Meteor.refresh (packages/ddp-server/server_convenience.js:9:1)
I20150724-15:56:32.499(-5)?     at refresh (packages/mongo/mongo_driver.js:349:1)
I20150724-15:56:32.499(-5)?     at packages/mongo/mongo_driver.js:309:1
I20150724-15:56:32.499(-5)?     at runWithEnvironment (packages/meteor/dynamics_nodejs.js:108:1)

Huh, can you provide a more detailed replication for this? This isn’t something I’ve seen.

@jasonxeno Similarly, can you provide a more specific reproduction here? This could have something to do with an optimization for Livequery:

I see kadira mentioned in that stack trace. Can you reproduce this without Kadira? I know Kadira has some hacks in places that we don’t provide hooks, and the commit above could have made a difference. cc @arunoda

Actually, this is a marker we add for the CPU profiler. I don’t think that would make a difference.

Here’s the code we used:

@glasser Thank you for the hint. I’m getting the same error without Kadira. I’m getting this in a complex area of my code, so I’ll spend some time trying to test simulated isolated pieces of it for a possible reproduction.

In the mean time, I’ll describe what my code is doing in case it helps, the part where the error occurs is when the server makes 5 async HTTP POST calls at the same time, then processes an array of 5 objects from the result of each call, and saves each object as a separate document in a collection in a loop. It errors out after only 1 document is saved after the first HTTP result is returned, and when it tries to save the next document. The whole process goes through several calls and functions.

The new PLUGINS-PREVIEW@2 pre-release has been pushed. The updates from the previous preview:

  • fixed some importing from imports bugs in Stylus
  • QA’d and tested on Windows (fixed bugs relevant to handling paths)
  • all build plugins should prefer using Plugin.fs and Plugin.path that work with the standard paths (/C/some path/file.exe as opposed to C:\some path\files.exe)
  • fixed import in accounts-ui's less file
  • a jscript fix for the babel-compiler package
  • renewed dev-bundle working well for Windows

I also ran into an instance where I’m getting the Mongo write fence error. This occurred when testing, using Velocity and Mocha.

Exception in Mongo write: Error: fence has already activated -- too late to add a callback
I20150729-05:24:28.230(-4)?     at [object Object]._.extend.onBeforeFire (packages/ddp-server/writefence.js:69:1)
I20150729-05:24:28.230(-4)?     at Object.callback (packages/mongo/oplog_observe_driver.js:154:1)
I20150729-05:24:28.231(-4)?     at packages/ddp-server/crossbar.js:109:1
I20150729-05:24:28.231(-4)?     at Array.forEach (native)
I20150729-05:24:28.231(-4)?     at Function._.each._.forEach (packages/underscore/underscore.js:105:1)
I20150729-05:24:28.231(-4)?     at [object Object] (packages/ddp-server/crossbar.js:107:1)
I20150729-05:24:28.231(-4)?     at Object.Meteor.refresh (packages/ddp-server/server_convenience.js:9:1)
I20150729-05:24:28.232(-4)?     at packages/mongo/mongo_driver.js:374:1
I20150729-05:24:28.232(-4)?     at Array.forEach (native)
I20150729-05:24:28.233(-4)?     at Function._.each._.forEach (packages/underscore/underscore.js:105:1)

Here’s a recreation:

The key file is foo-test.js

describe('Running some tests', () => {
  it('should run', (done) => {'dropThings', (err, res) => {
      console.log("test finished");

This will run fine on the client, not triggering any error. But running it on the server throws that Mongo error. Other observations:

  • It only happens when using in an it, before, or beforeEach block – not if it’s just in a describe block.
  • It doesn’t happen in the application. Checkout sandbox.js to see that – does the same thing, no problem
  • Operation on the collection doesn’t matter. I’ve tried removing and inserting, it still throws the same error
  • The error comes after the test has finished. I’ll see test finished in the console before I see the Mongo write fence error

@louis Let’s open a separate GitHub issue to track this down. It looks relevant to a recently merged optimization to oplog driver.

1 Like

@glasser @slava

Do we need to specify isobuild:compiler-plugin@1.0.0 as a dependency if we use Plugin.registerCompiler? I thought I read that somewhere. Or is that if we’re using the caching-compiler classes?

Yes @joe

1 Like

@vjau Ah, good to know. Thanks for the link! :smile: