Codemods that move an Aurelia 1 codebase to Aurelia 2. It applies the changes that are safe to make mechanically, leaves everything else alone, and writes a report explaining what it did, what it could not do, and why.
The rule for every pass is the same: convert when the outcome is certain, otherwise report. A wrong automatic change in bootstrap or routing costs more than doing it by hand, so those are only rewritten when the code is regular enough to be sure. Everything the tool emits is checked against Aurelia 2.0.0-rc.2.
npm install -g au-rogue
# or
npx au-rogue --helpcd my-aurelia-1-app
# See what would change
npx au-rogue --dry --diff
# Read au-rogue.report.md, then apply
npx au-rogueBoth a Markdown report (au-rogue.report.md) and a JSON one (au-rogue.report.json) are written. The Markdown report groups findings into "Needs review", "Changes applied" and "Guidance", and ends with a next-steps checklist. Every finding carries the pass and rule that produced it and, where there is one, a line number.
| Option | Default | Purpose |
|---|---|---|
--dry |
off | Report without writing files |
--diff |
off | Print a unified diff of every file the run changes (works with --dry) |
--sources <glob...> |
src/**/*.{ts,tsx,js,jsx} |
Source files to migrate |
--templates <glob...> |
src/**/*.{html,au}, index.html |
Templates to migrate |
--ignore <glob...> |
– | Extra paths to skip (node_modules, dist, build are always skipped) |
--only <pass...> |
– | Run only these passes (space or comma separated) |
--skip <pass...> |
– | Skip these passes |
--list-passes |
– | Print the pass names and exit |
--tsconfig <path> |
– | Load the project's tsconfig so types resolve |
--router-hooks |
off | Rename router hooks even on classes that might be dialogs |
--compat |
off | Add @aurelia/compat-v1 guidance to the report |
--report-dir <dir> |
. |
Where to write the reports |
--no-report |
– | Skip writing report files |
--fail-on-warn |
off | Exit non-zero if anything needs manual review |
--quiet |
off | Suppress everything but the summary |
Passing --tsconfig is worth it. Without resolvable types the DI pass has to assume that an unresolved constructor parameter type is a class token; with them it knows, and the report says which tokens it could not verify.
Running the tool twice is safe. Every pass is idempotent, and a second run over migrated code makes no further changes.
Dependency injection. @autoinject, @inject(A, B) and static inject = [A, B] all become resolve() class fields, in constructor order. Parameter properties convert directly; plain parameters convert when the constructor assigns them to this (including this.el = el as HTMLElement, and when the property is already declared). Other uses of a parameter inside the constructor body are rewritten to this.name, which is safe because class fields initialise before the body runs. A parameter passed to super() is left in place, and the remaining tokens move to a static inject so the class still works. v1 resolvers map across in both forms: Lazy.of(X) and @lazy(X) become lazy(X), likewise all, optional, newInstanceOf and factory. Element, HTMLElement and DOM.Element tokens resolve the host element without an import. A constructor left empty by the conversion is removed.
Routing. configureRouter() becomes a @route({ routes: [...] }) decorator when every statement in it is understood: config.map([...]) with literal route objects, or config.map(routes) where routes is an array in the same file or imported from another file in the project (spreads like ...childRoutes are followed). Route keys are translated (route to path, moduleId to component: import('...'), name to id, settings to data, activationStrategy to transitionPlan, redirect to redirectTo), config.title and config.options.pushState become notes about RouterConfiguration.customize, mapUnknownRoutes becomes fallback, and this.router = router becomes a resolve(IRouter) field. Route arrays declared outside configureRouter are converted in place. router.navigateToRoute(name, params) and router.navigate(url) become router.load(...), and router.generate(name, params) becomes router.generatePath(...). Anything irregular (pipeline steps, viewPorts, layouts, non-literal module ids) blocks the conversion for that class and the decorator the tool would have generated goes in the report instead.
Lifecycle. bind to binding, unbind to unbinding, detached to detaching. Renames only happen on classes that look like Aurelia view-models. Router hooks (canActivate to canLoad, activate to loading, canDeactivate to canUnload, deactivate to unloading) are renamed only for classes that are clearly routed: they own a configureRouter, import the router, or are the target of a route config somewhere in the project. Dialogs and <compose> view-models keep activate/deactivate, because Aurelia 2 still calls those on dialogs and <au-compose>; --router-hooks overrides the check.
Imports. Aurelia 1 packages are remapped to their v2 equivalents, including symbol renames: HttpClient becomes IHttpClient (or stays HttpClient where the code constructs one), Router and AppRouter become IRouter, EventAggregator becomes IEventAggregator, ValidationController becomes IValidationController, DialogService becomes IDialogService, bindingMode becomes BindingMode, aurelia-store becomes @aurelia/store-v1, and the forty-odd aurelia-* packages collapse into aurelia and the scoped @aurelia/* ones. Imports that nothing uses any more are dropped. Symbols with no v2 counterpart stay where they are and get reported.
Platform. PLATFORM.moduleName('x') is unwrapped to 'x'. PLATFORM.global, .location, .history, .performance, .requestAnimationFrame and .addEventListener become the browser globals they wrapped. DOM.createCustomEvent(...) becomes new CustomEvent(...), DOM.createElement and friends become document.*, and the imports are dropped once nothing uses them.
Task queue. this.taskQueue.queueMicroTask(cb) becomes queueTask(cb) from aurelia, flushMicroTaskQueue() becomes runTasks(), and the TaskQueue injection goes away once nothing else uses it. v1's queueTask ran as a macrotask; it converts too, with a warning about the timing change.
Validation. this.controller = this.factory.createForCurrentScope() becomes controller = resolve(newInstanceForScope(IValidationController)), the ValidationControllerFactory injection is removed, validateTrigger becomes ValidationTrigger, and ValidationRules moves to @aurelia/validation. addRenderer and controller.errors are flagged.
Templates. <require> to <import>, <router-view> to <au-viewport>, <compose> to <au-compose> (with view/view-model to template/component), <content> and light-DOM <slot> to <au-slot>, <template replaceable part="x"> to <au-slot name="x">, replace-part to au-slot, .delegate to .trigger, .one-way to .to-view, .call to .bind with a lambda whose parameters are inferred from the expression, view-model.ref to component.ref, element.ref to ref, route-href to load, css="${...}" to style, <template bindable="a, b"> to <bindable> elements, and view-spy/compile-spy removed. Templates written inline in @customElement({ template }) get the same treatment. Edits are applied as offset splices against the original file, so anything the rules don't touch comes out byte for byte identical.
Decorators. @computedFrom(...) to @computed(...), @inlineView/@noView to @customElement({ name, template }), @useView('./shared.html') to a namespace import of the view module plus @customElement({ name, template: view.template, dependencies: view.dependencies }), and @bindable options renamed (defaultBindingMode to mode, changeHandler to callback). Definitions without a name get one derived from the class, since an unnamed Aurelia 2 element registers as unnamed-N.
- Bootstrap.
configure(aurelia)withaurelia.use.plugin(...)gets a worked example of the equivalentAurelia.register(...).app(Root).start(), with the v1 plugins mapped to their v2 configurations (ValidationHtmlConfiguration,I18nConfiguration,DialogConfigurationClassic,StoreConfiguration,RouterConfigurationwithuseUrlFragmentHashmatching the v1pushStatesetting) and aTODOfor the ones it does not know. - Dependencies. The Aurelia 1 packages in
package.json, with the exactnpm install/npm uninstallcommands to swap them, split into runtime and dev tooling. - tsconfig.
experimentalDecoratorsandemitDecoratorMetadataare incompatible with Aurelia 2's TC39 decorators;importHelperswithouttslib,commonjsmodules and old targets are flagged too. - Project layout. An
aurelia_project/folder, webpack configs andaurelia-testingbased test setups. - Lifecycle traps. A property that shadows a v2 hook (the classic being
loading = truenext to aloading()route hook, which silently stops the hook from running), listeners set up inattached()with no teardown, DOM work inbinding(), and the changed signatures ofcreated()and the router hooks. - Lost
preventDefault. Aurelia 1 called it for you on delegated events. Form submits, anchors with anhref, and submit buttons inside a form are flagged individually; every other converted handler is covered by one project-wide note. - Composition.
<compose view-model="./path">with a module path, since Aurelia 2'scomponenttakes an element name, class or instance rather than a path. - Everything with no equivalent.
LogManager,Redirect, pipeline steps,router.currentInstruction, navigation options liketrigger: false,addRenderer, and so on, each with the v2 shape to use instead.
--list-passes prints them. Every finding in the report is tagged with the pass and rule that produced it, so --only and --skip let you work through a large migration one concern at a time:
npx au-rogue --only templates # just the HTML
npx au-rogue --skip lifecycle,router # everything except the risky renamesThe tool covers the mechanical middle of a migration, not the whole of it. A workable order:
- Stand up an Aurelia 2 shell (
npx makes aurelia) and rewritemain.tsfrom the report's bootstrap example. - Register
compatRegistrationfrom@aurelia/compat-v1so any v1 syntax the tool could not rewrite keeps working while you port. - Copy
src/over and runau-rogue --dry --diff, thenau-rogue. - Work through the report's "Needs review" section. Routing first, since the app cannot navigate without it.
- Build, run the tests, and fix what falls out.
- Remove
compatRegistrationand drop the@aurelia/compat-v1dependency. The migration is finished when nothing depends on it.
pnpm install
pnpm test # vitest
pnpm run check # type-check the tests too
pnpm run buildThe examples/ directory holds a small Aurelia 1 app covering the patterns the tool handles; examples/run-migration.sh runs the tool against a copy of it. The migrated output type-checks against aurelia@2.0.0-rc.2 apart from the things the report says to do by hand.
MIT