Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Adds (opt-out) experiment to disable cleaning up containers after a functions deploy (#6861)
- Adds (opt-out) experiment to disable cleaning up containers after a functions deploy (#6861)
- Fix Next.js image optimization check in app directory for Windows (#6930)
13 changes: 10 additions & 3 deletions src/frameworks/next/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { existsSync } from "fs";
import { pathExists } from "fs-extra";
import { basename, extname, join, posix } from "path";
import { basename, extname, join, posix, sep } from "path";
import { readFile } from "fs/promises";
import { sync as globSync } from "glob";
import type { PagesManifest } from "next/dist/build/webpack/plugins/pages-manifest-plugin";
Expand Down Expand Up @@ -31,6 +31,7 @@ import {
WEBPACK_LAYERS,
} from "./constants";
import { dirExistsSync, fileExistsSync } from "../../fsutils";
import { IS_WINDOWS } from "../../utils";

export const I18N_SOURCE = /\/:nextInternalLocale(\([^\)]+\))?/;

Expand Down Expand Up @@ -247,15 +248,21 @@ export async function isUsingNextImageInAppDirectory(
projectDir: string,
nextDir: string,
): Promise<boolean> {
const nextImagePath = ["node_modules", "next", "dist", "client", "image"];
const nextImageString = IS_WINDOWS
? // Note: Windows requires double backslashes to match Next.js generated file
nextImagePath.join(sep + sep)
: join(...nextImagePath);

const files = globSync(
join(projectDir, nextDir, "server", "**", "*client-reference-manifest.js"),
);

for (const filepath of files) {
const fileContents = await readFile(filepath);
const fileContents = await readFile(filepath, "utf-8");

// Return true when the first file containing the next/image component is found
if (fileContents.includes("node_modules/next/dist/client/image")) {
if (fileContents.includes(nextImageString)) {
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { FirebaseError } from "./error";
import { logger, LogLevel } from "./logger";
import { LogDataOrUndefined } from "./emulator/loggingEmulator";

const IS_WINDOWS = process.platform === "win32";
export const IS_WINDOWS = process.platform === "win32";
const SUCCESS_CHAR = IS_WINDOWS ? "+" : "✔";
const WARNING_CHAR = IS_WINDOWS ? "!" : "⚠";
const ERROR_CHAR = IS_WINDOWS ? "!!" : "⬢";
Expand Down