4 ms·
No, you can use ES6 modules. They've been natively supported by all browsers for years.
by foobarbecue 4y ago
No, you can use ES6 modules. They've been natively supported by all browsers for years.
- postalrat 4y agoES6 modules and your entire source tree?
- foobarbecue 4y agoYeah. You're right, that is a bit of a problem. On first load, this is 272 files. I'm checking it now for the first time and most of them are loading sequentially rather than in parallel, which is taking 3.7 seconds.
- jakelazaroff 4y agoThe problem is that this scales poorly as the depth of your module tree increases — your browser needs to download and parse a module before it can start downloading any modules it imports, which causes a waterfall effect.
- foobarbecue 4y agoYeah. Can I put a file that imports all the modules at the top of the tree and load them before the browser has to parse anything else, to pre-cache? I haven't tried this yet.
- jakelazaroff 4y agoIn theory, but "no bundle step" becomes a much less attractive pitch once you have to start manually maintaining something like that. IMO the advantage of ES module support in browsers is not needing to bundle in development (although with native bundlers like esbuild this is less of an issue) and for deploying small apps where the tree is shallow. If and when your codebase starts growing, you should use a bundler.
- foobarbecue 4y agoThanks, this is helpful advice. Not having to bundle in development is what I really want. In production I could see it as a necessary evil for the moment.