Skip to content

Conversation

alan-agius4
Copy link
Collaborator

The commit introduces dependencies prebundling and optimisation for SSR dependencies. This is primarily needed for Angular linking and async/await downlevelling. To enable this, we need to use the undocumented optimizeDeps setting under the ssr option. This is because, the top level optimizeDeps vite config option only controls browser dependencies.

For the above mentioned option to take effect and transform node packages, we also need to use noExternal and use a catch all RegExp. Note: setting this option to true has a different effect from a catch all RegExp, as the former will cause the external option to be ignored.

Additionally together with externalMetadata.explicit we add Node.js build-ins as external.

Closes: #26192

@alan-agius4 alan-agius4 added target: rc This PR is targeted for the next release-candidate action: review The PR is still awaiting reviews from at least one requested reviewer labels Nov 2, 2023
@alan-agius4 alan-agius4 requested a review from clydin November 2, 2023 12:57
@alan-agius4 alan-agius4 force-pushed the pre-bundle-ssr-dep-vite branch from 69421d7 to 0aa9d9b Compare November 2, 2023 12:58
@alan-agius4 alan-agius4 changed the title fix(@angular-devkit/build-angular): prebunde dependencies for SSR when using Vite fix(@angular-devkit/build-angular): prebundle dependencies for SSR when using Vite Nov 2, 2023
…en using Vite

The commit introduces dependencies prebundling and optimisation for SSR dependencies. This is primarily needed for Angular linking and async/await downlevelling. To enable this, we need to use the undocumented `optimizeDeps` setting under the `ssr` option. This is because, the top level `optimizeDeps` vite config option  only controls browser dependencies.

For the above mentioned option to take effect and transform node packages, we also need to use `noExternal` and use a catch all `RegExp`. Note: setting this option to `true` has a different effect from a catch all `RegExp`, as the former will cause the `external` option to be ignored.

Additionally together with `externalMetadata.explicit` we add Node.js build-ins as `external`.

Closes: angular#26192
@alan-agius4 alan-agius4 force-pushed the pre-bundle-ssr-dep-vite branch from 0aa9d9b to a28fa09 Compare November 2, 2023 14:39
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Nov 2, 2023
@alan-agius4 alan-agius4 merged commit 4c1265a into angular:main Nov 2, 2023
@alan-agius4 alan-agius4 deleted the pre-bundle-ssr-dep-vite branch November 2, 2023 15:03
@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 Dec 3, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker target: rc This PR is targeted for the next release-candidate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vite dev server crashes when server return 502
2 participants