Giter Club home page Giter Club logo

Comments (52)

popomore avatar popomore commented on March 29, 2024
  • app.js/agent.js 支持返回一个 promise

from egg.

dead-horse avatar dead-horse commented on March 29, 2024

+1 直接支持 app.js 是一个 generator 或者 async function 吧

from egg.

dead-horse avatar dead-horse commented on March 29, 2024

需求很强烈,app.js 里面可能要做挺多逻辑的

from egg.

popomore avatar popomore commented on March 29, 2024

增加 strict 参数,有些 warn 的直接抛错

from egg.

jtyjty99999 avatar jtyjty99999 commented on March 29, 2024

load filter能支持就好了,感觉可以单独抽象

from egg.

popomore avatar popomore commented on March 29, 2024

filter 原来就有吧

from egg.

atian25 avatar atian25 commented on March 29, 2024

之前是在 view 里面单独做的

from egg.

popomore avatar popomore commented on March 29, 2024

哦,懂了,我以为是 loader 参数。

helper 都应该放 view 里,先算了吧,view 有自己的 helper

from egg.

popomore avatar popomore commented on March 29, 2024

原来的加载顺序是 app > framework > plugin > egg,所以 loader 需要提供一个 eggPath 来指定 egg 的目录。

https://github.com/eggjs/egg-loader/blob/master/lib/base_loader.js#L187

from egg.

popomore avatar popomore commented on March 29, 2024

去除 eggPath 和 customEgg 参数,

  1. 顺序改为 app > framework > plugin,egg 作为 framework 的最底层,plugin 完全独立,无法覆盖 framework 和 app
  2. 继承 framework 必须指定 eggPath,所以不需要 customEgg 参数了。

from egg.

atian25 avatar atian25 commented on March 29, 2024

这个变更的出发点是?

from egg.

popomore avatar popomore commented on March 29, 2024

去除复杂性

from egg.

popomore avatar popomore commented on March 29, 2024

找 eggPaths 的时候是否需要强制指定当前框架的 eggPath

  1. 如果不强制指定,很容易忽略错误,某个框架未配置则忽略所有的文件。
  2. 如果强制指定,那会一直找到 koa,但是 koa 肯定不会配置的。

之前会指定 eggPath 参数为最底层的框架,但是这个变量容易被误解。

from egg.

fengmk2 avatar fengmk2 commented on March 29, 2024

找到 eggPath 就算到最底层了吧?egg 本身会依赖 koa,为何要 loader 去关注 koa 呢?

from egg.

popomore avatar popomore commented on March 29, 2024

看上面,去除 eggPath 了

from egg.

fengmk2 avatar fengmk2 commented on March 29, 2024

没搞明白如何能做到去掉 eggPath 的,去掉了多层继承是怎么做到的?

from egg.

popomore avatar popomore commented on March 29, 2024

这里说的 eggPath 是指 loader 的参数,指定最底层 egg 的路径。你说的 eggPath 是每层框架通过 symbol 来指定自己框架的路径。所以总是会存在理解差异,要去掉。一旦没有了最底层的 egg 路径,那么就不知道循环到哪里停止了,只能到 koa 了。

from egg.

popomore avatar popomore commented on March 29, 2024

这里 egg-loader 是不感知 egg 存在的,如果感知可以在 egg 加个 isEgg 的参数。

from egg.

fengmk2 avatar fengmk2 commented on March 29, 2024

一直找到 package.name === egg 的那个模块不就行了?

from egg.

fengmk2 avatar fengmk2 commented on March 29, 2024

而且对于 npm3,根本无法递归找下去。。。

from egg.

popomore avatar popomore commented on March 29, 2024

不是目录递归啊,是原型链

from egg.

fengmk2 avatar fengmk2 commented on March 29, 2024

egg 的 Application 设置一个 Application.isEgg = true 来判断是 egg 还是 koa?无法通过特殊值判断是否 koa Application 的。

from egg.

popomore avatar popomore commented on March 29, 2024
  return app.hasOwnProperty('use') &&
    app.hasOwnProperty('listen') &&
    Object.getPrototypeOf(app) === Emitter.prototype;

黑科技

from egg.

atian25 avatar atian25 commented on March 29, 2024

会不会太黑了

from egg.

popomore avatar popomore commented on March 29, 2024

是黑

from egg.

popomore avatar popomore commented on March 29, 2024

补充去除 lib/core 潜规则的原因

现在框架必须放到 lib/core 目录下,这个约定其实很奇怪,我希望所有的 load unit 都是一致的,所以对于框架来说也是可以放到 app, config 目录下。

from egg.

popomore avatar popomore commented on March 29, 2024

增加 strict 模式,强制不能 override

from egg.

gxcsoccer avatar gxcsoccer commented on March 29, 2024

加载顺序建议还是保持不变: app > framework > plugin > egg

eggPath 可以通过 require.resolve('egg') 来找?

from egg.

gxcsoccer avatar gxcsoccer commented on March 29, 2024

Symbol.for('egg#eggPath') 建议改个名字,egg#frameworkPath ? 不然老搞混

