We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e02e7a2 commit 7dfedc7Copy full SHA for 7dfedc7
lib/compile-exports.js
@@ -14,14 +14,23 @@ module.exports = function compileExports(result, importItemMatcher, camelCaseKey
14
var exportJs = Object.keys(result.exports).reduce(function(res, key) {
15
var valueAsString = JSON.stringify(result.exports[key]);
16
valueAsString = valueAsString.replace(result.importItemRegExpG, importItemMatcher);
17
- res.push("\t" + JSON.stringify(key) + ": " + valueAsString);
+ function addEntry(k) {
18
+ res.push("\t" + JSON.stringify(k) + ": " + valueAsString);
19
+ }
20
+ addEntry(key);
21
22
+ var targetKey;
23
if (camelCaseKeys === true) {
- res.push("\t" + JSON.stringify(camelCase(key)) + ": " + valueAsString);
24
+ targetKey = camelCase(key);
25
+ if (targetKey !== key) {
26
+ addEntry(targetKey);
27
28
} else if (camelCaseKeys === 'dashes') {
- res.push("\t" + JSON.stringify(dashesCamelCase(key)) + ": " + valueAsString);
29
+ targetKey = dashesCamelCase(key);
30
31
32
33
}
-
34
return res;
35
}, []).join(",\n");
36
test/camelCaseTest.js
@@ -1,6 +1,7 @@
1
/*globals describe */
2
3
var test = require("./helpers").test;
4
+var testRaw = require("./helpers").testRaw;
5
6
describe("camelCase", function() {
7
var css = ".btn-info_is-disabled { color: blue; }";
@@ -21,4 +22,7 @@ describe("camelCase", function() {
test("with", css, exports.with, "?modules");
test("without", css, exports.without, "?modules&camelCase");
test("dashes", css, exports.dashes, "?modules&camelCase=dashes");
+
+ testRaw("withoutRaw", '.a {}', 'exports.locals = {\n\t"a": "_1buUQJccBRS2-2i27LCoDf"\n};', "?modules&camelCase");
+ testRaw("dashesRaw", '.a {}', 'exports.locals = {\n\t"a": "_1buUQJccBRS2-2i27LCoDf"\n};', "?modules&camelCase=dashes");
});
test/helpers.js
@@ -32,6 +32,10 @@ function assetEvaluated(output, result, modules) {
exports.should.be.eql(result);
+function assertRaw(output, result) {
+ output.should.containEql(result);
37
+}
38
39
function runLoader(loader, input, map, addOptions, callback) {
40
var opt = {
41
options: {
@@ -69,6 +73,18 @@ exports.test = function test(name, input, result, query, modules) {
69
73
70
74
};
71
75
76
+exports.testRaw = function testRaw(name, input, result, query, modules) {
77
+ it(name, function(done) {
78
+ runLoader(cssLoader, input, undefined, !query || typeof query === "string" ? {
79
+ query: query
80
+ } : query, function(err, output) {
81
+ if(err) return done(err);
82
+ assertRaw(output, result, modules);
83
+ done();
84
+ });
85
86
87
72
88
exports.testError = function test(name, input, onError) {
89
it(name, function(done) {
90
runLoader(cssLoader, input, undefined, {}, function(err, output) { // eslint-disable-line no-unused-vars
0 commit comments