LearnNewsExamplesServices
Frontmatter
id8571
titleFeature: Native Declarative Config Injection (mergeFrom) in Container Items
stateClosed
labels
enhancementarchitecturecore
assigneestobiu
createdAtJan 12, 2026, 2:56 AM
updatedAtJan 12, 2026, 3:01 AM
githubUrlhttps://github.com/neomjs/neo/issues/8571
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtJan 12, 2026, 3:01 AM

Feature: Native Declarative Config Injection (mergeFrom) in Container Items

Closed v11.20.0 enhancementarchitecturecore
tobiu
tobiu commented on Jan 12, 2026, 2:56 AM

We have identified a powerful pattern for declarative configuration injection in Containers, dubbed the "Structural Injection Pattern". Currently, this is achieved manually in subclasses via afterSetContentItems.

We want to support this natively in Neo.container.Base by introducing a mergeFrom property (likely a Symbol) on item configurations.

Proposed Logic: When Container processes its items (in createItem), if it encounters an item with [mergeFrom]: 'configName', it should:

  1. Look up the configName on the container instance (e.g., this.headerConfig).
  2. Deeply merge the item's properties on top of the referenced config object.
  3. Use the merged result to create the item.

Benefits:

  • Eliminates manual Neo.assignDefaults in afterSet... hooks.
  • Decouples structural definition (items) from configuration data.
  • Enables cleaner subclassing where configuration can be injected declaratively.

Proof of Concept: A working prototype has been verified in test/playwright/unit/core/ConfigMerging.spec.mjs.

Tasks:

  1. Define the mergeFrom Symbol in src/core/ConfigSymbols.mjs.
  2. Implement the interception logic in src/container/Base.mjs (likely inside createItem).
  3. Ensure it handles both Object-based and Array-based item definitions if applicable (though createItem handles individual items).
  4. Verify with existing tests.
tobiu added the enhancement label on Jan 12, 2026, 2:56 AM
tobiu added the architecture label on Jan 12, 2026, 2:56 AM
tobiu added the core label on Jan 12, 2026, 2:56 AM
tobiu referenced in commit 0b56c73 - "feat: Implement native declarative config injection (mergeFrom) for Container items (#8571)" on Jan 12, 2026, 3:00 AM
tobiu
tobiu Jan 12, 2026, 3:00 AM

Input from Gemini 3 Pro:

✦ I have implemented the native mergeFrom feature in Neo.container.Base.

Changes:

  1. Symbol Definition: Added mergeFrom symbol to src/core/ConfigSymbols.mjs.
  2. Core Logic: Updated createItem in src/container/Base.mjs to intercept items with the mergeFrom symbol. It retrieves the referenced config from the instance, deeply merges the item properties on top of it, and cleans up the symbol.
  3. Verification: Added and verified test/playwright/unit/core/ConfigMerging.spec.mjs.

This enables the Structural Injection Pattern natively without manual afterSet... logic in subclasses.

Closing as completed.

tobiu assigned to @tobiu on Jan 12, 2026, 3:01 AM
tobiu closed this issue on Jan 12, 2026, 3:01 AM