from egg.

popomore avatar popomore commented on March 29, 2024

eggPath 就是框架 path 吧,我把所有都改下好了
GaoXiaochen [email protected]于2016年8月3日 周三上午9:37写道:

Symbol.for('egg#eggPath') 建议改个名字,frameworkPath ? 不然老搞混


You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
#19 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAWA1TYYpv_pdRtnSWsBGdQZZiH2xnyrks5qb_DfgaJpZM4JOMI-
.

from egg.

gxcsoccer avatar gxcsoccer commented on March 29, 2024

eggPath 我觉得就是 egg 的路径,上层的框架改成 egg#frameworkPath 这样没有歧义。

from egg.

popomore avatar popomore commented on March 29, 2024

现在就是去除这个概念,egg 本身来说也只是集合插件,增加默认配置,和框架无异。而插件功能应该独立,会依赖一些框架 api(使用哪些 api 由被哪些框架依赖决定),但不应该覆盖。

from egg.

gxcsoccer avatar gxcsoccer commented on March 29, 2024

我一下子想不到具体的场景,但是插件覆盖 egg 的场景肯定是有的。比如: egg 内置了一些功能,我开发了一个插件做了新的实现或者依赖某些功能的开启或关闭,是有可能对 egg 配置做调整的

from egg.

popomore avatar popomore commented on March 29, 2024

覆盖 egg 应该框架来做,插件只是使用 api

from egg.

dead-horse avatar dead-horse commented on March 29, 2024

指的是现在不允许插件覆盖 egg 或者框架定义的东西?

from egg.

gxcsoccer avatar gxcsoccer commented on March 29, 2024

覆盖 egg 应该框架来做,插件只是使用 api

这个步子迈的有点大,而且是否合理呢? 我认为能在插件里做掉的,就不要抛到 framework 里了

from egg.

popomore avatar popomore commented on March 29, 2024

我觉得是合理的,现在的 egg 更薄了,那在这之上的(比如内部使用版本)肯定是无法被插件覆盖的,所以尽量保持上面的原则。

from egg.

gxcsoccer avatar gxcsoccer commented on March 29, 2024

我理解 egg 是基线,plugin 是一堆扩展,framework 是最佳实践,app 是实际落地场景。

对于插件来说,最好的使用体验就是引入以后开启就好

from egg.

popomore avatar popomore commented on March 29, 2024

就是引入开启就好

  1. 提供 api
  2. 有必要使用框架和其他插件的 api,但不应该覆盖

from egg.

gxcsoccer avatar gxcsoccer commented on March 29, 2024

额,@popomore 你说的是最理想的情况,有些插件不光是提供 api,他可能依赖一些底层的能力(这些能力可能是需要通过配置来开启或者调整参数的)。

从逻辑上讲,插件是“插”在 egg 上的,现在加载顺序,egg 在 plugin 后面,plugin 往哪儿插呢?

from egg.

popomore avatar popomore commented on March 29, 2024

是的,但是这个本身不是 loader 文件做的,是在 app.js 自定义的,现在也是这样实现的。

from egg.

popomore avatar popomore commented on March 29, 2024

egg 的加载有两层切面,一个是现在说的顺序,另一层是各个模块(middleware, service, extend 等)。模块之间会有顺序,每个模块则是按上面的顺序加载。所以这里的顺序只是决定加载同名文件时的覆盖顺序,app.js 则是灵活的,所以叫 customApp。

from egg.

gxcsoccer avatar gxcsoccer commented on March 29, 2024

你的意思是:插件要覆盖 config,需要 app.js 里通过修改 app.config 来做?

还是说就不能覆盖?

from egg.

popomore avatar popomore commented on March 29, 2024

现在大部分也是这么做的

from egg.

gxcsoccer avatar gxcsoccer commented on March 29, 2024

app.config ? 这个。。。为什么要这样呢

from egg.

popomore avatar popomore commented on March 29, 2024

有业务场景才需要,不希望这样改。

比如在某个环境默认使用某些值,不希望被开发者覆盖,这时就需要修改 config

from egg.

popomore avatar popomore commented on March 29, 2024

loadHelperEextend 感觉可以移到 egg 里,依赖 app.Helper

from egg.

popomore avatar popomore commented on March 29, 2024

讨论的新结果是将 egg-loader 转成 egg-core,「一个带加载功能的 koa」。egg-core 保留 loader 功能,增加 constructor,初始化且加载。

这个 issue 等下更新下。

from egg.

popomore avatar popomore commented on March 29, 2024
  app.messenger.on('log-reload', () => {
    loggers.reload('got log-reload message');
    loggers.coreLogger.info('[egg:logger] logger reload: got log-reload message from self');
  });

这段逻辑放 logrotator?

from egg.

fengmk2 avatar fengmk2 commented on March 29, 2024

@popomore 方便,更加合适在 logrotator 插件,要不然还得约定 log-reload message

from egg.

popomore avatar popomore commented on March 29, 2024

#51

from egg.

popomore avatar popomore commented on March 29, 2024

#52

from egg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.