-
Notifications
You must be signed in to change notification settings - Fork 11.9k
fix(@angular/build): allow serving node_modules assets in monorepo setups #32939
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,7 +8,7 @@ | |||||||
|
|
||||||||
| import { readFile } from 'node:fs/promises'; | ||||||||
| import { join } from 'node:path'; | ||||||||
| import type { Connect, InlineConfig, SSROptions, ServerOptions } from 'vite'; | ||||||||
| import { type Connect, type InlineConfig, type SSROptions, type ServerOptions, searchForPackageRoot } from 'vite'; | ||||||||
| import type { ComponentStyleRecord } from '../../../tools/vite/middlewares'; | ||||||||
| import { | ||||||||
| ServerSsrMode, | ||||||||
|
|
@@ -75,9 +75,12 @@ async function createServerConfig( | |||||||
| // The first two are required for Vite to function in prebundling mode (the default) and to load | ||||||||
| // the Vite client-side code for browser reloading. These would be available by default but when | ||||||||
| // the `allow` option is explicitly configured, they must be included manually. | ||||||||
| // The package root search handles monorepo setups where node_modules may be hoisted | ||||||||
| // to a parent directory above the Angular workspace root. | ||||||||
| allow: [ | ||||||||
| cacheDir, | ||||||||
| join(serverOptions.workspaceRoot, 'node_modules'), | ||||||||
| searchForPackageRoot(serverOptions.workspaceRoot), | ||||||||
|
Comment on lines
82
to
+83
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The entry
Suggested change
|
||||||||
| ...[...assets.values()].map(({ source }) => source), | ||||||||
| ], | ||||||||
| }, | ||||||||
|
|
||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change introduces a top-level runtime import of
vite. The existing code in this file follows a pattern of using dynamic imports for Vite's runtime utilities (see line 152) to avoid eagerly loading thevitepackage when the module is first evaluated. To maintain this pattern,searchForPackageRootshould be imported dynamically where it is used, keeping this import as type-only.