Hacker News new | ask | show | jobs
by paul7986 2700 days ago
Im fairly new to Angular 2 and above and wonder why everytime I want to test a new piece of code does the project have to re-build itself. The rebuild takes almost up to five minutes.

I know this is a post about React (which doesn't it run on Node too), but as framework noob wondering why development has become so arduous vs. build it locally & refresh the page.

Also, the npm module stuff .. i mean some rando in the world updates their module and boom breaks the build for millions everywhere. WHAT? How is this efficient and better then prior to all these frameworks that run on Node?

6 comments

I work on an enterprise react application which hot reloads in <1s and tests re-run automatically when changing a file which impacts them automatically in a similar time. This used to be a large under taking to configure but now with create-react-app this is all out the box stuff and is trivial to set up.

I'm not sure what angular setup you have there but something is very wrong

I recommend you try using HMR mode, a medium sized project takes about 5 seconds to build. The stuff then updates without even needing to refresh the page, you can even store state and scroll position in between the module swapping. It really changes the way I develop a lot.
Not to mention that there are hundreds of authors and packages in most dependency trees, and it's highly unlikely people are doing any kind of audit on all of them and their updates, before letting them be part of their applications.
Really depends on how you are building. If you're building a decent sized project with Webpack and production mode (with minifier stuff), then it might take a few minutes. Dev mode, shouldn't take a ton of time.
Thanks so based on your comment and the other this is modern web development and we accept it.

Building sites in html/css & JavaScript was a better development UX and faster. This constant compiling even quickly is silly and a fourth of my day is spent doing so.

> Building sites in html/css & JavaScript was

This is still building sites in HTML/CSS & JS. You can even use React without Webpack if you want to if you are okay with a different syntax, and want to avoid transpiling at all cost.

If you want to have quick iteration cycles for tweaking CSS, you still cleanly separate your CSS from the rest of your component and use something like Storybook. The CSS changes will be detected and autoreloaded near instantly (sub-second).

But yeah, if you want to build robust interactive elements with syntactic sugar, you will have to bite the bullet and accept a bit slower refresh time (2-5 seconds with HMR on most projects I worked on).

It's because browsers are the target deployment environment, and browsers move pretty slowly (although a lot faster in recent years). So to use modern language features (such as ES6 or Typescript) you have to transpile back to older JS. For many projects, I don't personally think it's worth the tradeoff of tooling setup and dependencies, so I won't use it in those cases. But for decently complex projects it is nice to use modern language features.
Angular 6 and above is pretty fast if you have an SSD and plenty of RAM.

Further you can also split up your project in smaller libraries, build and deploy them to a local npm-repository for faster builds.

Are you using @angular/cli (The ng command line)?
Yes I am... should I not be using ng?
You should be using ng.