Skip to content

Commit fe916d5

Browse files
committed
fix for tests.
1 parent d43fdc0 commit fe916d5

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

lib/loader.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ module.exports = function(content, map) {
3030
externals = givenExternals;
3131
}
3232

33+
if (typeof externals === 'string') {
34+
externals = JSON.parse(externals);
35+
}
36+
3337
var externalsKeys = Object.keys(externals);
3438

3539
function findExternalFromImportUrl(importUrl) {
@@ -125,7 +129,6 @@ module.exports = function(content, map) {
125129
}.bind(this));
126130
}
127131

128-
129132
var exportJs = compileExports(result, importItemMatcher.bind(this), camelCaseKeys);
130133
if (exportJs) {
131134
exportJs = "exports.locals = " + exportJs + ";";

test/externalsTest.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*globals describe */
1+
/*globals describe, before, after */
22

33
var test = require("./helpers").test;
44

@@ -10,10 +10,8 @@ function testLocal(name, input, result, localsResult, query, modules) {
1010
describe("externals", function() {
1111
before(function () {
1212
global.External = {
13-
External: {
14-
c2: "imported-c2",
15-
c4: "imported-c4"
16-
}
13+
c2: "imported-c2",
14+
c4: "imported-c4"
1715
};
1816
});
1917

@@ -30,18 +28,14 @@ describe("externals", function() {
3028

3129
// result
3230
[
33-
[
34-
2,
35-
".test{c: d}",
36-
""
37-
],
3831
[
3932
1,
4033
[
4134
"._c1 { b: 1; }",
4235
"._c3 { b: 3; }",
4336
"._c5 { b: 5; }"
44-
].join("\n"), ""]
37+
].join("\n"), ""
38+
]
4539
],
4640

4741
// localsResult
@@ -52,12 +46,15 @@ describe("externals", function() {
5246
},
5347

5448
// query
55-
{
56-
localIdentName: '[name]__[local]___[hash:base64:5]',
57-
externals: {
58-
external: 'External'
59-
}
60-
},
49+
'?localIdentName=_[local]&externals={"external":"External"}',
50+
51+
// @TODO: test with query as an object too
52+
// {
53+
// localIdentName: '_[local]',
54+
// externals: {
55+
// external: 'External'
56+
// }
57+
// },
6158

6259
// modules
6360
{}

0 commit comments

Comments
 (0)