feat(pack): add devServer.proxy with pathRewrite and example#2664
feat(pack): add devServer.proxy with pathRewrite and example#2664
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces the highly anticipated Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a devServer.proxy feature, which is a valuable addition for development workflows. The implementation is comprehensive, including new configuration types, core proxying logic using http-proxy, and integration into the dev server for both HTTP and WebSocket requests. The inclusion of a new example project (with-proxy) is excellent for demonstrating the feature's usage. My main feedback is focused on improving the error handling in the proxy logic to make it more robust and prevent potential server errors when a proxy request fails.
|
现在是基于原生 Node.js 封装的,考虑到后期中间件的需求越来越多,还是需要一个成熟的框架
同时 utoo 很大一部分会考虑到跨平台使用(web nodejs wasm 等),hono 这种不挑运行时的框架可能是个不错的选择 不过由于 hono 是基于 web standard API 封装的,且由于 hono 自身的路由优化,可能需要这个 pr 先重构成 hono 的形式,以获得更好的性能。 |
13c445b to
297b02c
Compare
|
由于 hono 的 nodejs adapter 的封装问题,先给 ws 代理功能砍了,地址正则匹配功能留下来了 |
📊 Performance Benchmark Report (with-antd)Utoopack Performance ReportReport ID: Executive Summary
Build Phase TimelineShows when each build phase is active and how much CPU it consumes.
Workload Distribution by Diagnostic Tier
Top 20 Tasks by Self-TimeSelf-time is the exclusive duration: time spent in the task itself, not in sub-tasks.
Critical Path AnalysisThe longest sequential dependency chains that determine wall-clock time.
Batching CandidatesHigh-volume tasks dominated by a single parent. If the parent can batch them,
Duration Distribution
Action Items
Report generated by Utoopack Performance Analysis Agent |
297b02c to
3245db6
Compare
|
@yuzheng14 it seems conflict |
| @@ -0,0 +1,8 @@ | |||
| import { defineConfig } from "vitest/config"; | |||
There was a problem hiding this comment.
这个 vitest 配置要不在顶层放一个,然后去对应的每个 packages/** 里面去单独放一个?这样顶层 turbo 驱动 turbo test 的时候可以缓存每一次的 vitest 结果,也方便后面这个 monorepo 去添加新的子应用
package.json
Outdated
| "scripts": { | ||
| "build": "turbo run build", | ||
| "test": "turbo run test", | ||
| "test": "vitest run", |
There was a problem hiding this comment.
这个还是用 turbo run test 吧,给 pack-shared 和 pack 这两个包都加个 test 脚本就好了
- Add ProxyRule/DevServerProxy/PathRewrite types and proxy in pack-shared config - Implement proxy in pack: context match (prefix + ^regex), pathRewrite (object + function), changeOrigin/secure - Add proxyFromObject in pack-shared utils for object-to-array proxy config - Wire proxy into dev server HTTP and WebSocket in dev.ts - Add unit tests under __test__ (proxy, proxyFromObject), exclude from tsconfig - Add examples/with-proxy: React app fetching JSONPlaceholder via /api and /placeholder Made-with: Cursor
3245db6 to
bb5114c
Compare
Summary
Implements devServer.proxy for Utoo Pack dev server.
Changes
ProxyRule,DevServerProxy,PathRewritetypes;proxyFromObjectutil;devServer.proxyon config.core/proxy.ts— context match (prefix +^regex), pathRewrite (object + function), changeOrigin/secure; wired into HTTP and WebSocket indev.ts.__test__/utils.test.ts,__test__/proxy.test.ts(excluded from tsconfig).examples/with-proxy— React app proxying to JSONPlaceholder via/apiand/placeholder.Closes #2584
Made with Cursor