Skip to content

Add override for esbuild plugin #656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions packages/open-next/src/core/requestHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ import { requestHandler, setNextjsPrebundledReact } from "./util";
// This is used to identify requests in the cache
globalThis.__openNextAls = new AsyncLocalStorage();

//#override patchAsyncStorage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Long term, we should not delete it but have a cloudflare specific impl.
Maybe we could then override instead of deleting but at the same time the temporary patch in cloudflare is good enough before we have a long term solution.

WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one will hopefully be removed in the future in OpenNext as well.
Once this PR vercel/next.js#72082 gets merged it will not be necessary anymore.
I just have to figure out how to test with the new use cache stuff from next

patchAsyncStorage();
//#endOverride

export async function openNextHandler(
internalEvent: InternalEvent,
Expand Down
4 changes: 4 additions & 0 deletions packages/open-next/src/core/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ import {
overrideNextjsRequireHooks(NextConfig);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vicb These 2 uses require.resolve and are present on next >=13.4.13 and next <=13.5.1

applyNextjsRequireHooksOverride();
//#endOverride

//#override cacheHandlerPath
const cacheHandlerPath = require.resolve("./cache.cjs");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After some thought, i don't see how setting the NEXT_CACHE_HANDLER_PATH env would benefit us that much, at least not here.
The only way this would be useful would be at build time so that the cache is available during next build, but then it would mean that we'll have to either include open-next in the bundle (or at least a precompiled version of the cache in the node_modules) or still override it at build time like we do today.
It also means that both the tag and incremental cache would need to be available at build time

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here again we can not delete this but we should override or it will break the build.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, you could replace it using the replacement plugin instead of deleting

//#endOverride

// @ts-ignore
export const requestHandler = new NextServer.default({
//#override requestHandlerHost
Expand Down
Loading