feat: bundle server-side codes into a single file#8286
Draft
sylingd wants to merge 26 commits intoweb-infra-dev:mainfrom
Draft
feat: bundle server-side codes into a single file#8286sylingd wants to merge 26 commits intoweb-infra-dev:mainfrom
sylingd wants to merge 26 commits intoweb-infra-dev:mainfrom
Conversation
🦋 Changeset detectedLatest commit: 791267a The changes in this PR will be included in the next version bump. This PR includes changesets to release 110 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
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.
为方便 Review,拆分出更小的 PR
Summary
添加 bundle server 功能,该功能可以将所有 server 端内容及依赖(含 BFF)打包为一个单一 js 文件。
该功能拆分自 deploy edge env 的 PR,后续 edge deploy 会基于该功能实现。将该功能单独拆分,主要出于两个目的:
在项目中通过
server.ssr.bundleServer开启该功能。运行完原先的 build 流程后,会执行二次 build。二次 build 会将页面、loader 打包至 route 上,其他依赖(如 api/lambda)打包至一固定 dependencies 对象上;该对象是一个“伪”文件树结构。目前该功能并不完善,例如目前生成的单一 js 文件 server 还不支持静态文件,加上该功能主要是为了后续功能做铺垫,所以暂时不对用户透出,仅用于 integration test。如有需要可以后续再进行完善
主要改动:
solutions/app-tools的deploy/platforms/node中增加选项判断,调用 bundleServer 进行二次打包MODERN_SERVER_BUNDLE环境变量,标志是否会打包为单一文件。部分原先基于文件系统的行为将被替换:server/bff-core基于 dependencies 产生 API 列表。server/core从 dependencies 读取 manifest,从 route 读取 render、loadersolutions/app-tools增加 esm entry,修改相关 generator 逻辑server/bff-core改为仅使用 compatibleRequire,以前的为了兼容 jest 的代码疑似已经不再有用?browserslistsignaleora包,其并未被直接使用,而是被其他第三方包依赖graceful-fsgraceful-fs主要用于“优化”原生fs的一些边界情况,但其不兼容以 esm import 方式导入的 fs,会在 bundle server 中报错。ref/*#__PURE__*/标记lodash包名称,避免本地测试时 ndepe 复制错误的依赖。测试运行结果 integration-test-linux
Related Links
拆分自#8097
Checklist
pnpm run change.