Skip to content
Permalink
Browse files

feat: webpack inlining with configuration for v4 / v5 (#20598)

  • Loading branch information
guybedford committed Jan 14, 2021
1 parent e1184fb commit bddb02286fdcfb83fc97fa91df378cb6d92778e8
Showing with 239,351 additions and 458 deletions.
  1. +1 −0 .eslintignore
  2. +14 −3 .github/actions/next-stats-action/src/prepare/repo-setup.js
  3. +2 −4 .github/workflows/build_test_deploy.yml
  4. +2 −1 .prettierignore
  5. +1 −0 .prettierignore_staged
  6. +3 −0 check-pre-compiled.sh
  7. +1 −1 package.json
  8. +10 −4 packages/next/build/compiler.ts
  9. +22 −20 packages/next/build/webpack-config.ts
  10. +2 −2 packages/next/build/webpack/config/blocks/base.ts
  11. +3 −3 packages/next/build/webpack/config/blocks/css/index.ts
  12. +1 −1 packages/next/build/webpack/config/blocks/css/loaders/client.ts
  13. +1 −1 packages/next/build/webpack/config/blocks/css/loaders/getCssModuleLocalIdent.ts
  14. +1 −1 packages/next/build/webpack/config/blocks/css/loaders/global.ts
  15. +1 −1 packages/next/build/webpack/config/blocks/css/loaders/modules.ts
  16. +3 −3 packages/next/build/webpack/config/blocks/css/overrideCssConfiguration.ts
  17. +9 −6 packages/next/build/webpack/config/helpers.ts
  18. +1 −1 packages/next/build/webpack/config/index.ts
  19. +1 −1 packages/next/build/webpack/config/utils.ts
  20. +2 −2 packages/next/build/webpack/loaders/error-loader.ts
  21. +2 −2 packages/next/build/webpack/loaders/next-plugin-loader.ts
  22. +2 −2 packages/next/build/webpack/loaders/next-serverless-loader/index.ts
  23. +2 −2 packages/next/build/webpack/loaders/noop-loader.ts
  24. +10 −11 packages/next/build/webpack/plugins/build-manifest-plugin.ts
  25. +2 −2 packages/next/build/webpack/plugins/chunk-names-plugin.ts
  26. +7 −9 packages/next/build/webpack/plugins/css-minimizer-plugin.ts
  27. +11 −19 packages/next/build/webpack/plugins/font-stylesheet-gathering-plugin.ts
  28. +2 −2 packages/next/build/webpack/plugins/jsconfig-paths-plugin.ts
  29. +56 −51 packages/next/build/webpack/plugins/mini-css-extract-plugin/src/CssDependency.js
  30. +89 −83 packages/next/build/webpack/plugins/mini-css-extract-plugin/src/CssModule.js
  31. +16 −10 packages/next/build/webpack/plugins/mini-css-extract-plugin/src/index.js
  32. +5 −3 packages/next/build/webpack/plugins/mini-css-extract-plugin/src/loader.js
  33. +6 −12 packages/next/build/webpack/plugins/next-drop-client-page-plugin.ts
  34. +4 −5 packages/next/build/webpack/plugins/nextjs-require-cache-hot-reloader.ts
  35. +2 −2 packages/next/build/webpack/plugins/nextjs-ssr-import.ts
  36. +2 −6 packages/next/build/webpack/plugins/nextjs-ssr-module-cache.ts
  37. +10 −10 packages/next/build/webpack/plugins/pages-manifest-plugin.ts
  38. +11 −15 packages/next/build/webpack/plugins/react-loadable-plugin.ts
  39. +3 −8 packages/next/build/webpack/plugins/serverless-plugin.ts
  40. +7 −6 packages/next/build/webpack/plugins/terser-webpack-plugin/src/index.js
  41. +6 −6 packages/next/build/webpack/plugins/webpack-conformance-plugin/index.ts
  42. +2 −2 packages/next/build/webpack/plugins/wellknown-errors-plugin/index.ts
  43. +3 −4 packages/next/build/webpack/plugins/wellknown-errors-plugin/webpackModuleError.ts
  44. +7 −0 packages/next/bundles/package.json
  45. +12 −0 packages/next/bundles/webpack/bundle4.js
  46. +12 −0 packages/next/bundles/webpack/bundle5.js
  47. +377 −0 packages/next/bundles/webpack/packages/HotModuleReplacement.runtime.js
  48. +431 −0 packages/next/bundles/webpack/packages/JavascriptHotModuleReplacement.runtime.js
  49. +27 −0 packages/next/bundles/webpack/packages/webpack.js
  50. +539 −0 packages/next/bundles/yarn.lock
  51. +1 −1 packages/next/compiled/amphtml-validator/index.js
  52. +1 −1 packages/next/compiled/arg/index.js
  53. +1 −1 packages/next/compiled/async-retry/index.js
  54. +1 −1 packages/next/compiled/async-sema/index.js
  55. +1 −1 packages/next/compiled/babel/bundle.js
  56. +1 −1 packages/next/compiled/cacache/index.js
  57. +1 −1 packages/next/compiled/cache-loader/cjs.js
  58. +1 −1 packages/next/compiled/ci-info/index.js
  59. +1 −1 packages/next/compiled/comment-json/index.js
  60. +1 −1 packages/next/compiled/compression/index.js
  61. +1 −1 packages/next/compiled/conf/index.js
  62. +1 −1 packages/next/compiled/content-type/index.js
  63. +1 −1 packages/next/compiled/cookie/index.js
  64. +1 −1 packages/next/compiled/debug/index.js
  65. +1 −1 packages/next/compiled/devalue/devalue.umd.js
  66. +1 −1 packages/next/compiled/escape-string-regexp/index.js
  67. +1 −1 packages/next/compiled/file-loader/cjs.js
  68. +1 −1 packages/next/compiled/find-cache-dir/index.js
  69. +1 −1 packages/next/compiled/find-up/LICENSE
  70. +1 −1 packages/next/compiled/find-up/index.js
  71. +1 −1 packages/next/compiled/find-up/package.json
  72. +1 −1 packages/next/compiled/fresh/index.js
  73. +1 −1 packages/next/compiled/gzip-size/index.js
  74. +1 −1 packages/next/compiled/http-proxy/index.js
  75. +1 −1 packages/next/compiled/ignore-loader/index.js
  76. +1 −1 packages/next/compiled/is-animated/index.js
  77. +1 −1 packages/next/compiled/is-docker/index.js
  78. +1 −1 packages/next/compiled/is-wsl/index.js
  79. +1 −1 packages/next/compiled/json5/index.js
  80. +1 −1 packages/next/compiled/jsonwebtoken/index.js
  81. +1 −1 packages/next/compiled/lodash.curry/index.js
  82. +1 −1 packages/next/compiled/lru-cache/index.js
  83. +1 −1 packages/next/compiled/mkdirp/index.js
  84. +1 −1 packages/next/compiled/nanoid/index.cjs
  85. +1 −1 packages/next/compiled/neo-async/async.js
  86. +1 −1 packages/next/compiled/ora/index.js
  87. +1 −1 packages/next/compiled/postcss-flexbugs-fixes/index.js
  88. +1 −1 packages/next/compiled/postcss-loader/cjs.js
  89. +1 −1 packages/next/compiled/postcss-preset-env/index.js
  90. +1 −1 packages/next/compiled/postcss-scss/scss-syntax.js
  91. +1 −1 packages/next/compiled/recast/main.js
  92. +20 −0 packages/next/compiled/sass-loader/LICENSE
  93. +1 −0 packages/next/compiled/sass-loader/cjs.js
  94. +1 −0 packages/next/compiled/sass-loader/package.json
  95. +1 −1 packages/next/compiled/schema-utils/index.js
  96. +20 −0 packages/next/compiled/schema-utils3/LICENSE
  97. +1 −0 packages/next/compiled/schema-utils3/index.js
  98. +1 −0 packages/next/compiled/schema-utils3/package.json
  99. +1 −1 packages/next/compiled/semver/index.js
  100. +1 −1 packages/next/compiled/send/index.js
  101. +1 −1 packages/next/compiled/source-map/source-map.js
  102. +1 −1 packages/next/compiled/string-hash/index.js
  103. +1 −1 packages/next/compiled/strip-ansi/index.js
  104. +1 −1 packages/next/compiled/terser/bundle.min.js
  105. +1 −1 packages/next/compiled/text-table/index.js
  106. +1 −1 packages/next/compiled/thread-loader/cjs.js
  107. +1 −1 packages/next/compiled/thread-loader/worker.js
  108. +1 −1 packages/next/compiled/unistore/unistore.js
  109. +1 −1 packages/next/compiled/web-vitals/web-vitals.es5.umd.min.js
  110. +21 −0 packages/next/compiled/webpack-sources/LICENSE
  111. +1 −0 packages/next/compiled/webpack-sources/index.js
  112. +1 −0 packages/next/compiled/webpack-sources/package.json
  113. +21 −0 packages/next/compiled/webpack-sources2/LICENSE
  114. +1 −0 packages/next/compiled/webpack-sources2/index.js
  115. +1 −0 packages/next/compiled/webpack-sources2/package.json
  116. +377 −0 packages/next/compiled/webpack/HotModuleReplacement.runtime.js
  117. +431 −0 packages/next/compiled/webpack/JavascriptHotModuleReplacement.runtime.js
  118. +20 −0 packages/next/compiled/webpack/LICENSE
  119. +55 −0 packages/next/compiled/webpack/amd-define.js
  120. +54 −0 packages/next/compiled/webpack/amd-options.js
  121. +105,977 −0 packages/next/compiled/webpack/bundle4.js
  122. +129,048 −0 packages/next/compiled/webpack/bundle5.js
  123. +52 −0 packages/next/compiled/webpack/empty.js
  124. +72 −0 packages/next/compiled/webpack/global.js
  125. +76 −0 packages/next/compiled/webpack/harmony-module.js
  126. +109 −0 packages/next/compiled/webpack/index.js
  127. +341 −0 packages/next/compiled/webpack/minify.js
  128. +74 −0 packages/next/compiled/webpack/module.js
  129. +1 −0 packages/next/compiled/webpack/package.json
  130. +59 −0 packages/next/compiled/webpack/system.js
  131. +27 −0 packages/next/compiled/webpack/webpack.js
  132. +281 −0 packages/next/compiled/webpack/worker.js
  133. +2 −0 packages/next/next-server/server/config.ts
  134. +10 −8 packages/next/package.json
  135. +1 −1 packages/next/server/hot-middleware.ts
  136. +2 −1 packages/next/server/hot-reloader.ts
  137. +1 −1 packages/next/server/on-demand-entry-handler.ts
  138. +12 −3 packages/next/taskfile-ncc.js
  139. +145 −25 packages/next/taskfile.js
  140. +0 −3 packages/next/types/misc.d.ts
  141. +12 −0 packages/next/types/webpack.d.ts
  142. +10 −6 packages/react-dev-overlay/src/middleware.ts
  143. +35 −18 packages/react-refresh-utils/ReactRefreshWebpackPlugin.ts
  144. +2 −2 test/integration/build-output/test/index.test.js
  145. +176 −10 yarn.lock
@@ -4,6 +4,7 @@ node_modules
**/dist/**
examples/with-typescript-eslint-jest/**
examples/with-kea/**
packages/next/bundles/webpack/packages/*.runtime.js
packages/next/compiled/**/*
packages/react-refresh-utils/**/*.js
packages/react-dev-overlay/lib/**
@@ -69,13 +69,17 @@ module.exports = (actionInfo) => {
for (const pkg of pkgs) {
const pkgPath = path.join(repoDir, 'packages', pkg)
const packedPkgPath = path.join(pkgPath, `${pkg}-packed.tgz`)
// pack the package with yarn
await exec(`cd ${pkgPath} && yarn pack -f ${pkg}-packed.tgz`)

const pkgDataPath = path.join(pkgPath, 'package.json')
const pkgData = require(pkgDataPath)
const { name } = pkgData
pkgDatas.set(name, { pkgDataPath, pkgData, packedPkgPath })
pkgDatas.set(name, {
pkgDataPath,
pkg,
pkgPath,
pkgData,
packedPkgPath,
})
pkgPaths.set(name, packedPkgPath)
}

@@ -93,6 +97,13 @@ module.exports = (actionInfo) => {
'utf8'
)
}

// wait to pack packages until after dependency paths have been updated
// to the correct versions
for (const pkgName of pkgDatas.keys()) {
const { pkg, pkgPath } = pkgDatas.get(pkgName)
await exec(`cd ${pkgPath} && yarn pack -f ${pkg}-packed.tgz`)
}
return pkgPaths
},
}
@@ -160,6 +160,7 @@ jobs:
NEXT_TELEMETRY_DISABLED: 1
NEXT_TEST_JOB: 1
HEADLESS: true
NEXT_WEBPACK5: 1

steps:
- uses: actions/checkout@v2
@@ -170,9 +171,6 @@ jobs:
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }}

- run: cat package.json | jq '.resolutions.webpack = "^5.11.1"' > package.json.tmp && mv package.json.tmp package.json
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }}

- run: cat package.json | jq '.resolutions.react = "^17.0.1"' > package.json.tmp && mv package.json.tmp package.json
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }}

@@ -185,7 +183,7 @@ jobs:
- run: yarn list webpack react react-dom
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }}

- run: xvfb-run node run-tests.js test/integration/{link-ref,production,basic,async-modules,font-optimization,ssr-ctx}/test/index.test.js test/acceptance/*.test.js
- run: xvfb-run node run-tests.js test/integration/{link-ref,production,basic,async-modules,ssr-ctx}/test/index.test.js test/acceptance/*.test.js
if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs-only' }}

testFirefox:
@@ -2,6 +2,7 @@ node_modules
**/.next/**
**/_next/**
**/dist/**
packages/next/bundles/webpack/packages/*.runtime.js
packages/next/compiled/**
packages/react-refresh-utils/**/*.js
packages/react-refresh-utils/**/*.d.ts
@@ -14,4 +15,4 @@ packages/next-codemod/transforms/__tests__/**/*
packages/next-codemod/**/*.js
packages/next-codemod/**/*.d.ts
packages/next-env/**/*.d.ts
test-timings.json
test-timings.json
@@ -2,6 +2,7 @@
**/_next/**
**/dist/**
packages/next/compiled/**/*
packages/next/bundles/webpack/packages/*.runtime.js
lerna.json
packages/next-codemod/transforms/__testfixtures__/**/*
packages/next-codemod/transforms/__tests__/**/*
@@ -1,5 +1,8 @@
#!/bin/bash

yarn --cwd packages/next/bundles
cp packages/next/bundles/node_modules/webpack5/lib/hmr/HotModuleReplacement.runtime.js packages/next/bundles/webpack/packages/
cp packages/next/bundles/node_modules/webpack5/lib/hmr/JavascriptHotModuleReplacement.runtime.js packages/next/bundles/webpack/packages/
yarn --cwd packages/next ncc-compiled

# Make sure to exit with 1 if there are changes after running ncc-compiled
@@ -74,7 +74,7 @@
"eslint": "6.8.0",
"eslint-plugin-import": "2.20.2",
"eslint-plugin-jest": "23.13.1",
"eslint-plugin-react": "7.18.0",
"eslint-plugin-react": "7.19.0",
"eslint-plugin-react-hooks": "2.3.0",
"execa": "2.0.3",
"express": "4.17.0",
@@ -1,11 +1,14 @@
import webpack, { Stats, Configuration } from 'webpack'
import { webpack } from 'next/dist/compiled/webpack/webpack'

export type CompilerResult = {
errors: string[]
warnings: string[]
}

function generateStats(result: CompilerResult, stat: Stats): CompilerResult {
function generateStats(
result: CompilerResult,
stat: webpack.Stats
): CompilerResult {
const { errors, warnings } = stat.toJson('errors-warnings')
if (errors.length > 0) {
result.errors.push(...errors)
@@ -32,12 +35,15 @@ function closeCompiler(compiler: webpack.Compiler | webpack.MultiCompiler) {
}

export function runCompiler(
config: Configuration | Configuration[]
config: webpack.Configuration | webpack.Configuration[]
): Promise<CompilerResult> {
return new Promise((resolve, reject) => {
const compiler = webpack(config)
compiler.run(
(err: Error, statsOrMultiStats: { stats: Stats[] } | Stats) => {
(
err: Error,
statsOrMultiStats: { stats: webpack.Stats[] } | webpack.Stats
) => {
closeCompiler(compiler).then(() => {
if (err) {
const reason = err?.toString()
@@ -7,8 +7,11 @@ import semver from 'next/dist/compiled/semver'
// @ts-ignore No typings yet
import TerserPlugin from './webpack/plugins/terser-webpack-plugin/src/index.js'
import path from 'path'
import webpack from 'webpack'
import { Configuration } from 'webpack'
import {
webpack,
isWebpack5,
init as initWebpack,
} from 'next/dist/compiled/webpack/webpack'
import {
DOT_NEXT_ALIAS,
NEXT_PROJECT_ROOT,
@@ -61,23 +64,16 @@ import { NextConfig } from '../next-server/server/config'

type ExcludesFalse = <T>(x: T | false) => x is T

const isWebpack5 = parseInt(webpack.version!) === 5

if (isWebpack5 && semver.lt(webpack.version!, '5.11.1')) {
Log.error(
`webpack 5 version must be greater than v5.11.1 to work properly with Next.js, please upgrade to continue!\nSee more info here: https://err.sh/next.js/invalid-webpack-5-version`
)
process.exit(1)
}

const devtoolRevertWarning = execOnce((devtool: Configuration['devtool']) => {
console.warn(
chalk.yellow.bold('Warning: ') +
chalk.bold(`Reverting webpack devtool to '${devtool}'.\n`) +
'Changing the webpack devtool in development mode will cause severe performance regressions.\n' +
'Read more: https://err.sh/next.js/improper-devtool'
)
})
const devtoolRevertWarning = execOnce(
(devtool: webpack.Configuration['devtool']) => {
console.warn(
chalk.yellow.bold('Warning: ') +
chalk.bold(`Reverting webpack devtool to '${devtool}'.\n`) +
'Changing the webpack devtool in development mode will cause severe performance regressions.\n' +
'Read more: https://err.sh/next.js/improper-devtool'
)
}
)

function parseJsonFile(filePath: string) {
const JSON5 = require('next/dist/compiled/json5')
@@ -208,6 +204,12 @@ export default async function getBaseWebpackConfig(
rewrites: Rewrite[]
}
): Promise<webpack.Configuration> {
initWebpack(
config.future?.webpack5 ||
(config.future?.webpack5 !== false &&
Number(process.env.NEXT_WEBPACK5) > 0)
)

let plugins: PluginMetaData[] = []
let babelPresetPlugins: { dir: string; config: any }[] = []

@@ -909,7 +911,7 @@ export default async function getBaseWebpackConfig(
].filter(Boolean),
},
plugins: [
hasReactRefresh && new ReactRefreshWebpackPlugin(),
hasReactRefresh && new ReactRefreshWebpackPlugin(webpack),
// Makes sure `Buffer` and `process` are polyfilled in client-side bundles (same behavior as webpack 4)
isWebpack5 &&
!isServer &&
@@ -1,13 +1,13 @@
import isWslBoolean from 'next/dist/compiled/is-wsl'
import curry from 'next/dist/compiled/lodash.curry'
import { Configuration } from 'webpack'
import { webpack } from 'next/dist/compiled/webpack/webpack'
import { ConfigurationContext } from '../utils'

const isWindows = process.platform === 'win32' || isWslBoolean

export const base = curry(function base(
ctx: ConfigurationContext,
config: Configuration
config: webpack.Configuration
) {
config.mode = ctx.isDevelopment ? 'development' : 'production'
config.name = ctx.isServer ? 'server' : 'client'
@@ -1,6 +1,6 @@
import curry from 'next/dist/compiled/lodash.curry'
import path from 'path'
import webpack, { Configuration } from 'webpack'
import { webpack } from 'next/dist/compiled/webpack/webpack'
import MiniCssExtractPlugin from '../../../plugins/mini-css-extract-plugin'
import { loader, plugin } from '../../helpers'
import { ConfigurationContext, ConfigurationFn, pipe } from '../../utils'
@@ -26,7 +26,7 @@ const regexSassModules = /\.module\.(scss|sass)$/

export const css = curry(async function css(
ctx: ConfigurationContext,
config: Configuration
config: webpack.Configuration
) {
const {
prependData: sassPrependData,
@@ -38,7 +38,7 @@ export const css = curry(async function css(
// First, process files with `sass-loader`: this inlines content, and
// compiles away the proprietary syntax.
{
loader: require.resolve('sass-loader'),
loader: require.resolve('next/dist/compiled/sass-loader'),
options: {
// Source maps are required so that `resolve-url-loader` can locate
// files original to their source directory.
@@ -1,4 +1,4 @@
import webpack from 'webpack'
import { webpack } from 'next/dist/compiled/webpack/webpack'
import MiniCssExtractPlugin from '../../../../plugins/mini-css-extract-plugin'

export function getClientStyleLoader({
@@ -1,6 +1,6 @@
import loaderUtils from 'loader-utils'
import path from 'path'
import webpack from 'webpack'
import { webpack } from 'next/dist/compiled/webpack/webpack'

const regexLikeIndexModule = /(?<!pages[\\/])index\.module\.(scss|sass|css)$/

@@ -1,5 +1,5 @@
import { AcceptedPlugin } from 'postcss'
import webpack from 'webpack'
import { webpack } from 'next/dist/compiled/webpack/webpack'
import { ConfigurationContext } from '../../../utils'
import { getClientStyleLoader } from './client'
import { cssFileResolve } from './file-resolve'
@@ -1,5 +1,5 @@
import { AcceptedPlugin } from 'postcss'
import webpack from 'webpack'
import { webpack } from 'next/dist/compiled/webpack/webpack'
import { ConfigurationContext } from '../../../utils'
import { getClientStyleLoader } from './client'
import { cssFileResolve } from './file-resolve'
@@ -1,14 +1,14 @@
import { Configuration, RuleSetRule } from 'webpack'
import { webpack } from 'next/dist/compiled/webpack/webpack'
import { getPostCssPlugins } from './plugins'

export async function __overrideCssConfiguration(
rootDirectory: string,
isProduction: boolean,
config: Configuration
config: webpack.Configuration
) {
const postCssPlugins = await getPostCssPlugins(rootDirectory, isProduction)

function patch(rule: RuleSetRule) {
function patch(rule: webpack.RuleSetRule) {
if (
rule.options &&
typeof rule.options === 'object' &&
@@ -1,9 +1,9 @@
import curry from 'next/dist/compiled/lodash.curry'
import { Configuration, Plugin, RuleSetRule } from 'webpack'
import { webpack } from 'next/dist/compiled/webpack/webpack'

export const loader = curry(function loader(
rule: RuleSetRule,
config: Configuration
rule: webpack.RuleSetRule,
config: webpack.Configuration
) {
if (!config.module) {
config.module = { rules: [] }
@@ -22,8 +22,8 @@ export const loader = curry(function loader(
})

export const unshiftLoader = curry(function unshiftLoader(
rule: RuleSetRule,
config: Configuration
rule: webpack.RuleSetRule,
config: webpack.Configuration
) {
if (!config.module) {
config.module = { rules: [] }
@@ -41,7 +41,10 @@ export const unshiftLoader = curry(function unshiftLoader(
return config
})

export const plugin = curry(function plugin(p: Plugin, config: Configuration) {
export const plugin = curry(function plugin(
p: webpack.Plugin,
config: webpack.Configuration
) {
if (!config.plugins) {
config.plugins = []
}
@@ -1,4 +1,4 @@
import webpack from 'webpack'
import { webpack } from 'next/dist/compiled/webpack/webpack'
import { NextConfig } from '../../../next-server/server/config'
import { base } from './blocks/base'
import { css } from './blocks/css'
@@ -1,4 +1,4 @@
import webpack from 'webpack'
import { webpack } from 'next/dist/compiled/webpack/webpack'
import { NextConfig } from '../../../next-server/server/config'

export type ConfigurationContext = {
@@ -1,9 +1,9 @@
import chalk from 'chalk'
import loaderUtils from 'loader-utils'
import path from 'path'
import { loader } from 'webpack'
import { webpack } from 'next/dist/compiled/webpack/webpack'

const ErrorLoader: loader.Loader = function () {
const ErrorLoader: webpack.loader.Loader = function () {
const options = loaderUtils.getOptions(this) || {}

const { reason = 'An unknown error has occurred' } = options
@@ -1,4 +1,4 @@
import { loader } from 'webpack'
import { webpack } from 'next/dist/compiled/webpack/webpack'
import { parse } from 'querystring'
import { PluginMetaData, getPluginId } from '../../plugins/collect-plugins'

@@ -12,7 +12,7 @@ export const pluginLoaderOptions: {
plugins: [],
}

const nextPluginLoader: loader.Loader = function () {
const nextPluginLoader: webpack.loader.Loader = function () {
const { middleware }: NextPluginLoaderQuery =
typeof this.query === 'string' ? parse(this.query.substr(1)) : this.query

@@ -2,7 +2,7 @@ import devalue from 'next/dist/compiled/devalue'
import escapeRegexp from 'next/dist/compiled/escape-string-regexp'
import { join } from 'path'
import { parse } from 'querystring'
import { loader } from 'webpack'
import { webpack } from 'next/dist/compiled/webpack/webpack'
import { API_ROUTE } from '../../../../lib/constants'
import { isDynamicRoute } from '../../../../next-server/lib/router/utils'
import { __ApiPreviewProps } from '../../../../next-server/server/api-utils'
@@ -33,7 +33,7 @@ export type ServerlessLoaderQuery = {
i18n: string
}

const nextServerlessLoader: loader.Loader = function () {
const nextServerlessLoader: webpack.loader.Loader = function () {
const span = tracer.startSpan('next-serverless-loader')
return traceFn(span, () => {
const {

0 comments on commit bddb022

Please sign in to comment.