Development Infrastructure
OpenLayers maintains a comprehensive development infrastructure that encompasses build systems, development tools, testing frameworks, and documentation generation. This infrastructure supports the library's development workflow from source code to distribution packages, examples, and API documentation.
Infrastructure Overview
The development infrastructure consists of multiple interconnected systems that handle different aspects of the development lifecycle.
Development Infrastructure Architecture
Sources: package.json12-34
Core Dependencies and Structure
OpenLayers has a minimal set of runtime dependencies and a comprehensive set of development dependencies.
Core Dependencies
The library has only a few direct dependencies for runtime functionality:
| Dependency | Purpose |
|---|---|
| rbush | Spatial indexing |
| earcut | Polygon triangulation |
| geotiff | GeoTIFF parsing |
| pbf | Protocol buffer parsing |
Development Dependencies
The development dependencies include tools for building, testing, and documentation:
- Build Tools: Webpack, Rollup, TypeScript
- Testing Tools: Karma, Mocha, Puppeteer
- Documentation Tools: JSDoc
Build Process Flow
The build process in OpenLayers follows a series of steps defined in npm scripts, transforming source code into distributable formats.
Transpilation Process
The transpilation process is the first step in the build pipeline:
- Clean the build directory
- Create a new build directory structure
- Copy source code from
src/oltobuild/ol - Process web workers
- Set the library version
Command: npm run transpile
Building the Index
The index build process creates the main entry point for the library:
- Remove any existing index.js file
- Run the transpilation
- Generate the index file
Command: npm run build-index
Full Build
The full build creates bundled versions of the library using Rollup:
- Clean the full build directory
- Run the index build
- Bundle the library with Rollup
Command: npm run build-full
Package Build
The package build prepares the distribution package:
- Create the full build
- Copy CSS files
- Generate TypeScript declaration files
- Prepare the package
Command: npm run build-package
Testing Framework
OpenLayers has a comprehensive testing suite that includes browser tests, Node.js tests, and rendering tests.
Browser Testing
Browser tests run in a headless Chrome browser using Karma:
- Configure Karma with Webpack
- Set up headless Chrome with Puppeteer
- Run tests with source map support
Command: npm run test-browser
Node Testing
Node.js tests run with Mocha:
- Run tests recursively in the test/node directory
- Test Node.js-specific functionality
Command: npm run test-node
Rendering Tests
Rendering tests ensure consistent visual output:
- Build the full library
- Render test cases
- Compare with expected images
Command: npm run test-rendering
Development Workflow
The development workflow includes tools for serving examples, checking code quality, and generating documentation.
Serving Examples
For development, a Webpack dev server serves examples with live reloading:
Command: npm start or npm run serve-examples
Type Checking and Linting
Code quality is ensured with TypeScript and ESLint:
- TypeScript:
npm run typecheck,npm run typecheck-strict - ESLint:
npm run lint
Documentation Generation
API documentation is generated with JSDoc:
Command: npm run apidoc
Build Outputs
The build process produces several artifacts:
- build/ol: Transpiled source code
- build/full: Bundled library
- build/examples: Built examples
- build/apidoc: API documentation
Version Management
OpenLayers tracks version information in the package.json file and updates it during the build process. This allows for precise version control and ensures that built artifacts correctly reflect the current version.
The current version is specified as 10.5.1-dev, indicating development progress toward the next release.
Conclusion
The OpenLayers build system provides a comprehensive and flexible workflow for development, testing, and distribution. It leverages modern JavaScript tools to ensure code quality, compatibility across different environments, and efficient building processes. This infrastructure enables the team to maintain the library effectively and deliver high-quality releases.