Hey all
I’m trying to modernize a large Meteor app to benefit from all the amazing stuff Meteor 1.7+ has to offer.
I think I want to move our common components, such as text_box
, modal
, prompt
, title
etc. to a separate package and I’m wondering how I should go about doing it in the most flexible, “tree-shakeable” and convenient way.
So far the best approach I’ve come up with is to just put the files inside the package, exclude them from the mainModule
and then cherry-pick them by importing directly, like so:
// package contents
text_box/
index.js
text_box.m.css
text_box.html
section_title/
index.js
section_title.m.css
section_title.html
package.js
This is how you consume them in the app:
import 'meteor/arggh:ui/text_box';
Template.signup_form.helpers({ ...
<template name="signup_form">
{{> text_box }}
</template>
Using this approach:
Only the imported templates are actually imported
I need to use the file system as part of the import call
For brevity and not having to type the component’s name twice, all js
files have to be named index.js
Any tips or best practices to share, before I spend the next 48hrs refactoring about 400 components in this fashion?