103

Node 8 LTS + Egg 2.x 计划

 6 years ago
source link: https://zhuanlan.zhihu.com/p/30673066?
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Node 8 LTS + Egg 2.x 计划

前端开发话题下的优秀答主
> eggjs-feed-05, 系列期刊,用于汇总近期值得关注的 egg 相关动态,将不定期发布。

## Node 8 终于 LTS 了,启动 Egg 2.x 。

  • 基于新的 V8,因此性能得到大幅提升,我们内部好几个项目升级后数据提升蛮明显的。
  • Async 等期待已久的特性。
  • 新特性 N-API ,更好的跨平台兼容原生插件。
  • ES Modules 作为实验性特性已经引入,但目前还比较早期,不建议使用。
  • Node 成为 V8 的一等公民。
  • Node.js 8 Moves into Long-Term Support

因此,Egg 也正式开始 2.x 的计划,欢迎参与讨论,传送门:eggjs/egg#1564

同时再次重申下:早在 Egg 1.0 版本的时候,就支持使用 Async 和 Koa2 的生态,开发者无需关注 Egg 的底层版本。

## Egg 的 VSCode 插件尝鲜

  • 目前还处于早期版本,欢迎试用。
  • 期望对 TS 和 VSCode 熟悉的同学,能参与进来帮我们一起完善,尤其是智能提示这块。
  • eggjs - Visual Studio Marketplace
    • 自动生成调试配置文件 launch.json
    • 支持 Service 和 Controller 的 Snippet

## 值得注意的讨论和变更

在 eggjs 团队的日常协作中,遵循「基于 GitLab 的硬盘式异步协作模式」。
通过 issue 发起 RFC 提案 -> 讨论定稿-> 提交 Pull Request -> Code Review -> 发布。
这样便于沉淀,即使是当时没有参与讨论的开发者,事后也能通过 issue 了解某个功能设计的前因后果。

Θ 新增了订阅模型的规约

  • 提案地址:[RFC] 订阅模型
  • 所有的订阅模式都可以用相同的方式来写。
  • 上次提到的 egg-schedule 改造也是基于此的,相关文档已经更新:定时任务

Θ Controller 继承优化

Θ egg-scripts 优化,发布 2.x

  • 注意:该工具不再支持 Windows,线上服务端一般都是 Linux,因此发了大版本。
  • 增加启动期检查,新增 eggctl 别名等优化
  • eggjs/egg-scripts#9eggjs/egg-scripts#10

Θ egg-multipart 示例更新

Θ egg-bin 内置的 mocha 升级为 4.x

Θ egg-oss 插件支持 Promise,并增加 sts 模式

Θ egg-cluster 优化了启动体验


## 最佳实践分享

早期用户应该比较熟悉,可能也比较不喜欢以下这个风格的代码:

module.exports = app => {
  class UserService extends app.Service {
    async list() {
      return await this.ctx.curl('https://eggjs.org');
    }
  }
  return UserService;
};

现在我们已经支持更自然的写法:

(其实一直支持,只是未写到文档。)

const Service = require('egg').Service;

class UserService extends Service {
  async list() {
    return await this.ctx.curl('https://eggjs.org');
  }
}

module.exports = UserService;

通过这种方式,你可以享受到部分 VSCode + TS 的代码提示体验优化。

PS:上层框架开发者需要改变写法如下,否则用户自定义 Service 等基类会有问题:

const egg = require('egg');

module.export = Object.assign(egg, {
  Application: class MyApplication extends egg.Application {
    // ...
  },
  // ...
});

## 社区文章


Recommend

  • 67
    • www.tuicool.com 5 years ago
    • Cache

    Node v10.13.0 (LTS)

    This release marks the transition of Node.js 10.x into Long Term Support (LTS) with the codename 'Dubnium'. The 10.x release line now moves in to "Active LTS" and will remain so until April 2020. After that time it will m...

  • 39
    • www.tuicool.com 5 years ago
    • Cache

    Node v10.14.0 (LTS)

    deps : Upgrade to OpenSSL 1.1.0j, fixing CVE-2018-0734 and CVE-2019-0735 http : Headers received by HTTP servers must not exceed 8192 byte...

  • 131
    • www.tuicool.com 5 years ago
    • Cache

    Node v6.17.0 (LTS)

    This is a security release. All Node.js users should consult the security release summary at https://nodejs.org/en/blog/vulnerability...

  • 54
    • www.tuicool.com 5 years ago
    • Cache

    Node v10.15.3 (LTS)

    doc add antsmartian to collaborators (Anto Aravinth) #24655

  • 40
    • www.tuicool.com 4 years ago
    • Cache

    Node v10.16.0 (LTS)

    deps : update ICU to 64.2 (Ujjwal Sharma) #27361 upgrade npm to 6.9.0 (Kat Marchán)...

  • 21
    • www.tuicool.com 4 years ago
    • Cache

    Node v12.13.0 (LTS)

    This release marks the transition of Node.js 12.x into Long Term Support (LTS) with the codename 'Erbium'. The 12.x release line now moves into "Active LTS" and will remain so until October 2020. After that time, it will m...

  • 21
    • nodejs.org 4 years ago
    • Cache

    Node v12.13.1 (LTS)

    Experimental support for building Node.js with Python 3 is improved. ICU time zone data is updated to version 2019c. This fixes the date offset in Brazil. Commits [

  • 14
    • nodejs.org 4 years ago
    • Cache

    Node v12.14.1 (LTS)

    crypto : fix key requirements in asymmetric cipher (Tobias Nießen) #30249 deps : update llht...

  • 5
    • nodejs.org 3 years ago
    • Cache

    Node v14.15.2 (LTS)

    Node v14.15.2 (LTS) by Bethany Nicolle Griggs, 2020-12-15 Notable Changesdeps: upgrade npm to 6.14.9 (Myles Borins)

  • 3
    • nodejs.org 3 years ago
    • Cache

    Node v10.23.1 (LTS)

    Node v10.23.1 (LTS) by Richard Lau, 2021-01-04 Notable changesThis is a security release. Vulnerabilities fixed: CVE-2020-8265: use-after-free in T...

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK