Skip to content

feat: enhance mini program component handling with subpackage support - #6038

Open
chouchouji wants to merge 4 commits into
uni-app-vue3-devfrom
feat-subpackage-uni-modules
Open

feat: enhance mini program component handling with subpackage support#6038
chouchouji wants to merge 4 commits into
uni-app-vue3-devfrom
feat-subpackage-uni-modules

Conversation

@chouchouji

Copy link
Copy Markdown
Member

No description provided.

@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

Size report

Path Size
packages/size-check/dist/size-check.es.js 52.92 KB (0%)
packages/size-check/dist/style.css 2.83 KB (0%)
packages/uni-app/dist/uni-app.es.js 2.41 KB (0%)
packages/uni-h5-vue/dist/vue.runtime.esm.js 76.48 KB (0%)
packages/uni-mp-vue/dist/vue.runtime.esm.js 43.97 KB (0%)
packages/uni-mp-alipay/dist/uni.api.esm.js 15.84 KB (0%)
packages/uni-mp-alipay/dist/uni.mp.esm.js 9.38 KB (0%)
packages/uni-mp-baidu/dist/uni.api.esm.js 12.12 KB (0%)
packages/uni-mp-baidu/dist/uni.mp.esm.js 10.37 KB (0%)
packages/uni-mp-qq/dist/uni.api.esm.js 11.45 KB (0%)
packages/uni-mp-qq/dist/uni.mp.esm.js 8.44 KB (0%)
packages/uni-mp-toutiao/dist/uni.api.esm.js 11.4 KB (0%)
packages/uni-mp-toutiao/dist/uni.mp.esm.js 10.05 KB (0%)
packages/uni-mp-weixin/dist/uni.api.esm.js 12.53 KB (0%)
packages/uni-mp-weixin/dist/uni.mp.esm.js 9 KB (0%)
packages/uni-quickapp-webview/dist/uni.api.esm.js 11.4 KB (0%)
packages/uni-quickapp-webview/dist/uni.mp.esm.js 8.81 KB (0%)

@chouchouji
chouchouji force-pushed the feat-subpackage-uni-modules branch from 7524819 to 7f1404b Compare July 31, 2026 07:14

Copilot AI left a comment

Copy link
Copy Markdown

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 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_modules resolution.
  • Normalize emitted template/chunk/json filenames so uni_modules assets can be emitted under the correct subpackage root (or kept in main when shared).
  • Extend JSON generation/normalization logic in uni-cli-shared to rewrite usingComponents paths 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 }
)
@chouchouji
chouchouji requested a review from Copilot July 31, 2026 11:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants