direflow icon indicating copy to clipboard operation
direflow copied to clipboard

Bundle is injected into Head causing strange compat behavior with some libs

Open Psvensso opened this issue 3 years ago • 1 comments

Is your feature request related to a problem? Please describe.
We are using an external UI library, they are assuming document.body are available during eval execution. This can ofcourse be considered bad practise, i will create a bug there as well so that they null check it, but my guess is that more libs will have this problem. The root cause is that direflow injects the dev bundle into the head instead of at the end of body as for normal CRA. Is there a reason for this?

Describe the solution you'd like

  1. Inject into body so direflow mimics CRA as close as possible for maximum lib compatibility.
  2. Provide a config option for dev server bundle inject location.

I'm aware that this might not be possible, my knowledge of web-components are most definitely limited, perhaps the components must be defined prior to head?

Describe alternatives you've considered

Additional context

Psvensso avatar Oct 15 '20 09:10 Psvensso

Hi @Psvensso Thank you for creating this issue.

Yes, originally this modification was introduced in regards to how web-components work. As you point out, parts of the code will need to be run before the custom elements are attached to the DOM.

However, after we introduced asynchronous loading of the web-component polyfills, there's no reason that the server bundle cannot be injected into body instead of head.

Thanks for pointing it out. We'll look into this and have it fixed, as soon as possible :+1:

SimonHoiberg avatar Oct 21 '20 06:10 SimonHoiberg