neomjs / neo

The application worker driven frontend framework
https://neomjs.com
MIT License
2.75k stars 147 forks source link

Webpack creates wrong bundles (harmony) which can load & instanciate singletons multiple times #5489

Open tobiu opened 1 week ago

tobiu commented 1 week ago

i did not see it before using our LivePreview which dynamically imports apps which can dynamically import other modules.

sadly this is a "game over" for our dist/development & dist/production env.

imho we do not need harmony these days anyway => browsers and node are capable of using real JS modules.

Screenshot 2024-06-26 at 15 09 57

Screenshot 2024-06-26 at 15 14 47 Screenshot 2024-06-26 at 15 15 15 Screenshot 2024-06-26 at 15 15 40

@sokra

tobiu commented 1 week ago

steps to reproduce:

tobiu commented 1 week ago

i stepped more through the build logic and the new trouble-maker obviously is the LivePreview component.

Screenshot 2024-06-27 at 10 51 06

it makes sense: we have a string, which can change in any possible way at run-time, which then gets parsed (replacing static with dynamic imports) and then converted into JS.

IF the previews were readOnly, we could probably monkey-patch it (magic comments to ignore our custom logic and telling build-tools exactly what to import instead)

otherwise, the LivePreview is limited to the dev mode.

This still does not justify though that Webpack sneaks in singletons more than once.