Skip to content

feat: add conservative export detection - #141

Draft
BridgeAR wants to merge 1 commit into
nodejs:mainfrom
BridgeAR:BridgeAR/2026-10-28-cjs-conservative
Draft

BridgeAR wants to merge 1 commit into
nodejs:mainfrom
BridgeAR:BridgeAR/2026-10-28-cjs-conservative

Conversation

@BridgeAR

Copy link
Copy Markdown
Member

Consumers such as Node.js need broader object literal detection with the default descriptor getter and reexport policies. Conservative mode vetoes recognized object literal accessors and retains reexport replacement. Parenthesized assignments retain default detection to avoid uncertain names from comma expressions. Forwarding getters and unrecognized accessor forms can still execute when consumers read exports.

The Wasm binary shrinks from 28,959 to 27,925 bytes. Interleaved Node.js 22 trials reduce warmed angular.js CPU time by 5.9% with optimized Wasm compilation (--no-liftoff, seven fresh processes).

Consumers such as Node.js need broader object literal detection with the
default descriptor getter and reexport policies. Conservative mode vetoes
recognized object literal accessors and retains reexport replacement.
Parenthesized assignments retain default detection to avoid uncertain names
from comma expressions. Forwarding getters and unrecognized accessor forms
can still execute when consumers read exports.

The Wasm binary shrinks from 28,959 to 27,925 bytes. Interleaved Node.js 22
trials reduce warmed angular.js CPU time by 5.9% with optimized Wasm
compilation (--no-liftoff, seven fresh processes).

@guybedford guybedford left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'd prefer not to add a third mode. Since extended hasn't been released yet, could this instead redefine extended as the conservative variant?

  • Keep the object literal detection (arbitrary values, methods, shorthand, string/computed string keys), with accessors vetoing their names.
  • Keep the default defineProperty descriptor/getter allowlist, defineProperties and parenthesized assignment handling, and reexport replacement on each module.exports =.

That keeps the API at default | extended, with extended safe for Node.js to consume. If there's a real consumer for the current maximal behaviour (arbitrary descriptor getters, comma-expression objects, accumulated reexports), I'd rather expose that as a separate boolean alongside allowMinifiedEnumerable than as another mode.

Also, could the isTokenRunChar table, uint16_t astral table, readExportDefinition refactor and --converge change move to a separate PR? The size and perf numbers come from those rather than this feature, and --converge produces byte-identical output to -Oz here. Separately, the mode error message should keep listing the valid values.

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.

2 participants