Skip to content

Releases: TeamSupercell/typings-for-css-modules-loader

Release 2.5.2

22 Jan 23:44
Compare
Choose a tag to compare

No code changes in this release, upgrading the dependencies to resolve all security audit alerts

Release 2.5.1

30 Mar 23:41
Compare
Choose a tag to compare
  • Add auto-changelog ffe9354
  • Add github action to automate releases 6358f0d
  • Configure release-it to add github releases aa5333d

v2.4.0

29 Oct 11:10
Compare
Choose a tag to compare
  • Added optional prettierConfigFile option #35 thanks @glook

v2.3.0

19 Aug 09:29
Compare
Choose a tag to compare
  • Added support for css-loader 4 #36 - fixes #33

V2.2.1

03 Aug 00:20
Compare
Choose a tag to compare
  • Fix for Build error for CSS modules with :root only #27 by @jsikorski

V2.2.0

18 May 23:06
Compare
Choose a tag to compare
  • New option disableLocalsExport #23 by @raphael-leger
    An option to not concatenate a type with a locals key in generated d.ts files. Defaults to false
  • Fix conflicting names in d.ts when linter is configured with no-redeclare #21 by @raphael-leger

v2.1.1

15 Apr 04:53
Compare
Choose a tag to compare

New verifyOnly option

Validate generated *.d.ts files and fail if an update is needed (useful in CI).

module.exports = {
  module: {
    rules: [
      {
        test: /\.css$/i,
        use: [
          {
            loader: "@teamsupercell/typings-for-css-modules-loader",
            options: {
              verifyOnly: process.env.NODE_ENV === 'production'
            }
          },
          {
            loader: "css-loader",
            options: { modules: true }
          }
        ]
      }
    ]
  }
};

v2.1.0

17 Nov 09:41
Compare
Choose a tag to compare

New template for generated files to avoid issues with the requirement to use default imports in environments that don't have esModuleInterop enabled (PR #14) fixes #8

Example:

// generated d.ts
declare namespace ExampleCssModule {
  export interface IExampleCss {
    "bar-baz": string;
    composed: string;
    foo: string;
  }
}

declare const ExampleCssModule: ExampleCssModule.IExampleCss & {
  /** WARNING: Only available when `css-loader` is used without `style-loader` or `mini-css-extract-plugin` */
  locals: ExampleCssModule.IExampleCss;
};

export = ExampleCssModule;

This type declaration allows the following usage:

import * as styles from "./example.css";
import { IExampleCss } from "./example.css";

console.log(styles.composed);

// or default import when TS `esModuleInterop` enabled
import styles from "./example.css";
import { IExampleCss } from "./example.css";

console.log(styles.composed);

v2.0.1

17 Nov 09:34
6b2f4ab
Compare
Choose a tag to compare
  • Fixes invalid interface name when file includes dashes #10 (PR #13)

v2.0.0

14 Aug 12:34
56b60f5
Compare
Choose a tag to compare

Changes

  • Upgrade all dependencies and ensure the loader works with webpack>=4 and css-loader>=0.28.11
  • Remove babel build - make the loader compatible with Node 8+ without additional build steps.
  • Change the loader from being a drop-in replacement of css-loader to be used alongside css-loader.
  • Remove orderAlphabetically options - the output keys are sorted by default
  • Remove namedExport and camelCase options. Generated type definition files now have default export and can both export locals and support dashes in property names out of box. Example:
export interface IMyComponentScss {
  "some-class": string;
  someOtherClass: string;
  "some-class-sayWhat": string;
}

export const locals: IExampleCss;
export default locals;
  • Use the built-in webpack logger to report errors. Remove the silent options because it becomes redundant
  • Add a new formatter option to allow formatting the generated files with prettier. That should solve the eol issues and apply consistent code style with other files in the code base.

Upgrade guide:

  • Update webpack config
module.exports = {
  module: {
    rules: [
      {
        test: /\.css$/i,
        use: [
          "style-loader",
          {
            loader: "@teamsupercell/typings-for-css-modules-loader",
            options: {
              // pass all the options for `css-loader` to `css-loader`, eg.
-             namedExport: true
            }
          },
+         {
+           loader: "css-loader",
+           options: {
+             namedExport: true
+           }
+         },
        ]
      }
    ]
  }
};
  • ensure all the typescript files import styles as default
- import * as styles from './styles.css';
+ import styles from './styles.css';
  • add allowSyntheticDefaultImports TypeScript compiler option if there are type errors related to default imports