Upgrade to 3.x
This article will introduce how to upgrade from midway v2 to midway v3.
Upgrading from Midway v2 to Midway v3, there will be some Breaking Changes. This document will list these Breaking places in detail, so that users can know the changes in advance and respond to them.
Automatic upgrade tool
**Before the upgrade, please cut out a new branch to avoid the failure of the upgrade and cause no recovery! ! ! **
Copy the following script and execute it in the project root directory:
$ npx --ignore-existing midway-upgrade
Due to different business situations, please check the manual upgrade after the script upgrade.
Manual upgrade
**midway v3 support since node v12. **
Package version update
All component packages, core packages will be upgraded to 3.x version.
{
"dependencies": {
"@midwayjs/bootstrap": "^3.0.0",
"@midwayjs/core": "^3.0.0",
"@midwayjs/decorator": "^3.0.0",
"@midwayjs/koa": "^3.0.0",
"@midwayjs/task": "^3.0.0",
},
"devDependencies": {
"@midwayjs/cli": "^1.2.90",
"@midwayjs/luckyeye": "^1.0.0",
"@midwayjs/mock": "^3.0.0",
// ...
}
}
@midwayjs/cli
and @midwyajs/luckeye
, except @midwayjs/logger
version.
Query/Body/Param/Header decorator changes
Mainly the default behavior without parameters.
old
async invoke(@Query() name) {
// ctx.query.name
}
new
async invoke(@Query() name) {
// ctx.query
}
async invoke(@Query('name') name) {
// ctx.query.name
}