Skip to content

Commit 4e6bd42

Browse files
author
Nikita Gusakov
committed
Keep both key types in camelCase mode
1 parent 5126cff commit 4e6bd42

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

lib/loader.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,16 @@ module.exports = function(content, map) {
8484

8585
var exportJs = "";
8686
if(Object.keys(result.exports).length > 0) {
87-
exportJs = Object.keys(result.exports).map(function(key) {
87+
var boundImportItemMatcher = importItemMatcher.bind(this);
88+
exportJs = Object.keys(result.exports).reduce(function(res, key) {
8889
var valueAsString = JSON.stringify(result.exports[key]);
89-
valueAsString = valueAsString.replace(result.importItemRegExpG, importItemMatcher.bind(this));
90-
var exportKey = camelCaseKeys ? camelCase(key) : key;
91-
return "\t" + JSON.stringify(exportKey) + ": " + valueAsString;
92-
}.bind(this)).join(",\n");
90+
valueAsString = valueAsString.replace(result.importItemRegExpG, boundImportItemMatcher);
91+
res.push("\t" + JSON.stringify(key) + ": " + valueAsString);
92+
if (camelCaseKeys) {
93+
res.push("\t" + JSON.stringify(camelCase(key)) + ": " + valueAsString);
94+
}
95+
return res;
96+
}, []).join(",\n");
9397
exportJs = "exports.locals = {\n" + exportJs + "\n};";
9498
}
9599

test/camelCaseTest.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe("camelCase", function() {
1313
]
1414
};
1515
exports.with.locals = {'btn-info': '_38r5hlPyrqKLodJwWOdM1k'};
16-
exports.without.locals = {btnInfo: '_38r5hlPyrqKLodJwWOdM1k'};
16+
exports.without.locals = {btnInfo: '_38r5hlPyrqKLodJwWOdM1k', 'btn-info': '_38r5hlPyrqKLodJwWOdM1k'};
1717
test("with", css, exports.with, "?modules");
1818
test("without", css, exports.without, "?modules&camelCase");
1919
});

0 commit comments

Comments
 (0)