From 7a64da1575b98a077834afca86015d8ebddea7fa Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Tue, 2 Jun 2020 16:01:36 +0200 Subject: [PATCH] Get rid of autodll --- .../build/bundles/autodll-webpack-plugin.js | 15 ---- packages/next/build/webpack-config.ts | 28 +------ .../webpack/plugins/build-manifest-plugin.ts | 7 -- packages/next/package.json | 1 - packages/next/taskfile.js | 13 +--- packages/next/types/misc.d.ts | 21 ----- yarn.lock | 76 +------------------ 7 files changed, 6 insertions(+), 155 deletions(-) delete mode 100644 packages/next/build/bundles/autodll-webpack-plugin.js diff --git a/packages/next/build/bundles/autodll-webpack-plugin.js b/packages/next/build/bundles/autodll-webpack-plugin.js deleted file mode 100644 index 1b69526998c1d..0000000000000 --- a/packages/next/build/bundles/autodll-webpack-plugin.js +++ /dev/null @@ -1,15 +0,0 @@ -/* eslint-disable import/no-extraneous-dependencies */ -const path = require('path') - -module.exports = (distDir) => { - const autodllCachePath = path.resolve( - path.join(distDir, 'cache', 'autodll-webpack-plugin') - ) - - const autoDllWebpackPluginPaths = require('autodll-webpack-plugin/lib/paths') - autoDllWebpackPluginPaths.cacheDir = autodllCachePath - autoDllWebpackPluginPaths.getManifestPath = (hash) => (bundleName) => - path.resolve(autodllCachePath, hash, `${bundleName}.manifest.json`) - - return require('autodll-webpack-plugin') -} diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts index 621a18a24a9e8..e25cc61c24e7b 100644 --- a/packages/next/build/webpack-config.ts +++ b/packages/next/build/webpack-config.ts @@ -328,13 +328,6 @@ export default async function getBaseWebpackConfig( }, } - const devtool = - process.env.__NEXT_TEST_MODE && !process.env.__NEXT_TEST_WITH_DEVTOOL - ? false - : dev - ? 'cheap-module-source-map' - : false - const isModuleCSS = (module: { type: string }): boolean => { return ( // mini-css-extract-plugin @@ -919,27 +912,8 @@ export default async function getBaseWebpackConfig( new NextJsRequireCacheHotReloader(), ] - // Webpack 5 has the ability to cache packages persistently, so we - // do not need this DLL plugin: + // Webpack 5 enables HMR automatically in the development mode if (!isServer && !isWebpack5) { - const AutoDllPlugin = require('next/dist/compiled/autodll-webpack-plugin')( - distDir - ) - devPlugins.push( - new AutoDllPlugin({ - filename: '[name]_[hash].js', - path: './static/development/dll', - context: dir, - entry: { - dll: ['react', 'react-dom'], - }, - config: { - devtool, - mode: webpackMode, - resolve: resolveConfig, - }, - }) - ) devPlugins.push(new webpack.HotModuleReplacementPlugin()) } diff --git a/packages/next/build/webpack/plugins/build-manifest-plugin.ts b/packages/next/build/webpack/plugins/build-manifest-plugin.ts index ed577e7213610..3c2fbd23c7f8b 100644 --- a/packages/next/build/webpack/plugins/build-manifest-plugin.ts +++ b/packages/next/build/webpack/plugins/build-manifest-plugin.ts @@ -85,13 +85,6 @@ export default class BuildManifestPlugin { ) assetMap.devFiles.push(...(reactRefreshChunk?.files ?? [])) - for (const filePath of Object.keys(compilation.assets)) { - const path = filePath.replace(/\\/g, '/') - if (/^static\/development\/dll\//.test(path)) { - assetMap.devFiles.push(path) - } - } - // compilation.entrypoints is a Map object, so iterating over it 0 is the key and 1 is the value for (const [, entrypoint] of compilation.entrypoints.entries()) { const result = ROUTE_NAME_REGEX.exec(entrypoint.name) diff --git a/packages/next/package.json b/packages/next/package.json index f0959a33b21fc..065319ec31b9f 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -160,7 +160,6 @@ "ast-types": "0.13.2", "async-retry": "1.2.3", "async-sema": "3.0.0", - "autodll-webpack-plugin": "0.4.2", "babel-loader": "8.1.0", "babel-plugin-dynamic-import-node": "2.3.3", "cache-loader": "4.1.0", diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index 632b2de3c1271..89f5579c0af04 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -50,7 +50,7 @@ const externals = { 'webpack/lib/cache/getLazyHashedEtag': 'webpack/lib/cache/getLazyHashedEtag', 'webpack/lib/RequestShortener': 'webpack/lib/RequestShortener', chokidar: 'chokidar', - // dependents: babel-loader, async-retry, autodll-webpack-plugin, cache-loader, terser-webpack-plugin + // dependents: babel-loader, async-retry, cache-loader, terser-webpack-plugin 'find-cache-dir': 'find-cache-dir', // dependents: thread-loader 'loader-runner': 'loader-runner', @@ -104,15 +104,7 @@ export async function ncc_async_sema(task, opts) { .ncc({ packageName: 'async-sema', externals }) .target('compiled/async-sema') } -// eslint-disable-next-line camelcase -externals['autodll-webpack-plugin'] = - 'next/dist/compiled/autodll-webpack-plugin' -export async function ncc_autodll_webpack_plugin(task, opts) { - await task - .source(opts.src || 'build/bundles/autodll-webpack-plugin.js') - .ncc({ packageName: 'autodll-webpack-plugin', externals }) - .target('compiled/autodll-webpack-plugin') -} + // eslint-disable-next-line camelcase externals['babel-loader'] = 'next/dist/compiled/babel-loader' export async function ncc_babel_loader(task, opts) { @@ -552,7 +544,6 @@ export async function ncc(task) { 'ncc_arg', 'ncc_async_retry', 'ncc_async_sema', - 'ncc_autodll_webpack_plugin', 'ncc_babel_loader', 'ncc_cache_loader', 'ncc_chalk', diff --git a/packages/next/types/misc.d.ts b/packages/next/types/misc.d.ts index d49a6a0b8cf2a..9b586d3d634fb 100644 --- a/packages/next/types/misc.d.ts +++ b/packages/next/types/misc.d.ts @@ -226,27 +226,6 @@ declare module 'next/dist/compiled/comment-json' { export = m } -declare module 'autodll-webpack-plugin' { - import webpack from 'webpack' - class AutoDllPlugin implements webpack.Plugin { - constructor(settings?: { - inject?: boolean - plugins?: webpack.Configuration['plugins'] - context?: string - debug?: boolean - filename?: string - path?: string - inherit?: boolean - entry?: webpack.Entry - config?: webpack.Configuration - }) - apply: webpack.Plugin['apply']; - [k: string]: any - } - - export = AutoDllPlugin -} - declare module 'pnp-webpack-plugin' { import webpack from 'webpack' diff --git a/yarn.lock b/yarn.lock index 7275be28376e8..34d8f3355af81 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3729,21 +3729,6 @@ atob@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" -autodll-webpack-plugin@0.4.2: - version "0.4.2" - resolved "https://registry.yarnpkg.com/autodll-webpack-plugin/-/autodll-webpack-plugin-0.4.2.tgz#36e98fbaf30c235d1d5d076330464ac80901415c" - dependencies: - bluebird "^3.5.0" - del "^3.0.0" - find-cache-dir "^1.0.0" - lodash "^4.17.4" - make-dir "^1.0.0" - memory-fs "^0.4.1" - read-pkg "^2.0.0" - tapable "^1.0.0" - webpack-merge "^4.1.0" - webpack-sources "^1.0.1" - autoprefixer@^6.3.1: version "6.7.7" resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-6.7.7.tgz#1dbd1c835658e35ce3f9984099db00585c782014" @@ -5900,17 +5885,6 @@ defined@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693" -del@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/del/-/del-3.0.0.tgz#53ecf699ffcbcb39637691ab13baf160819766e5" - dependencies: - globby "^6.1.0" - is-path-cwd "^1.0.0" - is-path-in-cwd "^1.0.0" - p-map "^1.1.1" - pify "^3.0.0" - rimraf "^2.2.8" - delayed-stream@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" @@ -7006,14 +6980,6 @@ find-cache-dir@3.3.1, find-cache-dir@^3.0.0, find-cache-dir@^3.2.0: make-dir "^3.0.2" pkg-dir "^4.1.0" -find-cache-dir@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-1.0.0.tgz#9288e3e9e3cc3748717d39eade17cf71fc30ee6f" - dependencies: - commondir "^1.0.1" - make-dir "^1.0.0" - pkg-dir "^2.0.0" - find-cache-dir@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-2.1.0.tgz#8d0f94cd13fe43c6c7c261a0d86115ca918c05f7" @@ -7556,16 +7522,6 @@ globalyzer@^0.1.0: version "0.1.4" resolved "https://registry.yarnpkg.com/globalyzer/-/globalyzer-0.1.4.tgz#bc8e273afe1ac7c24eea8def5b802340c5cc534f" -globby@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/globby/-/globby-6.1.0.tgz#f5a6d70e8395e21c858fb0489d64df02424d506c" - dependencies: - array-union "^1.0.1" - glob "^7.0.3" - object-assign "^4.0.1" - pify "^2.0.0" - pinkie-promise "^2.0.0" - globby@^8.0.1: version "8.0.2" resolved "https://registry.yarnpkg.com/globby/-/globby-8.0.2.tgz#5697619ccd95c5275dbb2d6faa42087c1a941d8d" @@ -8477,22 +8433,6 @@ is-observable@^1.1.0: dependencies: symbol-observable "^1.1.0" -is-path-cwd@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d" - -is-path-in-cwd@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-path-in-cwd/-/is-path-in-cwd-1.0.1.tgz#5ac48b345ef675339bd6c7a48a912110b241cf52" - dependencies: - is-path-inside "^1.0.0" - -is-path-inside@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.1.tgz#8ef5b7de50437a3fdca6b4e865ef7aa55cb48036" - dependencies: - path-is-inside "^1.0.1" - is-plain-obj@^1.0.0, is-plain-obj@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e" @@ -11432,7 +11372,7 @@ p-map-series@^1.0.0: dependencies: p-reduce "^1.0.0" -p-map@^1.1.1, p-map@^1.2.0: +p-map@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/p-map/-/p-map-1.2.0.tgz#e4e94f311eabbc8633a1e79908165fca26241b6b" @@ -11699,10 +11639,6 @@ path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" -path-is-inside@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" - path-key@^2.0.0, path-key@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" @@ -13879,7 +13815,7 @@ rgba-regex@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/rgba-regex/-/rgba-regex-1.0.0.tgz#43374e2e2ca0968b0ef1523460b7d730ff22eeb3" -rimraf@2, rimraf@^2.2.8, rimraf@^2.5.4, rimraf@^2.6.2, rimraf@^2.6.3, rimraf@^2.7.1: +rimraf@2, rimraf@^2.5.4, rimraf@^2.6.2, rimraf@^2.6.3, rimraf@^2.7.1: version "2.7.1" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" dependencies: @@ -16068,13 +16004,7 @@ webpack-log@^2.0.0: ansi-colors "^3.0.0" uuid "^3.3.2" -webpack-merge@^4.1.0: - version "4.2.2" - resolved "https://registry.yarnpkg.com/webpack-merge/-/webpack-merge-4.2.2.tgz#a27c52ea783d1398afd2087f547d7b9d2f43634d" - dependencies: - lodash "^4.17.15" - -webpack-sources@1.4.3, webpack-sources@^1.0.1, webpack-sources@^1.1.0, webpack-sources@^1.4.0, webpack-sources@^1.4.1, webpack-sources@^1.4.3: +webpack-sources@1.4.3, webpack-sources@^1.1.0, webpack-sources@^1.4.0, webpack-sources@^1.4.1, webpack-sources@^1.4.3: version "1.4.3" resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.4.3.tgz#eedd8ec0b928fbf1cbfe994e22d2d890f330a933" dependencies: