parseBundle finds no modules in webpack 5 ESM output (`output.module`), so parsed and gzip sizes are missing
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 38/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, webpack
- Lĩnh vực
- build-system
Hướng nghiên cứu
Start in src/parseUtils.js at parseBundle, following how it walks the AST for IIFE-wrapped module maps. Two gaps to cover: an ExportNamedDeclaration case for export const __webpack_esm_modules__ (and older export const modules), and top-level var __webpack_modules__ = ({...}) entry chunks where no IIFE wraps the map, so the runtime IIFE is not mistaken for it. Reproduce with the small ESM fixture from the report and check getViewerData shows parsed and gzip sizes for main.mjs and 480.chunk.mjs. Note the reporter says a fix and tests are already in an incoming pull request, so coordinate before starting.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug Description
When a webpack 5 build uses experiments.outputModule with output.module: true, the analyzer does not crash anymore (#684, fixed by #685), but every module of the ESM build shows no parsed size and no gzip size. Only the stat size is shown.
parseBundle in src/parseUtils.js misses the module map in two places of the ESM chunk format:
- Async chunks export the map:
export const __webpack_esm_modules__ = { ... };(older webpack 5 releases:export const modules = { ... }). There is noExportNamedDeclarationcase, somodulesis{}. - The entry chunk has no wrapping IIFE. The map is a top-level
var __webpack_modules__ = ({ ... }). Only IIFE bodies are inspected, so the small runtime IIFE(() => { var installedChunks = { 792: 0 }; ... })()is taken as the module map (0looks like a deduplicated module id). The result ismodules = { "792": "0" }and the real modules are not found.
Steps to Reproduce
Tested on main at a90b30c6dedae8343acaed2b0f7857c95ec89bd1 with webpack 5.105.2, Node 24.
src/index.js: import { a } from "./a.js"; console.log(a); import("./lazy.js").then(m => console.log(m.b));
src/a.js: export const a = "hello a";
src/lazy.js: import { c } from "./c.js"; export const b = "lazy b" + c;
src/c.js: export const c = "ccc";
webpack config: mode: "production", target: "node", experiments: { outputModule: true }, output: { module: true, chunkFormat: "module", filename: "[name].mjs", chunkFilename: "[name].chunk.mjs" }, optimization: { concatenateModules: false, minimize: false }. Then call getViewerData(stats, outputPath).
Actual behavior (path, statSize, parsedSize)
main.mjs [["./src/index.js",93,null],["./src/a.js",28,null]]
480.chunk.mjs [["./src/lazy.js",57,null],["./src/c.js",24,null]]
parseBundle keys: main.mjs gives ['792'] (wrong), 480.chunk.mjs gives [].
Expected behavior
The same project built without output.module gives a.js 242, lazy.js 368, c.js 238 (index.js stays null there, it is the concatenated entry module, documented). The ESM build should give the same:
main.mjs [["./src/index.js",93,null],["./src/a.js",28,242]]
480.chunk.mjs [["./src/lazy.js",57,368],["./src/c.js",24,238]]
Real usage
output.module with this analyzer is used in real projects: #684 (user builds index.mjs), and the @wordpress/scripts webpack config in WordPress/gutenberg enables experiments.outputModule and output.module for script modules and BundleAnalyzerPlugin behind WP_BUNDLE_ANALYZER.
A fix and tests are in the pull request I am sending with this issue.
Validated with Claude Opus 5.5.
- Ngôn ngữ chính
- JavaScript
- Star
- 12.7k
- Fork
- 521
- Merge trung bình
- 2 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 7
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của webpack/webpack-bundle-analyzer
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
webpack/webpack-bundle-analyzer#737 · 5 bình luận ·
-
[bug] `TypeError: Cannot read properties of undefined (reading 'filter')` when passing stats objectĐang mởstatus: Needs triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
webpack/webpack-bundle-analyzer#669 · 6 bình luận · 3 reaction ·
-
[Nice to Have] plugin should use webpack InfrastructureLogger and output report to compiler.outputFileSystemCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
webpack/webpack-bundle-analyzer#476 · 1 bình luận ·
-
Errors when using with the webpack dev server 4Có thể đã có người làm @Br1an67 đã nhận 267 ngày trước. Đang mởflag: Community help wanted type: Bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
webpack/webpack-bundle-analyzer#471 · 18 bình luận · 3 reaction ·
-
status: Needs triage
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
webpack/webpack-bundle-analyzer#399 · 4 bình luận · 17 reaction ·
Tất cả issue của webpack/webpack-bundle-analyzer
Issue tương tự
-
[bug] 提瓦特记事本原石检测框宽度较窄Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
babalae/bettergi-scripts-list#3905 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] "Configure Colota" opens Colota with "Invalid configuration: No configuration data in URL"Đang mở
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 87/100
dedicatedcode/reitti#1445 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
New tool: Uncle DeskCó thể đã có người làm @github-actions đã nhận hôm nay. Đang mởsubmission triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
kausalflow/tools#384 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add spaced repetition schedulingĐang mởgood first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
-
Fuzz: css syntax bug foundĐang mởarea: css
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày