So we upgraded to 9.8.0 and have been having some problems with running a development build since the upgrade. Something with the barrel imports seems to be making some circular references and the build is dropping this error:
That is the only thing that drops as an error in the build. Other than that its just vite warnings about static and dynamically imported assets which is not causing this.
Trying to gather more information for you now. Im starting to think its something with our source maps.
the pure barrel was introduced, and files involving side effects have changed in architecture, but it should have continued working as is. I tested many different scenes making sure, but of course not saying i missed nothing. It would be great if we can debug this so I can know if it is something i can fix on our end, or it is something you can fix in your environment.
Yeah me and @Will_FrameVR are digging on this now, its for sure something with the source maps. Ill get you more info as we discover it. I appreciate you <3
Ok so, it seems to only happen on “inline” sourcemaps. I asked Opus about it and this is what it had to say:
```
That choice was fine before Babylon 9.8.0 — but the tree-shaking PR exploded effective chunk sizes (you can see it in the [vite:reporter] warnings above the crash: ShadowGenerator.js alone is now both statically and dynamically imported from inspector, cascadedShadowGenerator, index.js, FrameGraph, goKartsManager, etc., so Rollup merges huge graphs together). Larger chunks + inline maps = the mapFileCommentRegex in convert-source-map finally hits its catastrophic-backtracking ceiling.
```
Im not to confident about this though because on our git CI it fails even with source maps false.
Did some digging. I couldn’t find any issue with circular dependencies (which i was afraid off when you showed the error). The new pure barrel implementation introduced roughly 700 new files in the repo. So:
This is the only issue i could find with the new implementation. I assume you are not importing from the root index, but you are probably loading from some index barrels within the directory structure? The extra files might put some load on the number of inline sourcemaps added to each chunk.
So then I must have been mistaken about the causality being the source maps, thank you for looking into that. I’m going to a build on a prior version and then this version that we are struggling with and monitor the resources to see if I cant figure out more for us. There is definitely something here just not sure what yet. Thank you so much for trying to help us figure this out.
We looked at max memory usage during build and found no difference
We looked at total build size and found a only slight increase (3%) with Babylon 9.8
Maybe that one extra layer of import added to all our Babylon imports was just a straw that broke the camel’s back. Vite 8 ships a new bundler written in rust so its no surprise that would improve efficiency enough to get us across the line if that’s the case.
Will be really great if I could convince you to give the new pure barrel a try! It will provide you with the smallest package size and only involve registering aside effects using the Register functions.
Will also clean up your code and make things a little more structured
We’re already using exclusively deep-path direct imports and no barrel files (with an eslint rule to enforce it)
Those files we’re currently importing that do have side effects are (presumably) side effects that we require for Babylon to function
It seems like a lot of work to change every import to the pure and then discover which side effects we need to manually apply as a result
Worry about increased maintenance requirements as we have to repeat the side effect discovery process on future Babylon updates
Not expecting much gain on bundle size since we’re not using any barrel imports currently
I don’t see a top-level pure barrel @babylonjs/core/pure, which would be more appealing as we could simplify all Babylon imports and eslint enforcement