revert: fix(@angular/build): show error when Node.js built-ins are used during ng serve

This commit reverts 06f478bc18d3e0daa8902d0fef94e55a5d052348

Closes: #29077
This commit is contained in:
Alan Agius 2024-12-09 10:27:53 +00:00 committed by Alan Agius
parent e126bf9018
commit 28bdbeb62c
2 changed files with 0 additions and 46 deletions

View File

@ -69,26 +69,6 @@ export function getDepOptimizationConfig({
thirdPartySourcemaps: boolean;
}): DepOptimizationConfig {
const plugins: ViteEsBuildPlugin[] = [
{
name: 'angular-browser-node-built-in',
setup(build) {
// This namespace is configured by vite.
// @see: https://github.com/vitejs/vite/blob/a1dd396da856401a12c921d0cd2c4e97cb63f1b5/packages/vite/src/node/optimizer/esbuildDepPlugin.ts#L109
build.onLoad({ filter: /.*/, namespace: 'browser-external' }, (args) => {
if (!isBuiltin(args.path)) {
return;
}
return {
errors: [
{
text: `The package "${args.path}" wasn't found on the file system but is built into node.`,
},
],
};
});
},
},
{
name: `angular-vite-optimize-deps${ssr ? '-ssr' : ''}${
thirdPartySourcemaps ? '-vendor-sourcemap' : ''

View File

@ -1,26 +0,0 @@
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/,
);
}