https://futureofcoding.org/ logo
#present-company
Title
# present-company
a

alltom

02/06/2024, 4:37 AM
Can I be happy writing TypeScript for the browser? I made a Node project that imports Three.js, and Browserify takes almost four seconds to bundle it every time I make a change. Is this how it’s done?
i

Ivan Reese

02/06/2024, 4:52 AM
Why are you using node to build a web project?
a

alltom

02/06/2024, 4:57 AM
I don’t know, the TypeScript doc said ‘npm install typescript --save-dev’ and I just kept going 😂
d

Daniel Buckmaster

02/06/2024, 5:08 AM
This is why people keep reinventing web tooling! E.g. https://esbuild.github.io/
I think honestly the issue here is three.js moreso than typescript 😞 (I say this as someone who uses both a lot)
@alltom if you haven't done much frontend before... my condolences. I don't think I know of a way to use TypeScript without having to wade into the JS tooling ecosystem quagmire 😕
j

Joshua Horowitz

02/06/2024, 6:02 AM
Modern web tooling is, famously, a shit-show. I empathize with you if you’re new to it, @alltom! But, fwiw, I’m used to more like a 1/4 second latency between saving a file and seeing an update in the browser. That’s using Vite, but an older Webpack-based setup wasn’t that different. So I think you can do better than 4 seconds. Most build systems have a distinction between a production build mode and a hot-reloading development mode. Do you know if you’re using the development mode?
i

Ivan Reese

02/06/2024, 6:04 AM
I can second the Vite recommendation as a low(ish)-friction way to get started with TypeScript.
j

Jack Rusher

02/06/2024, 8:19 AM
Have you considered bringing in Three.js from a CDN and writing plain JS code? Despite my many complaints with JS-as-a-language, I find this the most civilized way to interact with that ecosystem in the browser.
d

Duncan Cragg

02/06/2024, 11:32 PM
I cannot understand why Typescript even exists. Javascript is Javascript. I suspect it's company architects trying to impose some sense of control over developers.
I've seen the sad decline that happened with JS from nifty ecosystem to quagmire happen with Java before it. Something around architects and pay rates seem to be the influences.
t

Timothy Johnson

02/07/2024, 4:06 AM
@Duncan Cragg If you want to build a website, and you prefer using static typing, isn't that a good enough reason to use Typescript? I personally use it. I don't love it, but I prefer it over plain Javascript.
i

Ivan Reese

02/07/2024, 4:10 AM
CoffeeScript: exists
Jokes aside — JS has long had a culture of choose your own syntax (and, to a limited extent, semantics) with things like Coffee, JSX, ClojureScript, and now TypeScript. So I think it's fair to say JavaScript is not just JavaScript — there's the browser and node runtimes, there's the transpiled languages, there's the npm ecosystem, there's the framework-centric culture, and more, all of them different, all of them opt-in, all of them desirable and offensive.
TypeScript is for the folks who want to build on those JS runtimes (and accrue all the benefits thereof) but also have the development aid of static typing. What more need it be?
a

alltom

02/07/2024, 5:55 AM
That's all I want it for. I've maintained large JavaScript code bases, and the TypeScript ones were easier for me. ¯\_(ツ)_/¯ Vite is great! Thanks a bunch!