Skip to content

Commit ce76b6e

Browse files
committed
emit more pretty es6 runtime code
1 parent 65b70bf commit ce76b6e

3 files changed

Lines changed: 18 additions & 18 deletions

File tree

‎lib/FunctionModuleTemplatePlugin.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ FunctionModuleTemplatePlugin.prototype.apply = function(moduleTemplate) {
2525
if(this.outputOptions.pathinfo) {
2626
var source = new ConcatSource();
2727
var req = module.readableIdentifier(this.requestShortener);
28-
if(Array.isArray(module.usedExports))
29-
source.add("/* exports used: " + module.usedExports.join(", ") + " */\n");
30-
else if(module.usedExports)
31-
source.add("/* all exports used */\n");
3228
if(Array.isArray(module.providedExports))
3329
source.add("/* exports provided: " + module.providedExports.join(", ") + " */\n");
3430
else if(module.providedExports)
3531
source.add("/* unknown exports provided */\n");
32+
if(Array.isArray(module.usedExports))
33+
source.add("/* exports used: " + module.usedExports.join(", ") + " */\n");
34+
else if(module.usedExports)
35+
source.add("/* all exports used */\n");
3636
source.add("/*!****" + req.replace(/./g, "*") + "****!*\\\n");
3737
source.add(" !*** " + req.replace(/\*\//g, "*_/") + " ***!\n");
3838
source.add(" \\****" + req.replace(/./g, "*") + "****/\n");

‎lib/dependencies/HarmonyExportImportedSpecifierDependency.js‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -135,19 +135,19 @@ HarmonyExportImportedSpecifierDependency.Template.prototype.apply = function(dep
135135
function getReexportStatement(key, valueKey) {
136136
return(importIsHarmony || !valueKey ? "" : "if(__webpack_require__.o(" + name + ", " + valueKey + ")) ") +
137137
"__webpack_require__.d(exports, " + key + ", " +
138-
"function() { return " + name + (valueKey === null ? "_default.a" : valueKey && "[" + valueKey + "]") + "; });"
138+
"function() { return " + name + (valueKey === null ? "_default.a" : valueKey && "[" + valueKey + "]") + "; });\n"
139139
}
140140
if(!used) { // we want to rexport something, but the export isn't used
141141
content = "/* unused harmony reexport " + dep.name + " */\n";
142142
} else if(!active) { // we want to reexport something but another exports overrides this one
143143
content = "/* inactive harmony reexport " + (dep.name || "namespace") + " */\n";
144144
} else if(dep.name && dep.id === "default" && !(importedModule && (!importedModule.meta || importedModule.meta.harmonyModule))) { // we want to reexport the default export from a non-hamory module
145-
content = "/* harmony reexport (default from non-hamory) */ " + getReexportStatement(JSON.stringify(used), null) + "\n";
145+
content = "/* harmony reexport (default from non-hamory) */ " + getReexportStatement(JSON.stringify(used), null);
146146
} else if(dep.name && dep.id) { // we want to reexport a key as new key
147147
var idUsed = importedModule && importedModule.isUsed(dep.id);
148-
content = "/* harmony reexport (std) */ " + getReexportStatement(JSON.stringify(used), JSON.stringify(idUsed)) + "\n";
148+
content = "/* harmony reexport (binding) */ " + getReexportStatement(JSON.stringify(used), JSON.stringify(idUsed));
149149
} else if(dep.name) { // we want to reexport the module object as named export
150-
content = "/* harmony reexport (module object) */ " + getReexportStatement(JSON.stringify(used), "") + "\n";
150+
content = "/* harmony reexport (module object) */ " + getReexportStatement(JSON.stringify(used), "");
151151
} else if(Array.isArray(dep.originModule.usedExports)) { // we know which exports are used
152152
activeExports = HarmonyModulesHelpers.getActiveExports(dep.originModule);
153153
items = dep.originModule.usedExports.map(function(id) {
@@ -159,9 +159,9 @@ HarmonyExportImportedSpecifierDependency.Template.prototype.apply = function(dep
159159
return [exportUsed, idUsed];
160160
}).filter(Boolean);
161161
if(items.length > 0) {
162-
content = "/* harmony namespace reexport (by used) */ " + items.map(function(item) {
163-
return getReexportStatement(JSON.stringify(item[0]), JSON.stringify(item[1]));
164-
}).join(" ") + "\n";
162+
content = items.map(function(item) {
163+
return "/* harmony namespace reexport (by used) */ " + getReexportStatement(JSON.stringify(item[0]), JSON.stringify(item[1]));
164+
}).join("");
165165
} else content = "/* unused harmony namespace reexport */\n";
166166
} else if(dep.originModule.usedExports && importedModule && Array.isArray(importedModule.providedExports)) { // not sure which exports are used, but we know which are provided
167167
activeExports = HarmonyModulesHelpers.getActiveExports(dep.originModule);
@@ -173,9 +173,9 @@ HarmonyExportImportedSpecifierDependency.Template.prototype.apply = function(dep
173173
return [exportUsed, idUsed];
174174
}).filter(Boolean);
175175
if(items.length > 0) {
176-
content = "/* harmony namespace reexport (by provided) */ " + items.map(function(item) {
177-
return getReexportStatement(JSON.stringify(item[0]), JSON.stringify(item[1]));
178-
}).join(" ") + "\n";
176+
content = items.map(function(item) {
177+
return "/* harmony namespace reexport (by provided) */ " + getReexportStatement(JSON.stringify(item[0]), JSON.stringify(item[1]));
178+
}).join("");
179179
} else content = "/* empty harmony namespace reexport */\n";
180180
} else if(dep.originModule.usedExports) { // not sure which exports are used and provided
181181
activeExports = HarmonyModulesHelpers.getActiveExports(dep.originModule);

‎lib/dependencies/HarmonyExportSpecifierDependency.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ HarmonyExportSpecifierDependency.Template.prototype.apply = function(dep, source
3939
var active = HarmonyModulesHelpers.isActive(dep.originModule, dep);
4040
var content;
4141
if(!used) {
42-
content = "/* unused harmony export " + (dep.name || "namespace") + " */";
42+
content = "/* unused harmony export " + (dep.name || "namespace") + " */\n";
4343
} else if(!active) {
44-
content = "/* inactive harmony export " + (dep.name || "namespace") + " */";
44+
content = "/* inactive harmony export " + (dep.name || "namespace") + " */\n";
4545
} else if(dep.immutable) {
46-
content = "/* harmony export */ exports[" + JSON.stringify(used) + "] = " + dep.id + ";";
46+
content = "/* harmony export (immutable) */ exports[" + JSON.stringify(used) + "] = " + dep.id + ";\n";
4747
} else {
48-
content = "\n/* harmony export */ __webpack_require__.d(exports, " + JSON.stringify(used) + ", function() { return " + dep.id + "; });";
48+
content = "/* harmony export (binding) */ __webpack_require__.d(exports, " + JSON.stringify(used) + ", function() { return " + dep.id + "; });\n";
4949
}
5050
source.insert(dep.position, content);
5151

0 commit comments

Comments
 (0)