Bug 1403106 - Fix rewrite-lazy require for non-named modules; r=Honza

MozReview-Commit-ID: 3vGooT3G450

--HG--
extra : rebase_source : 60d9dc3223e3c3ae0ff72e6685ae8950eda5451f
This commit is contained in:
Nicolas Chevobbe 2017-10-04 12:22:15 +02:00
parent 730fb6c537
commit e2539fb394

View File

@ -7,8 +7,14 @@
module.exports = function (content) {
this.cacheable && this.cacheable();
return content.replace(
// taking care of "named" depedencies.
let res = content.replace(
/loader.lazyRequireGetter\(this,\s*"([^"]+)",[^"]*"([^"]+)", true\);/g,
"let { $1 } = require(\"$2\")"
);
// And then of direct ones.
return res.replace(
/loader.lazyRequireGetter\(this,\s*"([^"]+)",[^"]*"([^"]+)"(, false)?\);/g,
"let $1 = require(\"$2\")"
);
};