Skip to content

Commit

Permalink
Merge pull request #5099 from KTruong888/4099_es6_refactor_harmonymod…
Browse files Browse the repository at this point in the history
…ulehelpers

4099 ES6 refactor of dependencies/HarmonyModuleHelpers
  • Loading branch information
sokra committed Jul 1, 2017
2 parents ea32473 + a1901e1 commit 6199454
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/dependencies/HarmonyModulesHelpers.js
Expand Up @@ -8,12 +8,12 @@ class HarmonyModulesHelpers {

static getModuleVar(state, request) {
if(!state.harmonyModules) state.harmonyModules = [];
var idx = state.harmonyModules.indexOf(request);
let idx = state.harmonyModules.indexOf(request);
if(idx < 0) {
idx = state.harmonyModules.length;
state.harmonyModules.push(request);
}
return "__WEBPACK_IMPORTED_MODULE_" + idx + "_" + request.replace(/[^A-Za-z0-9_]/g, "_").replace(/__+/g, "_") + "__";
return `__WEBPACK_IMPORTED_MODULE_${idx}_${request.replace(/[^A-Za-z0-9_]/g, "_").replace(/__+/g, "_")}__`;
}

static getNewModuleVar(state, request) {
Expand All @@ -31,17 +31,17 @@ class HarmonyModulesHelpers {
// checks if an harmony dependency is active in a module according to
// precedence rules.
static isActive(module, depInQuestion) {
var desc = depInQuestion.describeHarmonyExport();
const desc = depInQuestion.describeHarmonyExport();
if(!desc.exportedName) return true;
var before = true;
for(var i = 0; i < module.dependencies.length; i++) {
var dep = module.dependencies[i];
let before = true;
for(const moduleDependency of module.dependencies) {
const dep = moduleDependency;
if(dep === depInQuestion) {
before = false;
continue;
}
if(!dep.describeHarmonyExport) continue;
var d = dep.describeHarmonyExport();
const d = dep.describeHarmonyExport();
if(!d || !d.exportedName) continue;
if(d.exportedName === desc.exportedName) {
if(d.precedence < desc.precedence) {
Expand All @@ -58,17 +58,17 @@ class HarmonyModulesHelpers {
// get a list of named exports defined in a module
// doesn't include * reexports.
static getActiveExports(module, currentDependency) {
var desc = currentDependency && currentDependency.describeHarmonyExport();
const desc = currentDependency && currentDependency.describeHarmonyExport();
var currentIndex = currentDependency ? module.dependencies.indexOf(currentDependency) : -1;
return module.dependencies.map((dep, idx) => {
return {
dep: dep,
idx: idx
};
}).reduce((arr, data) => {
var dep = data.dep;
const dep = data.dep;
if(!dep.describeHarmonyExport) return arr;
var d = dep.describeHarmonyExport();
const d = dep.describeHarmonyExport();
if(!d) return arr;
if(!desc || (d.precedence < desc.precedence) || (d.precedence === desc.precedence && data.idx < currentIndex)) {
var names = [].concat(d.exportedName);
Expand Down

0 comments on commit 6199454

Please sign in to comment.