Skip to content

Commit

Permalink
use @eggjs/watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Dec 18, 2024
1 parent 6c0ce2f commit 9caff19
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions index-old.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ import EggCookies = require('egg-cookies');
import 'egg-onerror';
import 'egg-session';
import 'egg-i18n';
import 'egg-watcher';
import '@eggjs/watcher';
import 'egg-multipart';
import 'egg-security';
import 'egg-development';
import 'egg-logrotator';
import 'egg-schedule';
import '@eggjs/schedule';
import 'egg-static';
import 'egg-jsonp';
import 'egg-view';
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "egg",
"version": "4.0.0-beta.3",
"version": "4.0.0-beta.5",
"engines": {
"node": ">= 18.19.0"
},
Expand All @@ -24,6 +24,7 @@
"@eggjs/core": "^6.1.0",
"@eggjs/schedule": "^5.0.1",
"@eggjs/utils": "^4.0.2",
"@eggjs/watcher": "^4.0.0",
"@types/accepts": "^1.3.5",
"accepts": "^1.3.8",
"cache-content-type": "^2.0.0",
Expand All @@ -42,7 +43,6 @@
"egg-session": "^3.3.0",
"egg-static": "^2.2.0",
"egg-view": "^2.1.3",
"egg-watcher": "^3.1.1",
"extend2": "^4.0.0",
"graceful": "^1.1.0",
"is-type-of": "^2.1.0",
Expand Down
8 changes: 6 additions & 2 deletions site/docs/basics/plugin.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ order: 9
- 如何编写一个插件?

接下来我们就来逐一讨论。

## 为什么要插件

我们在使用 Koa 中间件过程中发现了下面一些问题:
Expand All @@ -35,12 +36,13 @@ order: 9
- 当遇到上一节提到的场景时,应用需引入插件。
- 插件本身可以包含中间件。
- 多个插件可以包装为一个[上层框架](../advanced/framework.md)

## 使用插件

插件通常通过 npm 模块的方式进行复用:

```bash
$ npm i egg-mysql --save
npm i egg-mysql --save
```

**注意:我们推荐通过 `^` 的方式引入依赖,并且强烈不建议锁定版本。**
Expand Down Expand Up @@ -118,7 +120,7 @@ exports.dev = {

**注意:**

- `plugin.default.js` 不存在
- `plugin.default.js` 不存在
- **只能在应用层使用,框架层请勿使用。**

### package 和 path
Expand All @@ -135,6 +137,7 @@ exports.mysql = {
path: path.join(__dirname, '../lib/plugin/egg-mysql'),
};
```

## 插件配置

插件一般会包含自己的默认配置。应用开发者可以在 `config.default.js` 中覆盖对应的配置:
Expand All @@ -153,6 +156,7 @@ exports.mysql = {
```

具体的合并规则可以参见[配置](./config.md)

## 插件列表

- 框架默认内置了企业级应用[常用的插件](https://eggjs.org/zh-cn/plugins/)
Expand Down
2 changes: 1 addition & 1 deletion src/config/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default {
*/
watcher: {
enable: true,
package: 'egg-watcher',
package: '@eggjs/watcher',
},

/**
Expand Down
2 changes: 1 addition & 1 deletion src/lib/egg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export class EggApplicationCore extends EggCore {
* - {Number} [maxWaitTime|30000] - leader startup max time, default is 30 seconds
* @return {ClientWrapper} wrapper
*/
cluster(clientClass: unknown, options: object) {
cluster(clientClass: unknown, options?: object) {
const clientClassOptions = {
...this.config.clusterClient,
...options,
Expand Down

0 comments on commit 9caff19

Please sign in to comment.