Upgrade aliases
The "Upgrade aliases" patch migrates your application from AdonisJS aliases to Node.js sub-path imports. Sub-path imports is a platform feature supported natively by Node.js and therefore we will embrace it with v6 applications.
npx @adonisjs/upgrade-kit@latest upgrade-aliases
pnpm dlx @adonisjs/upgrade-kit@latest upgrade-aliases
Following are the steps performed by this patch.
Config files updated
- Scan
.adonisrc.jsonfile for existing aliases. - Define a new set of aliases inside
package.jsonfile. Do note, the Node.js sub-paths import aliases must always start with a#. - Define the same set of aliases inside
tsconfig.jsonfile as well. - Remove aliases from the
.adonisrc.jsonfile.
Source code update
- Finally, we will update the import statements in your codebase to use new aliases prefixed with a
#.
Un-effected areas
- The patch will not update any dynamic imports.
- The patch will not update magic strings based imports referenced within routes file or the events file.
What is a magic string?
In the following example, the PostsController.index is a magic string. Since, the value is a string internally translated to an import by AdonisJS.
import Route from '@ioc:Adonis/Core/Route'
Route.get('posts', 'PostsController.index')