Skip to content

Commit 789a5c4

Browse files
clydinalan-agius4
authored andcommitted
refactor(@angular-devkit/build-angular): update Vite client code loading for v5
Vite v5 updated the client code's error dialog text. This requires that the text replacement code also be updated to remove unactionable information from the error dialog.
1 parent 153dfff commit 789a5c4

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

packages/angular_devkit/build_angular/src/tools/vite/angular-memory-plugin.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,16 +285,17 @@ export function createAngularMemoryPlugin(options: AngularMemoryPluginOptions):
285285
*/
286286
async function loadViteClientCode(file: string) {
287287
const originalContents = await readFile(file, 'utf-8');
288-
let contents = originalContents.replace('You can also disable this overlay by setting', '');
289-
contents = contents.replace(
288+
const firstUpdate = originalContents.replace('You can also disable this overlay by setting', '');
289+
assert(originalContents !== firstUpdate, 'Failed to update Vite client error overlay text. (1)');
290+
291+
const secondUpdate = firstUpdate.replace(
290292
// eslint-disable-next-line max-len
291-
'<code part="config-option-name">server.hmr.overlay</code> to <code part="config-option-value">false</code> in <code part="config-file-name">vite.config.js.</code>',
293+
'<code part="config-option-name">server.hmr.overlay</code> to <code part="config-option-value">false</code> in <code part="config-file-name">${hmrConfigName}.</code>',
292294
'',
293295
);
296+
assert(firstUpdate !== secondUpdate, 'Failed to update Vite client error overlay text. (2)');
294297

295-
assert(originalContents !== contents, 'Failed to update Vite client error overlay text.');
296-
297-
return contents;
298+
return secondUpdate;
298299
}
299300

300301
function pathnameWithoutBasePath(url: string, basePath: string): string {

0 commit comments

Comments
 (0)