Skip to content

docs(site): add Bundle Deployment guide#5988

Merged
killagu merged 2 commits into
eggjs:nextfrom
killagu:docs/bundle-deployment
Jun 23, 2026
Merged

docs(site): add Bundle Deployment guide#5988
killagu merged 2 commits into
eggjs:nextfrom
killagu:docs/bundle-deployment

Conversation

@killagu

@killagu killagu commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Adds a Bundle Deployment guide to the Core docs (EN + zh-CN), documenting the egg-bin bundle / @eggjs/egg-bundler workflow:

  • Buildegg-bin bundle, options, auto-externals, module.yml config
  • Output — artifact layout and bundle-manifest.json
  • Run — install externals next to worker.js (npm ci --omit=dev), single-process boot
  • Tegg applications — module discovery is served from the manifest's decoratedFiles (no on-disk glob), keeping the tegg DI graph intact for auto-resolved egg-compatible injects (httpClient/logger/config)
  • Limitations — single-process only, native addons external

Registered in the Core sidebar next to the Startup Manifest guide it builds on. Pairs with the bundle-boot fix in #5987.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation
    • Added a new “Bundle Deployment / 打包部署” documentation section, including the egg-bin bundle workflow, key CLI options, and how build outputs are structured in dist-bundle/.
    • Expanded runtime instructions (worker setup and single-process mode), plus module.yml configuration examples and documented limitations.
    • Updated both English and Chinese site navigation to include the new bundle page.
    • Refreshed the English bundle page to focus on Egg bundle deployment and remove tegg application coverage.

Document `egg-bin bundle` / `@eggjs/egg-bundler`: how to build a
deployable CommonJS artifact, the output layout, how to run it (install
externals next to worker.js, single-process boot), tegg-app support
(manifest-served module discovery keeps the DI graph intact), and current
limitations. Added to the Core sidebar (EN + zh-CN), next to the Startup
Manifest guide it builds on.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 23, 2026 02:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8e664a49-245d-4909-8c15-5f99751bce62

📥 Commits

Reviewing files that changed from the base of the PR and between d235756 and 9adbc16.

📒 Files selected for processing (2)
  • site/docs/core/bundle.md
  • site/docs/zh-CN/core/bundle.md
💤 Files with no reviewable changes (2)
  • site/docs/zh-CN/core/bundle.md
  • site/docs/core/bundle.md

📝 Walkthrough

Walkthrough

Two new documentation pages (site/docs/core/bundle.md and site/docs/zh-CN/core/bundle.md) are added, documenting the egg-bin bundle / @eggjs/egg-bundler workflow. Both locale sidebar configurations in site/.vitepress/config.mts are extended with a "Bundle Deployment" / "打包部署" navigation entry.

Changes

Bundle Deployment Documentation

Layer / File(s) Summary
Sidebar navigation entries (EN + ZH)
site/.vitepress/config.mts
Adds "Bundle Deployment" and "打包部署" sidebar links to the English and Chinese core sidebar sections, both pointing to the bundle page.
English bundle deployment docs
site/docs/core/bundle.md
New documentation covering the full bundle workflow: overview of single-process CommonJS artifact generation with manifest metadata reuse, egg-bin bundle CLI options and manifest auto-generation via metadataOnly: true, module.yml configuration for runtimeAssets and module resolution aliases, dist-bundle/ output layout, external package deployment steps, and limitations (single-process only, native addons always external, external packages required adjacent to worker.js).
Chinese bundle deployment docs
site/docs/zh-CN/core/bundle.md
Chinese localization covering the same sections as the English page: build command reference, module.yml configuration examples, dist-bundle/ directory structure, external dependency installation and runtime execution flow, and deployment constraints.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • eggjs/egg#5888: Implements the bundle subcommand in tools/egg-bin whose CLI options and behavior are directly documented in this PR.
  • eggjs/egg#5915: Updates bundler behavior for metadataOnly: true manifest generation and external/inline handling that this PR documents.
  • eggjs/egg#5931: Implements module.yml bundle.runtimeAssets and bundle.pack.resolve.alias configuration loading, which this PR documents under the configuration section.

