diff --git a/declarations/WebpackOptions.d.ts b/declarations/WebpackOptions.d.ts index a6e8f7739..56058b1c7 100644 --- a/declarations/WebpackOptions.d.ts +++ b/declarations/WebpackOptions.d.ts @@ -730,10 +730,6 @@ export interface ResolveOptions { * Enforce using one of the extensions from the extensions option */ enforceExtension?: boolean; - /** - * Enforce using one of the module extensions from the moduleExtensions option - */ - enforceModuleExtension?: boolean; /** * Extensions added to the request when trying to find the file */ @@ -752,10 +748,6 @@ export interface ResolveOptions { * Filenames used to find the default entry point if there is no description file or main field */ mainFiles?: ArrayOfStringValues; - /** - * Extensions added to the module request when trying to find the module - */ - moduleExtensions?: ArrayOfStringValues; /** * Folder names or directory paths where to find modules */ diff --git a/lib/Compilation.js b/lib/Compilation.js index 96f2a69cc..0330973c9 100644 --- a/lib/Compilation.js +++ b/lib/Compilation.js @@ -2259,16 +2259,6 @@ class Compilation { addAllToSet(this.missingDependencies, missingDependencies); } } - - for (const error of this.errors) { - if ( - typeof error.missing === "object" && - error.missing && - error.missing[Symbol.iterator] - ) { - addAllToSet(this.missingDependencies, error.missing); - } - } } createModuleHashes() { diff --git a/lib/ContextModuleFactory.js b/lib/ContextModuleFactory.js index c768a144b..db71a9b07 100644 --- a/lib/ContextModuleFactory.js +++ b/lib/ContextModuleFactory.js @@ -59,10 +59,22 @@ module.exports = class ContextModuleFactory extends ModuleFactory { ...dependency.options }, (err, beforeResolveResult) => { - if (err) return callback(err); + if (err) { + return callback(err, { + fileDependencies, + missingDependencies, + contextDependencies + }); + } // Ignored - if (!beforeResolveResult) return callback(); + if (!beforeResolveResult) { + return callback(null, { + fileDependencies, + missingDependencies, + contextDependencies + }); + } const context = beforeResolveResult.context; const request = beforeResolveResult.request; @@ -113,7 +125,11 @@ module.exports = class ContextModuleFactory extends ModuleFactory { {}, context, resource, - {}, + { + fileDependencies, + missingDependencies, + contextDependencies + }, (err, result) => { if (err) return callback(err); callback(null, result); @@ -128,7 +144,11 @@ module.exports = class ContextModuleFactory extends ModuleFactory { {}, context, loader, - {}, + { + fileDependencies, + missingDependencies, + contextDependencies + }, (err, result) => { if (err) return callback(err); callback(null, result); @@ -140,7 +160,13 @@ module.exports = class ContextModuleFactory extends ModuleFactory { } ], (err, result) => { - if (err) return callback(err); + if (err) { + return callback(err, { + fileDependencies, + missingDependencies, + contextDependencies + }); + } this.hooks.afterResolve.callAsync( { @@ -153,10 +179,22 @@ module.exports = class ContextModuleFactory extends ModuleFactory { ...beforeResolveResult }, (err, result) => { - if (err) return callback(err); + if (err) { + return callback(err, { + fileDependencies, + missingDependencies, + contextDependencies + }); + } // Ignored - if (!result) return callback(); + if (!result) { + return callback(null, { + fileDependencies, + missingDependencies, + contextDependencies + }); + } return callback(null, { module: new ContextModule(result.resolveDependencies, result), @@ -185,6 +223,7 @@ module.exports = class ContextModuleFactory extends ModuleFactory { const addDirectory = (directory, callback) => { fs.readdir(directory, (err, files) => { if (err) return callback(err); + files = files.map(file => file.normalize("NFC")); files = cmf.hooks.contextModuleFiles.call(files); if (!files || files.length === 0) return callback(null, []); asyncLib.map( diff --git a/lib/MemoryOutputFileSystem.js b/lib/MemoryOutputFileSystem.js deleted file mode 100644 index 6d63a8497..000000000 --- a/lib/MemoryOutputFileSystem.js +++ /dev/null @@ -1,8 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Author Tobias Koppers @sokra -*/ - -"use strict"; - -module.exports = require("memory-fs"); diff --git a/lib/ModuleNotFoundError.js b/lib/ModuleNotFoundError.js index 958f793d5..d043b52a7 100644 --- a/lib/ModuleNotFoundError.js +++ b/lib/ModuleNotFoundError.js @@ -80,7 +80,6 @@ class ModuleNotFoundError extends WebpackError { this.name = "ModuleNotFoundError"; this.details = err.details; - this.missing = err.missing; this.module = module; this.error = err; this.loc = loc; diff --git a/lib/NormalModuleFactory.js b/lib/NormalModuleFactory.js index 0e43a7d4e..9b07fc179 100644 --- a/lib/NormalModuleFactory.js +++ b/lib/NormalModuleFactory.js @@ -274,7 +274,6 @@ class NormalModuleFactory extends ModuleFactory { const resolveContext = { fileDependencies, - missing: missingDependencies, missingDependencies, contextDependencies }; @@ -473,12 +472,6 @@ class NormalModuleFactory extends ModuleFactory { resolveContext, (err, resolvedResource, resolvedResourceResolveData) => { if (err) return continueCallback(err); - - // TODO remove this when enhanced-resolve supports fileDependencies - if (resolvedResource) { - fileDependencies.add(resolvedResource); - } - resource = resolvedResource; resourceResolveData = resolvedResourceResolveData; continueCallback(); @@ -520,16 +513,34 @@ class NormalModuleFactory extends ModuleFactory { createData: {} }; this.hooks.beforeResolve.callAsync(resolveData, (err, result) => { - if (err) return callback(err); + if (err) { + return callback(err, { + fileDependencies, + missingDependencies, + contextDependencies + }); + } // Ignored - if (result === false) return callback(); + if (result === false) { + return callback(null, { + fileDependencies, + missingDependencies, + contextDependencies + }); + } if (typeof result === "object") throw new Error(deprecationChangedHookMessage("beforeResolve")); this.hooks.factorize.callAsync(resolveData, (err, module) => { - if (err) return callback(err); + if (err) { + return callback(err, { + fileDependencies, + missingDependencies, + contextDependencies + }); + } const factoryResult = { module, @@ -601,12 +612,6 @@ class NormalModuleFactory extends ModuleFactory { : item.options, ident: item.options === undefined ? undefined : item.ident }; - - // TODO remove this when enhanced-resolve supports fileDependencies - if (resolved.loader) { - resolveContext.fileDependencies.add(resolved.loader); - } - return callback(null, resolved); } ); diff --git a/lib/WebpackError.js b/lib/WebpackError.js index 434bd9741..040d67b9a 100644 --- a/lib/WebpackError.js +++ b/lib/WebpackError.js @@ -20,7 +20,6 @@ class WebpackError extends Error { super(message); this.details = undefined; - this.missing = undefined; this.module = undefined; /** @type {DependencyLocation} */ this.loc = undefined; @@ -43,7 +42,6 @@ class WebpackError extends Error { write(this.message); write(this.stack); write(this.details); - write(this.missing); write(this.loc); write(this.hideStack); } @@ -53,7 +51,6 @@ class WebpackError extends Error { this.message = read(); this.stack = read(); this.details = read(); - this.missing = read(); this.loc = read(); this.hideStack = read(); } diff --git a/lib/cache/ResolverCachePlugin.js b/lib/cache/ResolverCachePlugin.js index baea82922..a92edbc9b 100644 --- a/lib/cache/ResolverCachePlugin.js +++ b/lib/cache/ResolverCachePlugin.js @@ -49,7 +49,7 @@ class ResolverCachePlugin { const newResolveContext = { ...resolveContext, stack: new Set(), - missing: new Set(), + missingDependencies: new Set(), fileDependencies: new Set(), contextDependencies: new Set() }; @@ -67,13 +67,13 @@ class ResolverCachePlugin { "Cache miss", newResolveContext, (err, result) => { - propagate("missing"); propagate("fileDependencies"); propagate("contextDependencies"); + propagate("missingDependencies"); if (err) return callback(err); const fileDependencies = newResolveContext.fileDependencies; const contextDependencies = newResolveContext.contextDependencies; - const missingDependencies = newResolveContext.missing; + const missingDependencies = newResolveContext.missingDependencies; // TODO remove this when enhanced-resolve supports fileDependencies if (result && result.path) { fileDependencies.add(result.path); @@ -91,9 +91,9 @@ class ResolverCachePlugin { null, { result, - missing: newResolveContext.missing, fileDependencies: newResolveContext.fileDependencies, contextDependencies: newResolveContext.contextDependencies, + missingDependencies: newResolveContext.missingDependencies, snapshot }, storeErr => { @@ -147,9 +147,9 @@ class ResolverCachePlugin { callback ); } - if (resolveContext.missing) { - for (const item of cacheEntry.missing) { - resolveContext.missing.add(item); + if (resolveContext.missingDependencies) { + for (const item of cacheEntry.missingDependencies) { + resolveContext.missingDependencies.add(item); } } if (resolveContext.fileDependencies) { diff --git a/lib/index.js b/lib/index.js index 35bff48cb..2a322d128 100644 --- a/lib/index.js +++ b/lib/index.js @@ -56,7 +56,6 @@ exportPlugins(exports, { LibraryTemplatePlugin: () => require("./LibraryTemplatePlugin"), LoaderOptionsPlugin: () => require("./LoaderOptionsPlugin"), LoaderTargetPlugin: () => require("./LoaderTargetPlugin"), - MemoryOutputFileSystem: () => require("./MemoryOutputFileSystem"), Module: () => require("./Module"), ModuleFilenameHelpers: () => require("./ModuleFilenameHelpers"), NoEmitOnErrorsPlugin: () => require("./NoEmitOnErrorsPlugin"), diff --git a/lib/node/NodeEnvironmentPlugin.js b/lib/node/NodeEnvironmentPlugin.js index ba1d7e3cc..6bcd02748 100644 --- a/lib/node/NodeEnvironmentPlugin.js +++ b/lib/node/NodeEnvironmentPlugin.js @@ -6,7 +6,6 @@ "use strict"; const CachedInputFileSystem = require("enhanced-resolve/lib/CachedInputFileSystem"); -const NodeJsInputFileSystem = require("enhanced-resolve/lib/NodeJsInputFileSystem"); const fs = require("graceful-fs"); const NodeWatchFileSystem = require("./NodeWatchFileSystem"); @@ -18,10 +17,7 @@ class NodeEnvironmentPlugin { * @returns {void} */ apply(compiler) { - compiler.inputFileSystem = new CachedInputFileSystem( - new NodeJsInputFileSystem(), - 60000 - ); + compiler.inputFileSystem = new CachedInputFileSystem(fs, 60000); const inputFileSystem = compiler.inputFileSystem; compiler.outputFileSystem = fs; compiler.intermediateFileSystem = fs; diff --git a/lib/stats/DefaultStatsFactoryPlugin.js b/lib/stats/DefaultStatsFactoryPlugin.js index 1ad15f38f..6a433e0d3 100644 --- a/lib/stats/DefaultStatsFactoryPlugin.js +++ b/lib/stats/DefaultStatsFactoryPlugin.js @@ -135,7 +135,6 @@ const EXTRACT_ERROR = { if (typeof error !== "string") { object.details = error.details; object.stack = error.stack; - object.missing = error.missing; } } }; diff --git a/lib/stats/DefaultStatsPrinterPlugin.js b/lib/stats/DefaultStatsPrinterPlugin.js index 7859effb9..61ab1bf0b 100644 --- a/lib/stats/DefaultStatsPrinterPlugin.js +++ b/lib/stats/DefaultStatsPrinterPlugin.js @@ -393,7 +393,6 @@ const SIMPLE_PRINTERS = { "error.message": (message, { bold }) => bold(message), "error.details": details => details, "error.stack": stack => stack, - "error.missing[]": missing => `[${missing}]`, "error.moduleTrace": moduleTrace => undefined, "error.separator!": () => "\n", diff --git a/package.json b/package.json index 35922e953..754316520 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "ajv": "^6.1.0", "ajv-keywords": "^3.1.0", "chrome-trace-event": "^1.0.0", - "enhanced-resolve": "^4.1.0", + "enhanced-resolve": "5.0.0-beta.0", "eslint-scope": "^4.0.0", "events": "^3.0.0", "find-cache-dir": "^2.1.0", @@ -23,12 +23,11 @@ "json-parse-better-errors": "^1.0.2", "loader-runner": "3.0.0", "loader-utils": "^1.1.0", - "memory-fs": "~0.4.1", "neo-async": "^2.6.0", "schema-utils": "^1.0.0", "tapable": "2.0.0-beta.5", "terser-webpack-plugin": "^1.2.1", - "watchpack": "2.0.0-beta.5", + "watchpack": "2.0.0-beta.6", "webpack-sources": "2.0.0-beta.1" }, "devDependencies": { @@ -58,6 +57,7 @@ "less-loader": "^4.0.3", "lint-staged": "^8.0.4", "lodash": "^4.17.4", + "memory-fs": "~0.4.1", "mkdirp": "^0.5.1", "prettier": "^1.14.3", "pretty-format": "24.0.0", diff --git a/schemas/WebpackOptions.json b/schemas/WebpackOptions.json index 8e7ca1286..72ead08bc 100644 --- a/schemas/WebpackOptions.json +++ b/schemas/WebpackOptions.json @@ -1310,10 +1310,6 @@ "description": "Enforce using one of the extensions from the extensions option", "type": "boolean" }, - "enforceModuleExtension": { - "description": "Enforce using one of the module extensions from the moduleExtensions option", - "type": "boolean" - }, "extensions": { "description": "Extensions added to the request when trying to find the file", "anyOf": [ @@ -1341,14 +1337,6 @@ } ] }, - "moduleExtensions": { - "description": "Extensions added to the module request when trying to find the module", - "anyOf": [ - { - "$ref": "#/definitions/ArrayOfStringValues" - } - ] - }, "modules": { "description": "Folder names or directory paths where to find modules", "anyOf": [ diff --git a/yarn.lock b/yarn.lock index ff6aa9bfc..d793e2eb5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1596,14 +1596,13 @@ end-of-stream@^1.0.0, end-of-stream@^1.1.0: dependencies: once "^1.4.0" -enhanced-resolve@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-4.1.0.tgz#41c7e0bfdfe74ac1ffe1e57ad6a5c6c9f3742a7f" - integrity sha512-F/7vkyTtyc/llOIn8oWclcB25KdRaiPBpZYDgJHgh/UHtpgT2p2eldQgtQnLtUvfMKPKxbRaQM/hHkvLHt1Vng== +enhanced-resolve@5.0.0-beta.0: + version "5.0.0-beta.0" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.0.0-beta.0.tgz#7635594f4f38a515ba3a5a93498556828964d3ac" + integrity sha512-s0jFC1SvF64ZDMdJfkSATGvQPaXjOq49PJHEvodqUiY7pCMRzHjfQgTkTM+Nxpg29ym9ASjEPSiHqo1trqvVEA== dependencies: - graceful-fs "^4.1.2" - memory-fs "^0.4.0" - tapable "^1.0.0" + graceful-fs "^4.2.0" + tapable "^2.0.0-beta" errno@^0.1.1, errno@^0.1.3, errno@~0.1.7: version "0.1.7" @@ -2259,10 +2258,10 @@ globby@^6.1.0: pify "^2.0.0" pinkie-promise "^2.0.0" -graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2: - version "4.1.15" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00" - integrity sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA== +graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.2.0: + version "4.2.0" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.0.tgz#8d8fdc73977cb04104721cb53666c1ca64cd328b" + integrity sha512-jpSvDPV4Cq/bgtpndIWbI5hmYxhQGHPC4d4cqBPb4DLniCfhJokdXhwhaDuLBGLQdvvRum/UiX6ECVIPvDXqdg== "growl@~> 1.10.0": version "1.10.5" @@ -3698,7 +3697,7 @@ memoizee@^0.4.14: next-tick "1" timers-ext "^0.1.5" -memory-fs@^0.4.0, memory-fs@~0.4.1: +memory-fs@~0.4.1: version "0.4.1" resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.4.1.tgz#3a9a20b8462523e447cfbc7e8bb80ed667bfc552" integrity sha1-OpoguEYlI+RHz7x+i7gO1me/xVI= @@ -5342,16 +5341,11 @@ table@^5.2.3: slice-ansi "^2.1.0" string-width "^3.0.0" -tapable@2.0.0-beta.5: +tapable@2.0.0-beta.5, tapable@^2.0.0-beta: version "2.0.0-beta.5" resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.0.0-beta.5.tgz#51def4d94c58ad8fadf00cac7661216502fe9c70" integrity sha512-P4o84kC8CD66ZuCs6noh3QLU2ZuaBvMl0yCmp9rr0GXZyIfLd1sB2ZvJZjitQgfds8GDKRLmiiAcssr2bEHQ0A== -tapable@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.1.0.tgz#0d076a172e3d9ba088fd2272b2668fb8d194b78c" - integrity sha512-IlqtmLVaZA2qab8epUXbVWRn3aB1imbDMJtjB3nu4X0NqPkcY/JH9ZtCBWKHWPxs8Svi9tyo8w2dBoi07qZbBA== - terser-webpack-plugin@^1.2.1: version "1.3.0" resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-1.3.0.tgz#69aa22426299f4b5b3775cbed8cb2c5d419aa1d4" @@ -5703,10 +5697,10 @@ wast-loader@^1.5.5: dependencies: wabt "1.0.0-nightly.20180421" -watchpack@2.0.0-beta.5: - version "2.0.0-beta.5" - resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.0.0-beta.5.tgz#c005db39570d81d9d34334870abc0f548901b880" - integrity sha512-HGqh9e9QZFhow8JYX+1+E+kIYK0uTTsk6rCOkI0ff0f9kMO0wX783yW8saQC9WDx7qHpVGPXsRnld9nY7iwzQA== +watchpack@2.0.0-beta.6: + version "2.0.0-beta.6" + resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.0.0-beta.6.tgz#19dcb5bfebd2c580b05ed8991140b3fb46ab449c" + integrity sha512-CUtzBZ/aFrhsBPs1SJKWpaVG09mRC1ChCL8YZnR/uZf8IPddG7PcdUIGRnDb3yqaCYSyt23u/UxQUGKxGp0rDA== dependencies: glob-to-regexp "^0.4.1" graceful-fs "^4.1.2"