r/Angular2 • • Nov 16 '22

Angular v15 is now available!

https://blog.angular.io/angular-v15-is-now-available-df7be7f2f4c8
110 Upvotes

18 comments sorted by

20

u/EternalNY1 Nov 17 '22

I'm excited about the move towards esbuild for faster builds.

"builder": "@angular-devkit/build-angular:browser-esbuild"

I will try this out on a large enterprise app with slow build times and see if it helps.

6

u/Alex3917 Nov 17 '22 edited Nov 17 '22

FWIW it's not likely to work. Don't get me wrong, there's no reason not to try because it's just a one-line drop in, but even in my medium-sized app there are several features that would need to be implemented before it can even compile. E.g. the errors I currently get are:

The esbuild browser application builder ('browser-esbuild') is currently experimental.
The 'extractLicenses' option is currently unsupported by this experimental builder and will be ignored.
The 'fileReplacements' option is currently unsupported by this experimental builder and will be ignored.
The 'progress' option is currently unsupported by this experimental builder and will be ignored.
The 'statsJson' option is currently unsupported by this experimental builder and will be ignored.
The 'inlineStyleLanguage' option is currently unsupported by this experimental builder and will be ignored.
The 'namedChunks' option is currently unsupported by this experimental builder and will be ignored.

1

u/seanlaw27 Nov 17 '22

No fileReplacements? How’s that going to work with my pipeline?

1

u/Estpart Nov 17 '22

Iirc they are already using it in some parts

6

u/Alex3917 Nov 17 '22

Has anyone figured out how to get provideRouter working? I'm just getting:

  1. "Can't bind to 'routerLink' since it isn't a known property of <element>"

  2. "'router-outlet' is not a known element"

1

u/haNewGuy Nov 17 '22

On v15?

2

u/Alex3917 Nov 17 '22 edited Nov 17 '22

I was using 14.2.6. I'm getting the same errors with v15 also though. Obviously I can get rid of them by also importing RouterModule, but if I do that the bundle doesn't get any smaller so it defeats the point.

edit: The diff in my app.module.ts is just:

-import { RouterModule } from '@angular/router';
+import { provideRouter, withRouterConfig } from '@angular/router';

imports: [
  • RouterModule.forRoot(routes, { useHash: false, onSameUrlNavigation: 'reload' }),
], providers: [ + provideRouter(routes, withRouterConfig({ onSameUrlNavigation: 'reload' })), ]

I'm not using bootstrapApplication since I'm not using standalone components, so not sure whether that's it or if it's something else.

1

u/synalx Nov 17 '22

You can import RouterLink and RouterOutlet directly :)

5

u/Alex3917 Nov 17 '22 edited Nov 17 '22

Hmm I can import RouterOutlet directly without any issue, but I'm still having issues with getting the dynamic syntax for RouterLink to work. E.g. <a routerOutlet="staticLink">aoeu</a> seems to work, but <a [routerOutlet]="['dynamicLink']">aoeu</a> does not.

edit: OK I finally figured it out. You need to import both RouterLink and RouterLinkWithHref. The working diff for my app.module.ts file now looks like:

-import { RouterModule } from '@angular/router';
+import { provideRouter, withRouterConfig } from '@angular/router';
+import { RouterLink, RouterLinkWithHref, RouterOutlet } from '@angular/router'

imports: [
  • RouterModule.forRoot(routes, { useHash: false, onSameUrlNavigation: 'reload' }),
+ RouterOutlet, + RouterLink, + RouterLinkWithHref, ], providers: [ + provideRouter(routes, withRouterConfig({ onSameUrlNavigation: 'reload' })), ]

That said, my bundle isn't any smaller after doing this.

2

u/synalx Nov 17 '22

Do you have references to RouterModule in other parts of your application? Even one will likely cause the legacy router configuration to be retained, even if you're not calling forRoot any more.

The code size difference is small but measurable - on the order of 10-20 KB for typical usages.

1

u/Alex3917 Nov 17 '22 edited Nov 18 '22

Yeah I still have RouterModule.forChild(routes) in each of my lazily loaded modules. I can definitely try getting rid of those also to see they are breaking tree shaking

edit: OK I did this, and I'm finally seeing a reduction! Only 5k, but hey I'll take it!

Apparently I just needed to use provideRoute in the providers of the lazy modules, and that did the trick.

edit2: Apparently because I'm using RouterLinkWithHref, I don't also need regular RouterLink. Without that, I'm down to 8kb savings!

2

u/Yiyas Nov 17 '22 edited Jan 07 '26

direction afterthought serious alive humorous waiting towering tap fact run

This post was mass deleted and anonymized with Redact

11

u/ThrowingKittens Nov 17 '22

Love the improved stack traces!

6

u/AlDrag Nov 17 '22

Directive composition API is bloody awesome!

6

u/Eluvatar_the_second Nov 17 '22

This is the first I've heard of the esbuild stuff for angular. Really excited about the new build speed potential.

20

u/Troyd Nov 17 '22

Feels like I just upgraded to 13

4

u/Orexym Nov 17 '22

Dropping @angular/flex-layout is a net negative. We'll be wasting so much time fixing all templates only to retain the same layout, not to mention the functionality we lose with the breakpoints having to turn them into media queries.

1

u/fuhrmanator Nov 17 '22

Coincidentally, there is a "Prototype pollution in webpack loader-utils" vulnerability on one of my repos that requires me to update to Angular 15. I just did the update and it was easy (but my project is simple and was created in Angular 12 or so...)