Suggested reviewers

  • gxkl
  • akitaSummer
  • fengmk2

Poem

🐰 Hop hop, a bundle page appears,
With worker.js and chunks, the path is clear.
egg-bin bundle packs it all up tight,
No filesystem scans on a cold dark night.
The rabbit stamps docs in EN and ZH,
Deploy your eggs in the bundled way! 🥚

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'docs(site): add Bundle Deployment guide' directly and accurately describes the main change—adding documentation for bundle deployment with clear, specific language.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds documentation for Bundle Deployment in both English and Chinese, detailing how to bundle, configure, and run Egg applications using @eggjs/egg-bundler. It also updates the VitePress sidebar configuration to include these new pages. The review comments correctly point out that the documented npm ci command requires a package-lock.json file to run successfully, suggesting that both package.json and package-lock.json should be copied to the bundle directory.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread site/docs/core/bundle.md
Comment on lines +83 to +86
$ cd dist-bundle
$ cp ../package.json .
$ npm ci --omit=dev
$ node worker.js

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The npm ci command strictly requires a package-lock.json file to be present in the directory. Copying only package.json will cause the command to fail. You should copy package-lock.json as well, or use npm install --omit=dev instead.

Suggested change
$ cd dist-bundle
$ cp ../package.json .
$ npm ci --omit=dev
$ node worker.js
$ cd dist-bundle
$ cp ../package.json ../package-lock.json .
$ npm ci --omit=dev
$ node worker.js

Comment on lines +71 to +74
$ cd dist-bundle
$ cp ../package.json .
$ npm ci --omit=dev
$ node worker.js

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The npm ci command strictly requires a package-lock.json file to be present in the directory. Copying only package.json will cause the command to fail. You should copy package-lock.json as well, or use npm install --omit=dev instead.

Suggested change
$ cd dist-bundle
$ cp ../package.json .
$ npm ci --omit=dev
$ node worker.js
$ cd dist-bundle
$ cp ../package.json ../package-lock.json .
$ npm ci --omit=dev
$ node worker.js

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.91%. Comparing base (5b0d59f) to head (9adbc16).
⚠️ Report is 1 commits behind head on next.

Additional details and impacted files
@@           Coverage Diff           @@
##             next    #5988   +/-   ##
=======================================
  Coverage   85.91%   85.91%           
=======================================
  Files         669      669           
  Lines       19907    19907           
  Branches     3949     3949           
