New package "rocket:module" to provide CJS/AMD/ES6 Modules for Meteor packages with shared NPM dependencies

Due to a series of unfortunate events I was unable to present at DevShop on Thursday. We (the girls who coordinate the talkers, and I) will be ready for the next one. :laughing:

Anyways, I’ve started making docs! The example app is working (but not fully complete) and has some details on how to use rocket:module in the README.

Hey @trusktr, I’m using Ubuntu 14.04LTS

@gabrielhpugliese Awesome. I just published 0.5.2 for Linux and OS X. To try it out while Meteor’s new Plugin.registerCompiler API is in preview, you’ve gotta use

meteor --release PLUGINS-PREVIEW@2

instead of

meteor

for anything you do in your project. For example, to add rocket:module v0.5.2 from Atmosphere you’d run

meteor --release PLUGINS-PREVIEW@2 add rocket:module

. :blush:

Stil does not work :cry:

=> Using PLUGINS-PREVIEW@2 as requested (overriding Meteor 1.1.0.2)

[[[[[ ~/teste/module-example-app/meteor ]]]]]

=> Started proxy.
=> Errors prevented startup:

While checking for rocket:module@0.2.0:
error: No compatible binary build found for this package. Contact the
package author and ask them to publish it for your platform.

While checking for rocket:webpack@1.9.10_1:
error: No compatible binary build found for this package. Contact the
package author and ask them to publish it for your platform.

@gabrielhpugliese, ahh, that might be because you’re trying it in the same project and it’s trying to get an old version of rocket:module (0.2.0). You should edit .meteor/version and change the version of rocket:module to 0.5.2. If you want to try the latest features, you can just clone rocket:module from GitHub into packages/module of your app and it’ll override the version number.

Another way to update rocket:module would be to run

meteor --release PLUGINS-PREVIEW@2 update rocket:module

instead of editing the versions file manually.

Is the talk available somewhere?

Thanks for the great work here. I’m new to Meteor and this package is going to end up providing a lot of what I wasn’t finding in the core offering. I’m checking whether I’m reading you right – will this package provide support for importing ES6 modules from NPM? I tried with your recent usage instructions, and it doesn’t seem like this is implemented yet.

My example: I have private github NPM modules that are ES6-only (not transpiled). I’d like to be able to import these and have them webpack’d (via babel-loader?) via rocket:module.

1 Like

@jzempel Yes, you read it right, it works with NPM dependencies of any module type (Es6/CJS/AMD). More docs coming this weekend! For now, there’s some basics in the example app. Ping me in the meteor-rocket/module chat room on Gitter and I can help you out.

@benjick Unfortunately I didn’t get to talk at the last devshop (the girl managing the talkers didn’t know I was present), but I will at this upcoming devshop.

I am about to push 0.8.1, which now includes build caching. It’s going fast!

Alright, 0.8.1 is on Atmosphere, with fast rebuilds. It requires Meteor 1.2-rc.7, and sometimes there will be a bug (?) where Meteor will lag for up to a minute sometimes.

Oops, I forgot to take out console.logs. Updated to 0.8.2.

A++ would ride meteor into sun

Is there a way to use this to lazily/incrementally load templates?

Background: I’m building a large app (already 10K+ LOC) that will be very, very modular—essentially, it’s a platform inside of which we have custom mini-apps for our paying clients, which are currently pulled in as dynamic Blaze Templates. Right now, because of the way Meteor works, all users have to download all of the dynamic templates even if they only use one of them, so I’m absolutely desperate for a solution that lets me modularize things on a template level.

1 Like

Hey @trusktr, quick question. I’m getting this error after adding rocket:module and using it to install react from npm

  While determining active plugins:
   error: conflict: two packages included in the app (rocket:module and ecmascript) are both trying to handle
   *.js

Is it possible to use the ecmascript package with rocket:module?

Thanks for the package btw, ES6 modules ftw :+1:

@skosch Unfortunately, even with rocket:module (or Meteor’s new es2015 module support that will be in Meteor 1.3), Blaze templates will still all be initialized all at once. If you switch to React and use es2015 modules, you can instantiate views only when you need them, but the setup code will still initialize all component classes that are ever imported into any file all at once.

One way you could achieve what you want is to use SystemJS or JSPM, which make it easy to load remote scripts at runtime using the ES2015 Module API at runtime.

1 Like

@efrancis rocket:module isn’t compatible with the ecmascript package. Good news though!: As mentioned in my previous comment, ES2015 modules will be supported in Meteor 1.3. I believe the ecmascript package will be compatible with the es2015 module implementation.

Thanks @trusktr! I’ve switched to webpack in the meantime, so this isn’t an issue for me anymore. Still great to hear that MDG is moving towards more modularity!

1 Like

Yeah, I can’t wait for it to land!

Hello everyone, I’d like to announce that I’ll be deprecating rocket:module in favor of the new modules package in Meteor 1.3, which is awesome. It’s been an great experience prototyping the feature of ES2015 modules in Meteor, but now Meteor has taken it into official hands (with some inspiration from rocket:module and other packages like @macrusher’s universe:modules and webpack:webpack). :smile:

Meteor’s new modules package is the right direction to go in, thanks to @benjamn, and I’ll be devoting time (if any) on writing build plugins for Meteor 1.3+ that bring similar functionality to Meteor as what Webpack loaders bring to Webpack. I’ll probably do these on a as-needed basis. One thing I foresee is needing glslify for loading vertext/fragment shaders.

4 Likes