From 3344b6fc7eee4d507f8cd6b27254d834d9d4c62d Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Mon, 9 Dec 2024 10:30:30 +0000 Subject: [PATCH] revert: fix(@angular/build): show error when Node.js built-ins are used during ng serve This commit reverts 06f478bc18d3e0daa8902d0fef94e55a5d052348 Closes: #29077 --- .../angular/build/src/tools/vite/utils.ts | 20 -------------- .../vite/browser-node-module-dep-error.ts | 26 ------------------- 2 files changed, 46 deletions(-) delete mode 100644 tests/legacy-cli/e2e/tests/vite/browser-node-module-dep-error.ts diff --git a/packages/angular/build/src/tools/vite/utils.ts b/packages/angular/build/src/tools/vite/utils.ts index 7aa37482bf81..83085d910f60 100644 --- a/packages/angular/build/src/tools/vite/utils.ts +++ b/packages/angular/build/src/tools/vite/utils.ts @@ -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' : '' diff --git a/tests/legacy-cli/e2e/tests/vite/browser-node-module-dep-error.ts b/tests/legacy-cli/e2e/tests/vite/browser-node-module-dep-error.ts deleted file mode 100644 index 7d2f45198c7c..000000000000 --- a/tests/legacy-cli/e2e/tests/vite/browser-node-module-dep-error.ts +++ /dev/null @@ -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.+node:path/, { - CI: '0', - NO_COLOR: 'true', - }); - - assert.match( - stderr, - /The package "node:path" wasn't found on the file system but is built into node/, - ); -}