Skip to main content
The rspack package integrates the Rspack bundler into Meteor’s build system, providing a modern, fast bundling solution for Meteor applications with support for React, Angular, TypeScript, and more.

Overview

Rspack is a high-performance JavaScript bundler that runs independently within the Meteor lifecycle. It supports development mode with hot module replacement (HMR) and production builds with optimization.

Installation

The package automatically installs required dependencies when enabled. Manual installation:

Configuration

Entry Points

Rspack requires entry points defined in package.json:
Required fields:
  • meteor.mainModule.client - Client-side entry point
  • meteor.mainModule.server - Server-side entry point
Optional fields:
  • meteor.testModule.client - Client test entry
  • meteor.testModule.server - Server test entry
  • meteor.testModule - Single test file for both client and server

Rspack Configuration File

Create rspack.config.js in your project root. The package provides a default configuration that will be created automatically if missing. Basic example:

Meteor Configuration

Configure Rspack behavior in package.json:
Configuration Options:
  • autoInstallDeps - Automatically install Rspack dependencies (default: true)
  • devServerPort - Dev server port (default: calculated automatically)
  • verbose - Enable verbose logging
  • bundleVisualizer.enabled - Enable bundle analysis with Rsdoctor
  • bundleVisualizer.clientPort - Rsdoctor client port
  • bundleVisualizer.serverPort - Rsdoctor server port

Build Modes

Development Mode

Run with meteor run or meteor:
Features:
  • Hot Module Replacement (HMR)
  • Fast rebuilds with watch mode
  • Source maps enabled
  • Dev server for client assets
  • File watching for server code

Production Mode

Run with meteor run --production or meteor build:
Features:
  • Minified bundles
  • Optimized code
  • No dev server
  • Watch mode in run --production
  • Single build in meteor build

Test Mode

Run tests with Rspack:
Test modes supported:
  • Unit tests (meteor test)
  • Full-app tests (meteor test --full-app)
  • Watch mode for continuous testing

Plugin Architecture

Main Entry Point

The plugin orchestrates the Rspack integration:

Build Context

Rspack uses a .rspack directory for build artifacts:

File Ignoring

The package automatically configures .meteorignore patterns:
Ignored by default:
  • node_modules/**
  • Non-entrypoint directories
  • Build context folders
  • CSS/HTML files in entry point directories (handled by Rspack)

Framework Support

React

Automatically detected and configured:
Required packages:
  • react
  • react-dom
  • @rspack/plugin-react-refresh (auto-installed)

TypeScript

Automatic TypeScript support when detected:
Supported file extensions:
  • .ts - TypeScript
  • .tsx - TypeScript with JSX

Angular

Angular support detection:

Dev Server

Port Configuration

Ports are automatically calculated or configured:

Proxy Middleware

Client assets are served through a proxy:
Client bundles accessed via:

Bundle Visualization

Enable Rsdoctor for bundle analysis:
Access the visualizer:
  • Client: http://localhost:3200
  • Server: http://localhost:3201

Compilation Tracking

The package tracks first compilation to ensure Meteor waits:

Environment Variables

  • RSPACK_DEVSERVER_PORT - Dev server port
  • RSDOCTOR_CLIENT_PORT - Rsdoctor client port
  • RSDOCTOR_SERVER_PORT - Rsdoctor server port
  • YARN_ENABLED - Whether project uses Yarn
  • METEOR_DISABLE_COLORS - Disable colored output

Debugging

Enable verbose logging:
Or in package.json:
Verbose output shows:
  • Rspack configuration paths
  • Dev server ports
  • Rsdoctor ports
  • NPM/Yarn prefixes
  • Entry points
  • Ignore patterns

Cleanup

Automatic cleanup on exit:

Limitations

  • Requires explicit entry points in package.json
  • Client and server must have separate entry files
  • .meteorignore is automatically modified
  • Legacy browser support requires additional configuration
  • Native mobile builds use production mode

Example Projects

React Application

package.json:
client/main.jsx:

TypeScript Application

package.json:
tsconfig.json: