Skip to content
This repository was archived by the owner on Mar 17, 2021. It is now read-only.

Commit f412b3e

Browse files
michael-ciniawskyjoshwiens
authored andcommitted
fix(index): revert to CJS exports (#212)
1 parent c49aceb commit f412b3e

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ export default function loader(content) {
6565
if (options.emitFile === undefined || options.emitFile) {
6666
this.emitFile(outputPath, content);
6767
}
68-
69-
return `export default ${publicPath};`;
68+
// TODO revert to ES2015 Module export, when new CSS Pipeline is in place
69+
return `module.exports = ${publicPath};`;
7070
}
7171

7272
export const raw = true;

test/loader.test.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -90,39 +90,39 @@ describe('correct-filename', () => {
9090
describe('publicPath option', () => {
9191
it('should be supported', () => {
9292
expect(run('/file.txt', 'publicPath=http://cdn/').result).toEqual(
93-
'export default "http://cdn/81dc9bdb52d04dc20036dbd8313ed055.txt";',
93+
'module.exports = "http://cdn/81dc9bdb52d04dc20036dbd8313ed055.txt";',
9494
);
9595
});
9696

9797
it('should override public path when given empty string', () => {
9898
expect(run('/file.txt', 'publicPath=').result).toEqual(
99-
'export default "81dc9bdb52d04dc20036dbd8313ed055.txt";',
99+
'module.exports = "81dc9bdb52d04dc20036dbd8313ed055.txt";',
100100
);
101101
});
102102

103103
it('should use webpack public path when not set', () => {
104104
expect(run('/file.txt').result).toEqual(
105-
'export default __webpack_public_path__ + "81dc9bdb52d04dc20036dbd8313ed055.txt";',
105+
'module.exports = __webpack_public_path__ + "81dc9bdb52d04dc20036dbd8313ed055.txt";',
106106
);
107107
});
108108
});
109109

110110
describe('useRelativePath option', () => {
111111
it('should be supported', () => {
112112
expect(run('/this/is/the/context/file.txt', 'useRelativePath=true').result).toEqual(
113-
'export default __webpack_public_path__ + \"./81dc9bdb52d04dc20036dbd8313ed055.txt\";',
113+
'module.exports = __webpack_public_path__ + \"./81dc9bdb52d04dc20036dbd8313ed055.txt\";',
114114
);
115115

116116
expect(run('/this/is/file.txt', 'useRelativePath=true').result).toEqual(
117-
'export default __webpack_public_path__ + \"../../81dc9bdb52d04dc20036dbd8313ed055.txt\";',
117+
'module.exports = __webpack_public_path__ + \"../../81dc9bdb52d04dc20036dbd8313ed055.txt\";',
118118
);
119119

120120
expect(run('/this/file.txt', 'context=/this/is/the/&useRelativePath=true').result).toEqual(
121-
'export default __webpack_public_path__ + \"../../81dc9bdb52d04dc20036dbd8313ed055.txt\";',
121+
'module.exports = __webpack_public_path__ + \"../../81dc9bdb52d04dc20036dbd8313ed055.txt\";',
122122
);
123123

124124
expect(run('/this/file.txt', 'context=/&useRelativePath=true').result).toEqual(
125-
'export default __webpack_public_path__ + \"this/81dc9bdb52d04dc20036dbd8313ed055.txt\";',
125+
'module.exports = __webpack_public_path__ + \"this/81dc9bdb52d04dc20036dbd8313ed055.txt\";',
126126
);
127127
});
128128
});
@@ -134,7 +134,7 @@ describe('outputPath function', () => {
134134

135135
expect(runWithOptions('/this/is/the/context/file.txt', options).result)
136136
.toEqual(
137-
'export default __webpack_public_path__ + \"/path/set/by/func\";',
137+
'module.exports = __webpack_public_path__ + \"/path/set/by/func\";',
138138
);
139139
});
140140

@@ -145,7 +145,7 @@ describe('outputPath function', () => {
145145

146146
expect(runWithOptions('/this/is/the/context/file.txt', options).result)
147147
.toEqual(
148-
'export default __webpack_public_path__ + \"./81dc9bdb52d04dc20036dbd8313ed055.txt\";',
148+
'module.exports = __webpack_public_path__ + \"./81dc9bdb52d04dc20036dbd8313ed055.txt\";',
149149
);
150150
});
151151
});

0 commit comments

Comments
 (0)