Skip to content

Commit 1869d8e

Browse files
authored
Merge pull request webpack#7694 from webpack/bugfix/loc-in-context
make loc in context dependencies a correct object
2 parents 78d8f4a + 79846d1 commit 1869d8e

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

lib/ContextModule.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,28 @@ const contextify = require("./util/identifier").contextify;
1212

1313
/** @typedef {import("./dependencies/ContextElementDependency")} ContextElementDependency */
1414

15+
/**
16+
* @callback ResolveDependenciesCallback
17+
* @param {Error=} err
18+
* @param {ContextElementDependency[]} dependencies
19+
*/
20+
21+
/**
22+
* @callback ResolveDependencies
23+
* @param {TODO} fs
24+
* @param {TODO} options
25+
* @param {ResolveDependenciesCallback} callback
26+
*/
27+
1528
class ContextModule extends Module {
1629
// type ContextMode = "sync" | "eager" | "weak" | "async-weak" | "lazy" | "lazy-once"
1730
// type ContextOptions = { resource: string, recursive: boolean, regExp: RegExp, addon?: string, mode?: ContextMode, chunkName?: string, include?: RegExp, exclude?: RegExp, groupOptions?: Object }
1831
// resolveDependencies: (fs: FS, options: ContextOptions, (err: Error?, dependencies: Dependency[]) => void) => void
1932
// options: ContextOptions
33+
/**
34+
* @param {ResolveDependencies} resolveDependencies function to get dependencies in this context
35+
* @param {TODO} options options object
36+
*/
2037
constructor(resolveDependencies, options) {
2138
let resource;
2239
let resourceQuery;
@@ -194,7 +211,9 @@ class ContextModule extends Module {
194211

195212
// enhance dependencies with meta info
196213
for (const dep of dependencies) {
197-
dep.loc = dep.userRequest;
214+
dep.loc = {
215+
name: dep.userRequest
216+
};
198217
dep.request = this.options.addon + dep.request;
199218
}
200219

lib/Dependency.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const DependencyReference = require("./dependencies/DependencyReference");
3030

3131
/** @typedef {Object} SynteticDependencyLocation
3232
* @property {string} name
33-
* @property {number} index
33+
* @property {number=} index
3434
*/
3535

3636
/** @typedef {SynteticDependencyLocation|RealDependencyLocation} DependencyLocation */

0 commit comments

Comments
 (0)