Structure and modules on
Meteor.js
Vyacheslav
Voronchuk
CEO of Starbuildr LLC
Meteor modules
• /server - scripts are executed only on
server
• /client - scripts are executed only on
client
• /public - images and other static assets
• all other scripts are executed both on
server and client
Execution scope
• HTML template are loaded first
• After HTML templates scripts from /lib
folder are loaded
• main.* is loaded the last
• Files which are nested deeper in file
structure have priority in execution order
• All other files are executed in alphabetic
order
Loading order
• lib/module1/*
• lib/module2/*
• client/module1/*
• client/module2/*
• server/module1/*
• server/module2/*
Modules by execution type
• module1/lib/*
• module1/client/*
• module1/server/*
• module2/lib/*
• module2/client/*
• module2/server/*
Modules by folders
• packages/module1/package.js
• packages/module1/*
• packages/module2/package.js
• packages/module2/*
Packages
var ACCESS_CLIENT = 'client';
var ACCESS_SERVER = 'server';
var ACCESS_BOTH = [ACCESS_CLIENT, ACCESS_SERVER];
var DEP_CONFIG = [
{ name: 'coffeescript', access: ACCESS_BOTH },
{ name: 'jquery', access: ACCESS_CLIENT },
{ name: 'underscore', access: ACCESS_BOTH },
{ name: 'meteor-platform', access: ACCESS_BOTH },
{ name: 'accounts-ui', access: ACCESS_BOTH },
];
var NPM_DEP_CONFIG = {
'redis': '0.12.1'
};
Module dependencies
Package.on_use(function(api) {
var depConfig, accessType, accessPaths, _i, _len;
for (_i = 0, _len = DEP_CONFIG.length; _i < _len; _i++)
{
depConfig = DEP_CONFIG[_i];
api.use(depConfig.name, depConfig.access);
}
Npm.depends(NPM_DEP_CONFIG);
});
Package bootstrap
var FILE_CONFIG = {};
FILE_CONFIG['ACCESS_BOTH'] = {
'coffee/': [
'bootstrap.coffee'
],
'coffee/route/': [
'config.coffee',
'IndexController.coffee'
]
};
FILE_CONFIG['ACCESS_CLIENT'] = {
'client/view/': [
'index.html',
'indexLayout.html'
],
'client/style/': [
'fix-icon.css',
'main.css'
],
};
File loading order
Package.on_use(function(api) {
var file, filesToLoad, path, accessType, accessPaths, _i, _len;
for (accessType in FILE_CONFIG) {
accessPaths = FILE_CONFIG[accessType];
for (path in accessPaths) {
filesToLoad = accessPaths[path];
for (_i = 0, _len = filesToLoad.length; _i < _len; _i++) {
file = filesToLoad[_i];
api.add_files(path + file, eval(accessType));
}
}
}
});
More package bootstrapping
var EXPORT = [‘Module1’, ‘Model1’];
Package.on_use(function(api) {
return api.export(EXPORT);
});
Public module namespace
Module1 = {}
Module1.ROUTE_NAME = 'index'
Module1.TEMPLATE_NAME = 'index'
Meteor.startup(function() {
if (Meteor.isServer) {
bootstrapServer();
}
if (Meteor.isClient) {
bootstrapClient();
}
});
var bootstrapClient = function() {};
var bootstrapServer = function() {
Model1.setInstance(Model1.factory());
};
Module loader
class Model1
@COLLECTION_NAME = ‘model1'
@collection = null
@getCollection: -> @collection
@setCollection: (collection) -> @collection = collection
constructor: (data) -> _.extend @, data
getCollection: -> Model1.getCollection()
customMethod: ->
Model1.setCollection new Mongo.Collection
Model1.COLLECTION_NAME,
transform: (data) -> new Model1 data
Model
• Production-ready hosting for meteor deploy
• Kubernetes.io (Docker container
management system)
• Official support for React.js and Angular
• Official support for ECMAScript 2015 (ES6)
• Better build tools
Next release (Galaxy, Meteor
1.2)
• Support of SQL
• REST and micro-services
• Testing with Velocity
• Better tools for mobile development and
testing
• Integration of routing in a core
After Meteor 1.2
Thank you!
voronchuk@starbuildr.com
Skype: voronhukvk
https://www.linkedin.com/in/voronchuk

More Related Content

PDF
Drupal - short introduction.
PDF
MuleSoft ESB Shared Library
TXT
Codedaftarisi
PDF
Develop plugin for Mozilla Firefox and structure a JS-based application
PPTX
Building and Managing Projects with Maven
PDF
Ch. 13 filters and wrappers
PPT
Web logs and rss
PDF
Apache2 BootCamp : Using Apache to Serve Static Content
Drupal - short introduction.
MuleSoft ESB Shared Library
Codedaftarisi
Develop plugin for Mozilla Firefox and structure a JS-based application
Building and Managing Projects with Maven
Ch. 13 filters and wrappers
Web logs and rss
Apache2 BootCamp : Using Apache to Serve Static Content

What's hot (9)

PDF
SFScon 2020 - Nikola Milisavljevic - BASE - Python REST API framework
PDF
JBoss AS7 web services
PPTX
M property
PPTX
Using properties in mule
PPTX
MuleSoft ESB Scripting Example
PPT
Firefox vs. chrome
PPT
Wordpress architecture
PPT
Architecture of Drupal - Drupal Camp
PPTX
Web browser
SFScon 2020 - Nikola Milisavljevic - BASE - Python REST API framework
JBoss AS7 web services
M property
Using properties in mule
MuleSoft ESB Scripting Example
Firefox vs. chrome
Wordpress architecture
Architecture of Drupal - Drupal Camp
Web browser
Ad

Viewers also liked (12)

PDF
Эндогенное дыхание - книга
ODP
FRP and Bacon.js
PPSX
Информация и правила работы с ней.
PPTX
презентация ДО ПриCутствия
PPTX
Laboring - защити свои права!
PDF
Inter capital en
PDF
Coffeescript a z
PPSX
Как стать профессиональным дайвером в море информации
PPTX
Явление Иерархии
PPTX
жителям мд
PDF
Odoo 2016 - Retrospective
Эндогенное дыхание - книга
FRP and Bacon.js
Информация и правила работы с ней.
презентация ДО ПриCутствия
Laboring - защити свои права!
Inter capital en
Coffeescript a z
Как стать профессиональным дайвером в море информации
Явление Иерархии
жителям мд
Odoo 2016 - Retrospective
Ad

Similar to Meteor modules (20)

PPT
Build Automation of PHP Applications
PDF
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
ODP
CodeIgniter PHP MVC Framework
PPTX
Introduction to Monsoon PHP framework
PDF
Social Connections VI — IBM Connections Extensions and Themes Demystified
PDF
Decoupled Libraries for PHP
PPT
CICON2010: Adam Griffiths - CodeIgniter 2
PPTX
Drupal 8 configuration development flow
PDF
Intro to WordPress Plugin Development
PDF
Staging Drupal 8 31 09 1 3
PDF
Where Flux and InfluxDB Are Headed | Paul Dix | InfluxData
PPTX
Requiring your own files.pptx
ODP
Custom module and theme development in Drupal7
PDF
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
PPTX
Creating Custom Templates for Joomla! 2.5
PDF
OroCRM Partner Technical Training: September 2015
PDF
Customising the CloudStack UI - CloudStack European User Group Virtual, May 2...
PPTX
Webinar - Managing Files with Puppet
PPTX
CodeIgniter & MVC
PDF
Codeigniter : Two Step View - Concept Implementation
Build Automation of PHP Applications
Challenges of Simple Documents: When Basic isn't so Basic - Cassandra Targett...
CodeIgniter PHP MVC Framework
Introduction to Monsoon PHP framework
Social Connections VI — IBM Connections Extensions and Themes Demystified
Decoupled Libraries for PHP
CICON2010: Adam Griffiths - CodeIgniter 2
Drupal 8 configuration development flow
Intro to WordPress Plugin Development
Staging Drupal 8 31 09 1 3
Where Flux and InfluxDB Are Headed | Paul Dix | InfluxData
Requiring your own files.pptx
Custom module and theme development in Drupal7
Drupal Day 2012 - Automating Drupal Development: Make!les, Features and Beyond
Creating Custom Templates for Joomla! 2.5
OroCRM Partner Technical Training: September 2015
Customising the CloudStack UI - CloudStack European User Group Virtual, May 2...
Webinar - Managing Files with Puppet
CodeIgniter & MVC
Codeigniter : Two Step View - Concept Implementation

Recently uploaded (20)

PDF
BIOCHEM CH2 OVERVIEW OF MICROBIOLOGY.pdf
PPTX
Top Website Bugs That Hurt User Experience – And How Expert Web Design Fixes
DOCX
Memecoinist Update: Best Meme Coins 2025, Trump Meme Coin Predictions, and th...
PPTX
在线订购名古屋艺术大学毕业证, buy NUA diploma学历认证失败怎么办
PDF
Exploring The Internet Of Things(IOT).ppt
PPTX
Partner to Customer - Sales Presentation_V23.01.pptx
PDF
Session 1 (Week 1)fghjmgfdsfgthyjkhfdsadfghjkhgfdsa
DOCX
Powerful Ways AIRCONNECT INFOSYSTEMS Pvt Ltd Enhances IT Infrastructure in In...
PDF
Computer Networking, Internet, Casting in Network
PDF
Uptota Investor Deck - Where Africa Meets Blockchain
PDF
SlidesGDGoCxRAIS about Google Dialogflow and NotebookLM.pdf
PDF
simpleintnettestmetiaerl for the simple testint
PDF
Course Overview and Agenda cloud security
PPSX
AI AppSec Threats and Defenses 20250822.ppsx
PPTX
Artificial_Intelligence_Basics use in our daily life
PPTX
Viva Digitally Software-Defined Wide Area Network.pptx
PPTX
AI_Cyberattack_Solutions AI AI AI AI .pptx
PPTX
curriculumandpedagogyinearlychildhoodcurriculum-171021103104 - Copy.pptx
PPTX
MY PRESENTATION66666666666666666666.pptx
PPTX
10.2981-wlb.2004.021Figurewlb3bf00068fig0001.pptx
BIOCHEM CH2 OVERVIEW OF MICROBIOLOGY.pdf
Top Website Bugs That Hurt User Experience – And How Expert Web Design Fixes
Memecoinist Update: Best Meme Coins 2025, Trump Meme Coin Predictions, and th...
在线订购名古屋艺术大学毕业证, buy NUA diploma学历认证失败怎么办
Exploring The Internet Of Things(IOT).ppt
Partner to Customer - Sales Presentation_V23.01.pptx
Session 1 (Week 1)fghjmgfdsfgthyjkhfdsadfghjkhgfdsa
Powerful Ways AIRCONNECT INFOSYSTEMS Pvt Ltd Enhances IT Infrastructure in In...
Computer Networking, Internet, Casting in Network
Uptota Investor Deck - Where Africa Meets Blockchain
SlidesGDGoCxRAIS about Google Dialogflow and NotebookLM.pdf
simpleintnettestmetiaerl for the simple testint
Course Overview and Agenda cloud security
AI AppSec Threats and Defenses 20250822.ppsx
Artificial_Intelligence_Basics use in our daily life
Viva Digitally Software-Defined Wide Area Network.pptx
AI_Cyberattack_Solutions AI AI AI AI .pptx
curriculumandpedagogyinearlychildhoodcurriculum-171021103104 - Copy.pptx
MY PRESENTATION66666666666666666666.pptx
10.2981-wlb.2004.021Figurewlb3bf00068fig0001.pptx

Meteor modules

  • 1. Structure and modules on Meteor.js Vyacheslav Voronchuk CEO of Starbuildr LLC
  • 3. • /server - scripts are executed only on server • /client - scripts are executed only on client • /public - images and other static assets • all other scripts are executed both on server and client Execution scope
  • 4. • HTML template are loaded first • After HTML templates scripts from /lib folder are loaded • main.* is loaded the last • Files which are nested deeper in file structure have priority in execution order • All other files are executed in alphabetic order Loading order
  • 5. • lib/module1/* • lib/module2/* • client/module1/* • client/module2/* • server/module1/* • server/module2/* Modules by execution type
  • 6. • module1/lib/* • module1/client/* • module1/server/* • module2/lib/* • module2/client/* • module2/server/* Modules by folders
  • 7. • packages/module1/package.js • packages/module1/* • packages/module2/package.js • packages/module2/* Packages
  • 8. var ACCESS_CLIENT = 'client'; var ACCESS_SERVER = 'server'; var ACCESS_BOTH = [ACCESS_CLIENT, ACCESS_SERVER]; var DEP_CONFIG = [ { name: 'coffeescript', access: ACCESS_BOTH }, { name: 'jquery', access: ACCESS_CLIENT }, { name: 'underscore', access: ACCESS_BOTH }, { name: 'meteor-platform', access: ACCESS_BOTH }, { name: 'accounts-ui', access: ACCESS_BOTH }, ]; var NPM_DEP_CONFIG = { 'redis': '0.12.1' }; Module dependencies
  • 9. Package.on_use(function(api) { var depConfig, accessType, accessPaths, _i, _len; for (_i = 0, _len = DEP_CONFIG.length; _i < _len; _i++) { depConfig = DEP_CONFIG[_i]; api.use(depConfig.name, depConfig.access); } Npm.depends(NPM_DEP_CONFIG); }); Package bootstrap
  • 10. var FILE_CONFIG = {}; FILE_CONFIG['ACCESS_BOTH'] = { 'coffee/': [ 'bootstrap.coffee' ], 'coffee/route/': [ 'config.coffee', 'IndexController.coffee' ] }; FILE_CONFIG['ACCESS_CLIENT'] = { 'client/view/': [ 'index.html', 'indexLayout.html' ], 'client/style/': [ 'fix-icon.css', 'main.css' ], }; File loading order
  • 11. Package.on_use(function(api) { var file, filesToLoad, path, accessType, accessPaths, _i, _len; for (accessType in FILE_CONFIG) { accessPaths = FILE_CONFIG[accessType]; for (path in accessPaths) { filesToLoad = accessPaths[path]; for (_i = 0, _len = filesToLoad.length; _i < _len; _i++) { file = filesToLoad[_i]; api.add_files(path + file, eval(accessType)); } } } }); More package bootstrapping
  • 12. var EXPORT = [‘Module1’, ‘Model1’]; Package.on_use(function(api) { return api.export(EXPORT); }); Public module namespace
  • 13. Module1 = {} Module1.ROUTE_NAME = 'index' Module1.TEMPLATE_NAME = 'index' Meteor.startup(function() { if (Meteor.isServer) { bootstrapServer(); } if (Meteor.isClient) { bootstrapClient(); } }); var bootstrapClient = function() {}; var bootstrapServer = function() { Model1.setInstance(Model1.factory()); }; Module loader
  • 14. class Model1 @COLLECTION_NAME = ‘model1' @collection = null @getCollection: -> @collection @setCollection: (collection) -> @collection = collection constructor: (data) -> _.extend @, data getCollection: -> Model1.getCollection() customMethod: -> Model1.setCollection new Mongo.Collection Model1.COLLECTION_NAME, transform: (data) -> new Model1 data Model
  • 15. • Production-ready hosting for meteor deploy • Kubernetes.io (Docker container management system) • Official support for React.js and Angular • Official support for ECMAScript 2015 (ES6) • Better build tools Next release (Galaxy, Meteor 1.2)
  • 16. • Support of SQL • REST and micro-services • Testing with Velocity • Better tools for mobile development and testing • Integration of routing in a core After Meteor 1.2