Aurelia Bundler (SystemJS)
aurelia-bundler is a utility library specifically designed for bundling JavaScript, HTML, and CSS assets within applications built using the Aurelia 1 framework, leveraging SystemJS as the module loader. It provides programmatic APIs, commonly integrated into build automation tools like Gulp, to consolidate application modules and their dependencies into optimized bundles for production deployment. The package is considered abandoned, with its last release, version 0.7.0, dating back approximately eight years. It has been superseded by the built-in bundler provided by the Aurelia CLI for Aurelia 1 projects, and is not compatible with Aurelia 2, which has transitioned to modern bundlers such as Vite, Webpack, or Parcel. The package primarily addresses the bundling needs of legacy Aurelia 1 applications that explicitly relied on the SystemJS module ecosystem. Its release cadence was irregular towards the end of its active lifecycle, focusing on minor updates and bug fixes.
Common errors
-
Uncaught (in promise) TypeError: Class extends value undefined is not a constructor or null
cause Occurs during migration from `aurelia-bundler` to alternative bundlers for Aurelia 1, often due to issues with dependency injection, `tslib` configuration, or incorrect handling of module imports and exports by the new bundler.fixEnsure `tslib` is correctly configured and bundled. Verify that all dependencies are properly resolved and available at runtime. Review how the new bundler handles CommonJS/ESM interop and dependency injection for Aurelia 1 components. -
Views not included in the bundles / Error: No View for [ViewModel]
cause The bundler failed to automatically trace and include associated HTML view templates, especially in projects with non-standard file structures or dynamically generated views.fixExplicitly configure the bundler to include HTML files using patterns like `'*.html!text'`. For dynamically generated views, ensure the bundling configuration is aware of their paths or modify the application to fetch them at runtime rather than relying on bundling.
Warnings
- breaking The `aurelia-bundler` project has been officially archived on GitHub since March 2020 and is no longer actively maintained. It was superseded by the built-in bundler in the Aurelia CLI.
- breaking This bundler is designed exclusively for Aurelia 1 applications using SystemJS. It is incompatible with Aurelia 2, which has a different module resolution and bundling strategy.
- gotcha Aurelia 1 projects often used `PLATFORM.moduleName()` for Webpack compatibility to hint at dynamic module loading. `aurelia-bundler` typically didn't require this for SystemJS, but migration away from it often means understanding new bundler configurations for module resolution.
Install
-
npm install aurelia-bundler -
yarn add aurelia-bundler -
pnpm add aurelia-bundler
Imports
- bundle
const bundle = require('aurelia-bundler').bundle;import { bundle } from 'aurelia-bundler';
Quickstart
import gulp from 'gulp';
import { bundle } from 'aurelia-bundler';
const config = {
force: true,
baseURL: '.', // Relative path to your project root
configPath: './config.js', // Path to your SystemJS config file
bundles: {
"dist/app-build": {
includes: [
'[*.js]', // Include all JS files
'*.html!text', // Include all HTML templates as text
'*.css!text', // Include all CSS files as text
// Add other Aurelia modules or your app-specific modules here
],
options: {
inject: true,
minify: true
}
},
"dist/vendor-build": {
includes: [
'aurelia-bootstrapper',
'aurelia-fetch-client',
'aurelia-router',
'aurelia-animator-css',
// Add other vendor dependencies here
],
options: {
inject: true,
minify: true
}
}
}
};
gulp.task('bundle', function() {
console.log('Starting Aurelia bundling...');
return bundle(config)
.then(() => console.log('Aurelia bundling complete!'))
.catch(err => console.error('Aurelia bundling error:', err));
});
// To run this: ensure gulp and aurelia-bundler are installed as dev dependencies.
// Then run 'gulp bundle' from your terminal.