You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(bundler): lazy-externalize undici + urllib by default for snapshots
Add `undici` and `urllib` to DEFAULT_SNAPSHOT_LAZY_MODULES so an app gets a
serializable V8 startup snapshot without listing them in
`egg.snapshot.lazyModules`. Egg builds its HttpClient (urllib -> undici) during
boot, and undici instantiates an llhttp WebAssembly module (disabled under
--build-snapshot) + an HTTPParser that cannot be snapshot-serialized.
As npm packages, urllib/undici would otherwise be inlined into the bundle and
evaluated at build time; listing them here forces them external so the prelude's
member-proxy stub is used at build and the real module is required on restore.
The member-proxy (eggjs#6003) already replays the recorded access path, so egg's
`class HttpClient extends urllib.HttpClient` keeps working across the
build->restore boundary.
Adds a unit assertion for the default list and a real @utoo/pack build test that
exercises `class Sub extends pkg.Base` for a forced-external npm package across
the build-stub / restore-real boundary (upstream only covered the node:http
builtin).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- change: Added `undici` + `urllib` to `DEFAULT_SNAPSHOT_LAZY_MODULES` so an app gets a serializable V8 snapshot without listing them in `egg.snapshot.lazyModules`. Egg builds its HttpClient (urllib → undici) during boot, and undici's llhttp `WebAssembly` + `HTTPParser` cannot be snapshot-serialized. As npm packages they would be inlined; listing them forces them external (`Bundler` adds lazy ids to the externals map) so the prelude member-proxy stub is used at build and the real module is required on restore.
11
+
- history note: the PR originally (off the older `next`) shipped a bespoke per-export forwarder in `__makeLazyExt` to make `class HttpClient extends urllib.HttpClient` survive the build→restore boundary. While the PR was open, #6003 landed on `next` and rewrote `__makeLazyExt` into a general **access-path-recording member-proxy** (`makeMember`) that already handles `class X extends pkg.Klass` / `DataTypes.INTEGER(11).UNSIGNED` plus `ownKeys`/`getOwnPropertyDescriptor` via `__EXTERNAL_EXPORTS`. The PR was rebased onto that and **reduced to just the default-list addition** (forwarder dropped as superseded). Note `makeMember`'s `protoProxy` has only a `get` trap (no `getPrototypeOf`), so `instanceof RealBase` on a snapshot-frozen subclass is `false` — methods/fields/super() work, identity-by-prototype does not.
12
+
- verification: unit test asserts undici+urllib in the default list; new real `@utoo/pack` build test exercises a **forced-external npm package**`class Sub extends pkg.Base` across the build-stub / restore-real boundary in one process (upstream only realbuild-tested the `node:http` builtin). 28 lazy/realbuild tests green; tsgo + oxlint clean. Pre-existing macOS `ManifestLoader`/`EntryGenerator` tmpdir-symlink failures unrelated.
0 commit comments