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
f717a54
commit 06f478b
Showing
3 changed files
with
59 additions
and
21 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
26 changes: 26 additions & 0 deletions
26
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,26 @@ | ||
import assert from 'node:assert'; | ||
import { execAndWaitForOutputToMatch, ng } from '../../utils/process'; | ||
import { writeFile } from '../../utils/fs'; | ||
import { getGlobalVariable } from '../../utils/env'; | ||
|
||
export default async function () { | ||
assert( | ||
getGlobalVariable('argv')['esbuild'], | ||
'This test should not be called in the Webpack suite.', | ||
); | ||
|
||
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/, | ||
); | ||
} |
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