-
-
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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, JSONP, | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The implementation in
Suggested change
|
||||||
| 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 `jsonp` customize response handling for | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The configuration key used in the
Suggested change
|
||||||
| 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. | ||||||
| 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. |
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