5 ms·
Personally I don't get why you wouldn't use JSX for such a tool. If you're building JS apps for production you'll invariably use a bundler like Webpack so trans
by ThePhysicist 4y ago
Personally I don't get why you wouldn't use JSX for such a tool. If you're building JS apps for production you'll invariably use a bundler like Webpack so transpiling JSX to JS is not an issue, and it makes Markup code in JS so much more readable.
- foobarbecue 4y agoThe self-fulfilling prophecy "you'll have to have a build step" makes me so sad.
- ThePhysicist 4y agoWith JS modules it might be possible to just write JS code and include it in your HTML directly, I'm not sure if I'd recommend that though as performance might not be great as of now, and there are still many other caveats. In a few years this might be less of an issue though when HTTP/3 is widely deployed and loading many tiny files instead of one big one won't make that much of a difference.
- foobarbecue 4y agoHTTP/2 already mostly solved that, as I understand it, except for some retransmit issues that can't be fixed until TCP is replaced with QUIC. Right?
- postalrat 4y agoIf you don't have a build do you just have a couple giant js files you edit?
- foobarbecue 4y agoNo, 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.
- andsoitis 4y agoFor one, JS engines don't support TypeScript natively and it turns out that many teams who build and maintain large, ambitious SPAs think TypeScript is a productivity boost.
- toastercat 4y agoNot everyone uses/prefers TypeScript, and not everyone is on a team that builds and maintains a large ambitious SPA. There's room for both frameworks like Next.js and small libraries that work without build steps.
- draw_down 4y agoGoing without linting, testing (automated testing anyway), type checking would make me a lot sadder.
- foobarbecue 4y agoA build step is not required for any of that. I use prettier and jenkins on a large js codebase that never gets transpiled, packed, or minified.
- draw_down 4y agoThat’s true, I guess you can just run those locally. But if there’s CI in the picture the “build step” is a fait accompli, as far as setup and maintenance and so forth.
- foobarbecue 4y agoGithub runs jenkins. Jenkinsfile specifies tests and linting. How would webpack make this easier?
- draw_down 4y agoOh I didn’t say anything about webpack. I haven’t used the GitHub features you’re talking about but that sounds like a build to me!
- foobarbecue 4y agoUsually when people say "build" they mean something that creates a build product which is different from the original source files. This could mean compiling and linking c to object files / executables, transpiling TypeScript to javascript, bundling lots of javascript files to one big javascript file, going from readable js to minified js, etc. I've never heard of testing or linting referred to as building. BTW, I'm not the one that keeps downvoting you to death!
- ilrwbwrkhv 4y agoYup it's ugly and tedious. Something like imba is far superior with vastly better ergonomics.