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 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = {
],

"@typescript-eslint/unbound-method": "error",
"@typescript-eslint/consistent-type-imports": "error",
},
overrides: [
{
Expand Down
2 changes: 1 addition & 1 deletion example/sst.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SSTConfig } from "sst";
import type { SSTConfig } from "sst";
import { Config, NextjsSite } from "sst/constructs";

export default {
Expand Down
2 changes: 1 addition & 1 deletion examples/app-pages-router/app/albums/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from "react";
import type { ReactNode } from "react";

export default function Layout({
children,
Expand Down
4 changes: 3 additions & 1 deletion examples/app-pages-router/app/parallel/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use client";
import { ReactNode, useState } from "react";
import { useState } from "react";

import type { ReactNode } from "react";

export default function Layout({
a,
Expand Down
2 changes: 1 addition & 1 deletion examples/app-pages-router/app/ssr/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PropsWithChildren } from "react";
import type { PropsWithChildren } from "react";

export default function Layout({ children }: PropsWithChildren) {
return (
Expand Down
3 changes: 2 additions & 1 deletion examples/app-pages-router/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NextRequest, NextResponse } from "next/server";
import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";

export function middleware(request: NextRequest) {
const path = request.nextUrl.pathname; //new URL(request.url).pathname;
Expand Down
2 changes: 1 addition & 1 deletion examples/app-pages-router/pages/pages_isr/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InferGetStaticPropsType } from "next";
import type { InferGetStaticPropsType } from "next";

export async function getStaticProps() {
return {
Expand Down
2 changes: 1 addition & 1 deletion examples/app-pages-router/pages/pages_ssr/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InferGetServerSidePropsType } from "next";
import type { InferGetServerSidePropsType } from "next";

export async function getServerSideProps() {
return {
Expand Down
2 changes: 1 addition & 1 deletion examples/app-router/app/albums/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from "react";
import type { ReactNode } from "react";

export default function Layout({
children,
Expand Down
3 changes: 2 additions & 1 deletion examples/app-router/app/api/isr/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import fs from "fs/promises";
import { NextRequest, NextResponse } from "next/server";
import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";
import path from "path";

export const dynamic = "force-dynamic";
Expand Down
2 changes: 1 addition & 1 deletion examples/app-router/app/api/sse/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { wait } from "@open-next/utils";
import { NextRequest } from "next/server";
import type { NextRequest } from "next/server";

export const dynamic = "force-dynamic";

Expand Down
4 changes: 3 additions & 1 deletion examples/app-router/app/parallel/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use client";
import { ReactNode, useState } from "react";
import { useState } from "react";

import type { ReactNode } from "react";

export default function Layout({
a,
Expand Down
2 changes: 1 addition & 1 deletion examples/app-router/app/ssr/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PropsWithChildren } from "react";
import type { PropsWithChildren } from "react";

export default function Layout({ children }: PropsWithChildren) {
return (
Expand Down
3 changes: 2 additions & 1 deletion examples/app-router/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NextRequest, NextResponse } from "next/server";
import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";

export function middleware(request: NextRequest) {
const path = request.nextUrl.pathname; //new URL(request.url).pathname;
Expand Down
3 changes: 2 additions & 1 deletion examples/pages-router/src/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NextRequest, NextResponse } from "next/server";
import type { NextRequest } from "next/server";
import { NextResponse } from "next/server";

export function middleware(request: NextRequest) {
return NextResponse.next({
Expand Down
2 changes: 1 addition & 1 deletion examples/pages-router/src/pages/isr/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InferGetStaticPropsType } from "next";
import type { InferGetStaticPropsType } from "next";
import Link from "next/link";

export async function getStaticProps() {
Expand Down
2 changes: 1 addition & 1 deletion examples/pages-router/src/pages/ssr/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InferGetServerSidePropsType } from "next";
import type { InferGetServerSidePropsType } from "next";

export async function getServerSideProps() {
return {
Expand Down
3 changes: 2 additions & 1 deletion examples/shared/components/Modal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"use client";
import { MouseEventHandler, useCallback, useEffect, useRef } from "react";
import { useCallback, useEffect, useRef } from "react";

import { useRouter } from "next/navigation";
import type { MouseEventHandler } from "react";

export default function Modal({ children }: { children: React.ReactNode }) {
const overlay = useRef(null);
Expand Down
3 changes: 1 addition & 2 deletions examples/shared/components/Nav/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"use client";
import { PropsWithChildren } from "react";

import Link from "next/link";
import type { PropsWithChildren } from "react";

type Props = PropsWithChildren & {
href: string;
Expand Down
2 changes: 1 addition & 1 deletion examples/sst/sst.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SSTConfig } from "sst";
import type { SSTConfig } from "sst";

import { AppPagesRouter } from "./stacks/AppPagesRouter";
import { AppRouter } from "./stacks/AppRouter";
Expand Down
6 changes: 3 additions & 3 deletions examples/sst/stacks/OpenNextReferenceImplementation.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { execSync } from "node:child_process";

import type { BehaviorOptions, ICachePolicy } from "aws-cdk-lib/aws-cloudfront";
import {
AllowedMethods,
BehaviorOptions,
CacheCookieBehavior,
CachedMethods,
CacheHeaderBehavior,
Expand All @@ -12,7 +12,6 @@ import {
Function as CloudfrontFunction,
FunctionCode,
FunctionEventType,
ICachePolicy,
OriginRequestPolicy,
ViewerProtocolPolicy,
} from "aws-cdk-lib/aws-cloudfront";
Expand All @@ -22,7 +21,8 @@ import {
Billing,
TableV2 as Table,
} from "aws-cdk-lib/aws-dynamodb";
import { IGrantable, Policy, PolicyStatement } from "aws-cdk-lib/aws-iam";
import type { IGrantable } from "aws-cdk-lib/aws-iam";
import { Policy, PolicyStatement } from "aws-cdk-lib/aws-iam";
import {
Architecture,
Code,
Expand Down
2 changes: 1 addition & 1 deletion packages/open-next/src/adapters/cache.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IncrementalCache } from "../overrides/incrementalCache/types.js";
import { TagCache } from "../overrides/tagCache/types.js";
import type { TagCache } from "../overrides/tagCache/types.js";
import { isBinaryContentType } from "./binary.js";
import { debug, error, warn } from "./logger.js";

Expand Down
4 changes: 2 additions & 2 deletions packages/open-next/src/adapters/config/util.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import fs from "fs";
import path from "path";
import {
import type {
MiddlewareManifest,
NextConfig,
PrerenderManifest,
RoutesManifest,
} from "types/next-types";

import { PublicFiles } from "../../build";
import type { PublicFiles } from "../../build";

export function loadConfig(nextDir: string) {
const filePath = path.join(nextDir, "required-server-files.json");
Expand Down
9 changes: 5 additions & 4 deletions packages/open-next/src/adapters/image-optimization-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { createHash } from "node:crypto";
import {
import type {
IncomingMessage,
OutgoingHttpHeaders,
ServerResponse,
} from "node:http";
import https from "node:https";
import path from "node:path";
import { Writable } from "node:stream";
import type { Writable } from "node:stream";

import { loadBuildId, loadConfig } from "config/util.js";
import { OpenNextNodeResponse, StreamCreator } from "http/openNextResponse.js";
import type { StreamCreator } from "http/openNextResponse.js";
import { OpenNextNodeResponse } from "http/openNextResponse.js";
// @ts-ignore
import { defaultConfig } from "next/dist/server/config-shared";
import {
Expand All @@ -18,7 +19,7 @@ import {
} from "next/dist/server/image-optimizer";
// @ts-ignore
import type { NextUrlWithParsedQuery } from "next/dist/server/request-meta";
import { InternalEvent, InternalResult } from "types/open-next.js";
import type { InternalEvent, InternalResult } from "types/open-next.js";
import { emptyReadableStream, toReadableStream } from "utils/stream.js";

import { createGenericHandler } from "../core/createGenericHandler.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/open-next/src/adapters/logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BaseOpenNextError } from "utils/error";
import type { BaseOpenNextError } from "utils/error";

declare global {
var openNextDebug: boolean;
Expand Down
2 changes: 1 addition & 1 deletion packages/open-next/src/adapters/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InternalEvent, Origin } from "types/open-next";
import type { InternalEvent, Origin } from "types/open-next";

import { debug } from "../adapters/logger";
import { createGenericHandler } from "../core/createGenericHandler";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { IncomingMessage, ServerResponse } from "node:http";
import type { IncomingMessage, ServerResponse } from "node:http";

import { APIGatewayProxyEventHeaders } from "aws-lambda";
import { NextConfig } from "next/dist/server/config-shared";
import type { APIGatewayProxyEventHeaders } from "aws-lambda";
import type { NextConfig } from "next/dist/server/config-shared";
//#override imports
import { imageOptimizer } from "next/dist/server/image-optimizer";
//#endOverride
import { NextUrlWithParsedQuery } from "next/dist/server/request-meta";
import type { NextUrlWithParsedQuery } from "next/dist/server/request-meta";

import { debug } from "../../logger.js";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable unused-imports/no-unused-vars */
import { InternalEvent } from "types/open-next";
import type { InternalEvent } from "types/open-next";

import { MiddlewareOutputEvent } from "../../../core/routingHandler";
import type { MiddlewareOutputEvent } from "../../../core/routingHandler";
// This is available in requestHandler.ts
declare const internalEvent: InternalEvent;

Expand Down
2 changes: 1 addition & 1 deletion packages/open-next/src/build/buildNextApp.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cp from "node:child_process";
import path from "node:path";

import * as buildHelper from "./helper.js";
import type * as buildHelper from "./helper.js";

export function setStandaloneBuildMode(options: buildHelper.BuildOptions) {
// Equivalent to setting `output: "standalone"` in next.config.js
Expand Down
2 changes: 1 addition & 1 deletion packages/open-next/src/build/compileConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import os from "node:os";
import path from "node:path";

import { buildSync } from "esbuild";
import { OpenNextConfig } from "types/open-next.js";
import type { OpenNextConfig } from "types/open-next.js";

import logger from "../logger.js";
import { validateConfig } from "./validateConfig.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/open-next/src/build/copyTracedFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
writeFileSync,
} from "fs";
import path from "path";
import { NextConfig, PrerenderManifest } from "types/next-types";
import type { NextConfig, PrerenderManifest } from "types/next-types";

import logger from "../logger.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/open-next/src/build/createServerBundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from "node:fs";
import { createRequire } from "node:module";
import path from "node:path";

import {
import type {
FunctionOptions,
OpenNextConfig,
SplittedFunctionOptions,
Expand Down
7 changes: 4 additions & 3 deletions packages/open-next/src/build/edge/createEdgeBundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { mkdirSync } from "node:fs";
import { build } from "esbuild";
import fs from "fs";
import path from "path";
import { MiddlewareInfo, MiddlewareManifest } from "types/next-types";
import {
import type { MiddlewareInfo, MiddlewareManifest } from "types/next-types";
import type {
IncludedConverter,
OpenNextConfig,
OverrideOptions,
Expand All @@ -16,7 +16,8 @@ import logger from "../../logger.js";
import { openNextEdgePlugins } from "../../plugins/edge.js";
import { openNextReplacementPlugin } from "../../plugins/replacement.js";
import { openNextResolvePlugin } from "../../plugins/resolve.js";
import { BuildOptions, copyOpenNextConfig, esbuildAsync } from "../helper.js";
import type { BuildOptions } from "../helper.js";
import { copyOpenNextConfig, esbuildAsync } from "../helper.js";

interface BuildEdgeBundleOptions {
appBuildOutputPath: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/open-next/src/build/generateOutput.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as fs from "node:fs";
import path from "node:path";

import { NextConfig } from "types/next-types.js";
import {
import type { NextConfig } from "types/next-types.js";
import type {
BaseOverride,
DefaultOverrideOptions,
FunctionOptions,
Expand Down
9 changes: 3 additions & 6 deletions packages/open-next/src/build/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@ import { createRequire } from "node:module";
import path from "node:path";
import url from "node:url";

import {
build as buildAsync,
BuildOptions as ESBuildOptions,
buildSync,
} from "esbuild";
import { OpenNextConfig } from "types/open-next.js";
import type { BuildOptions as ESBuildOptions } from "esbuild";
import { build as buildAsync, buildSync } from "esbuild";
import type { OpenNextConfig } from "types/open-next.js";

import logger from "../logger.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/open-next/src/build/validateConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
FunctionOptions,
IncludedConverter,
IncludedWrapper,
Expand Down
2 changes: 1 addition & 1 deletion packages/open-next/src/core/createMainHandler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { AsyncLocalStorage } from "node:async_hooks";

import type { OpenNextConfig } from "types/open-next";
import { DetachedPromiseRunner } from "utils/promise";
import type { DetachedPromiseRunner } from "utils/promise";

import { debug } from "../adapters/logger";
import { generateUniqueId } from "../adapters/util";
Expand Down
12 changes: 5 additions & 7 deletions packages/open-next/src/core/requestHandler.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import { AsyncLocalStorage } from "node:async_hooks";

import {
IncomingMessage,
OpenNextNodeResponse,
StreamCreator,
} from "http/index.js";
import { InternalEvent, InternalResult } from "types/open-next";
import type { OpenNextNodeResponse, StreamCreator } from "http/index.js";
import { IncomingMessage } from "http/index.js";
import type { InternalEvent, InternalResult } from "types/open-next";
import { DetachedPromiseRunner } from "utils/promise";

import { debug, error, warn } from "../adapters/logger";
import { patchAsyncStorage } from "./patchAsyncStorage";
import { convertRes, createServerResponse, proxyRequest } from "./routing/util";
import routingHandler, { MiddlewareOutputEvent } from "./routingHandler";
import type { MiddlewareOutputEvent } from "./routingHandler";
import routingHandler from "./routingHandler";
import { requestHandler, setNextjsPrebundledReact } from "./util";

// This is used to identify requests in the cache
Expand Down
4 changes: 2 additions & 2 deletions packages/open-next/src/core/resolve.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
BaseEventOrResult,
Converter,
DefaultOverrideOptions,
Expand All @@ -12,7 +12,7 @@ import {
Wrapper,
} from "types/open-next.js";

import { TagCache } from "../overrides/tagCache/types.js";
import type { TagCache } from "../overrides/tagCache/types.js";

export async function resolveConverter<
E extends BaseEventOrResult = InternalEvent,
Expand Down
Loading