Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESBuild suddenly displays blank page in development mode [17.1.0] #26902

Closed
1 task
spock123 opened this issue Jan 19, 2024 · 11 comments
Closed
1 task

ESBuild suddenly displays blank page in development mode [17.1.0] #26902

spock123 opened this issue Jan 19, 2024 · 11 comments

Comments

@spock123
Copy link

spock123 commented Jan 19, 2024

Command

serve

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

Since yesterday, suddenly all our 4 clients started to only display a blank page when run in development mode. No errors anywhere.

Building and deployment works fine.

When changing the builder back to "browser" everything works again.

I have tried to create a minimal version by stripping away all code, but still maintain the issue, as least in our end.

Minimal Reproduction

git clone https://github.com/spock123/esbuild-blankspace.git

npm install 

npm run dev

Stop serving, change angular-json:

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

to:

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

npm run dev

Exception or Error

When loading the page, a blank screen is displayed.
Initial index.html is loaded but application not bootstrapped or loaded.

Your Environment

Angular CLI: 17.1.0
Node: 20.10.0
Package Manager: npm 10.2.3
OS: darwin arm64

Angular: 17.1.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, localize, material, platform-browser
... platform-browser-dynamic, router, service-worker, ssr

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1701.0
@angular-devkit/build-angular   17.1.0
@angular-devkit/core            17.1.0
@angular-devkit/schematics      17.1.0
@angular/fire                   17.0.1
@schematics/angular             17.1.0
rxjs                            7.8.1
typescript                      5.2.2
zone.js                         0.14.0

Anything else relevant?

It apparently stopped working since yesterday, where all our clients were functioning without issue.
Multiple developers experience same issue, so it's probably not a local environment issue.
We have reverted to use the old browser builder and it works fine there, - frustratingly.

Appreciate any help

@spock123 spock123 changed the title ESBuild suddenly display blank page in development mode ESBuild suddenly displays blank page in development mode Jan 19, 2024
@spock123
Copy link
Author

Update: I downgraded to 17.0.9 and now it works again!

In the linked github project, this is the branch called "downgrade"

@spock123 spock123 changed the title ESBuild suddenly displays blank page in development mode ESBuild suddenly displays blank page in development mode [17.1.0] Jan 20, 2024
@alan-agius4
Copy link
Collaborator

What is happening here is that the baseHref is set to /en which vite normalizes to /en/ which causes the files to only be accessible from /en/.

This can be seen in the response The server is configured with a public base URL of /en - did you mean to visit [/en/polyfills.js](http://localhost:4100/en/polyfills.js) instead?

What are your intentions of having a base-href of /en instead of /en/? From our end, we could probably ignore setting the public base to base href when it does not terminate with a slash.

@spock123
Copy link
Author

Thanks @alan-agius4 .
This must have be changed between 10.0.9 and 10.1.0, as it worked up to this point? Change in Vite perhaps?
The idea with the base-href is that we serve multiple languages for our app (the repo is a very stripped down version with just one language). I'll definitely investigate and update status, thanks!

@spock123
Copy link
Author

spock123 commented Jan 22, 2024

@alan-agius4 it works! Amazing, thank you so much!

You're welcome to close the issue, apparently it allows for the missing slash in 17.0.9, and not in 17.1.0.

Cheers, and thank you

@spock123
Copy link
Author

Found this old PR in Vite, where they allowed missing trailing slashes:

vitejs/vite#10723

@spock123
Copy link
Author

spock123 commented Jan 22, 2024

@alan-agius4 before you close it, I noticed that now that I changed the baseHref to include a trailing slash, references to assets like this: /assets/test.gif do not work in development mode, as the link does not get the baseHref added.

Anything we can do about this? It would be pretty unfortunate if global references to assets stopped working.

If I remove the trailing slash again, links to /assets work again - but of course then the compiler complains once it's time to do a production build.

Update: I did some digging and that's apparently by design. baseHref is only prepended to relative urls, not global urls.

@alan-agius4
Copy link
Collaborator

@spock123, that is indeed working as expected. I am not quick sure what setup / structure are you going for but from the gist of it it looks like you'd want to set a base-href of /.

@spock123
Copy link
Author

spock123 commented Jan 23, 2024

@alan-agius4 yes thanks. I think I will do that in development mode. thank you.
Unfortunately I don't think it's possible to set/override baseHref with a parameter to the cli, which makes it a bit more tricky.
It means that we cannot use targets in our configuration, as they all have the correct baseHref.

We could of course replicate the cli configuration targets but it is already quite large due to the amounts of locales (we have 12!)

It used to be an option for the cli, to set the base href when using ng serve, but that was taken away long time ago.

We'll solve it somehow, thanks for your time

@alan-agius4
Copy link
Collaborator

Closing as the issue seems to have been resolved.

@alan-agius4 alan-agius4 closed this as not planned Won't fix, can't repro, duplicate, stale Jan 25, 2024
@spock123
Copy link
Author

@alan-agius4 It has indeed. Thanks

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants