Skip to content

Commit

Permalink
Fix Angular SSR deployment on Windows
Browse files Browse the repository at this point in the history
fixes #6543
  • Loading branch information
sonallux committed Nov 28, 2023
1 parent dbedf74 commit 5379d78
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/frameworks/angular/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join, posix } from "path";
import { join, posix, sep } from "path";
import { execSync } from "child_process";
import { spawn, sync as spawnSync } from "cross-spawn";
import { copy, pathExists } from "fs-extra";
Expand Down Expand Up @@ -212,6 +212,7 @@ export async function ɵcodegenFunctionsDirectory(

let bootstrapScript: string;
if (browserLocales) {
const serverOutputPosixPath = serverOutputPath.split(sep).join(posix.sep);
const locales = serverLocales?.filter((it) => browserLocales.includes(it));
bootstrapScript = `const localizedApps = new Map();
const ffi18n = import("firebase-frameworks/i18n");
Expand All @@ -227,8 +228,8 @@ exports.handle = function(req,res) {
} else {
${
serverEntry?.endsWith(".mjs")
? `import(\`./${serverOutputPath}/\${locale}/${serverEntry}\`)`
: `Promise.resolve(require(\`./${serverOutputPath}/\${locale}/${serverEntry}\`))`
? `import(\`./${serverOutputPosixPath}/\${locale}/${serverEntry}\`)`
: `Promise.resolve(require(\`./${serverOutputPosixPath}/\${locale}/${serverEntry}\`))`
}.then(server => {
const app = server.app(locale);
localizedApps.set(locale, app);
Expand All @@ -238,10 +239,11 @@ exports.handle = function(req,res) {
});
};\n`;
} else if (serverOutputPath) {
const serverOutputPosixPath = serverOutputPath.split(sep).join(posix.sep);
bootstrapScript = `const app = ${
serverEntry?.endsWith(".mjs")
? `import(\`./${serverOutputPath}/${serverEntry}\`)`
: `Promise.resolve(require('./${serverOutputPath}/${serverEntry}'))`
? `import(\`./${serverOutputPosixPath}/${serverEntry}\`)`
: `Promise.resolve(require('./${serverOutputPosixPath}/${serverEntry}'))`
}.then(server => server.app());
exports.handle = (req,res) => app.then(it => it(req,res));\n`;
} else {
Expand Down

0 comments on commit 5379d78

Please sign in to comment.