{"id":"16bdcb79744a1175","repo":"webpack/webpack","slug":"module-property-was-removed-from-dependency-use-c-16bdcb","errorCode":null,"errorMessage":"module property was removed from Dependency (use compilation.moduleGraph.updateModule(dependency, module) instead)","messagePattern":"module property was removed from Dependency \\(use compilation\\.moduleGraph\\.updateModule\\(dependency, module\\) instead\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/Dependency.js","lineNumber":492,"sourceCode":"Object.defineProperty(Dependency.prototype, \"module\", {\n\t/**\n\t * Returns throws.\n\t * @deprecated\n\t * @returns {EXPECTED_ANY} throws\n\t */\n\tget() {\n\t\tthrow new Error(\n\t\t\t\"module property was removed from Dependency (use compilation.moduleGraph.getModule(dependency) instead)\"\n\t\t);\n\t},\n\n\t/**\n\t * Updates module.\n\t * @deprecated\n\t * @returns {never} throws\n\t */\n\tset() {\n\t\tthrow new Error(\n\t\t\t\"module property was removed from Dependency (use compilation.moduleGraph.updateModule(dependency, module) instead)\"\n\t\t);\n\t}\n});\n\n/**\n * Returns true if the dependency is a low priority dependency.\n * @param {Dependency} dependency dep\n * @returns {boolean} true if the dependency is a low priority dependency\n */\nDependency.isLowPriorityDependency = (dependency) =>\n\t/** @type {ModuleDependency} */ (dependency).sourceOrder === Infinity;\n\n// TODO in webpack 6, call canConcatenate() directly on the dependency instance instead of using this static method.\n/**\n * Returns true if the dependency can be concatenated (scope hoisting).\n * @param {Dependency} dependency dep\n * @param {boolean} concatenateCommonJsModules whether optimization.concatenateModules.commonjs is enabled","sourceCodeStart":474,"sourceCodeEnd":510,"githubUrl":"https://github.com/webpack/webpack/blob/318421ea8ac81371f5171236a6efb63675576528/lib/Dependency.js#L474-L510","documentation":"The `dependency.module` setter was removed alongside the getter (webpack 5): dependencies are immutable graph nodes and the link to their target module is managed by the module graph, not by assigning on the dependency. The throwing setter prevents old code from silently no-op'ing while believing it changed the graph.","triggerScenarios":"Assigning `dependency.module = someModule` in plugin or custom-dependency code. Appears in webpack 4 plugins that rewired a dependency's target at build time.","commonSituations":"Plugins that dynamically retarget imports (e.g. redirecting a require to a different module) by mutating the dependency. Migration of mutation-heavy webpack 4 plugins.","solutions":["Replace `dependency.module = m` with `compilation.moduleGraph.updateModule(dependency, m)`.","If you are creating a new edge, add a new dependency and wire it through the module graph rather than mutating an existing one.","Review custom Dependency subclasses for constructor-time `this.module =` assignments (also invalid)."],"exampleFix":"// before\ndependency.module = newModule;\n\n// after\ncompilation.moduleGraph.updateModule(dependency, newModule);","handlingStrategy":"validation","validationCode":"function retarget(compilation, dependency, module) {\n  // Never assign dependency.module = ...; update via the graph.\n  compilation.moduleGraph.updateModule(dependency, module);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never assign `dependency.module`; use `compilation.moduleGraph.updateModule(dep, module)`.","Prefer creating a new dependency over mutating an existing one's target.","Lint against `\\.module\\s*=` on dependency-typed variables."],"tags":["deprecation","dependency","module-graph","migration"],"analyzedSha":"318421ea8ac81371f5171236a6efb63675576528","analyzedAt":"2026-08-03T19:39:56.731Z","schemaVersion":2}