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
75998eb
commit a26f6b6
Showing
2 changed files
with
38 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
19 changes: 19 additions & 0 deletions
19
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,19 @@ | ||
import assert from 'node:assert'; | ||
import { execAndWaitForOutputToMatch, ng } from '../../utils/process'; | ||
import { installPackage } from '../../utils/packages'; | ||
import { writeFile } from '../../utils/fs'; | ||
|
||
export default async function () { | ||
await ng('cache', 'clean'); | ||
await ng('cache', 'on'); | ||
|
||
await installPackage('express@4'); | ||
await writeFile('src/main.ts', `import 'express';`); | ||
|
||
const { stderr } = await execAndWaitForOutputToMatch('ng', ['serve', '--port=0'], /ERROR/, { | ||
CI: '0', | ||
NO_COLOR: 'true', | ||
}); | ||
|
||
assert.match(stderr, /The package "http" wasn't found on the file system but is built into node/); | ||
} |