diff --git a/lib/compile-exports.js b/lib/compile-exports.js index 06904fac..318743ce 100644 --- a/lib/compile-exports.js +++ b/lib/compile-exports.js @@ -14,14 +14,23 @@ module.exports = function compileExports(result, importItemMatcher, camelCaseKey var exportJs = Object.keys(result.exports).reduce(function(res, key) { var valueAsString = JSON.stringify(result.exports[key]); valueAsString = valueAsString.replace(result.importItemRegExpG, importItemMatcher); - res.push("\t" + JSON.stringify(key) + ": " + valueAsString); + function addEntry(k) { + res.push("\t" + JSON.stringify(k) + ": " + valueAsString); + } + addEntry(key); + var targetKey; if (camelCaseKeys === true) { - res.push("\t" + JSON.stringify(camelCase(key)) + ": " + valueAsString); + targetKey = camelCase(key); + if (targetKey !== key) { + addEntry(targetKey); + } } else if (camelCaseKeys === 'dashes') { - res.push("\t" + JSON.stringify(dashesCamelCase(key)) + ": " + valueAsString); + targetKey = dashesCamelCase(key); + if (targetKey !== key) { + addEntry(targetKey); + } } - return res; }, []).join(",\n"); diff --git a/package.json b/package.json index d1cf44d6..b4d05d66 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "css-loader", - "version": "0.26.2", + "version": "0.26.3", "author": "Tobias Koppers @sokra", "description": "css loader module for webpack", "engines": { diff --git a/test/camelCaseTest.js b/test/camelCaseTest.js index 86803005..c8be53b3 100644 --- a/test/camelCaseTest.js +++ b/test/camelCaseTest.js @@ -1,6 +1,7 @@ /*globals describe */ var test = require("./helpers").test; +var testRaw = require("./helpers").testRaw; describe("camelCase", function() { 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"); }); diff --git a/test/helpers.js b/test/helpers.js index f50941f2..ba7f72be 100644 --- a/test/helpers.js +++ b/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); +} + function runLoader(loader, input, map, addOptions, callback) { var opt = { options: { @@ -69,6 +73,18 @@ exports.test = function test(name, input, result, query, modules) { }); }; +exports.testRaw = function testRaw(name, input, result, query, modules) { + it(name, function(done) { + runLoader(cssLoader, input, undefined, !query || typeof query === "string" ? { + query: query + } : query, function(err, output) { + if(err) return done(err); + assertRaw(output, result, modules); + done(); + }); + }); +} + exports.testError = function test(name, input, onError) { it(name, function(done) { runLoader(cssLoader, input, undefined, {}, function(err, output) { // eslint-disable-line no-unused-vars diff --git a/yarn.lock b/yarn.lock index a7894e3d..79f133ab 100644 --- a/yarn.lock +++ b/yarn.lock @@ -165,14 +165,7 @@ browser-stdout@1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.0.tgz#f351d32969d32fa5d7a5567154263d928ae3bd1f" -browserslist@^1.0.1, browserslist@^1.5.2: - version "1.6.0" - resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-1.6.0.tgz#85fb7c993540d3fda31c282baf7f5aee698ac9ee" - dependencies: - caniuse-db "^1.0.30000613" - electron-to-chromium "^1.2.0" - -browserslist@~1.5.1: +browserslist@^1.0.1, browserslist@^1.5.2, browserslist@~1.5.1: version "1.5.2" resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-1.5.2.tgz#1c82fde0ee8693e6d15c49b7bff209dc06298c56" dependencies: @@ -206,7 +199,7 @@ caniuse-api@^1.5.2: lodash.uniq "^4.3.0" shelljs "^0.7.0" -caniuse-db@^1.0.30000346, caniuse-db@^1.0.30000604, caniuse-db@^1.0.30000613: +caniuse-db@^1.0.30000346, caniuse-db@^1.0.30000604: version "1.0.30000613" resolved "https://registry.yarnpkg.com/caniuse-db/-/caniuse-db-1.0.30000613.tgz#639133b7a5380c1416f9701d23d54d093dd68299" @@ -493,10 +486,6 @@ ecc-jsbn@~0.1.1: dependencies: jsbn "~0.1.0" -electron-to-chromium@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.2.0.tgz#3bd7761f85bd4163602259ae6c7ed338050b17e7" - emojis-list@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" @@ -1107,14 +1096,13 @@ levn@^0.3.0, levn@~0.3.0: prelude-ls "~1.1.2" type-check "~0.3.2" -loader-utils@~0.2.2: - version "0.2.16" - resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-0.2.16.tgz#f08632066ed8282835dff88dfb52704765adee6d" +loader-utils@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.0.3.tgz#566c320c24c33cb3f02db4df83f3dbf60b253de3" dependencies: big.js "^3.1.3" emojis-list "^2.0.0" json5 "^0.5.0" - object-assign "^4.0.1" lodash._baseassign@^3.0.0: version "3.2.0"