Skip to content

Support class names that conflict with JS keywords #1

@bhollis

Description

@bhollis

If a class name conflicts with a JS keyword (for example, ".class"), css-loader will output it differently:

export { _1 as "class" };

You can use the regex /export { [_a-z0-9]+ as ("[^\\"]+") }/g to find these. You'll probably need to export them the same way.

In seek-oss/css-modules-typescript-loader#50 the workaround was to export sorta similar to the non-namedExport version:

interface CssExports {
  'class': string;
}
export const cssExports: CssExports;
export = cssExports;

The key being the export = cssExports; line which exports all the properties of CssExports individually.

This actually comes up quite a lot given how many keywords there are in JS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions