Skip to content

Commit b8c738b

Browse files
kraenhansenmarkdalgleish
authored andcommitted
fix: Support files without exported locals (#16)
1 parent 6a97315 commit b8c738b

File tree

6 files changed

+30
-4
lines changed

6 files changed

+30
-4
lines changed

index.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ module.exports = function(content, ...rest) {
6969

7070
const localExports = content.split('exports.locals')[1];
7171

72-
if (!localExports) {
73-
return failed(new Error(`No exported locals found for ${filename}`));
74-
}
75-
7672
while ((match = keyRegex.exec(localExports))) {
7773
if (cssModuleKeys.indexOf(match[1]) < 0) {
7874
cssModuleKeys.push(match[1]);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
index.css.d.ts
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Can emit valid declaration without classes 1`] = `
4+
"// This file is automatically generated.
5+
// Please do not change this file!
6+
interface CssExports {
7+
8+
}
9+
declare var cssExports: CssExports;
10+
export = cssExports;
11+
"
12+
`;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
const fs = require('fs');
2+
const compiler = require('../compiler.js');
3+
4+
test('Can emit valid declaration without classes', async () => {
5+
await compiler(require.resolve('./index.js'));
6+
7+
const declaration = fs.readFileSync(
8+
require.resolve('./index.css.d.ts'),
9+
'utf-8'
10+
);
11+
12+
expect(declaration).toMatchSnapshot();
13+
});

test/emit-empty-declaration/index.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
html {
2+
/* No class selectors in this file ... */
3+
}

test/emit-empty-declaration/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "./index.css";

0 commit comments

Comments
 (0)