eleventy-plugin-react
eleventy-plugin-react copied to clipboard
Move away from JSDOM for comment transformation
The current marker generation logic takes multiple passes to generate the marker comments for the client-side hydration step.
- It renders a script tag with the necessary data serialized as data attributes.
- Post-rendering to string, the plugin manually replaces these script tags with HTML comments to avoid breaking any styles that might rely sibling selectors.
This second step currently uses JSDOM as a quick-and-dirty way to get it working, but this is probably overkill for what we're doing here, and a simpler string replacement would probably be more performant since we don't need access to all the DOM APIs to do this transformation.