mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-17 11:03:53 +08:00
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:
parent
e126bf9018
commit
28bdbeb62c
@ -69,26 +69,6 @@ export function getDepOptimizationConfig({
|
|||||||
thirdPartySourcemaps: boolean;
|
thirdPartySourcemaps: boolean;
|
||||||
}): DepOptimizationConfig {
|
}): DepOptimizationConfig {
|
||||||
const plugins: ViteEsBuildPlugin[] = [
|
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' : ''}${
|
name: `angular-vite-optimize-deps${ssr ? '-ssr' : ''}${
|
||||||
thirdPartySourcemaps ? '-vendor-sourcemap' : ''
|
thirdPartySourcemaps ? '-vendor-sourcemap' : ''
|
||||||
|
@ -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/,
|
|
||||||
);
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user