-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(AoTPlugin): don't override context module deps
Fix #2496
- Loading branch information
1 parent
08bb738
commit 9fc3d40
Showing
3 changed files
with
68 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,22 @@ | ||
const ContextElementDependency = require('webpack/lib/dependencies/ContextElementDependency'); | ||
|
||
export function createResolveDependenciesFromContextMap(createContextMap: Function) { | ||
export function createResolveDependenciesFromContextMap( | ||
contextMap: { [route: string]: string }, | ||
originalResolveDependencies: any | ||
) { | ||
return (fs: any, resource: any, recursive: any, regExp: RegExp, callback: any) => { | ||
createContextMap(fs, function(err: Error, map: any) { | ||
const newCallback = (err: any, deps: any) => { | ||
if (err) { | ||
return callback(err); | ||
} | ||
|
||
const dependencies = Object.keys(map) | ||
.map((key) => new ContextElementDependency(map[key], key)); | ||
const dependencies = Object.keys(contextMap) | ||
.map((key) => new ContextElementDependency(contextMap[key], key)); | ||
|
||
callback(null, dependencies); | ||
}); | ||
callback(null, deps.concat(dependencies)); | ||
}; | ||
|
||
// Use original resolver and add in context map to result | ||
originalResolveDependencies(fs, resource, recursive, regExp, newCallback); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters