diff --git a/packages/next/compiled/webpack/bundle5.js b/packages/next/compiled/webpack/bundle5.js index 3a07b86d8a697..c88b374d6fa61 100644 --- a/packages/next/compiled/webpack/bundle5.js +++ b/packages/next/compiled/webpack/bundle5.js @@ -38,7 +38,7 @@ module.exports = JSON.parse("{\"application/1d-interleaved-parityfec\":{\"source /***/ (function(module) { "use strict"; -module.exports = {"i8":"5.64.3"}; +module.exports = {"i8":"5.64.4"}; /***/ }), @@ -63809,7 +63809,20 @@ class IgnoringWatchFileSystem { fileTimestamps.set(path, IGNORE_TIME_ENTRY); } return fileTimestamps; - } + }, + getInfo: + watcher.getInfo && + (() => { + const info = watcher.getInfo(); + const { fileTimeInfoEntries, contextTimeInfoEntries } = info; + for (const path of ignoredFiles) { + fileTimeInfoEntries.set(path, IGNORE_TIME_ENTRY); + } + for (const path of ignoredDirs) { + contextTimeInfoEntries.set(path, IGNORE_TIME_ENTRY); + } + return info; + }) }; } } @@ -63958,30 +63971,44 @@ class Watching { this.lastWatcherStartTime = Date.now(); } this.compiler.fsStartTime = Date.now(); - this._mergeWithCollected( - changedFiles || - (this.pausedWatcher && + if ( + changedFiles && + removedFiles && + fileTimeInfoEntries && + contextTimeInfoEntries + ) { + this._mergeWithCollected(changedFiles, removedFiles); + this.compiler.fileTimestamps = fileTimeInfoEntries; + this.compiler.contextTimestamps = contextTimeInfoEntries; + } else if (this.pausedWatcher) { + if (this.pausedWatcher.getInfo) { + const { + changes, + removals, + fileTimeInfoEntries, + contextTimeInfoEntries + } = this.pausedWatcher.getInfo(); + this._mergeWithCollected(changes, removals); + this.compiler.fileTimestamps = fileTimeInfoEntries; + this.compiler.contextTimestamps = contextTimeInfoEntries; + } else { + this._mergeWithCollected( this.pausedWatcher.getAggregatedChanges && - this.pausedWatcher.getAggregatedChanges()), - (this.compiler.removedFiles = - removedFiles || - (this.pausedWatcher && + this.pausedWatcher.getAggregatedChanges(), this.pausedWatcher.getAggregatedRemovals && - this.pausedWatcher.getAggregatedRemovals())) - ); - + this.pausedWatcher.getAggregatedRemovals() + ); + this.compiler.fileTimestamps = + this.pausedWatcher.getFileTimeInfoEntries(); + this.compiler.contextTimestamps = + this.pausedWatcher.getContextTimeInfoEntries(); + } + } this.compiler.modifiedFiles = this._collectedChangedFiles; this._collectedChangedFiles = undefined; this.compiler.removedFiles = this._collectedRemovedFiles; this._collectedRemovedFiles = undefined; - this.compiler.fileTimestamps = - fileTimeInfoEntries || - (this.pausedWatcher && this.pausedWatcher.getFileTimeInfoEntries()); - this.compiler.contextTimestamps = - contextTimeInfoEntries || - (this.pausedWatcher && this.pausedWatcher.getContextTimeInfoEntries()); - const run = () => { if (this.compiler.idle) { return this.compiler.cache.endIdle(err => { @@ -73007,6 +73034,7 @@ const AsyncDependenciesBlock = __webpack_require__(11315); const Module = __webpack_require__(85887); const RuntimeGlobals = __webpack_require__(49404); const Template = __webpack_require__(92066); +const StaticExportsDependency = __webpack_require__(67967); const makeSerializable = __webpack_require__(26522); const ContainerExposedDependency = __webpack_require__(50); @@ -73101,6 +73129,7 @@ class ContainerEntryModule extends Module { strict: true, topLevelDeclarations: new Set(["moduleMap", "get", "init"]) }; + this.buildMeta.exportsType = "namespace"; this.clearDependenciesAndBlocks(); @@ -73124,6 +73153,7 @@ class ContainerEntryModule extends Module { } this.addBlock(block); } + this.addDependency(new StaticExportsDependency(["get", "init"], false)); callback(); } @@ -88858,18 +88888,16 @@ module.exports = ExportWebpackRequireRuntimeModule; -const { ConcatSource, RawSource } = __webpack_require__(96192); +const { ConcatSource } = __webpack_require__(96192); const { RuntimeGlobals } = __webpack_require__(48169); const HotUpdateChunk = __webpack_require__(39222); const Template = __webpack_require__(92066); +const { getAllChunks } = __webpack_require__(8272); const { getCompilationHooks, getChunkFilenameTemplate } = __webpack_require__(76767); -const { - generateEntryStartup, - updateHashForEntryStartup -} = __webpack_require__(30951); +const { updateHashForEntryStartup } = __webpack_require__(30951); /** @typedef {import("../Compiler")} Compiler */ @@ -88937,63 +88965,90 @@ class ModuleChunkFormatPlugin { } ) .split("/"); - const runtimeOutputName = compilation - .getPath( - getChunkFilenameTemplate( - runtimeChunk, - compilation.outputOptions - ), - { - chunk: runtimeChunk, - contentHashType: "javascript" - } - ) - .split("/"); // remove filename, we only need the directory - const outputFilename = currentOutputName.pop(); + currentOutputName.pop(); - // remove common parts - while ( - currentOutputName.length > 0 && - runtimeOutputName.length > 0 && - currentOutputName[0] === runtimeOutputName[0] - ) { - currentOutputName.shift(); - runtimeOutputName.shift(); - } + const getRelativePath = chunk => { + const baseOutputName = currentOutputName.slice(); + const chunkOutputName = compilation + .getPath( + getChunkFilenameTemplate( + chunk, + compilation.outputOptions + ), + { + chunk: chunk, + contentHashType: "javascript" + } + ) + .split("/"); - // create final path - const runtimePath = - (currentOutputName.length > 0 - ? "../".repeat(currentOutputName.length) - : "./") + runtimeOutputName.join("/"); + // remove common parts + while ( + baseOutputName.length > 0 && + chunkOutputName.length > 0 && + baseOutputName[0] === chunkOutputName[0] + ) { + baseOutputName.shift(); + chunkOutputName.shift(); + } + // create final path + return ( + (baseOutputName.length > 0 + ? "../".repeat(baseOutputName.length) + : "./") + chunkOutputName.join("/") + ); + }; const entrySource = new ConcatSource(); entrySource.add(source); entrySource.add(";\n\n// load runtime\n"); entrySource.add( `import __webpack_require__ from ${JSON.stringify( - runtimePath + getRelativePath(runtimeChunk) )};\n` ); - entrySource.add( - `import * as __webpack_self_exports__ from ${JSON.stringify( - "./" + outputFilename - )};\n` - ); - entrySource.add( - `${RuntimeGlobals.externalInstallChunk}(__webpack_self_exports__);\n` - ); - const startupSource = new RawSource( - generateEntryStartup( - chunkGraph, - runtimeTemplate, - entries, - chunk, - false - ) + + const startupSource = new ConcatSource(); + startupSource.add( + `var __webpack_exec__ = ${runtimeTemplate.returningFunction( + `__webpack_require__(${RuntimeGlobals.entryModuleId} = moduleId)`, + "moduleId" + )}\n` ); + + const loadedChunks = new Set(); + let index = 0; + for (let i = 0; i < entries.length; i++) { + const [module, entrypoint] = entries[i]; + const final = i + 1 === entries.length; + const moduleId = chunkGraph.getModuleId(module); + const chunks = getAllChunks( + entrypoint, + runtimeChunk, + undefined + ); + for (const chunk of chunks) { + if (loadedChunks.has(chunk)) continue; + loadedChunks.add(chunk); + startupSource.add( + `import * as __webpack_chunk_${index}__ from ${JSON.stringify( + getRelativePath(chunk) + )};\n` + ); + startupSource.add( + `${RuntimeGlobals.externalInstallChunk}(__webpack_chunk_${index}__);\n` + ); + index++; + } + startupSource.add( + `${ + final ? "var __webpack_exports__ = " : "" + }__webpack_exec__(${JSON.stringify(moduleId)});\n` + ); + } + entrySource.add( hooks.renderStartup.call( startupSource, @@ -92557,6 +92612,47 @@ BasicEvaluatedExpression.isValidRegExpFlags = flags => { module.exports = BasicEvaluatedExpression; +/***/ }), + +/***/ 8272: +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + +"use strict"; +/* + MIT License http://www.opensource.org/licenses/mit-license.php + Author Tobias Koppers @sokra +*/ + + + +const Entrypoint = __webpack_require__(86695); + +/** @typedef {import("../Chunk")} Chunk */ + +/** + * @param {Entrypoint} entrypoint a chunk group + * @param {Chunk} excludedChunk1 current chunk which is excluded + * @param {Chunk} excludedChunk2 runtime chunk which is excluded + * @returns {Set} chunks + */ +const getAllChunks = (entrypoint, excludedChunk1, excludedChunk2) => { + const queue = new Set([entrypoint]); + const chunks = new Set(); + for (const entrypoint of queue) { + for (const chunk of entrypoint.chunks) { + if (chunk === excludedChunk1) continue; + if (chunk === excludedChunk2) continue; + chunks.add(chunk); + } + for (const parent of entrypoint.parentsIterable) { + if (parent instanceof Entrypoint) queue.add(parent); + } + } + return chunks; +}; +exports.getAllChunks = getAllChunks; + + /***/ }), /***/ 57634: @@ -95645,14 +95741,15 @@ class JavascriptParser extends Parser { const node = /** @type {TaggedTemplateExpressionNode} */ (_node); const tag = this.evaluateExpression(node.tag); - if (tag.isIdentifier() && tag.identifier !== "String.raw") return; - const { quasis, parts } = getSimplifiedTemplateResult( - "raw", - node.quasi - ); - return new BasicEvaluatedExpression() - .setTemplateString(quasis, parts, "raw") - .setRange(node.range); + if (tag.isIdentifier() && tag.identifier === "String.raw") { + const { quasis, parts } = getSimplifiedTemplateResult( + "raw", + node.quasi + ); + return new BasicEvaluatedExpression() + .setTemplateString(quasis, parts, "raw") + .setRange(node.range); + } }); this.hooks.evaluateCallExpressionMember @@ -98352,10 +98449,10 @@ exports.approve = () => true; -const Entrypoint = __webpack_require__(86695); const RuntimeGlobals = __webpack_require__(49404); const Template = __webpack_require__(92066); const { isSubset } = __webpack_require__(34715); +const { getAllChunks } = __webpack_require__(8272); const { chunkHasJs } = __webpack_require__(76767); /** @typedef {import("../util/Hash")} Hash */ @@ -98366,30 +98463,6 @@ const { chunkHasJs } = __webpack_require__(76767); /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */ /** @typedef {(string|number)[]} EntryItem */ -// TODO move to this file to ../javascript/ChunkHelpers.js - -/** - * @param {Entrypoint} entrypoint a chunk group - * @param {Chunk} excludedChunk1 current chunk which is excluded - * @param {Chunk} excludedChunk2 runtime chunk which is excluded - * @returns {Set} chunks - */ -const getAllChunks = (entrypoint, excludedChunk1, excludedChunk2) => { - const queue = new Set([entrypoint]); - const chunks = new Set(); - for (const entrypoint of queue) { - for (const chunk of entrypoint.chunks) { - if (chunk === excludedChunk1) continue; - if (chunk === excludedChunk2) continue; - chunks.add(chunk); - } - for (const parent of entrypoint.parentsIterable) { - if (parent instanceof Entrypoint) queue.add(parent); - } - } - return chunks; -}; - const EXPORT_PREFIX = "var __webpack_exports__ = "; /** @@ -101701,6 +101774,7 @@ module.exports = NodeTemplatePlugin; +const util = __webpack_require__(31669); const Watchpack = __webpack_require__(29149); /** @typedef {import("../../declarations/WebpackOptions").WatchOptions} WatchOptions */ @@ -101764,7 +101838,22 @@ class NodeWatchFileSystem { if (callbackUndelayed) { this.watcher.once("change", callbackUndelayed); } + + const fetchTimeInfo = () => { + const fileTimeInfoEntries = new Map(); + const contextTimeInfoEntries = new Map(); + if (this.watcher) { + this.watcher.collectTimeInfoEntries( + fileTimeInfoEntries, + contextTimeInfoEntries + ); + } + return { fileTimeInfoEntries, contextTimeInfoEntries }; + }; this.watcher.once("aggregated", (changes, removals) => { + // pause emitting events (avoids clearing aggregated changes and removals on timeout) + this.watcher.pause(); + if (this.inputFileSystem && this.inputFileSystem.purge) { const fs = this.inputFileSystem; for (const item of changes) { @@ -101774,8 +101863,14 @@ class NodeWatchFileSystem { fs.purge(item); } } - const times = this.watcher.getTimeInfoEntries(); - callback(null, times, times, changes, removals); + const { fileTimeInfoEntries, contextTimeInfoEntries } = fetchTimeInfo(); + callback( + null, + fileTimeInfoEntries, + contextTimeInfoEntries, + changes, + removals + ); }); this.watcher.watch({ files, directories, missing, startTime }); @@ -101795,39 +101890,71 @@ class NodeWatchFileSystem { this.watcher.pause(); } }, - getAggregatedRemovals: () => { - const items = this.watcher && this.watcher.aggregatedRemovals; - if (items && this.inputFileSystem && this.inputFileSystem.purge) { - const fs = this.inputFileSystem; - for (const item of items) { - fs.purge(item); + getAggregatedRemovals: util.deprecate( + () => { + const items = this.watcher && this.watcher.aggregatedRemovals; + if (items && this.inputFileSystem && this.inputFileSystem.purge) { + const fs = this.inputFileSystem; + for (const item of items) { + fs.purge(item); + } } - } - return items; - }, - getAggregatedChanges: () => { - const items = this.watcher && this.watcher.aggregatedChanges; - if (items && this.inputFileSystem && this.inputFileSystem.purge) { + return items; + }, + "Watcher.getAggregatedRemovals is deprecated in favor of Watcher.getInfo since that's more performant.", + "DEP_WEBPACK_WATCHER_GET_AGGREGATED_REMOVALS" + ), + getAggregatedChanges: util.deprecate( + () => { + const items = this.watcher && this.watcher.aggregatedChanges; + if (items && this.inputFileSystem && this.inputFileSystem.purge) { + const fs = this.inputFileSystem; + for (const item of items) { + fs.purge(item); + } + } + return items; + }, + "Watcher.getAggregatedChanges is deprecated in favor of Watcher.getInfo since that's more performant.", + "DEP_WEBPACK_WATCHER_GET_AGGREGATED_CHANGES" + ), + getFileTimeInfoEntries: util.deprecate( + () => { + return fetchTimeInfo().fileTimeInfoEntries; + }, + "Watcher.getFileTimeInfoEntries is deprecated in favor of Watcher.getInfo since that's more performant.", + "DEP_WEBPACK_WATCHER_FILE_TIME_INFO_ENTRIES" + ), + getContextTimeInfoEntries: util.deprecate( + () => { + return fetchTimeInfo().contextTimeInfoEntries; + }, + "Watcher.getContextTimeInfoEntries is deprecated in favor of Watcher.getInfo since that's more performant.", + "DEP_WEBPACK_WATCHER_CONTEXT_TIME_INFO_ENTRIES" + ), + getInfo: () => { + const removals = this.watcher && this.watcher.aggregatedRemovals; + const changes = this.watcher && this.watcher.aggregatedChanges; + if (this.inputFileSystem && this.inputFileSystem.purge) { const fs = this.inputFileSystem; - for (const item of items) { - fs.purge(item); + if (removals) { + for (const item of removals) { + fs.purge(item); + } + } + if (changes) { + for (const item of changes) { + fs.purge(item); + } } } - return items; - }, - getFileTimeInfoEntries: () => { - if (this.watcher) { - return this.watcher.getTimeInfoEntries(); - } else { - return new Map(); - } - }, - getContextTimeInfoEntries: () => { - if (this.watcher) { - return this.watcher.getTimeInfoEntries(); - } else { - return new Map(); - } + const { fileTimeInfoEntries, contextTimeInfoEntries } = fetchTimeInfo(); + return { + changes, + removals, + fileTimeInfoEntries, + contextTimeInfoEntries + }; } }; } @@ -118312,9 +118439,9 @@ class ConsumeSharedRuntimeModule extends RuntimeModule { ] )};`, `var getInvalidSingletonVersionMessage = ${runtimeTemplate.basicFunction( - "key, version, requiredVersion", + "scope, key, version, requiredVersion", [ - `return "Unsatisfied version " + version + " of shared singleton module " + key + " (required " + rangeToString(requiredVersion) + ")"` + `return "Unsatisfied version " + version + " from " + (version && scope[key][version].from) + " of shared singleton module " + key + " (required " + rangeToString(requiredVersion) + ")"` ] )};`, `var getSingletonVersion = ${runtimeTemplate.basicFunction( @@ -118322,7 +118449,7 @@ class ConsumeSharedRuntimeModule extends RuntimeModule { [ "var version = findSingletonVersionKey(scope, key);", "if (!satisfy(requiredVersion, version)) " + - 'typeof console !== "undefined" && console.warn && console.warn(getInvalidSingletonVersionMessage(key, version, requiredVersion));', + 'typeof console !== "undefined" && console.warn && console.warn(getInvalidSingletonVersionMessage(scope, key, version, requiredVersion));', "return get(scope[key][version]);" ] )};`, @@ -118331,7 +118458,7 @@ class ConsumeSharedRuntimeModule extends RuntimeModule { [ "var version = findSingletonVersionKey(scope, key);", "if (!satisfy(requiredVersion, version)) " + - "throw new Error(getInvalidSingletonVersionMessage(key, version, requiredVersion));", + "throw new Error(getInvalidSingletonVersionMessage(scope, key, version, requiredVersion));", "return get(scope[key][version]);" ] )};`, @@ -129220,6 +129347,15 @@ const path = __webpack_require__(85622); /** @typedef {function((NodeJS.ErrnoException | Error | null)=, any=): void} ReadJsonCallback */ /** @typedef {function((NodeJS.ErrnoException | Error | null)=, IStats|string=): void} LstatReadlinkAbsoluteCallback */ +/** + * @typedef {Object} WatcherInfo + * @property {Set} changes get current aggregated changes that have not yet send to callback + * @property {Set} removals get current aggregated removals that have not yet send to callback + * @property {Map} fileTimeInfoEntries get info about files + * @property {Map} contextTimeInfoEntries get info about directories + */ + +// TODO webpack 6 deprecate missing getInfo /** * @typedef {Object} Watcher * @property {function(): void} close closes the watcher and all underlying file watchers @@ -129228,6 +129364,7 @@ const path = __webpack_require__(85622); * @property {function(): Set=} getAggregatedRemovals get current aggregated removals that have not yet send to callback * @property {function(): Map} getFileTimeInfoEntries get info about files * @property {function(): Map} getContextTimeInfoEntries get info about directories + * @property {function(): WatcherInfo=} getInfo get info about timestamps and changes */ /** diff --git a/packages/next/package.json b/packages/next/package.json index c2d903e3b0403..5dad4ecb4cd02 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -267,7 +267,7 @@ "webpack-sources1": "npm:webpack-sources@1.4.3", "webpack-sources3": "npm:webpack-sources@3.2.2", "webpack4": "npm:webpack@4.44.1", - "webpack5": "npm:webpack@5.64.3", + "webpack5": "npm:webpack@5.64.4", "ws": "8.2.3" }, "resolutions": { diff --git a/yarn.lock b/yarn.lock index e585904f107cf..3308677139458 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19884,7 +19884,7 @@ watchpack-chokidar2@^2.0.0: dependencies: chokidar "^2.1.8" -watchpack@2.3.0, watchpack@^2.2.0: +watchpack@2.3.0, watchpack@^2.2.0, watchpack@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.3.0.tgz#a41bca3da6afaff31e92a433f4c856a0c25ea0c4" integrity sha512-MnN0Q1OsvB/GGHETrFeZPQaOelWh/7O+EiFlj8sM9GPjtQkis7k01aAxrg/18kTfoIVcLL+haEVFlXDaSRwKRw== @@ -20020,10 +20020,10 @@ webpack-sources@^3.2.2: watchpack "^1.7.4" webpack-sources "^1.4.1" -"webpack5@npm:webpack@5.64.3": - version "5.64.3" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.64.3.tgz#f4792cc3f8528db2c18375fa2cd269f69e0bf69f" - integrity sha512-XF6/IL9Bw2PPQioiR1UYA8Bs4tX3QXJtSelezKECdLFeSFzWoe44zqTzPW5N+xI3fACaRl2/G3sNA4WYHD7Iww== +"webpack5@npm:webpack@5.64.4": + version "5.64.4" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.64.4.tgz#e1454b6a13009f57cc2c78e08416cd674622937b" + integrity sha512-LWhqfKjCLoYJLKJY8wk2C3h77i8VyHowG3qYNZiIqD6D0ZS40439S/KVuc/PY48jp2yQmy0mhMknq8cys4jFMw== dependencies: "@types/eslint-scope" "^3.7.0" "@types/estree" "^0.0.50" @@ -20047,7 +20047,7 @@ webpack-sources@^3.2.2: schema-utils "^3.1.0" tapable "^2.1.1" terser-webpack-plugin "^5.1.3" - watchpack "^2.2.0" + watchpack "^2.3.0" webpack-sources "^3.2.2" "webpack@link:./node_modules/webpack5":