-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
docs(wiki): sync bundled runtime support notes #5929
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| --- | ||
| title: Onerror Plugin | ||
| type: package | ||
| summary: Default Egg error-handling plugin and configurable response negotiation layer. | ||
| source_files: | ||
| - plugins/onerror/README.md | ||
| - plugins/onerror/src/app.ts | ||
| - plugins/onerror/src/lib/onerror.ts | ||
| - plugins/onerror/src/lib/error_view.ts | ||
| - plugins/onerror/src/config/config.default.ts | ||
| updated_at: 2026-05-06 | ||
| status: active | ||
| --- | ||
|
|
||
| # Onerror Plugin | ||
|
|
||
| `@eggjs/onerror` is the default Egg error-handling plugin. It installs | ||
| `ctx.onerror` and supports configurable handlers for HTML, text, JSON, JS | ||
| (JSONP), redirect, and catch-all error responses. | ||
|
|
||
| ## Public Configuration | ||
|
|
||
| - `errorPageUrl` redirects production HTML requests after unexpected errors. | ||
| - `accepts` customizes content negotiation. | ||
| - `all`, `html`, `text`, `json`, and `js` customize response handling for | ||
| specific response types. | ||
| - `appErrorFilter` can suppress logging for selected errors. | ||
|
|
||
| ## Current Behavior | ||
|
|
||
| The plugin owns its Koa-style `onerror()` implementation in | ||
| `plugins/onerror/src/lib/onerror.ts` instead of importing it from | ||
| `koa-onerror`. This keeps the response behavior local to the plugin and avoids | ||
| reading `koa-onerror` package templates when the plugin app boot hook is | ||
| imported, which is important for static bundling. | ||
|
|
||
| Default HTML error-page rendering still flows through `ErrorView` and the | ||
| plugin's local default template. Applications can continue to provide custom | ||
| templates and handlers through the documented `config.onerror` options. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| --- | ||
| title: Utils Package | ||
| type: package | ||
| summary: Shared utility package for Egg module loading, config/plugin helpers, and bundled module-loader integration. | ||
| source_files: | ||
| - packages/utils/README.md | ||
| - packages/utils/src/import.ts | ||
| - packages/utils/test/bundle-import.test.ts | ||
| updated_at: 2026-05-06 | ||
| status: active | ||
| --- | ||
|
|
||
| # Utils Package | ||
|
|
||
| `@eggjs/utils` is a shared utility package used across Egg packages. | ||
|
|
||
| ## Public Surfaces | ||
|
|
||
| - `getPlugins(options)`, `getLoadUnits(options)`, `getConfig(options)`, and | ||
| `getFrameworkPath(options)` expose application/framework discovery helpers. | ||
| - `importModule(filepath, options)` and `importResolve(filepath, options)` | ||
| centralize runtime module loading. | ||
| - `setBundleModuleLoader(loader)` registers the bundled runtime loader hook. | ||
|
|
||
| ## Bundled Module Loading | ||
|
|
||
| `setBundleModuleLoader(loader)` stores the hook on `globalThis` so bundled and | ||
| external copies of `@eggjs/utils` share the same loader. The loader receives the | ||
| original `importModule()` filepath after POSIX separator normalization, or a | ||
| virtual specifier. Returning `undefined` falls back to the normal resolution | ||
| path; other return values follow the same default-export unwrapping rules as | ||
| `importModule()`. | ||
|
|
||
| When a bundle loader is installed and `importModule()` falls through to native | ||
| ESM loading, `packages/utils/src/import.ts` uses an opaque native dynamic import | ||
| created with `new Function('specifier', 'return import(specifier);')`. This | ||
| prevents bundlers such as Turbopack from rewriting non-static dynamic import | ||
| expressions and preserves Node's native fallback for external ESM modules. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a non-future log date to avoid chronology drift.
Line 3 records
2026-05-06, but this PR is dated2026-05-05(2026-05-05T18:06:51Z). Please align to the actual entry date (or explicitly document UTC-based dating) so the log and packageupdated_atfields don’t appear future-dated.🤖 Prompt for AI Agents