Skip to content

Commit

Permalink
use commonjs compatibility similar to babel
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Dec 22, 2015
1 parent 0915889 commit a1ed89e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/dependencies/HarmonyImportDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ HarmonyImportDependency.makeStatement = function(declare, dep, outputOptions, re
} else if(dep.importedVar) {
content = "/* harmony import */ " + declaration + dep.importedVar + " = __webpack_require__(" + comment + JSON.stringify(dep.module.id) + ");\n";
if(!dep.module.meta.harmonyModule) {
content += "/* harmony import */ " + declaration + dep.importedVar + "_default = function() { return " + dep.importedVar + " && typeof " + dep.importedVar + " === 'object' && 'default' in " + dep.importedVar + " ? " + dep.importedVar + "['default'] : " + dep.importedVar + "; }\n";
content += "/* harmony import */ Object.defineProperty(" + dep.importedVar + "_default, 'a', { get: function() { return " + dep.importedVar + "_default(); }});\n";
content += "/* harmony import */ " + declaration + dep.importedVar + "_default = " + dep.importedVar + " && " + dep.importedVar + ".__esModule ? function() { return " + dep.importedVar + "['default'] } : function() { return " + dep.importedVar + "; }\n";
content += "/* harmony import */ Object.defineProperty(" + dep.importedVar + "_default, 'a', { get: " + dep.importedVar + "_default });\n";
}
} else {
content = "";
Expand Down
4 changes: 3 additions & 1 deletion test/cases/parsing/harmony/node_modules/commonjs-trans.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a1ed89e

Please sign in to comment.