Build System Overview
Highcharts uses a modular build system powered by:- TypeScript - Source code in
ts/directory - Gulp - Build orchestration and task automation
- @highcharts/highcharts-assembler - Module bundling and assembly
- SWC - Fast JavaScript/TypeScript compilation and minification
- Webpack - Module bundling for ES modules
Understanding the Module System
Highcharts is structured as ES6 modules that can be assembled in different ways:Build Commands
Creating a Custom Build
1
Identify Required Modules
Determine which Highcharts features you need:
2
Use ES Modules
Import only what you need:
3
Bundle with Your Tool
Use your preferred bundler:
Build Configuration
TypeScript Configuration
The main TypeScript configuration is ints/tsconfig.json:
Compilation Process
Highcharts uses SWC for fast compilation and minification:Using Highcharts Assembler
The@highcharts/highcharts-assembler package builds distributable modules:
Tree Shaking with Modern Bundlers
Modern bundlers like Webpack 5, Rollup, and Vite support tree shaking with Highcharts ES modules, automatically removing unused code.
Optimizing Build Size
1
Use ES Modules
Always prefer ES modules for better tree shaking:
2
Import Only Needed Modules
3
Enable Compression
Configure your bundler for optimal compression:
Build Products
Highcharts supports building different products:Custom Build Examples
Minimal Chart Build
Stock Chart with Indicators
Chart with Exporting
Development Workflow
1
Start Watch Mode
2
Make Changes
Edit files in the
ts/ directory:3
Test Changes
The build system automatically compiles to
code/es-modules/:CI/CD Integration
Performance Tips
- Use specific imports - Avoid importing the entire library
- Enable minification - Always minify production builds
- Enable gzip/brotli - Configure your server for compression
- Use CDN for common builds - Let browsers cache standard builds
- Lazy load modules - Load optional features on demand