feat: enhance mini program component handling with subpackage support - #6038
Open
chouchouji wants to merge 4 commits into
Open
feat: enhance mini program component handling with subpackage support#6038chouchouji wants to merge 4 commits into
chouchouji wants to merge 4 commits into
Conversation
Size report
|
chouchouji
force-pushed
the
feat-subpackage-uni-modules
branch
from
July 31, 2026 07:14
7524819 to
7f1404b
Compare
There was a problem hiding this comment.
Pull request overview
This PR enhances Uni MP (mini program) component handling to support subpackage-scoped uni_modules components by tracking “component package roots” and propagating that context through virtual component URLs, template emission, chunk naming, and generated JSON usingComponents.
Changes:
- Add “packageRoot” propagation to virtual component IDs and dynamic imports, enabling subpackage-scoped
uni_modulesresolution. - Normalize emitted template/chunk/json filenames so
uni_modulesassets can be emitted under the correct subpackage root (or kept in main when shared). - Extend JSON generation/normalization logic in
uni-cli-sharedto rewriteusingComponentspaths based on final package-root decisions, with added test coverage.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/uni-mp-vite/src/plugins/usingComponents.ts | Detects/propagates packageRoot into dynamic imports and component tracking. |
| packages/uni-mp-vite/src/plugins/entry.ts | Extends virtual component info to include packageRoot; adds subpackage-root helpers and component filename normalization. |
| packages/uni-mp-vite/src/plugin/template.ts | Normalizes template files to emit per final component package roots (including multi-root scenarios). |
| packages/uni-mp-vite/src/plugin/configResolved.ts | Adjusts CSS chunk naming for virtual component entries with package-root support. |
| packages/uni-mp-vite/src/plugin/build.ts | Adjusts dynamic entry chunk naming to place uni_modules component JS under resolved package roots. |
| packages/uni-cli-shared/src/mp/usingComponents.ts | Threads owner package-root context into usingComponents generation for uni_modules components. |
| packages/uni-cli-shared/src/json/mp/jsonFile.ts | Tracks component package-root sets and normalizes JSON output/paths accordingly. |
| packages/uni-mp-vite/tests/usingComponents.spec.ts | Adds tests for package-root retention/removal in dynamic imports. |
| packages/uni-mp-vite/tests/entry.spec.ts | Adds tests for virtual component parsing and template emission under package roots. |
| packages/uni-mp-vite/tests/build.spec.ts | Adds tests for chunk naming under package roots and main-package override behavior. |
| packages/uni-cli-shared/tests/usingComponents.spec.ts | Adds test ensuring subpackage-root keeps uni_modules component imports inside subpackage. |
| packages/uni-cli-shared/tests/jsFile.spec.ts | Adds tests for JSON normalization across (sub)packages and independent roots. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
98
to
102
| const { appJson } = parseMiniProgramPagesJson( | ||
| fs.readFileSync(pagesJsonFile, 'utf8'), | ||
| platform, | ||
| { subpackages: true } | ||
| ) |
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.
No description provided.