css-modules-typescript-loader
Advanced tools
Comparing version 1.1.1 to 2.0.0
17
index.js
@@ -9,2 +9,4 @@ const fs = require('fs'); | ||
const cssModuleExport = 'declare var cssExports: CssExports;\nexport = cssExports;\n'; | ||
const getNoDeclarationFileError = ({ filename }) => | ||
@@ -23,8 +25,9 @@ new Error( | ||
const cssModuleToNamedExports = cssModuleKeys => { | ||
return cssModuleKeys | ||
const cssModuleToInterface = (cssModuleKeys) => { | ||
const interfaceFields = cssModuleKeys | ||
.sort() | ||
.map(key => `export const ${key}: string;`) | ||
.join('\n') | ||
.concat('\n'); | ||
.map(key => ` '${key}': string;`) | ||
.join('\n'); | ||
return `interface CssExports {\n${interfaceFields}\n}`; | ||
}; | ||
@@ -75,5 +78,3 @@ | ||
const cssModuleDefinition = `${bannerMessage}\n${cssModuleToNamedExports( | ||
cssModuleKeys | ||
)}`; | ||
const cssModuleDefinition = `${bannerMessage}\n${cssModuleToInterface(cssModuleKeys)}\n${cssModuleExport}`; | ||
@@ -80,0 +81,0 @@ if (mode === 'verify') { |
{ | ||
"name": "css-modules-typescript-loader", | ||
"version": "1.1.1", | ||
"version": "2.0.0", | ||
"description": "Webpack loader to create TypeScript declarations for CSS Modules", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -17,4 +17,2 @@ [![Build Status](https://img.shields.io/travis/seek-oss/css-modules-typescript-loader/master.svg?style=flat-square)](http://travis-ci.org/seek-oss/css-modules-typescript-loader) [![npm](https://img.shields.io/npm/v/css-modules-typescript-loader.svg?style=flat-square)](https://www.npmjs.com/package/css-modules-typescript-loader) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release) [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square)](http://commitizen.github.io/cz-cli/) | ||
- Doesn't silently ignore invalid TypeScript identifiers. If a class name is not valid TypeScript (e.g. `.foo-bar`, instead of `.fooBar`), `tsc` should report an error. | ||
## Usage | ||
@@ -21,0 +19,0 @@ |
// This file is automatically generated. | ||
// Please do not change this file! | ||
export const classInBothFiles: string; | ||
export const classInTypeScriptFile: string; | ||
interface CssExports { | ||
'classInBothFiles': string; | ||
'classInTypeScriptFile': string; | ||
} | ||
declare var cssExports: CssExports; | ||
export = cssExports; |
// This file is automatically generated. | ||
// Please do not change this file! | ||
export const otherClass: string; | ||
export const someClass: string; | ||
export const validClass: string; | ||
interface CssExports { | ||
'hyphened-classname': string; | ||
'otherClass': string; | ||
'someClass': string; | ||
'underscored_classname': string; | ||
'validClass': string; | ||
} | ||
declare var cssExports: CssExports; | ||
export = cssExports; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13653
243
68