When migrating an Aurelia 1 application to Aurelia 2 recently, I had to deal with many routes I needed to convert tediously. As you might have discovered, the Aurelia 2 @aurelia/router
is different to the Aurelia 1 router.
Not wanting to change 50+ manual PLATFORM.moduleName
values, I opted for a regular expression. I hate RegEx because I don’t understand it, but you cannot deny its power. Here’s the solution I used.
- Find: PLATFORM.moduleName(’(.*)')
- Replace: () => import(’$1')
This will take: PLATFORM.moduleName(‘pages/about-us/about-us’) and convert it to: () => import(‘pages/about-us/about-us’)