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
[edge] serialize custom config to middleware-manifest #40881
Changes from 2 commits
92e2386
095eb55
2716fe9
b3bbedb
09de605
024d3fe
8cc7b08
8d59882
fd937bb
bd3b1fe
d460fba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,6 +166,8 @@ export function getEdgeServerEntry(opts: { | |
middleware?: Partial<MiddlewareConfig> | ||
pagesType?: 'app' | 'pages' | 'root' | ||
appDirLoader?: string | ||
// TODO(schniz): mark as optional | ||
Schniz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
userConfig: Record<string, unknown> | undefined | ||
}) { | ||
if (isMiddlewareFile(opts.page)) { | ||
const loaderParams: MiddlewareLoaderOptions = { | ||
|
@@ -175,6 +177,7 @@ export function getEdgeServerEntry(opts: { | |
matchers: opts.middleware?.matchers | ||
? encodeMatchers(opts.middleware.matchers) | ||
: '', | ||
...(opts.userConfig && { userConfig: JSON.stringify(opts.userConfig) }), | ||
} | ||
|
||
return `next-middleware-loader?${stringify(loaderParams)}!` | ||
|
@@ -185,6 +188,7 @@ export function getEdgeServerEntry(opts: { | |
absolutePagePath: opts.absolutePagePath, | ||
page: opts.page, | ||
rootDir: opts.rootDir, | ||
...(opts.userConfig && { userConfig: JSON.stringify(opts.userConfig) }), | ||
} | ||
|
||
return `next-edge-function-loader?${stringify(loaderParams)}!` | ||
|
@@ -205,6 +209,7 @@ export function getEdgeServerEntry(opts: { | |
appDirLoader: Buffer.from(opts.appDirLoader || '').toString('base64'), | ||
sriEnabled: !opts.isDev && !!opts.config.experimental.sri?.algorithm, | ||
hasFontLoaders: !!opts.config.experimental.fontLoaders, | ||
...(opts.userConfig && { userConfig: JSON.stringify(opts.userConfig) }), | ||
} | ||
|
||
return { | ||
|
@@ -493,6 +498,7 @@ export async function createEntrypoints(params: CreateEntrypointsParams) { | |
middleware: staticInfo?.middleware, | ||
pagesType, | ||
appDirLoader, | ||
userConfig: staticInfo?.userConfig, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency I think we may want to have this be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I kept the entire config so we will be able to serialize what we want in |
||
}) | ||
}, | ||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: how about throwing an error like
you can't specify both "matcher" and "matchers"
instead of discardingmatcher
here silently?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a validation, I just don’t want to serialize the matcher again (it already exists in the middleware manifest)