Error when importing @angular/material CSS files with esbuild after updating from @angular/cli 16.1 to 16.2 on Windows
Command
build, serve
Is this a regression?
- [X] Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
16.1.8
Description
After updating Angular CLI to 16.2.0, our project using @angular/material does no longer build when using esbuild on Windows.
I found that this commit is at least partially causing this: https://github.com/angular/angular-cli/commit/61a652d91274f4adce20182e630fe9963b4ceddd
Note that it doesn't break on Linux.
Minimal Reproduction
Be on Windows, pull the following repo, install dependencies, and then ng serve / ng build.
https://github.com/wartab/angular-material-issue
(This is not caused by the space in the path name, I have tested it with another directory and the issue remains)
Exception or Error
> ng serve
The esbuild-based browser application builder ('browser-esbuild') is currently in developer preview and is not yet recommended for production use. For additional information, please see https://angular.io/guide/esbuild
The 'namedChunks' option is not used by this builder and will be ignored.
The 'vendorChunk' option is not used by this builder and will be ignored.
X [ERROR] Invalid URL: Scheme not starting with alphabetic character
╷
1 │ @use "__NG_PACKAGE__;C:/Users/Vincent\ Lycoops/test-project/src/styles;@angular/material" as mat;
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
╵
src\styles\material-custom.scss 1:6 @import
src\styles\styles.scss 1:9 root stylesheet [plugin angular-sass]
angular:styles/global:styles:1:8:
1 │ @import 'src/styles/styles.scss';
╵ ~~~~~~~~~~~~~~~~~~~~~~~~
➜ Local: http://localhost:4200/
Watch mode enabled. Watching for file changes...
Your Environment
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 16.2.0
Node: 18.16.0
Package Manager: npm 9.6.4
OS: win32 x64
Angular: 16.2.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, material, platform-browser, platform-browser-dynamic
... router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1602.0
@angular-devkit/build-angular 16.2.0
@angular-devkit/core 16.2.0
@angular-devkit/schematics 16.2.0
@schematics/angular 16.2.0
rxjs 7.8.1
typescript 5.1.6
zone.js 0.13.1
Anything else relevant?
We weren't able to reproduce this on Linux machines, only Windows seems affected.
same for me, filed a separate issue https://github.com/angular/angular-cli/issues/25662 at the same time as this, but using pnpm as package manager...
it's not the first time esbuild has broken something, i stopped counting
That's the nature of developer previews, I don't think it's very fair to complain about it. Having esbuild support already saved us countless of hours in project compilation.
Avoiding Angular updates when things are broken or not using esbuild until things are fixed is a good trade off imo.
or it's just bad programming depending on how you say it.
first you make bad software and then you brag about how you made a better one, only to realize after a while that you made a bad one again and brag again about how new technology X is better than technology Y.
there is no doubt that the new technology is better, but then why did you make a bad one before !?! because you are a bad programmer or because good programmers create bad technology !?! if good technology is good it should not be replaced
same problem
I tried to debug the issue somewhat and it seems like Sass thinks that __NG_PACKAGE__;C: is considered a scheme, such as http:. I wasn't able to find a workaround however. Removing the colon and even removing the drive name with the colon doesn't work.
Just noticed this PR, which does fix it: https://github.com/angular/angular-cli/pull/25666
It started happening even before the 16.2.0 version I just ran into this issue and tried with the angular-builder & cli at 16.1.8 and the issue already popped up there too. Looking at the release notes, it might have been present from 16.1.4 ? Though this is only a guess.
No, it's only a thing since 16.2
No, it's only a thing since 16.2
My bad, thought the cli and build-angular versions were coupled since the ng update @angular/cli command updated both.
hoping for an update today, https://github.com/angular/angular-cli/pull/25666 was merged almost 2 weeks ago, and hoping for a performance boost since I'm using pnpm on windows. Right now I'm using latest angular with 16.1.8 cli
16.2.1 fixed this! 16.2 was a huge performance boost compared to 16.1 when running pnpm and material with esbuild:-)
can confirm this works with 16.2.1 (after 3+ weeks)
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.