Skip to content

fix(): enable force standalone mode by default#4858

Merged
WHChen-Alex merged 1 commit intov3from
steve/v3-force-standalone
Feb 6, 2026
Merged

fix(): enable force standalone mode by default#4858
WHChen-Alex merged 1 commit intov3from
steve/v3-force-standalone

Conversation

@weareoutman
Copy link
Member

@weareoutman weareoutman commented Feb 6, 2026

依赖检查

组件之间的依赖声明,是微服务组件架构下的重要信息,请确保其正确性。

请勾选以下两组选项其中之一:

  • 本次 MR 没有使用上游组件(例如框架、后台组件等)的较新版本提供的特性。

或者:

  • 本次 MR 使用了上游组件(例如框架、后台组件等)的较新版本提供的特性。
  • 在对应的文件中更新了该上游组件的依赖版本(或确认了当前声明的依赖版本已包含本次 MR 使用的新特性)。

提交信息检查

Git 提交信息将决定包的版本发布及自动生成的 CHANGELOG,请检查工作内容与提交信息是否相符,并在以下每组选项中都依次确认。

破坏性变更是针对于下游使用者而言,可以通过本次改动对下游使用者的影响来识别变更类型:

  • 下游使用者不做任何改动,仍可以正常工作时,那么它属于普通变更。
  • 反之,下游使用者不做改动就无法正常工作时,那么它属于破坏性变更。

例如,构件修改了一个属性名,小产品 Storyboard 中需要使用新属性名才能工作,那么它就是破坏性变更。
又例如,构件还没有任何下游使用者,那么它的任何变更都是普通变更。

破坏性变更:

  • ⚠️ 本次 MR 包含破坏性变更的提交,请继续确认以下所有选项:
  • 没有更好的兼容方案,必须做破坏性变更。
  • 使用了 feat 作为提交类型。
  • 标注了 BREAKING CHANGE: 你的变更说明
  • 同时更新了本仓库中所有下游使用者的调用。
  • 同时更新了本仓库中所有下游使用者对该子包的依赖为即将发布的 major 版本。
  • 同时为其它仓库的 Migrating 做好了准备,例如文档或批量改动的方法。
  • 手动验证过破坏性变更在 Migrate 后可以正常工作。
  • 破坏性变更所在的提交没有意外携带其它子包的改动。

新特性:

  • 本次 MR 包含新特性的提交,且该提交不带有破坏性变更,并使用了 feat 作为提交类型。
  • 给新特性添加了单元测试。
  • 手动验证过新特性可以正常工作。

问题修复:

  • 本次 MR 包含问题修复的提交,且该提交不带有新特性或破坏性变更,并使用了 fix 作为提交类型。
  • 给问题修复添加了单元测试。
  • 手动验证过问题修复得到解决。

杂项工作:

即所有对下游使用者无任何影响、且没有必要显示在 CHANGELOG 中的改动,例如修改注释、测试用例、开发文档等:

  • 本次 MR 包含杂项工作的提交,且该提交不带有问题修复、新特性或破坏性变更,并使用了 chore, docs, test 等作为提交类型。

Summary by CodeRabbit

发布说明

  • 新功能

    • 新增 --no-force-standalone 命令行选项,允许用户灵活控制是否启用独立模式(默认启用)
  • 改进

    • 优化了独立模式下的故事板配置和资源注入流程,增强了应用部署的灵活性

@coderabbitai
Copy link

coderabbitai bot commented Feb 6, 2026

实现概述

通过 --no-force-standalone CLI 标志在环境配置中引入新的独立模式控制,并在代理逻辑中添加条件分支以根据该标志处理 HTML 注入流程。

变更

