From d07422f931e5c2a784f44931b0107cd0c65ff189 Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Fri, 22 Nov 2024 12:58:14 +0100 Subject: [PATCH] chore: rename modules for better meaning and searching (#73067) --- .eslintrc.json | 2 +- ...nfig.js => next-runtime.webpack-config.js} | 0 .../parseNotFoundError.ts | 2 +- .../{middleware.ts => middleware-webpack.ts} | 0 .../src/server/dev/hot-reloader-webpack.ts | 2 +- .../lib/router-utils/setup-dev-bundler.ts | 2 +- .../next/src/server/patch-error-inspect.ts | 2 +- .../next/src/server/web/sandbox/context.ts | 5 +++-- .../next/src/server/web/sandbox/sandbox.ts | 2 +- packages/next/taskfile.js | 20 +++++++++---------- 10 files changed, 19 insertions(+), 18 deletions(-) rename packages/next/{webpack.config.js => next-runtime.webpack-config.js} (100%) rename packages/next/src/client/components/react-dev-overlay/server/{middleware.ts => middleware-webpack.ts} (100%) diff --git a/.eslintrc.json b/.eslintrc.json index 43e2f76141c0e..821101586227a 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -162,7 +162,7 @@ "files": ["packages/**"], "excludedFiles": [ "packages/next/taskfile*.js", - "packages/next/webpack.config.js" + "packages/next/next-runtime.webpack-config.js" ], "rules": { "no-shadow": ["error", { "builtinGlobals": false }], diff --git a/packages/next/webpack.config.js b/packages/next/next-runtime.webpack-config.js similarity index 100% rename from packages/next/webpack.config.js rename to packages/next/next-runtime.webpack-config.js diff --git a/packages/next/src/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.ts b/packages/next/src/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.ts index 76a65f621aa7a..6addcca076812 100644 --- a/packages/next/src/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.ts +++ b/packages/next/src/build/webpack/plugins/wellknown-errors-plugin/parseNotFoundError.ts @@ -3,7 +3,7 @@ import { SimpleWebpackError } from './simpleWebpackError' import { createOriginalStackFrame, getIgnoredSources, -} from '../../../../client/components/react-dev-overlay/server/middleware' +} from '../../../../client/components/react-dev-overlay/server/middleware-webpack' import type { webpack } from 'next/dist/compiled/webpack/webpack' // Based on https://github.com/webpack/webpack/blob/fcdd04a833943394bbb0a9eeb54a962a24cc7e41/lib/stats/DefaultStatsFactoryPlugin.js#L422-L431 diff --git a/packages/next/src/client/components/react-dev-overlay/server/middleware.ts b/packages/next/src/client/components/react-dev-overlay/server/middleware-webpack.ts similarity index 100% rename from packages/next/src/client/components/react-dev-overlay/server/middleware.ts rename to packages/next/src/client/components/react-dev-overlay/server/middleware-webpack.ts diff --git a/packages/next/src/server/dev/hot-reloader-webpack.ts b/packages/next/src/server/dev/hot-reloader-webpack.ts index 44eb9479a203e..7d0b1827c8c33 100644 --- a/packages/next/src/server/dev/hot-reloader-webpack.ts +++ b/packages/next/src/server/dev/hot-reloader-webpack.ts @@ -10,7 +10,7 @@ import { webpack, StringXor } from 'next/dist/compiled/webpack/webpack' import { getOverlayMiddleware, getSourceMapMiddleware, -} from '../../client/components/react-dev-overlay/server/middleware' +} from '../../client/components/react-dev-overlay/server/middleware-webpack' import { WebpackHotMiddleware } from './hot-middleware' import { join, relative, isAbsolute, posix } from 'path' import { diff --git a/packages/next/src/server/lib/router-utils/setup-dev-bundler.ts b/packages/next/src/server/lib/router-utils/setup-dev-bundler.ts index 2106524da5204..8785551306d72 100644 --- a/packages/next/src/server/lib/router-utils/setup-dev-bundler.ts +++ b/packages/next/src/server/lib/router-utils/setup-dev-bundler.ts @@ -70,7 +70,7 @@ import { getSourceMapFromFile, parseStack, getIgnoredSources, -} from '../../../client/components/react-dev-overlay/server/middleware' +} from '../../../client/components/react-dev-overlay/server/middleware-webpack' import { batchedTraceSource, createOriginalStackFrame as createOriginalTurboStackFrame, diff --git a/packages/next/src/server/patch-error-inspect.ts b/packages/next/src/server/patch-error-inspect.ts index 774c63ae7277e..c05dda0db9c87 100644 --- a/packages/next/src/server/patch-error-inspect.ts +++ b/packages/next/src/server/patch-error-inspect.ts @@ -4,7 +4,7 @@ import * as url from 'url' import type * as util from 'util' import { SourceMapConsumer as SyncSourceMapConsumer } from 'next/dist/compiled/source-map' import type { StackFrame } from 'next/dist/compiled/stacktrace-parser' -import { parseStack } from '../client/components/react-dev-overlay/server/middleware' +import { parseStack } from '../client/components/react-dev-overlay/server/middleware-webpack' import { getOriginalCodeFrame } from '../client/components/react-dev-overlay/server/shared' import { workUnitAsyncStorage } from './app-render/work-unit-async-storage.external' import { dim } from '../lib/picocolors' diff --git a/packages/next/src/server/web/sandbox/context.ts b/packages/next/src/server/web/sandbox/context.ts index 3428ab7f34a43..58f4a0f39b4d1 100644 --- a/packages/next/src/server/web/sandbox/context.ts +++ b/packages/next/src/server/web/sandbox/context.ts @@ -29,11 +29,12 @@ interface ModuleContext { warnedEvals: Set } -let getServerError: typeof import('../../../client/components/react-dev-overlay/server/middleware').getServerError +let getServerError: typeof import('../../../client/components/react-dev-overlay/server/middleware-webpack').getServerError let decorateServerError: typeof import('../../../shared/lib/error-source').decorateServerError if (process.env.NODE_ENV === 'development') { - const middleware = require('../../../client/components/react-dev-overlay/server/middleware') + const middleware = + require('../../../client/components/react-dev-overlay/server/middleware-webpack') as typeof import('../../../client/components/react-dev-overlay/server/middleware-webpack') getServerError = middleware.getServerError decorateServerError = require('../../../shared/lib/error-source').decorateServerError diff --git a/packages/next/src/server/web/sandbox/sandbox.ts b/packages/next/src/server/web/sandbox/sandbox.ts index d7c7279225118..e1ca75aae7450 100644 --- a/packages/next/src/server/web/sandbox/sandbox.ts +++ b/packages/next/src/server/web/sandbox/sandbox.ts @@ -44,7 +44,7 @@ type RunnerFn = (params: RunnerFnParams) => Promise function withTaggedErrors(fn: RunnerFn): RunnerFn { if (process.env.NODE_ENV === 'development') { const { getServerError } = - require('../../../client/components/react-dev-overlay/server/middleware') as typeof import('../../../client/components/react-dev-overlay/server/middleware') + require('../../../client/components/react-dev-overlay/server/middleware-webpack') as typeof import('../../../client/components/react-dev-overlay/server/middleware-webpack') return (params) => fn(params) diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index be1b7e9178b34..fee8e1a466525 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -2823,7 +2823,7 @@ export async function release(task) { export async function next_bundle_app_turbo(task, opts) { await task.source('dist').webpack({ watch: opts.dev, - config: require('./webpack.config')({ + config: require('./next-runtime.webpack-config')({ turbo: true, bundleType: 'app', }), @@ -2834,7 +2834,7 @@ export async function next_bundle_app_turbo(task, opts) { export async function next_bundle_app_prod(task, opts) { await task.source('dist').webpack({ watch: opts.dev, - config: require('./webpack.config')({ + config: require('./next-runtime.webpack-config')({ dev: false, bundleType: 'app', }), @@ -2845,7 +2845,7 @@ export async function next_bundle_app_prod(task, opts) { export async function next_bundle_app_dev(task, opts) { await task.source('dist').webpack({ watch: opts.dev, - config: require('./webpack.config')({ + config: require('./next-runtime.webpack-config')({ dev: true, bundleType: 'app', }), @@ -2856,7 +2856,7 @@ export async function next_bundle_app_dev(task, opts) { export async function next_bundle_app_turbo_experimental(task, opts) { await task.source('dist').webpack({ watch: opts.dev, - config: require('./webpack.config')({ + config: require('./next-runtime.webpack-config')({ turbo: true, bundleType: 'app', experimental: true, @@ -2868,7 +2868,7 @@ export async function next_bundle_app_turbo_experimental(task, opts) { export async function next_bundle_app_prod_experimental(task, opts) { await task.source('dist').webpack({ watch: opts.dev, - config: require('./webpack.config')({ + config: require('./next-runtime.webpack-config')({ dev: false, bundleType: 'app', experimental: true, @@ -2880,7 +2880,7 @@ export async function next_bundle_app_prod_experimental(task, opts) { export async function next_bundle_app_dev_experimental(task, opts) { await task.source('dist').webpack({ watch: opts.dev, - config: require('./webpack.config')({ + config: require('./next-runtime.webpack-config')({ dev: true, bundleType: 'app', experimental: true, @@ -2892,7 +2892,7 @@ export async function next_bundle_app_dev_experimental(task, opts) { export async function next_bundle_pages_prod(task, opts) { await task.source('dist').webpack({ watch: opts.dev, - config: require('./webpack.config')({ + config: require('./next-runtime.webpack-config')({ dev: false, bundleType: 'pages', }), @@ -2903,7 +2903,7 @@ export async function next_bundle_pages_prod(task, opts) { export async function next_bundle_pages_dev(task, opts) { await task.source('dist').webpack({ watch: opts.dev, - config: require('./webpack.config')({ + config: require('./next-runtime.webpack-config')({ dev: true, bundleType: 'pages', }), @@ -2914,7 +2914,7 @@ export async function next_bundle_pages_dev(task, opts) { export async function next_bundle_pages_turbo(task, opts) { await task.source('dist').webpack({ watch: opts.dev, - config: require('./webpack.config')({ + config: require('./next-runtime.webpack-config')({ turbo: true, bundleType: 'pages', }), @@ -2925,7 +2925,7 @@ export async function next_bundle_pages_turbo(task, opts) { export async function next_bundle_server(task, opts) { await task.source('dist').webpack({ watch: opts.dev, - config: require('./webpack.config')({ + config: require('./next-runtime.webpack-config')({ dev: false, bundleType: 'server', }),