Skip to content

Commit c1383d1

Browse files
committed
fix(@nguniversal/builders): correctly handle path normalizations on Windows
Closes angular#2706
1 parent c5b6b34 commit c1383d1

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

modules/builders/src/prerender/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
import { BrowserBuilderOptions } from '@angular-devkit/build-angular';
1616
import { normalizeOptimization } from '@angular-devkit/build-angular/src/utils/normalize-optimization';
1717
import { augmentAppWithServiceWorker } from '@angular-devkit/build-angular/src/utils/service-worker';
18-
import { normalize, resolve as resolvePath } from '@angular-devkit/core';
1918
import * as fs from 'fs';
2019
import ora from 'ora';
2120
import * as path from 'path';
@@ -92,9 +91,11 @@ async function _renderUniversal(
9291
throw new Error('The builder requires a target.');
9392
}
9493

95-
const root = normalize(context.workspaceRoot);
9694
const projectMetadata = await context.getProjectMetadata(projectName);
97-
const projectRoot = resolvePath(root, normalize((projectMetadata.root as string) || ''));
95+
const projectRoot = path.join(
96+
context.workspaceRoot,
97+
(projectMetadata.root as string | undefined) ?? '',
98+
);
9899

99100
// Users can specify a different base html file e.g. "src/home.html"
100101
const indexFile = getIndexOutputFile(browserOptions);
@@ -160,7 +161,7 @@ async function _renderUniversal(
160161
await augmentAppWithServiceWorker(
161162
projectRoot,
162163
context.workspaceRoot,
163-
normalize(outputPath),
164+
outputPath,
164165
browserOptions.baseHref || '/',
165166
browserOptions.ngswConfigPath,
166167
);

modules/builders/src/static-generator/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
import { BrowserBuilderOptions, BrowserBuilderOutput } from '@angular-devkit/build-angular';
1616
import { normalizeOptimization } from '@angular-devkit/build-angular/src/utils/normalize-optimization';
1717
import { augmentAppWithServiceWorker } from '@angular-devkit/build-angular/src/utils/service-worker';
18-
import { normalize, resolve } from '@angular-devkit/core';
1918
import express from 'express';
2019
import * as http from 'http';
2120
import ora from 'ora';
@@ -145,14 +144,16 @@ async function generateServiceWorker(
145144
throw new Error('The builder requires a target.');
146145
}
147146

148-
const root = normalize(context.workspaceRoot);
149147
const projectMetadata = await context.getProjectMetadata(projectName);
150-
const projectRoot = resolve(root, normalize((projectMetadata.root as string) ?? ''));
148+
const projectRoot = path.join(
149+
context.workspaceRoot,
150+
(projectMetadata.root as string | undefined) ?? '',
151+
);
151152

152153
await augmentAppWithServiceWorker(
153154
projectRoot,
154155
context.workspaceRoot,
155-
normalize(outputPath),
156+
outputPath,
156157
browserOptions.baseHref || '/',
157158
browserOptions.ngswConfigPath,
158159
);

0 commit comments

Comments
 (0)