Skip to content

Conversation

@lightninglu10
Copy link
Contributor

@lightninglu10 lightninglu10 commented Dec 3, 2025

Add JS metadata map and wrapper-skip modes; Next.js auto-detection

This PR introduces options to avoid React wrapper elements and to store heavy metadata in a JS map instead of DOM attributes, improving compatibility with Next.js and slot/polymorphic component patterns.

Key Changes:

  • New config: skipProviderWrap, skipMarkerWrap, useJsMetadataMap; auto-enabled when Next.js is detected.
  • Inject window.CODEPRESS_MAP with per-module metadata via Object.assign.
  • Add React key to codepress-marker wrappers to stabilize reconciliation.
  • Avoid wrapping for components using asChild/forwardedAs props.

Review Notes:

  • In JS map mode, DOM only holds codepress-data-fp; other metadata moves to window.CODEPRESS_MAP.
  • Provider wrapping is skipped when skipProviderWrap is true or auto-detected (e.g., Next.js).

@lightninglu10 lightninglu10 self-assigned this Dec 3, 2025
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

❇️ CodePress Review Summary

👋 Hey team,

Overall the changes look solid, but I spotted 4 must-fix issues and left 0 helpful notes inline.

Here's the quick rundown:

✅ Decision: APPROVE
The changes are coherent, guarded by config/auto-detection, and avoid unsafe DOM mutations. No clear correctness, security, or breaking issues were found; noted risks are non-blocking and testable.

🚧 Needs a bit of love

The required findings focus on unsafe reliance on new Function for metadata injection and generated code, which violates common CSP policies and can fail at function creation time—causing unhandled initialization errors and breaking pages in CSP-restricted environments. The auto-enabled JS metadata map mode exacerbates risk by both depending on eval and skipping DOM-based markers; under CSP this leads to silent, total loss of metadata, and for custom components the early return leaves no reliable DOM anchor carrying codepress-data-fp. Remediation should remove dynamic eval in favor of CSP-safe, AST-emitted assignments and try/catch logic (or at minimum guard the outer invocation), ensure a deterministic DOM element carries codepress-data-fp even in JS map mode, and adjust defaults or add fallbacks so metadata is preserved if JS map population fails.

@lightninglu10 lightninglu10 merged commit d3362aa into main Dec 5, 2025
7 checks passed
@lightninglu10 lightninglu10 deleted the jsmap branch December 5, 2025 01:29
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