Side-by-side comparison

Welcome to the comprehensive guide for migrating from Aurelia 1 to Aurelia 2! This guide will walk you through every aspect of the migration process, highlighting what's changed, what's improved, and what you need to know to successfully upgrade your application.

Aurelia 2 represents a significant evolution of the framework, bringing modern JavaScript features, improved performance, better tooling support, and a more streamlined developer experience. While many core concepts remain familiar, there are important changes that will make your applications more maintainable and powerful.


Table of Contents


Application Bootstrapping

The HTML Entry Point

The way you initialize your Aurelia application has been simplified and modernized.

The aurelia-app attribute told the framework where to find your main configuration file, and you had to include the aurelia-bootstrapper script.

Application Configuration and Startup

The main configuration file has been significantly streamlined, with a more intuitive API and better bundler compatibility.

Key concepts in v1:

  • PLATFORM.moduleName: Required for Webpack compatibility - you had to wrap every module reference

  • standardConfiguration(): Loaded default framework features

  • globalResources(): Made components available app-wide

  • feature(): Loaded grouped functionality

  • plugin(): Added third-party packages

  • setRoot(): Defined the root component

Registering Global Resources

Making components available throughout your app is now more flexible and type-safe.


Components and Templates

Component Structure

Components in Aurelia 2 maintain the same view-model pairing but with enhanced conventions and flexibility.

Template Syntax Enhancements

Aurelia 2 maintains familiar binding syntax while adding powerful new features.


Component Lifecycle

The component lifecycle has been expanded and refined with more hooks and better async support.

V1 Lifecycle Order: constructor → created → bind → attached → detached → unbind


Dependency Injection

Aurelia 2's DI system has been significantly enhanced with better type safety and more flexible registration options.


Logging System

The logging system has been completely redesigned with a more powerful and flexible architecture.


Router and Navigation

The router has been redesigned with a focus on type safety, better performance, and modern navigation patterns.


Data Binding

Data binding has been enhanced with better performance, new features, and more intuitive syntax.


What's New in Aurelia 2

Beyond the improvements to existing features, Aurelia 2 introduces several entirely new capabilities:

Shadow DOM Support

Custom Attribute Patterns

Create your own binding syntax!

Enhanced Custom Elements

Watch Decorator for Advanced Observation


Migration Checklist

Use this checklist to ensure you've covered all aspects of your migration:

🏗️ Project Setup

🧩 Components

🔗 Data Binding

🚦 Routing

💉 Dependency Injection

📝 Logging

🎨 Templates and Features

🧪 Testing

🔧 Advanced Features


Conclusion

Migrating from Aurelia 1 to Aurelia 2 brings significant benefits: better performance, improved developer experience, enhanced type safety, and modern JavaScript features. While there are changes to learn, the core concepts remain familiar, and the improvements make building applications more enjoyable and maintainable.

The enhanced DI system, redesigned router, automatic observation, and new template features make Aurelia 2 a powerful platform for building modern web applications. Take your time with the migration, test thoroughly, and don't hesitate to leverage the new features that make development more productive.

Remember that Aurelia 2 maintains the same philosophy of convention over configuration and stays out of your way, while providing powerful tools when you need them. The migration effort will be rewarded with a more maintainable, performant, and developer-friendly application.

Last updated

Was this helpful?