Get rid of autodll (#13669)

Prepares for the upgrade to webpack 5
This commit is contained in:
Tim Neutkens 2020-06-02 21:20:37 +02:00 committed by GitHub
parent 7f6c6f0316
commit 08e7fa16db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 6 additions and 178 deletions

View file

@ -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')
}

View file

@ -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
@ -897,27 +890,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())
}

View file

@ -79,13 +79,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)

View file

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2017 Asaf Katz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

File diff suppressed because one or more lines are too long

View file

@ -1 +0,0 @@
{"name":"autodll-webpack-plugin","main":"autodll-webpack-plugin.js","author":"Asaf Katz","license":"MIT"}

View file

@ -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",

View file

@ -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',

View file

@ -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'

View file

@ -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: