Apart from the module support, it has native NPM support. That means, you could import NPM packages inside the node_modules directory. So, sooner or later we may need to publish our packages to NPM rather to Atmosphere.
I just started to considering porting some of our Meteor packages to NPM and I found it so harder to find a good way to write ES2015 inside as a NPM package.
It took me a while to setup a good environment with liniting, testing and proper transpilation. I made it as a base repo so everyone can use and we’ll support it.
I’m also tired of creating wrappers for Npm packages and the npm-base is really helpful. Thanks for that. Just started to rewrite one of my Meteor packages in React and it will be only Npm package.
@arunoda I was trying to move my packages to npm aproach and migrate views from Blaze to React but some templates will stay on Blaze. I’m unable to figure out how export/import Blaze from npm. Do you know it?
Any repo example?
I don’t think that’s possible right now.
Only possible reason to write NPM modules right now is for re-usable React components and some other non-meteor libraries.
Could the NPM module assume that Meteor and Template for example is globally available and the user would have to make sure that Meteor was ready before importing?
Just want to chip in here regarding the boilerplate and what to do if you prefer - like we do - to create meteor agnostic npm packages now. Since we’re on npm, we can not only provide ES2015.
@benjamn made some crucial points (see below) about how npm packages should look like to transition to true ES2015 import / export statements. Since npm is currently split between ES5 and ES6 he basically advocates the jsnextproperty inside a package.json to provide both the ES2015 and transpiled ES5 js entry points: Checkout the jsnext-skeleton boilerplate
He gave a talk in November (video below) about this issue in which he pleas to publish both source files and (if you care about npm) transpiled js routed via the ‘jsnext’ property (slide 71+)
I personally like the skeleton very very much - untying everything in a npm package from meteor. @arunoda what do you think? Maybe you can include this alternative in your medium post / faq section?
This is good idea in general that I’ve been using in libraries I contribute to or write: If you’d like the most people possible to use your library, include all forms of your source (original, compiled, global UMD) in your package since each form is still just a script, with instructions on how to use each. I usually put original files in a src folder, compile everything into lib or just into the root of the project, and also place a global version at the root.
Wait, so how do we bring in old templates into our new import / export React code? I’m used to BlazeToReact('template') but that doesn’t seem to work. Any suggestions?
That should still work. Template always load before JS, so I’m not sure what that’s not working. Make sure the package that provides BlazeToReact loads before your main.js entry point.