|
| 1 | +import assert from 'node:assert'; |
| 2 | +import { findFreePort } from '../../utils/network'; |
| 3 | +import { execAndWaitForOutputToMatch, killAllProcesses, ng } from '../../utils/process'; |
| 4 | +import { getGlobalVariable } from '../../utils/env'; |
| 5 | + |
| 6 | +export default async function () { |
| 7 | + const useWebpackBuilder = !getGlobalVariable('argv')['esbuild']; |
| 8 | + if (useWebpackBuilder) { |
| 9 | + return; |
| 10 | + } |
| 11 | + |
| 12 | + await ng('cache', 'clean'); |
| 13 | + await ng('cache', 'on'); |
| 14 | + |
| 15 | + try { |
| 16 | + const port = await findFreePort(); |
| 17 | + |
| 18 | + // Make sure serve is consistent with build |
| 19 | + await execAndWaitForOutputToMatch( |
| 20 | + 'ng', |
| 21 | + ['serve', '--port', `${port}`], |
| 22 | + /vite:deps Dependencies bundled/, |
| 23 | + // Use CI:0 to force caching |
| 24 | + { DEBUG: 'vite:deps', CI: '0' }, |
| 25 | + ); |
| 26 | + |
| 27 | + // Make request so that vite writes the cache. |
| 28 | + const response = await fetch(`http://localhost:${port}/@vite/client`); |
| 29 | + assert(response.ok, `Expected 'response.ok' to be 'true'.`); |
| 30 | + |
| 31 | + // Terminate the dev-server |
| 32 | + await killAllProcesses(); |
| 33 | + |
| 34 | + // The Node.js specific module should not be found |
| 35 | + await execAndWaitForOutputToMatch( |
| 36 | + 'ng', |
| 37 | + ['serve', '--port=0'], |
| 38 | + /vite:deps Hash is consistent\. Skipping/, |
| 39 | + // Use CI:0 to force caching |
| 40 | + { DEBUG: 'vite:deps', CI: '0' }, |
| 41 | + ); |
| 42 | + } finally { |
| 43 | + await killAllProcesses(); |
| 44 | + } |
| 45 | +} |
0 commit comments