Package Structure
Every Meteor package requires apackage.js file that defines metadata, dependencies, and files.
Basic Package.js
package.js
Core Package Example
Here’s a real example frompackages/tracker/package.js:
Complex Package Example
Frompackages/mongo/package.js:
Package API Methods
Package.describe()
api.versionsFrom()
Specify compatible Meteor versions:api.use()
Declare package dependencies:api.addFiles()
Add source files to the package:api.mainModule()
Specify the main entry point (recommended over addFiles):api.export()
Export symbols globally:api.addAssets()
Add non-code assets:Npm.depends()
Declare npm dependencies:Creating a Package
1
Create package structure
Use the Meteor command to scaffold a package:
2
Edit package.js
Update the package metadata and dependencies:
3
Write your code
Create your main module file:
main.js
4
Add tests
Write tests in your test file:
tests.js
Testing Packages
Local Testing
Test your package in a local app:Running Package Tests
Testing from Meteor Checkout
When contributing to core packages:Publishing Packages
Prerequisites
1
Ensure Meteor 3 compatibility
For Meteor 3 packages, specify the release:
2
Test thoroughly
Run all tests and verify functionality:
3
Write documentation
Create a comprehensive README.md with:
- Installation instructions
- Usage examples
- API documentation
Publishing to Atmosphere
Version Bumping
Follow semantic versioning:- Patch (1.0.0 → 1.0.1): Bug fixes, no breaking changes
- Minor (1.0.0 → 1.1.0): New features, backward compatible
- Major (1.0.0 → 2.0.0): Breaking changes
- Patch bump: Changes OK to release independently
- Minor bump: Requires new Meteor release
- Major bump: Major rewrite, requires new Meteor release
Core Package Contributions
When contributing to core Meteor packages:Guidelines
- Each package should stand separately
- APIs should be consistent between client and server where possible
- Prefer synchronous APIs (use
Meteor.wrapAsyncon server) - Don’t harm the new developer experience
- Don’t preclude experts from advanced usage
Submitting Pull Requests
1
Propose your change
Create a Discussion to build consensus before coding
2
Wait for 'ready' label
Once labeled
ready, leave a comment and start working3
Include tests
All code changes must include tests
4
Bump version
Update version in
package.js according to change type5
Follow code style
Use the Meteor Style Guide
Package Best Practices
Structure
- Use
api.mainModule()instead ofapi.addFiles()for modern packages - Organize code by feature, not by client/server
- Use ES modules (
import/export)
Dependencies
- Minimize dependencies to reduce bloat
- Use weak dependencies for optional integrations
- Specify version constraints for stability
Exports
- Only export public API symbols
- Use
testOnly: truefor internal test helpers - Document all exported functions
Testing
- Test both client and server code
- Test integration with common packages
- Include edge cases and error handling
Documentation
- Clear README with examples
- API reference for all exports
- Changelog for version updates
Next Steps
Testing Guidelines
Learn how to write comprehensive tests
Release Process
Understand how Meteor releases work