=======================================
  Hits        17104    17104           
  Misses       2425     2425           
  Partials      378      378           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@site/docs/core/bundle.md`:
- Around line 62-71: Add a language tag to the markdown code fence that displays
the file tree output. The fence currently opens with just triple backticks but
needs a language identifier to satisfy markdownlint rule MD040. Add either
`text` or `console` as the language tag to the opening fence before the
dist-bundle/ tree structure to make the documentation lint-clean.
- Around line 78-86: The bash recipe in the example needs two updates: First,
replace the `cp ../package.json .` step with an approach that preserves the
bundle's intentional `{ "type": "commonjs" }` manifest instead of overwriting it
(consider merging dependencies or documenting how to safely combine manifests).
Second, add an explicit step to copy the appropriate lockfile
(package-lock.json, npm-shrinkwrap.json, pnpm-lock.yaml, or yarn.lock) before
running `npm ci`, since npm ci requires a lockfile to function properly.
Additionally, add a language specifier (e.g., text) to the unlabeled code fence
that appears earlier in the document before this example.

In `@site/docs/zh-CN/core/bundle.md`:
- Around line 52-61: The code block containing the dist-bundle directory
structure tree is missing a language identifier on the opening code fence, which
causes markdownlint rule MD040 to report a warning. Add a language identifier
(either `text` or `console`) immediately after the opening triple backticks of
the code block that shows the dist-bundle directory tree with worker.js,
_root-of-the-server chunks, and other files.
- Around line 67-75: The bash example in the bundle documentation currently
shows copying the app's package.json to dist-bundle, which overwrites the
bundler-generated package.json that explicitly contains { "type": "commonjs" }.
This is problematic because if the app declares "type": "module", Node will
misinterpret the bundled CommonJS files as ESM. Additionally, the npm ci command
requires either package-lock.json or npm-shrinkwrap.json to exist. Update the
example to either preserve the bundler's package.json (which contains the
critical "type": "commonjs" declaration) while only copying necessary
dependencies, or explicitly copy the lockfile from the parent directory before
running npm ci and document why the package type declaration is important for
CommonJS module resolution.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f496f131-669f-4944-b40a-7dacd4e5dc2b

📥 Commits

Reviewing files that changed from the base of the PR and between 5b0d59f and d235756.

📒 Files selected for processing (3)
  • site/.vitepress/config.mts
  • site/docs/core/bundle.md
  • site/docs/zh-CN/core/bundle.md

Comment thread site/docs/core/bundle.md
Comment on lines +62 to +71
```
dist-bundle/
├── worker.js # synthetic worker entry produced by the bundler
├── _root-of-the-server__*.js # @utoo/pack module-graph chunks (opaque names)
├── _turbopack__runtime.js # @utoo/pack runtime shim
├── app/... # copied runtime assets (html/static, etc.)
├── tsconfig.json # written for the SWC compiler
├── package.json # { "type": "commonjs" }
└── bundle-manifest.json # reference metadata (externals, chunks, ...)
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add a language tag to the output tree fence.

The tree block is unlabeled, so markdownlint flags it (MD040). Mark it as text or console to keep the docs lint-clean.

Suggested fix
-```
+```text
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```
dist-bundle/
├── worker.js # synthetic worker entry produced by the bundler
├── _root-of-the-server__*.js # @utoo/pack module-graph chunks (opaque names)
├── _turbopack__runtime.js # @utoo/pack runtime shim
├── app/... # copied runtime assets (html/static, etc.)
├── tsconfig.json # written for the SWC compiler
├── package.json # { "type": "commonjs" }
└── bundle-manifest.json # reference metadata (externals, chunks, ...)
```
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 62-62: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@site/docs/core/bundle.md` around lines 62 - 71, Add a language tag to the
markdown code fence that displays the file tree output. The fence currently
opens with just triple backticks but needs a language identifier to satisfy
markdownlint rule MD040. Add either `text` or `console` as the language tag to
the opening fence before the dist-bundle/ tree structure to make the
documentation lint-clean.

Source: Linters/SAST tools

Comment thread site/docs/core/bundle.md
Comment on lines +78 to +86
Packages classified as **external** are not inlined and must be installed
alongside the bundle. The simplest way is to copy the app's `package.json` next
to `worker.js` and install production dependencies:

```bash
$ cd dist-bundle
$ cp ../package.json .
$ npm ci --omit=dev
$ node worker.js

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, find and examine the documentation file
find . -name "bundle.md" -type f

Repository: eggjs/egg

Length of output: 207


🏁 Script executed:

# Search for information about dist-bundle package.json and its generation
rg "dist-bundle" --type md --type json -A 3 -B 3

Repository: eggjs/egg

Length of output: 147


🏁 Script executed:

# Check for any bundle build configuration or documentation about the CommonJS manifest
rg '"type".*"commonjs"' -A 2 -B 2

Repository: eggjs/egg

Length of output: 147


🏁 Script executed:

# Search for markdownlint configuration
find . -name ".markdownlint*" -o -name "markdownlint.config.*" | head -10

Repository: eggjs/egg

Length of output: 147


🏁 Script executed:

# Read the bundle.md file around lines 78-86
cat -n site/docs/core/bundle.md | sed -n '70,95p'

Repository: eggjs/egg

Length of output: 1160


🏁 Script executed:

# Read more of the file to understand the context of the run section
cat -n site/docs/core/bundle.md | sed -n '1,100p'

Repository: eggjs/egg

Length of output: 4931


🏁 Script executed:

# Search for bundle build code to understand how dist-bundle is generated
rg "dist-bundle|package.json" --type js --type ts -A 3 -B 1 | head -100

Repository: eggjs/egg

Length of output: 147


🏁 Script executed:

# Look for the build or bundle configuration files
find . -name "*bundle*" -type f | grep -E "\.(js|ts|json)$" | head -20

Repository: eggjs/egg

Length of output: 330


🏁 Script executed:

# Look at the bundle command implementation to understand how package.json is generated
cat -n ./tools/egg-bin/src/commands/bundle.ts | head -150

Repository: eggjs/egg

Length of output: 5411


🏁 Script executed:

# Search for where the dist-bundle package.json is created
rg "package.json.*commonjs|type.*commonjs" --type ts --type js -B 5 -A 5

Repository: eggjs/egg

Length of output: 147


🏁 Script executed:

# Check the egg-bundler source for package.json generation
find ./tools/egg-bundler -name "*.ts" -o -name "*.js" | head -20

Repository: eggjs/egg

Length of output: 1194


🏁 Script executed:

# Look for the bundler's output generation logic
rg "dist-bundle|write.*package" ./tools/egg-bundler --type ts -A 3 -B 1 | head -80

Repository: eggjs/egg

Length of output: 6510


🏁 Script executed:

# Look at the PackRunner test that confirms package.json { "type": "commonjs" } is written
cat -n ./tools/egg-bundler/test/PackRunner.test.ts | sed -n '1,100p'

Repository: eggjs/egg

Length of output: 4783


🏁 Script executed:

# Find the specific test and see what it does
rg 'writes package.json.*commonjs' ./tools/egg-bundler/test/PackRunner.test.ts -A 30

Repository: eggjs/egg

Length of output: 1594


🏁 Script executed:

# Look at the PackRunner implementation to see where package.json is written
cat -n ./tools/egg-bundler/src/lib/PackRunner.ts | head -150

Repository: eggjs/egg

Length of output: 7400


🏁 Script executed:

# Search for where the bundle's package.json is generated with commonjs type
rg '"type".*"commonjs"' ./tools/egg-bundler -A 3 -B 3

Repository: eggjs/egg

Length of output: 1678


🏁 Script executed:

# Check if there's a markdownlint config in the project
find . -type f \( -name ".markdownlint*" -o -name "markdownlint*" \) 2>/dev/null | head -20

Repository: eggjs/egg

Length of output: 147


🏁 Script executed:

# Check for markdown linting rules or standards
rg "fence|code.*block" site/docs --type md -i | head -20

Repository: eggjs/egg

Length of output: 147


🏁 Script executed:

# Let's verify the fence labeling issue by checking the actual lines 62-71
cat -n site/docs/core/bundle.md | sed -n '60,75p'

Repository: eggjs/egg

Length of output: 912


Preserve the bundle-generated manifest and add the lockfile step.

The example at lines 82-86 has two problems:

  1. cp ../package.json . overwrites the bundle's intentional { "type": "commonjs" } manifest, which can break node worker.js for apps with a different package type (e.g., "type": "module").
  2. npm ci fails without a lockfile. You must also copy package-lock.json (or npm-shrinkwrap.json / pnpm-lock.yaml / yarn.lock as appropriate).

Update the recipe to keep the bundle's CommonJS manifest intact and document the lockfile step explicitly.

