farrow-js / farrow

A Type-Friendly Web Framework for Node.js
https://www.farrowjs.com
MIT License
770 stars 37 forks source link

farrow-vite@1.11.5 版本 dist 内容不正确 #152

Closed cloudcome closed 2 years ago

cloudcome commented 2 years ago

实际结果:

// dist/vite.js
const vite = (options) => {
    const router = (0, farrow_http_1.Router)();
    const config = Object.assign({}, options);
    let viteDevServers = [];
    router.useLazy(() => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () {
           ^^^^^^^^^

会有以下错误:

TypeError: router.useLazy is not a function
    at vite (/node_modules/farrow-vite/dist/vite.js:14:12)

期望结果:

// dist/vite.js
const vite = (options) => {
    const router = (0, farrow_http_1.Router)();
    const config = Object.assign({}, options);
    let viteDevServers = [];
    router.use(() => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () {
          ^^^^^
github-actions[bot] commented 2 years ago

Thank feedback. We will check it later:-)

Lucifier129 commented 2 years ago

router.useLazy 是正确的,那里就是要延迟执行。

找不到 useLazy可能是别的原因,检查一下模块加载方式是否符合预期。

cloudcome commented 2 years ago

可是我下载了源代码本地编译结果就是 router.use

image

cloudcome commented 2 years ago

一个月之前就已经修改为了 router.use 了:

image

Lucifier129 commented 2 years ago

@tqma113 farrow-vite 里应该用 useLazy 而非 use 吧,不然每次都会创建一个 viteDevServer.

另外,farrow-httpRouter 内部应该用 createAsyncPipeline 而非 createPipeline,前者拓展了其它方法,如 .useLazy

性能优化的代码产生了 breaking change,需要逐个添加 test-cases 并加以 fix。

@cloudcome 请先回退版本并固定,后续我们修复后再放开~

tqma113 commented 2 years ago

Patch version released. https://www.npmjs.com/package/farrow-http/v/1.11.3 https://www.npmjs.com/package/farrow-vite/v/1.11.6