2026: Uni-app Mini Program says the main package exceeds 2M on submit—there are only a few pages, so what is actually taking up the size?
Conclusion first: In 2026, when Uni-app compiles to a WeChat Mini Program and reports that the main package exceeds 2M, the common large contributors are usually not business code but images and fonts in static, UI component libraries imported as a whole package, and uni_modules that are installed but not used. Start with a package size analysis to identify the top two contributors, then handle them in the order of measure, move, compress, and split. This usually saves more rework than splitting directories right away. WeChat Mini Programs have an upper limit on main package size; the common understanding is a main package of around 2MB, with a separate cap on the total of subpackages, subject to the platform's official documentation. When Uni-app builds, pages, components, static assets, and dependencies that are not placed in subpackages are all counted in the main package, while business logic usually accounts for only a few hundred KB. Errors about exceeding the size limit often appear during preview or submission review; the development stage may not stop you. By the time it shows up at submission review, the remaining time is often only enough for one round of adjustment, and campaign-type projects may also hit their launch window.
The main package limit applies to the build output, not source code; business code is usually not the main cause
Main package size is based on the actual output submitted to the platform, not the size of the source directory. Uni-app compiles non-subpackaged pages, shared components, uni_modules, npm dependencies, and static assets together, so business logic itself is generally not the first conflict. A common situation in 2026 projects is: there are not many pages, but design assets, component libraries, and plugins push the size up first.
- Counted in the main package: images and fonts in static, uni_modules plugins, npm dependencies, shared components, tabBar pages, and pages not placed in subpackages.
- Generally not in the main package: pages inside subpackage directories and their unique assets, images and videos served from a CDN, and plugins externalized according to platform rules.
- Easy to miss: code that takes effect only on one platform through conditional compilation, component libraries without on-demand imports, and shared dependencies across subpackages that are pulled back into the main package.
Size accounting comes before action: measure, move, compress, and split in four steps
The order of these four steps matters. Measure before acting because the size distribution of Mini Program output is very uneven; in experience, the top two dependencies and assets often account for more than half of the main package. Seeing the proportions first prevents spending half a day on several small files of only tens of KB. The acceptance criteria for each step should also be reviewed separately.
- Measure (about half a day): Use the developer tool's code dependency analysis or package size analysis to break the main package into dependencies, uni_modules, static assets, and business code, and note the top two by share. The pass criterion is being able to say in one sentence which two things account for more than half of the main package.
- Move (about half a day to one day): Move images, fonts, and video covers that are not required for the first screen to a CDN or object storage; keep and compress items that must stay local, such as tabBar icons. The pass criterion is that there are no large images left in the static directory.
- Compress (about half a day): Change the UI library to on-demand imports and keep only the components actually used; subset fonts or switch to system fonts; remove installed but unused uni_modules. The pass criterion is that it still compiles normally after deletion and page styles are not visibly distorted.
- Split (about one to three days): Move non-first-screen pages such as campaign pages, detail pages, and secondary personal center pages into subpackages, then configure subpackage pre-download as needed. The pass criterion is that the main package size falls back, subpackage pages can open independently, and there are no errors in cross-package references.
Among the four steps, splitting is the easiest to overdo. Subpackaging is not free: once the directory changes, route paths, relative references, and shared component ownership all need to be adjusted. If a component shared by two subpackages is pulled back into the main package, the size may rebound.
Delivery scenario: constraints, approach, and cost
A common delivery scenario is: the campaign Mini Program schedule has only two weeks left, design delivers dozens of 2x images at once, product adds two secondary pages midway, no one mentions a size budget at kickoff, and by preview the main package is already clearly over the limit. The approach at the time was to follow the order—move non-tabBar pages into subpackages, move all large images to a CDN, remove the unused half of a UI library, and switch fonts to system fonts—and the main package fell back to an experience range close to but within the limit. For regular projects, the common reduction is 30% to 50%. The cost was that shared components between subpackages were promoted back into the main package and the size bounced once, taking about one extra day to rearrange the directory; that rework could have been avoided with a size budget table at kickoff.
Common pitfalls at submission review
- All images stuffed into static: A single 2x image is commonly 50–300KB; twenty or thirty of them can consume most of the main package.
- Importing an entire UI library: Only buttons and modals are used, but the whole component library is bundled into the output—this is one of the more frequent causes of abnormal size.
- Installing uni_modules without deleting them: Plugins that were tried and not used remain in the directory and are compiled as well.
- Ignoring cross-subpackage dependencies: Components shared by two subpackages are pulled back into the main package, making it larger after splitting.
- Treating the debug build as the final build: Output with sourcemaps or debug options enabled is not the same as the size of the submission build.
Slim down first or split first: comparing several approaches
When the main package exceeds the limit, there are generally three paths, and which one to choose depends on how far over it is and how many pages there are. The durations below are experience ranges that vary with project scale; they are only for scheduling reference and cannot be used as a quotation basis.
- Slim down dependencies and assets first: Suitable for projects where the main package is only modestly over the limit—by experience, 20% to 50% over—and the number of pages is not large; about 0.5–2 person-days, low risk, and no change to page structure.
- Split into subpackages: Suitable for projects with many pages and clear non-first-screen business; about 1–3 person-days, requires changing directories and routes together, and has a larger regression scope.
- Move campaign pages to H5 or App hosting: Suitable for strongly marketing-oriented pages with frequent iteration; however, it adds the cost of adaptation and sharing configuration, and it is not recommended to temporarily change the architecture just to save 2M.
Images involve a similar trade-off: hosting them locally in static has the benefit of stable review and availability on weak networks, at the cost of every image, tens to hundreds of KB each, being counted in the main package; hosting them on a CDN does not count toward package size and lets you change images without resubmitting for review, but you need to configure the domain whitelist in advance, and the first screen will have one extra wait on weak networks. In 2026 delivery, this trade-off should be decided at the page list stage, not by moving images temporarily before submission review.
Applicable scenarios and boundaries
Size governance is worth doing upfront in projects with many pages, many assets, and multi-platform release; if it is just a tool-type Mini Program with five or six pages and the main package is already within 1M, forcing a subpackage split will instead increase maintenance cost and cross-package debugging trouble.
- Suitable for upfront work: campaign Mini Programs, e-commerce detail and personal center flows, projects that need to ship H5 and App at the same time, and projects with frequent design asset iteration.
- Not necessary: tool-type Mini Programs with very few pages and a main package clearly below the limit; Mini Programs used purely internally and not subject to public review.
- Boundary reminder: Subpackaging can solve package size, but it cannot solve first-screen experience. A smaller main package does not mean faster startup; first-screen rendering still needs separate review of the number of initial requests and the subpackage pre-download strategy.
FAQ
Is the 2M main package limit based on source code or the submitted build output?
It is calculated based on the actual build output submitted to the platform, not source code size; deleting comments or changing coding style has limited meaning—you need to look at the share of each module after compilation.
After subpackaging, what must still remain in the main package?
tabBar pages, global shared components, and base dependencies usually remain in the main package; other non-first-screen pages can generally be moved out, and components shared across subpackages need their ownership confirmed separately.
How much can package size drop if the UI library is changed to on-demand imports?
It can drop, and the extent depends on how many components are actually used; when only a few basic components are used, the typical range in experience is a 10% to 30% reduction in the main package, depending on the library's implementation.
All images are on a CDN, so why is the main package still over the limit?
It is most likely that dependencies or uni_modules still occupy the main package; images are only one item. Run package size analysis again to see the top two by share, then decide whether to remove dependencies or split into subpackages.
If I only ship H5 and App, will I still hit the 2M limit?
You will not hit the Mini Program main package limit, but first-screen resource size still needs control; H5 cares more about first-screen loading and crawlable structure, while App cares about the installation package and startup resources.
It is advisable to write the size budget into the page list at kickoff: leave headroom in the main package, use a CDN for images by default, and check size before adding new dependencies. If the project is close to submission review, first run a package size analysis to locate the top two contributors, then decide whether to move, compress, or split. The above experience ranges apply to regular small and medium-sized Mini Programs; for large projects, verify against the platform's official documentation and measured data.
-
H5 first screen filled with vh: why does the whole page jolt when the mobile address bar hides and shows, and how does 100vh differ from screen height?
Date: Nov 29, 2026 Read: 2
-
It's 2026—why does a Flutter product feed get hotter the further you scroll, then cool down after leaving and re-entering? How many times are those images decoded?
Date: Nov 27, 2026 Read: 13
-
In 2026, list pages only append cards after scrolling to the second screen—Baidu's source contains not a single detail link; is the crawler simply not scrolling down for you?
Date: Nov 26, 2026 Read: 19
-
In 2026, a chart in an Angular admin modal just appeared and the console logs ExpressionChangedAfterItHasBeenCheckedError—is the size write-back one cycle late?
Date: Nov 25, 2026 Read: 26
-
If a user leaves an admin tab open all day and the menu goes blank after an evening release, can the frontend know the old JS has already been replaced?
Date: Nov 24, 2026 Read: 44




