feat: bundle server-side codes into a single file#8286
Open
sylingd wants to merge 29 commits intoweb-infra-dev:mainfrom
Open
feat: bundle server-side codes into a single file#8286sylingd wants to merge 29 commits intoweb-infra-dev:mainfrom
sylingd wants to merge 29 commits intoweb-infra-dev:mainfrom
Conversation
🦋 Changeset detectedLatest commit: d3d0d1e The changes in this PR will be included in the next version bump. This PR includes changesets to release 114 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✅ Deploy Preview for modernjs-v3 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
3 tasks
✅ Deploy Preview for modernjs-byted ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
Author
|
@zllkjc Hello,这个PR已经ready,有空的时候review一下哦~ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
添加 bundle server 功能,该功能可以将所有 server 端内容及依赖(含 BFF)打包为一个单一 js 文件。
该功能拆分自 deploy edge env 的 PR,后续 edge deploy 会基于该功能实现。
拆分出该功能的目的,并不是希望用户直接使用该功能,而是出于两个考虑:
因此,该功能不完善,例如目前生成的单一 js 文件 server 还不支持静态文件,故不对用户透出,仅用于 integration test。
在项目中通过
server.ssr.bundleServer开启该功能。运行完原先的 build 流程后,会执行二次 build。二次 build 会将页面、loader 打包至 route 上,其他依赖(如 api/lambda)打包至一固定 dependencies 对象上;该对象是一个“伪”文件树结构。主要改动:
solutions/app-tools的deploy/platforms/node中增加选项判断,调用 bundleServer 进行二次打包MODERN_SERVER_BUNDLE环境变量,标志是否会打包为单一文件。部分原先基于文件系统的行为将被替换:server/bff-core基于 dependencies 产生 API 列表。server/core从 dependencies 读取 manifest,从 route 读取 render、loaderserver/prod-server抽取公共逻辑到 base-server 中signaleora包,其并未被直接使用,而是被其他第三方包依赖graceful-fsgraceful-fs主要用于“优化”原生fs的一些边界情况,但其不兼容以 esm import 方式导入的 fs,会在 bundle server 中报错。refruntime/plugin-runtime中增加了sort语句,以保持不同平台下行为一致,避免ut失败的情况(sort逻辑原先是在graceful-fs中做的)/*#__PURE__*/标记runtime/plugin-runtime中的一些常量移动到公共包,因 bundle server 功能需要使用几个常量,避免不必要的依赖过深,所以进行移动。测试运行结果 integration-test-linux
Related Links
拆分自#8097
Checklist
pnpm run change.