refactor: migrate lib.autoExternal to output.autoExternal to leverage Rsbuild's capability#1641
Open
elecmonkey wants to merge 3 commits into
Open
refactor: migrate lib.autoExternal to output.autoExternal to leverage Rsbuild's capability#1641elecmonkey wants to merge 3 commits into
lib.autoExternal to output.autoExternal to leverage Rsbuild's capability#1641elecmonkey wants to merge 3 commits into
Conversation
Deploying rslib with
|
| Latest commit: |
1a5b36f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://d9ac31c0.rslib.pages.dev |
| Branch Preview URL: | https://refactor-migrate-auto-extern.rslib.pages.dev |
Leverage Rsbuild 2.0.7's native output.autoExternal instead of maintaining custom externalization logic. The deprecated lib.autoExternal is kept as a thin shim with a logger warning. - Remove composeAutoExternalConfig, composeExternalsWarnConfig, composeModuleImportWarn, handleMatchedExternal, getAutoExternalDefaultValue - Set autoExternal default in composeFormatConfig (ESM/CJS bundle → true) - Add exeExternalOverride to disable autoExternal for exe mode - CLI writes to output.autoExternal instead of lib.autoExternal - Add autoExternal field to RslibOutputConfig type
- Add output.autoExternal section to Rsbuild output docs (en/zh) - Add deprecation warning banner to lib.autoExternal docs (en/zh) - Update output.externals description to reference output.autoExternal
b2e6446 to
1a5b36f
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR migrates Rslib’s dependency auto-externalization behavior from the legacy lib.autoExternal option to Rsbuild’s output.autoExternal, aligning implementation with Rsbuild’s built-in capability while keeping backward compatibility via a deprecation shim.
Changes:
- Add
output.autoExternaldocumentation (EN/ZH) and marklib.autoExternalas deprecated in docs and public config typings. - Refactor core config composition to rely on
output.autoExternal(and remove the previous customcomposeAutoExternalConfigimplementation and its unit tests). - Update CLI option wiring and test expectations/snapshots to reflect the new configuration location.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| website/docs/zh/config/rsbuild/output.mdx | Add output.autoExternal docs and update output.externals wording to reference it. |
| website/docs/zh/config/lib/auto-external.mdx | Add deprecation warning pointing to output.autoExternal. |
| website/docs/en/config/rsbuild/output.mdx | Add output.autoExternal docs and update output.externals wording to reference it. |
| website/docs/en/config/lib/auto-external.mdx | Add deprecation warning pointing to output.autoExternal. |
| tests/integration/externals/index.test.ts | Remove the module-import warning integration test that depended on the old warning logic. |
| tests/integration/auto-external/index.test.ts | Remove the module-import warning integration test and simplify imports accordingly. |
| packages/core/tests/external.test.ts | Remove unit tests for the deleted composeAutoExternalConfig. |
| packages/core/tests/config.test.ts | Update CLI snapshot expectations for new output.autoExternal location. |
| packages/core/tests/cli.test.ts | Assert CLI populates lib.output.autoExternal instead of lib.autoExternal. |
| packages/core/tests/snapshots/config.test.ts.snap | Update snapshots to reflect externals ordering and output.autoExternal presence. |
| packages/core/src/types/config.ts | Deprecate lib.autoExternal in typings and add output.autoExternal override typing/docs. |
| packages/core/src/config.ts | Remove custom auto-externalization + warning logic; set defaults via output.autoExternal; add deprecation shim. |
| packages/core/src/cli/init.ts | Wire --auto-external CLI flag to lib.output.autoExternal. |
Comments suppressed due to low confidence (2)
website/docs/en/config/lib/auto-external.mdx:15
- The page frontmatter/intro still describes
lib.autoExternalas an active configuration, but the option is now deprecated. Update the page description/intro to clearly state it’s kept for backward compatibility and point readers tooutput.autoExternalas the canonical option.
# lib.autoExternal
:::warning
`lib.autoExternal` is deprecated. Please use [output.autoExternal](/config/rsbuild/output#outputautoexternal) instead.
:::
:::info
`autoExternal` is a specific configuration for bundle mode. It will not take effect in bundleless mode (set [lib.bundle](/config/lib/bundle) to `false`) since deps will not be bundled in bundleless mode.
website/docs/zh/config/lib/auto-external.mdx:15
- 当前页面的描述仍然把
lib.autoExternal当作主要配置项,但这里已标记为废弃。建议同步更新页面的描述/开头说明,明确这是兼容性保留配置,并引导用户迁移到output.autoExternal。
# lib.autoExternal
:::warning
`lib.autoExternal` 已废弃,请使用 [output.autoExternal](/config/rsbuild/output#outputautoexternal) 代替。
:::
:::info
`autoExternal` 是 bundle 模式的特定配置。在 bundleless 模式(将 [lib.bundle](/config/lib/bundle) 设置为 `false`)下不会生效,因为 bundleless 模式下依赖不会被打包。
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Migrated
lib.autoExternalto reuse Rsbuild's nativeoutput.autoExternal(available since Rsbuild 2.0.7).The deprecated
lib.autoExternalfield is preserved that maps tooutput.autoExternalwith a deprecation warning.