diff --git a/index.js b/index.js index 6f318ed..6c7a989 100644 --- a/index.js +++ b/index.js @@ -69,10 +69,6 @@ module.exports = function(content, ...rest) { const localExports = content.split('exports.locals')[1]; - if (!localExports) { - return failed(new Error(`No exported locals found for ${filename}`)); - } - while ((match = keyRegex.exec(localExports))) { if (cssModuleKeys.indexOf(match[1]) < 0) { cssModuleKeys.push(match[1]); diff --git a/test/emit-empty-declaration/.gitignore b/test/emit-empty-declaration/.gitignore new file mode 100644 index 0000000..cc5d7db --- /dev/null +++ b/test/emit-empty-declaration/.gitignore @@ -0,0 +1 @@ +index.css.d.ts diff --git a/test/emit-empty-declaration/__snapshots__/emit-empty-declaration.test.js.snap b/test/emit-empty-declaration/__snapshots__/emit-empty-declaration.test.js.snap new file mode 100644 index 0000000..9ecd79a --- /dev/null +++ b/test/emit-empty-declaration/__snapshots__/emit-empty-declaration.test.js.snap @@ -0,0 +1,12 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Can emit valid declaration without classes 1`] = ` +"// This file is automatically generated. +// Please do not change this file! +interface CssExports { + +} +declare var cssExports: CssExports; +export = cssExports; +" +`; diff --git a/test/emit-empty-declaration/emit-empty-declaration.test.js b/test/emit-empty-declaration/emit-empty-declaration.test.js new file mode 100644 index 0000000..88e3977 --- /dev/null +++ b/test/emit-empty-declaration/emit-empty-declaration.test.js @@ -0,0 +1,13 @@ +const fs = require('fs'); +const compiler = require('../compiler.js'); + +test('Can emit valid declaration without classes', async () => { + await compiler(require.resolve('./index.js')); + + const declaration = fs.readFileSync( + require.resolve('./index.css.d.ts'), + 'utf-8' + ); + + expect(declaration).toMatchSnapshot(); +}); diff --git a/test/emit-empty-declaration/index.css b/test/emit-empty-declaration/index.css new file mode 100644 index 0000000..2da8ff0 --- /dev/null +++ b/test/emit-empty-declaration/index.css @@ -0,0 +1,3 @@ +html { + /* No class selectors in this file ... */ +} diff --git a/test/emit-empty-declaration/index.js b/test/emit-empty-declaration/index.js new file mode 100644 index 0000000..3a29aed --- /dev/null +++ b/test/emit-empty-declaration/index.js @@ -0,0 +1 @@ +import "./index.css";