🚨Angular URGENT Update #1: Angular 17 CLI EsBuild: OFF By Default

Поделиться
HTML-код
  • Опубликовано: 22 окт 2024

Комментарии • 45

  • @AngularUniversity
    @AngularUniversity  8 месяцев назад +4

    Let me know if you turned on the EsBuild system, and what performance benefits did you notice? 😊 If you are looking to learn Angular, check out my courses at the Angular University 👍 - angular-university.io

    • @RajinderYadav
      @RajinderYadav 8 месяцев назад +1

      Didn't even know this was a thing. My PC is powerful enough that this doesn't even factor into the equation. I use to code in C++ where the build and linking took 10min to 1 hour depending on the project size.

    • @lapin07
      @lapin07 8 месяцев назад

      Still trying, I have issue with alias and path

    • @AngularUniversity
      @AngularUniversity  8 месяцев назад

      @@lapin07 I hope the video will help then 👍

    • @hatsvids
      @hatsvids 8 месяцев назад +1

      I am using ESBuild... the final bundle size seems somewhat bigger (more 40/50Kb in the final build), but the compilation time has decreased from about 40 seconds to 16 seconds with ESBuild... I haven't had the chance to try the new 'application' method yet, I believe it requires some additional reconfiguration of the angular.json.

    • @AngularUniversity
      @AngularUniversity  8 месяцев назад +1

      @@hatsvids There is a new migration for that, plus a couple of code changes are likely needed. I think you will like the video then 😉

  • @AleksandarT10
    @AleksandarT10 6 месяцев назад

    Running the command + fixing some of the imports did the trick for me! Thanks a lot for that, it speed up our builds by more than 30-40%

  • @AlainBoudard
    @AlainBoudard 8 месяцев назад +1

    Spot on Vasco ! You're right, the v16 build was already much faster than previous versions, but now they made a big step !
    Thanks for the hint about http2 I didn't know !

    • @AngularUniversity
      @AngularUniversity  8 месяцев назад

      You're welcome Alain, yes and Angular 17 build is even faster, even if it's not the ESBuild version. 😊 The ESBuild faster is slightly faster in development, but much faster while doing the production build.

  • @hatsvids
    @hatsvids 8 месяцев назад +1

    Thank you for the tips, I will try to use the migration later on.

    • @AngularUniversity
      @AngularUniversity  8 месяцев назад

      You're welcome, I'm glad it helped and let me know how it went 👍

  • @ВолодимирНакутний
    @ВолодимирНакутний 8 месяцев назад +1

    Thank you for this. We already updated our project to ver17.1.3
    Let's try it tomorrow 😊

    • @AngularUniversity
      @AngularUniversity  8 месяцев назад

      You're welcome, let me know how it went. 😊 👍

  • @margaridasemedo7846
    @margaridasemedo7846 3 месяца назад

    Great video! Thank you for sharing. How would you suggest to set up environment variables. Esbuild doesn't seem to have anything out of the box. Been struggling with it. On build esbuild can't find my environment variables. Using Anguar 17.3.11

  • @NoName-1337
    @NoName-1337 8 месяцев назад

    Great video, thank you very much.

  • @walterluszczyk
    @walterluszczyk 8 месяцев назад +1

    Great, I need to try in my code. Meanwhile I have a question. I've notice in start version of code, that there was massive amount of Angular Material in your main bundle. After migration it has disappeared. Was it automatically separated to some shared bundle?

    • @AngularUniversity
      @AngularUniversity  8 месяцев назад +1

      Yes, the ESbuild build system will split the main bundle into separate smaller chunks. It works in a very different way than the standard bundler. Remember that we need a production server with support for HTTP 2, but this shouldn't be an issue 👍

  • @ChrisPHolder
    @ChrisPHolder 6 месяцев назад

    Have you considered that the bundle size decrease might just be because you were opting out of tree shaking by using require and CJS?
    Would be interesting to see if the bundle would decrease the same amount if you simply use ESM and don’t opt out of Tree shaking with require calls 🤔

    • @AngularUniversity
      @AngularUniversity  6 месяцев назад

      It could be, also this build splits the code into many smaller bundles. 👍

  • @vasiliuandrei4971
    @vasiliuandrei4971 Месяц назад

    Hello! I have a problem after migrating to esbuild (automatic migration). When I try to test build production output using http-server , the application starts with the loading page but none of the http requests starts. No errors / warnings shown in the console. Reverting back to angular-build:browser, the problem is gone. Starting with Ng serve, it works as expected. Any ideas to solve build production with esbuild?

  • @ico0z
    @ico0z 8 месяцев назад +1

    The status for ESBuilds wasn't it in preview and only for dev server?

    • @AngularUniversity
      @AngularUniversity  8 месяцев назад +1

      It was in preview for 16 and our of preview in 17.The new esbuild is now out of developer preview and it's the default for new applications. But existing applications need to migrate manually, that's the catch. 👍😊

  • @drax432
    @drax432 4 месяца назад

    By default (without any explicit configuration from developer), does Angular 18 uses vite and esbuild? Or is it still using webpack?

    • @AngularUniversity
      @AngularUniversity  4 месяца назад

      Since Angular 17, the new ESbuild was enabled by default to new apps, but the migration to 17 did not migrate it, you had to migrate manually. The migration to 18 will now ask if you want to migrate to ESBuild. 👍

    • @drax432
      @drax432 4 месяца назад

      thanks for replying. When i use angular 18 directly (no migration involved), i wonder if by default, ESbuild is enabled. Cos when i look at the package-lock.json, i saw dependencies related to Esbuild and webpack. So i wonder which is the default one used

    • @AngularUniversity
      @AngularUniversity  4 месяца назад +1

      @@drax432 Check the output on the build folder. Webpack will only output 4 main files, plus one bundle part lazy loaded element, but esbuild will output way more files, and they are named chunk* I think the dependency with webpack is not yet fully removed with the CLI, or they install it both not knowing which one you will use.

  • @Anbu_Sampath
    @Anbu_Sampath 8 месяцев назад +1

    Will esbuild become default in future version of angular?

    • @AngularUniversity
      @AngularUniversity  8 месяцев назад +2

      I'm guessing that it will be the default eventually, but I don't remember seeing that mentioned anywhere.

    • @LarsRyeJeppesen
      @LarsRyeJeppesen 8 месяцев назад

      I think it is already

  • @giorgipaikidze85
    @giorgipaikidze85 7 месяцев назад

    Thank you Vasco. I got an error when turned on esbuild. App build works fine, it's really fast, but it throws the following error when changing the route - dynamic require of is not supported. And it points to lazy lodede modules. After some research It seems esbuild does not support dynamic imports. Do you have any idea about this?

    • @AngularUniversity
      @AngularUniversity  7 месяцев назад +1

      How are you making the imports? I have my platform running on Esbuild, we use router dynamic imports and it works. This seems like something to your project? 👍

    • @giorgipaikidze85
      @giorgipaikidze85 7 месяцев назад

      @@AngularUniversity Yes, it seems something is missing in my project. I use nx and updated recently to 17.1 with nx. I am using standard lazy loading - loadChildren property. With old browser builder project works fine, but after switching to browser-esbuild it gives this error. After debugging it seems when dynamic import is triggered esbuild checks if require is defined or not and since it is not present in the browser it throws the error. here is the code which throws the error:
      var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) { if (typeof require !== "undefined") return require.apply(this, arguments); throw new Error('Dynamic require of "' + x + '" is not supported'); });

    • @giorgipaikidze85
      @giorgipaikidze85 7 месяцев назад

      @@AngularUniversity yes,something is miising in my project. I use nx and updated recently to 17.1 with nx. I am using standard lazy loading - loadChildren: () => import('some.module').then(m => m.SomeModule). With old browser builder project works fine, but after switching to browser-esbuild it gives the error. After debugging it seems when dynamic import is triggered esbuild checks if require is defined or not and since it is not present in the browser it throws the error. Here is the code which throws the error:
      var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) { if (typeof require !== "undefined") return require.apply(this, arguments); throw new Error('Dynamic require of "' + x + '" is not supported'); });

    • @giorgipaikidze85
      @giorgipaikidze85 7 месяцев назад

      @@AngularUniversity yes,something is miising in my project. I use nx and updated recently to 17.1 with nx. I am using standard lazy loading - loadChildren: () => import('some.module').then(m => m.SomeModule). With old browser builder project works fine, but after switching to browser-esbuild it gives the error. After debugging it seems when dynamic import is triggered esbuild checks if require is defined or not and since it is not present in the browser it throws the error.

    • @AngularUniversity
      @AngularUniversity  7 месяцев назад

      @@giorgipaikidze85 I did not try the new EsBuild with module-based lazy loading, as the platform had already been migrated to standalone components, but I assume that it not related. what I suspect that happens in your case is that maybe not all the EsBuild bindles are being sent to production. Does it work locally?

  • @bullettime2808
    @bullettime2808 8 месяцев назад +1

    Still no fast refresh 😢

    • @AngularUniversity
      @AngularUniversity  8 месяцев назад

      Weird, are you sure you updated? The refresh is blazing fast for me, way better than in Angular 16. I often can't even switch to the browser enough to see the reload happening.

    • @bullettime2808
      @bullettime2808 8 месяцев назад +1

      @@AngularUniversity I mean state-full fast refresh like React, Flutter and most other frameworks , In Angular if you make a change your entire app restarts

  • @gleitonfranco1260
    @gleitonfranco1260 8 месяцев назад

    🔝‼

  • @КонстантинХ-у4ф
    @КонстантинХ-у4ф 8 месяцев назад

    where is source??????

    • @AngularUniversity
      @AngularUniversity  8 месяцев назад

      this source code is not public, it's my company code.