blob: 9e21b2360195716ecaa348e5bd52e2f7290f97d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
const path = require("path");
const { ImportManager } = require("import-manager");
const sharedModules = webpackRequire("utils/shared-modules.js");
module.exports = function(source) {
const { sortedSharedModules } = this.getOptions();
const manager = new ImportManager(source);
for (const unit of manager.imports.es6.units) {
const moduleIndex = sharedModules.indexOf(unit.module.name);
if (moduleIndex >= 0) {
const currentSharedModuleName = sharedModules[moduleIndex];
if (!sortedSharedModules.includes(currentSharedModuleName)) {
sortedSharedModules.push(currentSharedModuleName);
}
}
}
sortedSharedModules.push(path.basename(this.resourcePath.substring(0, this.resourcePath.length - 3)));
return source;
};
|