Also, the unlabeled code fence at lines 62-71 should specify a language (e.g., ```text).

🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 83-83: Dollar signs used before commands without showing output

(MD014, commands-show-output)


[warning] 84-84: Dollar signs used before commands without showing output

(MD014, commands-show-output)


[warning] 85-85: Dollar signs used before commands without showing output

(MD014, commands-show-output)


[warning] 86-86: Dollar signs used before commands without showing output

(MD014, commands-show-output)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@site/docs/core/bundle.md` around lines 78 - 86, The bash recipe in the
example needs two updates: First, replace the `cp ../package.json .` step with
an approach that preserves the bundle's intentional `{ "type": "commonjs" }`
manifest instead of overwriting it (consider merging dependencies or documenting
how to safely combine manifests). Second, add an explicit step to copy the
appropriate lockfile (package-lock.json, npm-shrinkwrap.json, pnpm-lock.yaml, or
yarn.lock) before running `npm ci`, since npm ci requires a lockfile to function
properly. Additionally, add a language specifier (e.g., text) to the unlabeled
code fence that appears earlier in the document before this example.

Comment on lines +52 to +61
```
dist-bundle/
├── worker.js # 打包器生成的 worker 入口
├── _root-of-the-server__*.js # @utoo/pack 模块图 chunk(文件名不透明)
├── _turbopack__runtime.js # @utoo/pack 运行时垫片
├── app/... # 拷贝的运行时资源(html/静态资源等)
├── tsconfig.json # 供 SWC 编译器读取
├── package.json # { "type": "commonjs" }
└── bundle-manifest.json # 参考元数据(externals、chunks 等)
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

给产物树代码块补一个语言标记。

这个代码块没有语言标记,markdownlint(MD040)会报警。这里标成 textconsole 就行。

建议修改
-```
+```text
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```
dist-bundle/
├── worker.js # 打包器生成的 worker 入口
├── _root-of-the-server__*.js # @utoo/pack 模块图 chunk(文件名不透明)
├── _turbopack__runtime.js # @utoo/pack 运行时垫片
├── app/... # 拷贝的运行时资源(html/静态资源等)
├── tsconfig.json # 供 SWC 编译器读取
├── package.json # { "type": "commonjs" }
└── bundle-manifest.json # 参考元数据(externals、chunks 等)
```
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 52-52: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@site/docs/zh-CN/core/bundle.md` around lines 52 - 61, The code block
containing the dist-bundle directory structure tree is missing a language
identifier on the opening code fence, which causes markdownlint rule MD040 to
report a warning. Add a language identifier (either `text` or `console`)
immediately after the opening triple backticks of the code block that shows the
dist-bundle directory tree with worker.js, _root-of-the-server chunks, and other
files.

Source: Linters/SAST tools

Comment on lines +67 to +75
被识别为 **external** 的包不会被内联,必须与产物一起安装。最简单的方式是把应用的
`package.json` 拷贝到 `worker.js` 旁边,并安装生产依赖:

```bash
$ cd dist-bundle
$ cp ../package.json .
$ npm ci --omit=dev
$ node worker.js
```

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# First, let's locate and read the specific file
find . -name "bundle.md" -path "*/zh-CN/*" | head -5

Repository: eggjs/egg

Length of output: 180


🏁 Script executed:

# Also check for the English version to compare
find . -name "bundle.md" | grep -E "(en|english)" | head -5

Repository: eggjs/egg

Length of output: 147


🏁 Script executed:

# Check the structure of the docs directory
ls -la site/docs/ 2>/dev/null || echo "Directory not found"

Repository: eggjs/egg

Length of output: 833


🏁 Script executed:

# Read the specific lines from the Chinese bundle.md file
cat -n site/docs/zh-CN/core/bundle.md | sed -n '60,85p'

Repository: eggjs/egg

Length of output: 1008


🏁 Script executed:

# Check if there's an English version to compare
find site/docs -name "bundle.md" -not -path "*/zh-CN/*" | head -5

Repository: eggjs/egg

Length of output: 172


🏁 Script executed:

# Check the total length of the file
wc -l site/docs/zh-CN/core/bundle.md

Repository: eggjs/egg

Length of output: 181


🏁 Script executed:

# Read the English version
cat -n site/docs/core/bundle.md | sed -n '60,85p'

Repository: eggjs/egg

Length of output: 1265


🏁 Script executed:

# Let's also check the full context of both files to understand the bundle output structure
cat -n site/docs/zh-CN/core/bundle.md | sed -n '40,80p'

Repository: eggjs/egg

Length of output: 1459


🏁 Script executed:

# Check the bundler documentation mentioned in the file
find . -path "*/egg-bundler/docs/output-structure.md" | head -5

Repository: eggjs/egg

Length of output: 192


🏁 Script executed:

# Let's read more context from the English version to see if there's any additional explanation
cat -n site/docs/core/bundle.md | sed -n '76,95p'

Repository: eggjs/egg

Length of output: 898


🏁 Script executed:

# Check what package.json the bundler generates
find . -name "*.ts" -o -name "*.js" | xargs grep -l "type.*commonjs" | grep -i bundl | head -5

Repository: eggjs/egg

Length of output: 2258


🏁 Script executed:

# Look for any bundler code that generates package.json
find ./tools/egg-bundler -type f \( -name "*.ts" -o -name "*.js" \) | head -10

Repository: eggjs/egg

Length of output: 592


🏁 Script executed:

# Check the PackRunner to see how package.json is generated
cat -n tools/egg-bundler/src/lib/PackRunner.ts | head -100

Repository: eggjs/egg

Length of output: 4718


🏁 Script executed:

# Look for package.json generation in the bundler
rg "package.json" tools/egg-bundler/src --context 3 | head -60

Repository: eggjs/egg

Length of output: 5221


🏁 Script executed:

# Check if the bundler writes a package.json with "type": "commonjs"
rg "commonjs" tools/egg-bundler/src

Repository: eggjs/egg

Length of output: 674


Preserve the bundler-generated package.json to maintain CommonJS type declaration.

The bundler explicitly writes { "type": "commonjs" } to dist-bundle/package.json to prevent the parent ESM package from forcing CJS modules into ESM parse mode. Copying the app's package.json overwrites this critical declaration. If the app declares "type": "module", Node will then misinterpret the bundled CJS files as ESM, causing module resolution to fail.

Additionally, the example does not mention that npm ci requires a package-lock.json or npm-shrinkwrap.json to exist; without it, the command will fail.

Update the example to either preserve the bundler's manifest or explicitly copy the lockfile and explain the package type requirement.

🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 71-71: Dollar signs used before commands without showing output

(MD014, commands-show-output)


[warning] 72-72: Dollar signs used before commands without showing output

(MD014, commands-show-output)


[warning] 73-73: Dollar signs used before commands without showing output

(MD014, commands-show-output)


[warning] 74-74: Dollar signs used before commands without showing output

(MD014, commands-show-output)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@site/docs/zh-CN/core/bundle.md` around lines 67 - 75, The bash example in the
bundle documentation currently shows copying the app's package.json to
dist-bundle, which overwrites the bundler-generated package.json that explicitly
contains { "type": "commonjs" }. This is problematic because if the app declares
"type": "module", Node will misinterpret the bundled CommonJS files as ESM.
Additionally, the npm ci command requires either package-lock.json or
npm-shrinkwrap.json to exist. Update the example to either preserve the
bundler's package.json (which contains the critical "type": "commonjs"
declaration) while only copying necessary dependencies, or explicitly copy the
lockfile from the parent directory before running npm ci and document why the
package type declaration is important for CommonJS module resolution.

Remove the "Tegg applications" section (manifest decoratedFiles / DI-graph
internals) — too implementation-focused for a user-facing guide.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@killagu killagu merged commit c1e30a7 into eggjs:next Jun 23, 2026
20 of 21 checks passed

@fengmk2 fengmk2 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice!

@fengmk2

fengmk2 commented Jun 23, 2026

Copy link
Copy Markdown
Member

估计很快可以将 egg 部署到 cf workers 上了

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.

3 participants