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
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.
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.
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 !
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.
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
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?
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 👍
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 🤔
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?
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. 👍😊
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. 👍
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
@@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.
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?
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? 👍
@@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'); });
@@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'); });
@@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.
@@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?
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.
@@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
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
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.
Still trying, I have issue with alias and path
@@lapin07 I hope the video will help then 👍
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.
@@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 😉
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%
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 !
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.
Thank you for the tips, I will try to use the migration later on.
You're welcome, I'm glad it helped and let me know how it went 👍
Thank you for this. We already updated our project to ver17.1.3
Let's try it tomorrow 😊
You're welcome, let me know how it went. 😊 👍
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
you can try ng add environments
Great video, thank you very much.
I'm glad it helped 😊
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?
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 👍
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 🤔
It could be, also this build splits the code into many smaller bundles. 👍
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?
The status for ESBuilds wasn't it in preview and only for dev server?
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. 👍😊
By default (without any explicit configuration from developer), does Angular 18 uses vite and esbuild? Or is it still using webpack?
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. 👍
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
@@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.
Will esbuild become default in future version of angular?
I'm guessing that it will be the default eventually, but I don't remember seeing that mentioned anywhere.
I think it is already
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?
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? 👍
@@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'); });
@@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'); });
@@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.
@@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?
Still no fast refresh 😢
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.
@@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
🔝‼
Thank you! Stay tuned and enjoy the videos
where is source??????
this source code is not public, it's my company code.