mpx-mode-migration

Audits Mpx projects for mode/srcMode semantic migration issues after framework upgrades.

3.9k|388|Updated Dec 6, 2018
One-click install
npx skills add https://github.com/didi/mpx --skill mpx-mode-migration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mpx-mode-migration
Source: https://github.com/didi/mpx/tree/main/.agents/skills/mpx-mode-migration
Command: npx skills add https://github.com/didi/mpx --skill mpx-mode-migration

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

Upgrading Mpx changes the semantics of conditional compilation: mode now only filters targets while srcMode controls source dialect. Existing projects relying on the old implicit source-dialect behavior (.ali.* files, mode="ali" SFC blocks, @ali attributes, modeRules config) may silently break, and manually finding every affected location is error-prone.

Core Features & Use Cases

  • Deterministic project scanning: Runs scripts/scan-project.js to produce a high-recall candidate set covering conditional files, SFC blocks, @mode attributes, modeRules/srcModeRules conflicts, and <import>/<include> template references.
  • Rule-based verification: Uses references/migration-rules.md and scripts/resolve-platform.js to check each candidate against the actually installed @mpxjs/webpack-plugin platform rules, classifying findings as must-fix, needs-confirmation, compatible-cleanup, or no-change.
  • Minimal migration guidance: Recommends the smallest fix per case (rewrite to project srcMode syntax, add src-mode attributes, or apply precise srcModeRules coverage) and outputs a structured audit report with file and line references.
  • Use Case: After upgrading a project from Mpx 2.11 that targets WeChat, Alipay, and React Native, run the audit to find every .ali.mpx file, mode="ali" block, and @ali attribute that depends on old semantics, then receive a report distinguishing real breakage from safe pass-throughs.

Quick Start

Ask the assistant to audit your Mpx project for mode/srcMode migration issues after the upgrade and produce a report without modifying any code.

Frequently Asked Questions about mpx-mode-migration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I check my Mpx project for mode/srcMode migration issues after upgrading?

Run the bundled scanner with node scripts/scan-project.js <project-root> to get a candidate list, then verify each hit against the migration rules matrix. The audit classifies findings as must-fix, needs-confirmation, compatible-cleanup, or no-change with file and line references.

What changed between mode and srcMode in the Mpx upgrade?

After the upgrade, mode only controls whether files, SFC blocks, nodes, or attributes apply to a target platform, while srcMode controls which platform dialect the source uses and whether cross-platform conversion runs. Conditional files and blocks no longer implicitly set source dialect.

Does the scanner modify my project files automatically?

No, the scanning script is read-only and only produces an audit report. Code changes happen only when you explicitly request the migration to be implemented, followed by regression tests and per-target build verification.

Do all @ali or @ios attributes need migration after the Mpx upgrade?

Not necessarily. Each @mode attribute must be checked against the installed @mpxjs/webpack-plugin platform rules; if no rule renames, rewrites, or removes it, the target-native syntax passes through safely. The @_mode form is fully compatible and only an optional cleanup.

What are the limitations of static scanning for Mpx migration?

Regex scanning cannot reliably interpret webpack configs built via variables or functions, and srcModeRules include/exclude coverage needs manual verification against webpack rule semantics. Dynamically generated templates, loader virtual modules, and build-time codegen are outside static scan scope.