Skip to content

Vite Pre-transform error #26897

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

Closed
1 task done
Enngage opened this issue Jan 18, 2024 · 7 comments · Fixed by #26913
Closed
1 task done

Vite Pre-transform error #26897

Enngage opened this issue Jan 18, 2024 · 7 comments · Fixed by #26913

Comments

@Enngage
Copy link

Enngage commented Jan 18, 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

17.0.9

Description

Hey,

We've just upgraded from 17.0.9 to 17.1.0 and when running ng server we are getting these logs in console on each request -

9:08:17 AM [vite] Pre-transform error: Failed to load url /pdf/diet/polyfills.js (resolved id: /pdf/diet/polyfills.js). Does the file exist?
9:08:17 AM [vite] Pre-transform error: Failed to load url /pdf/diet/main.js (resolved id: /pdf/diet/main.js). Does the file exist?
9:06:33 AM [vite] Pre-transform error: Failed to load url /auth/trainer/dashboard/polyfills.js (resolved id: /auth/trainer/dashboard/polyfills.js). Does the file exist?
9:06:33 AM [vite] Pre-transform error: Failed to load url /auth/trainer/dashboard/main.js (resolved id: /auth/trainer/dashboard/main.js). Does the file exist?

As you can see the path changes based on the URL of request.

It doesn't seem to have any effect on functionality from our testing as it seems to work just fine, but why are we getting these logs? Can someone help as determine as to what might be the cause of this?

Minimal Reproduction

Exception or Error

No response

Your Environment

Angular CLI: 17.1.0
Node: 18.18.2
Package Manager: npm 9.8.1
OS: win32 x64

Angular: 17.1.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, localize, platform-browser, platform-browser-dynamic
... platform-server, router, 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
@schematics/angular             17.1.0
rxjs                            7.8.1
typescript                      5.3.3
zone.js                         0.14.3

Anything else relevant?

No response

@alan-agius4
Copy link
Collaborator

This seems like a bug but we'll need to look at a reproduction to find and fix the problem. Can you setup a minimal repro please?

You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

This might be related to your directory structure so its really important to get an accurate repro to diagnose this.

@alan-agius4 alan-agius4 added the needs: repro steps We cannot reproduce the issue with the information given label Jan 18, 2024
@fabian-laine
Copy link

I have the same problem on 3 different projects after update

@tirtza-weinfeld
Copy link

As a workaround
to prevent Vite load errors

angular.json
"build": {
"builder": "@angular-devkit/build-angular:application",
"options": {
"externalDependencies":[""],

This simply set the preTransformRequests option to false

@telmaco
Copy link

telmaco commented Jan 19, 2024

same issue here , just did the update 😥

@BeSaRa
Copy link

BeSaRa commented Jan 20, 2024

I have the same issue on 5 different projects after update

@armingdev
Copy link

armingdev commented Jan 20, 2024

Here is some info about this issue:

I'm using the latest MacOS 14.2.1

Node version:

node -v
v20.11.0

NG version:

Angular CLI: 17.1.0
Node: 20.11.0
Package Manager: npm 10.2.4
OS: darwin arm64

Angular: 17.1.0
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router, 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
@schematics/angular             17.1.0
rxjs                            7.8.1
typescript                      5.3.3
zone.js                         0.14.3

Here is a repo to reproduce:
github.com/armingdev/angular-bug

command to run:

ng serve

When I hit route in my Angular 17.1.0 with SSR: http://localhost:4200/users/1

I got the error in the console:

ng serve

Initial Chunk Files | Names         |  Raw Size
polyfills.js        | polyfills     |  83.46 kB |
main.js             | main          |  22.24 kB |
styles.css          | styles        |  96 bytes |

                    | Initial Total | 105.79 kB

Lazy Chunk Files    | Names         |  Raw Size
chunk-JXFM6VDR.js   | users-routes  |   1.33 kB |

Application bundle generation complete. [2.409 seconds]
Watch mode enabled. Watching for file changes...
  ➜  Local:   http://localhost:4200/
  ➜  press h + enter to show help
8:43:20 PM [vite] Pre-transform error: Failed to load url /users/polyfills.js (resolved id: /users/polyfills.js). Does the file exist?
8:43:20 PM [vite] Pre-transform error: Failed to load url /users/main.js (resolved id: /users/main.js). Does the file exist?
id 1

I hope this helps you.

@alan-agius4 alan-agius4 self-assigned this Jan 22, 2024
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Jan 22, 2024
…te with SSR

This commit fixes a regression which causes a pre-transform error when using vite with ssr. The `request.url` is now passed to the index transformer instead of `request.originalUrl`. This is because the `request.url` will have a value of the `index.html`.

Closes angular#26897
alan-agius4 added a commit to alan-agius4/angular-cli that referenced this issue Jan 22, 2024
…te with SSR

This commit fixes a regression which causes a pre-transform error when using vite with ssr. The `request.url` is now passed to the index transformer instead of `request.originalUrl`. This is because the `request.url` will have a value of the `index.html`.

Closes angular#26897
alan-agius4 added a commit that referenced this issue Jan 22, 2024
…te with SSR

This commit fixes a regression which causes a pre-transform error when using vite with ssr. The `request.url` is now passed to the index transformer instead of `request.originalUrl`. This is because the `request.url` will have a value of the `index.html`.

Closes #26897
alan-agius4 added a commit that referenced this issue Jan 22, 2024
…te with SSR

This commit fixes a regression which causes a pre-transform error when using vite with ssr. The `request.url` is now passed to the index transformer instead of `request.originalUrl`. This is because the `request.url` will have a value of the `index.html`.

Closes #26897

(cherry picked from commit 0b0df5a)
@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 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.