Cohort / 文件(s) 摘要
CLI 标志与环境配置
packages/brick-container/serve/env.js
新增 forceStandalone 布尔类型 CLI 标志(默认值为 true),通过 --no-force-standalone 选项控制,并将该属性暴露到 getEnv 返回的环境对象中。
Standalone 配置注入逻辑
packages/brick-container/serve/getProxy.js
导入 getMatchedStoryboard 和 getStandaloneConfig 工具函数,在 HTML 注入分支中增加条件逻辑:当 env.forceStandalone 为真时,通过请求路径查询匹配的故事板,获取其独立配置,并注入相应的 HTML。

预估代码审查工作量

🎯 2 (Simple) | ⏱️ ~10 分钟

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive PR描述仅包含模板的复选框内容,但所有项目均未勾选,缺少对变更内容、目的和实现细节的实际说明。 请补充PR描述:描述本次MR的具体工作内容、修复/新增的功能、选择合适的提交类型并勾选对应的检查项,例如若为问题修复应勾选问题修复部分并说明修复内容。
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed PR标题清晰准确地概括了主要变更:在配置中添加了强制独立模式标志并默认启用,这与代码摘要中的核心功能一致。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch steve/v3-force-standalone

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cypress
Copy link

cypress bot commented Feb 6, 2026

next-core    Run #11934

Run Properties:  status check passed Passed #11934  •  git commit 6cb372cc51 ℹ️: Merge 3fcd2c708f0d81efdba26e0cba55910ba093cf11 into 6f770693e9786f976e05509b9cba...
Project next-core
Branch Review steve/v3-force-standalone
Run status status check passed Passed #11934
Run duration 00m 27s
Commit git commit 6cb372cc51 ℹ️: Merge 3fcd2c708f0d81efdba26e0cba55910ba093cf11 into 6f770693e9786f976e05509b9cba...
Committer Shenwei Wang
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 17
View all changes introduced in this branch ↗︎

@WHChen-Alex WHChen-Alex merged commit bb2178a into v3 Feb 6, 2026
12 of 13 checks passed
@WHChen-Alex WHChen-Alex deleted the steve/v3-force-standalone branch February 6, 2026 08:02
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/brick-container/serve/getProxy.js`:
- Around line 432-440: The local variable named content in the
env.forceStandalone branch shadows an outer content variable and reduces
readability; rename that local variable to rawIndexHtml (or similar) in the
block where you call getRawIndexHtml(), i.e. inside the branch guarded by
env.forceStandalone that calls getMatchedStoryboard(), getRawIndexHtml(),
getStandaloneConfig() and returns injectIndexHtml(...); update any subsequent
references in that block to use rawIndexHtml so the outer content variable is no
longer shadowed.

Comment on lines +432 to 440
} else if (env.forceStandalone) {
const storyboard = await getMatchedStoryboard(
env,
req.path.replace(/^\/next\//, "/")
);
const content = await getRawIndexHtml();
const standaloneConfig = getStandaloneConfig(storyboard);
return injectIndexHtml(env, content, standaloneConfig);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's locate and examine the main file and understand the context
fd "getProxy.js" | head -5

Repository: easyops-cn/next-core

Length of output: 106


🏁 Script executed:

# Find the getMatchedStoryboard function implementation
rg "getMatchedStoryboard" --type js -A 15 | head -50

Repository: easyops-cn/next-core

Length of output: 3770


🏁 Script executed:

# Find the getStandaloneConfig function implementation
rg "getStandaloneConfig" --type js -A 10 | head -50

Repository: easyops-cn/next-core

Length of output: 3737


🏁 Script executed:

# Get the structure of the serve directory
tree packages/brick-container/serve -L 2

Repository: easyops-cn/next-core

Length of output: 677


🏁 Script executed:

# Read the full getStandaloneConfig.js file
cat packages/brick-container/serve/utils/getStandaloneConfig.js

Repository: easyops-cn/next-core

Length of output: 509


🏁 Script executed:

# Read the full getStoryboards.js file
cat packages/brick-container/serve/utils/getStoryboards.js

Repository: easyops-cn/next-core

Length of output: 1968


🏁 Script executed:

# Read getProxy.js focusing on the relevant sections
wc -l packages/brick-container/serve/getProxy.js

Repository: easyops-cn/next-core

Length of output: 110


🏁 Script executed:

# Read the relevant sections of getProxy.js
sed -n '310,450p' packages/brick-container/serve/getProxy.js

Repository: easyops-cn/next-core

Length of output: 6044


🏁 Script executed:

# Read the injectIndexHtml.js to understand how it handles null config
cat packages/brick-container/serve/utils/injectIndexHtml.js

Repository: easyops-cn/next-core

Length of output: 2372


🏁 Script executed:

# Get more context around line 318 in getProxy.js to understand variable scope
sed -n '315,450p' packages/brick-container/serve/getProxy.js | cat -n

Repository: easyops-cn/next-core

Length of output: 6849


变量命名不清晰导致代码混淆。

第 437 行的变量 content 遮蔽了第 318 行外层作用域的同名变量。虽然它们在语义上表示不同的内容(一个是响应的 HTML,一个是原始的 index HTML),但同一变量名在嵌套作用域中使用会降低可读性。建议重命名为 rawIndexHtml 以保持一致性和清晰度。

另注:getStandaloneConfig 已通过可选链操作符 storyboard?.app.standaloneMode 安全地处理 undefined 情况,injectIndexHtml 也通过 if (standaloneConfig) 检查来处理 null 值,所以即使 getMatchedStoryboard 返回 undefined,现有代码也能安全处理。

🤖 Prompt for AI Agents
In `@packages/brick-container/serve/getProxy.js` around lines 432 - 440, The local
variable named content in the env.forceStandalone branch shadows an outer
content variable and reduces readability; rename that local variable to
rawIndexHtml (or similar) in the block where you call getRawIndexHtml(), i.e.
inside the branch guarded by env.forceStandalone that calls
getMatchedStoryboard(), getRawIndexHtml(), getStandaloneConfig() and returns
injectIndexHtml(...); update any subsequent references in that block to use
rawIndexHtml so the outer content variable is no longer shadowed.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables force standalone mode by default for the brick-container development server. The change allows developers to test standalone micro-apps behavior during local development without explicitly enabling the flag. The implementation adds a new CLI flag --no-force-standalone to disable this behavior when needed.

Changes:

  • Added forceStandalone CLI flag with true as default value in env.js
  • Added logic to handle force standalone mode in the proxy response interceptor in getProxy.js

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/brick-container/serve/env.js Adds --no-force-standalone CLI flag and forceStandalone configuration with default value true
packages/brick-container/serve/getProxy.js Imports required utilities and adds conditional logic to inject standalone configuration when force standalone mode is enabled

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

env,
req.path.replace(/^\/next\//, "/")
);
const content = await getRawIndexHtml();
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent variable naming: This should be named rawIndexHtml to match the existing pattern in the same file (see line 321). Using content here creates variable shadowing with the outer content variable declared on line 318 and is inconsistent with the established naming convention.

Copilot uses AI. Check for mistakes.
env,
req.path.replace(/^\/next\//, "/")
);
const content = await getRawIndexHtml();
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The getMatchedStoryboard function can return undefined when no storyboard matches the pathname (see getStoryboards.js line 67). This will cause getStandaloneConfig to receive undefined, and while it handles null/undefined storyboards gracefully by returning null, the subsequent call to injectIndexHtml will receive a null standaloneConfig. While injectIndexHtml does handle null standaloneConfig, consider adding error handling or fallback logic when no storyboard matches, as this might indicate a configuration issue that should be logged or handled explicitly.

Suggested change
const content = await getRawIndexHtml();
const content = await getRawIndexHtml();
if (!storyboard) {
// No storyboard matched the current path while forceStandalone is enabled.
// Log a warning and fall back to injecting the index HTML without standalone config.
console.warn(
`[brick-container] No storyboard matched for path "${req.path}" while forceStandalone is enabled. Falling back to default index HTML.`
);
return injectIndexHtml(env, content);
}

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants