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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,219 changes: 1,062 additions & 157 deletions npm-shrinkwrap.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@
"googleapis": "^105.0.0",
"mocha": "^11.7.1",
"mock-fs": "5.2.0",
"next": "^14.1.0",
"next": "15.5.24",
"nock": "^13.0.5",
"node-mocks-http": "^1.11.0",
"nyc": "^15.1.0",
Expand Down
39 changes: 20 additions & 19 deletions src/frameworks/next/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,49 +49,50 @@ const WEBPACK_LAYERS_NAMES = {
/**
* The browser client bundle layer for actions.
*/ actionBrowser: "action-browser",
/**
* The layer for the API routes.
*/ api: "api",
apiNode: "api-node",
apiEdge: "api-edge",
/**
* The layer for the middleware code.
*/ middleware: "middleware",
instrument: "instrument",
/**
* The layer for assets on the edge.
*/ edgeAsset: "edge-asset",
/**
* The browser client bundle layer for App directory.
*/ appPagesBrowser: "app-pages-browser",
/**
* The server bundle layer for metadata routes.
*/ appMetadataRoute: "app-metadata-route",
/**
* The layer for the server bundle for App Route handlers.
*/ appRouteHandler: "app-route-handler",
pagesDirBrowser: "pages-dir-browser",
pagesDirEdge: "pages-dir-edge",
pagesDirNode: "pages-dir-node",
} as const;

// This is copied from Next.js source code to keep WEBPACK_LAYERS in sync with the Next.js definition.
export const WEBPACK_LAYERS: typeof NEXTJS_WEBPACK_LAYERS = {
...WEBPACK_LAYERS_NAMES,
GROUP: {
server: [
builtinReact: [WEBPACK_LAYERS_NAMES.reactServerComponents, WEBPACK_LAYERS_NAMES.actionBrowser],
serverOnly: [
WEBPACK_LAYERS_NAMES.reactServerComponents,
WEBPACK_LAYERS_NAMES.actionBrowser,
WEBPACK_LAYERS_NAMES.appMetadataRoute,
WEBPACK_LAYERS_NAMES.appRouteHandler,
],
nonClientServerTarget: [
// plus middleware and pages api
WEBPACK_LAYERS_NAMES.instrument,
WEBPACK_LAYERS_NAMES.middleware,
WEBPACK_LAYERS_NAMES.api,
],
app: [
neutralTarget: [WEBPACK_LAYERS_NAMES.apiNode, WEBPACK_LAYERS_NAMES.apiEdge],
clientOnly: [WEBPACK_LAYERS_NAMES.serverSideRendering, WEBPACK_LAYERS_NAMES.appPagesBrowser],
bundled: [
WEBPACK_LAYERS_NAMES.reactServerComponents,
WEBPACK_LAYERS_NAMES.actionBrowser,
WEBPACK_LAYERS_NAMES.appMetadataRoute,
WEBPACK_LAYERS_NAMES.appRouteHandler,
WEBPACK_LAYERS_NAMES.serverSideRendering,
WEBPACK_LAYERS_NAMES.appPagesBrowser,
WEBPACK_LAYERS_NAMES.shared,
WEBPACK_LAYERS_NAMES.instrument,
WEBPACK_LAYERS_NAMES.middleware,
],
appPages: [
WEBPACK_LAYERS_NAMES.reactServerComponents,
WEBPACK_LAYERS_NAMES.serverSideRendering,
WEBPACK_LAYERS_NAMES.appPagesBrowser,
WEBPACK_LAYERS_NAMES.actionBrowser,
],
},
};
3 changes: 3 additions & 0 deletions src/frameworks/next/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@
const DEFAULT_NUMBER_OF_REASONS_TO_LIST = 5;

function getReactVersion(cwd: string): string | undefined {
return findDependency("react-dom", { cwd, omitDev: false })?.version;

Check warning on line 100 in src/frameworks/next/index.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unsafe member access .version on an `any` value

Check warning on line 100 in src/frameworks/next/index.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unsafe return of an `any` typed value
}

/**
* Returns whether this codebase is a Next.js backend.
*/
export async function discover(dir: string) {

Check warning on line 106 in src/frameworks/next/index.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Missing return type on function
if (!(await pathExists(join(dir, "package.json")))) return;
const version = getNextVersion(dir);
if (!(await whichNextConfigFile(dir)) && !version) return;
Expand Down Expand Up @@ -160,10 +160,10 @@

const nextBuild = new Promise((resolve, reject) => {
const buildProcess = spawn(cli, ["build"], { cwd: dir, env });
buildProcess.stdout?.on("data", (data) => logger.info(data.toString()));

Check warning on line 163 in src/frameworks/next/index.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unsafe call of an `any` typed value

Check warning on line 163 in src/frameworks/next/index.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unsafe member access .toString on an `any` value

Check warning on line 163 in src/frameworks/next/index.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unsafe argument of type `any` assigned to a parameter of type `Error`
buildProcess.stderr?.on("data", (data) => logger.info(data.toString()));

Check warning on line 164 in src/frameworks/next/index.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unsafe call of an `any` typed value

Check warning on line 164 in src/frameworks/next/index.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unsafe member access .toString on an `any` value

Check warning on line 164 in src/frameworks/next/index.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Unsafe argument of type `any` assigned to a parameter of type `Error`
buildProcess.on("error", (err) => {
reject(new FirebaseError(`Unable to build your Next.js app: ${err}`));

Check warning on line 166 in src/frameworks/next/index.ts

View workflow job for this annotation

GitHub Actions / lint (24)

Invalid type "Error" of template literal expression
});
buildProcess.on("exit", (code) => {
resolve(code);
Expand Down Expand Up @@ -513,9 +513,12 @@
{
srcRoute: null,
initialRevalidateSeconds: false,
initialExpireSeconds: undefined,
dataRoute: "",
experimentalPPR: false,
renderingMode: undefined,
prefetchDataRoute: "",
allowHeader: [],
},
];
}),
Expand Down
13 changes: 7 additions & 6 deletions src/frameworks/next/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { RouteHas } from "next/dist/lib/load-custom-routes";
import type { ImageConfigComplete } from "next/dist/shared/lib/image-config";
import type { MiddlewareManifest as MiddlewareManifestV2FromNext } from "next/dist/build/webpack/plugins/middleware-plugin";
import type { HostingHeaders } from "../../firebaseConfig";
import type { CONFIG_FILES } from "./constants";

Expand Down Expand Up @@ -83,17 +82,19 @@ export interface ExportMarker {
isNextImageImported: boolean;
}

export type MiddlewareManifest =
| MiddlewareManifestV1
| MiddlewareManifestV2FromNext
| MiddlewareManifestV3;
export type MiddlewareManifest = MiddlewareManifestV1 | MiddlewareManifestV2 | MiddlewareManifestV3;

/**
* Middleware manifest type used between Next.js 12.2.0 - 14.1.4
*
* @see https://github.com/vercel/next.js/blob/v14.1.4/packages/next/src/build/webpack/plugins/middleware-plugin.ts#L45-L50
*/
export type MiddlewareManifestV2 = MiddlewareManifestV2FromNext;
export type MiddlewareManifestV2 = {
version: 2;
sortedMiddleware: string[];
middleware: { [page: string]: Omit<EdgeFunctionDefinition, "env"> };
functions: { [page: string]: Omit<EdgeFunctionDefinition, "env"> };
};

/**
* Middleware manifest types used since Next.js 14.2.0
Expand Down
6 changes: 6 additions & 0 deletions src/frameworks/next/testing/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,23 @@ export const prerenderManifest: PrerenderManifest = {
routes: {
"/": {
initialRevalidateSeconds: false,
initialExpireSeconds: undefined,
srcRoute: "/",
dataRoute: "/index.rsc",
experimentalPPR: false,
renderingMode: undefined,
prefetchDataRoute: "",
allowHeader: [],
},
"/api/static": {
initialRevalidateSeconds: false,
initialExpireSeconds: undefined,
srcRoute: "/api/static",
dataRoute: "",
experimentalPPR: false,
renderingMode: undefined,
prefetchDataRoute: "",
allowHeader: [],
},
},
dynamicRoutes: {},
Expand Down
4 changes: 4 additions & 0 deletions src/frameworks/next/testing/images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ export const imagesManifest: ImagesManifest = {
disableStaticImages: false,
minimumCacheTTL: 60,
formats: ["image/avif", "image/webp"],
maximumDiskCacheSize: undefined,
maximumResponseBody: 50000000,
dangerouslyAllowSVG: false,
contentSecurityPolicy: "script-src 'none'; frame-src 'none'; sandbox;",
contentDispositionType: "inline",
localPatterns: undefined,
remotePatterns: [
{
protocol: "https",
Expand All @@ -37,6 +40,7 @@ export const imagesManifest: ImagesManifest = {
pathname: "^(?:\\/image\\/upload(?:\\/(?!\\.)(?:(?:(?!(?:^|\\/)\\.).)*?)|$))$",
},
],
qualities: undefined,
unoptimized: false,
sizes: [640, 750, 828, 1080, 1200, 1920, 2048, 3840, 16, 32, 48, 64, 96, 128, 256, 384],
},
Expand Down
2 changes: 1 addition & 1 deletion src/frameworks/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ ${prefix}${clc.bold("Submit a feature request:")} ${FEATURE_REQUEST_URL}
${prefix}We'd love to learn from you. Express your interest in helping us shape the future of Firebase Hosting: ${MAILING_LIST_URL}`;
}

export function validateLocales(locales: string[] | undefined = []) {
export function validateLocales(locales: readonly string[] | undefined = []) {
const invalidLocales = locales.filter(
(locale) => !VALID_LOCALE_FORMATS.some((format) => locale.match(format)),
);
Expand Down
Loading