Skip to content

Commit

Permalink
rename config
Browse files Browse the repository at this point in the history
  • Loading branch information
ijjk committed Oct 14, 2022
1 parent c444dfc commit ee27085
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
6 changes: 3 additions & 3 deletions packages/next/build/webpack-config.ts
Expand Up @@ -251,7 +251,7 @@ export function getDefineEnv({
'process.env.__NEXT_I18N_DOMAINS': JSON.stringify(config.i18n?.domains),
'process.env.__NEXT_ANALYTICS_ID': JSON.stringify(config.analyticsId),
'process.env.__NEXT_ALLOW_MIDDLEWARE_RESPONSE_BODY': JSON.stringify(
config.experimental.dangerouslyAllowMiddlewareResponseBody
config.experimental.allowMiddlewareResponseBody
),
'process.env.__NEXT_NO_MIDDLEWARE_URL_NORMALIZE': JSON.stringify(
config.experimental.skipMiddlewareUrlNormalize
Expand Down Expand Up @@ -1895,8 +1895,8 @@ export default async function getBaseWebpackConfig(
dev,
sriEnabled: !dev && !!config.experimental.sri?.algorithm,
hasFontLoaders: !!config.experimental.fontLoaders,
dangerouslyAllowMiddlewareResponseBody:
!!config.experimental.dangerouslyAllowMiddlewareResponseBody,
allowMiddlewareResponseBody:
!!config.experimental.allowMiddlewareResponseBody,
}),
isClient &&
new BuildManifestPlugin({
Expand Down
18 changes: 8 additions & 10 deletions packages/next/build/webpack/plugins/middleware-plugin.ts
Expand Up @@ -340,14 +340,14 @@ function getCodeAnalyzer(params: {
dev: boolean
compiler: webpack.Compiler
compilation: webpack.Compilation
dangerouslyAllowMiddlewareResponseBody: boolean
allowMiddlewareResponseBody: boolean
}) {
return (parser: webpack.javascript.JavascriptParser) => {
const {
dev,
compiler: { webpack: wp },
compilation,
dangerouslyAllowMiddlewareResponseBody,
allowMiddlewareResponseBody,
} = params
const { hooks } = parser

Expand Down Expand Up @@ -563,7 +563,7 @@ Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime`,
.tap(NAME, handleWrapWasmInstantiateExpression)
}

if (!dangerouslyAllowMiddlewareResponseBody) {
if (!allowMiddlewareResponseBody) {
hooks.new.for('Response').tap(NAME, handleNewResponseExpression)
hooks.new.for('NextResponse').tap(NAME, handleNewResponseExpression)
}
Expand Down Expand Up @@ -806,24 +806,23 @@ export default class MiddlewarePlugin {
private readonly dev: boolean
private readonly sriEnabled: boolean
private readonly hasFontLoaders: boolean
private readonly dangerouslyAllowMiddlewareResponseBody: boolean
private readonly allowMiddlewareResponseBody: boolean

constructor({
dev,
sriEnabled,
hasFontLoaders,
dangerouslyAllowMiddlewareResponseBody,
allowMiddlewareResponseBody,
}: {
dev: boolean
sriEnabled: boolean
hasFontLoaders: boolean
dangerouslyAllowMiddlewareResponseBody: boolean
allowMiddlewareResponseBody: boolean
}) {
this.dev = dev
this.sriEnabled = sriEnabled
this.hasFontLoaders = hasFontLoaders
this.dangerouslyAllowMiddlewareResponseBody =
dangerouslyAllowMiddlewareResponseBody
this.allowMiddlewareResponseBody = allowMiddlewareResponseBody
}

public apply(compiler: webpack.Compiler) {
Expand All @@ -836,8 +835,7 @@ export default class MiddlewarePlugin {
dev: this.dev,
compiler,
compilation,
dangerouslyAllowMiddlewareResponseBody:
this.dangerouslyAllowMiddlewareResponseBody,
allowMiddlewareResponseBody: this.allowMiddlewareResponseBody,
})
hooks.parser.for('javascript/auto').tap(NAME, codeAnalyzer)
hooks.parser.for('javascript/dynamic').tap(NAME, codeAnalyzer)
Expand Down
2 changes: 1 addition & 1 deletion packages/next/server/config-schema.ts
Expand Up @@ -268,7 +268,7 @@ const configSchema = {
appDir: {
type: 'boolean',
},
dangerouslyAllowMiddlewareResponseBody: {
allowMiddlewareResponseBody: {
type: 'boolean',
},
externalDir: {
Expand Down
2 changes: 1 addition & 1 deletion packages/next/server/config-shared.ts
Expand Up @@ -79,7 +79,7 @@ export interface NextJsWebpackConfig {
}

export interface ExperimentalConfig {
dangerouslyAllowMiddlewareResponseBody?: boolean
allowMiddlewareResponseBody?: boolean
skipMiddlewareUrlNormalize?: boolean
skipTrailingSlashRedirect?: boolean
optimisticClientCache?: boolean
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/skip-trailing-slash-redirect/app/next.config.js
Expand Up @@ -3,7 +3,7 @@ const nextConfig = {
experimental: {
skipTrailingSlashRedirect: true,
skipMiddlewareUrlNormalize: true,
dangerouslyAllowMiddlewareResponseBody: true,
allowMiddlewareResponseBody: true,
},
async redirects() {
return [
Expand Down

0 comments on commit ee27085

Please sign in to comment.