forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@angular/build): show error when Node.js built-ins are used durin…
…g `ng serve` This commit ensures consistent behavior between `ng build` and `ng serve`. Previously, `ng serve` did not display an error message when Node.js built-in modules were included in browser bundles. By default, Vite replaces Node.js built-ins with empty modules, which can lead to unexpected runtime issues. This update addresses the problem by surfacing clear error messages, providing better developer feedback and alignment between the two commands. Closes: angular#27425
- Loading branch information
1 parent
1ca260e
commit 5ab7df8
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
tests/legacy-cli/e2e/tests/vite/browser-node-module-dep-error.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import assert from 'node:assert'; | ||
import { execAndWaitForOutputToMatch, ng } from '../../utils/process'; | ||
import { writeFile } from '../../utils/fs'; | ||
|
||
export default async function () { | ||
await ng('cache', 'clean'); | ||
await ng('cache', 'on'); | ||
|
||
await writeFile('src/main.ts', `import '@angular-devkit/core/node';`); | ||
|
||
const { stderr } = await execAndWaitForOutputToMatch('ng', ['serve'], /ERROR/, { | ||
CI: '0', | ||
NO_COLOR: 'true', | ||
}); | ||
|
||
assert.match( | ||
stderr, | ||
/The package "node:path" wasn't found on the file system but is built into node/, | ||
); | ||
} |