Skip to content

Code will not build when using CSS Modules + TypeScript #822

@nickrttn

Description

@nickrttn

Summary

I'm trying to bundle a React component library. I'm using Typescript and CSS Modules. When I try to build (or watch for that matter), I receive the error:

(rpt2 plugin) Error: ..../project/src/component.tsx(1,20): semantic error TS2307: Cannot find module './component.module.css' or its corresponding type declarations.

I can reproduce this in a reduced test case: https://github.com/nickrttn/microbundle-ts-css-modules

With the types added in the test case as documented in #740 I would have expected this to build. I've also tried to add https://github.com/mrmckeb/typescript-plugin-css-modules instead, with the same results. Strangely, VS Code does pick up on both of these changes.

Expected result

yarn build should work. I've taken the custom tsconfig.json and types from #740.

Actual result

This error during building or watching:

(rpt2 plugin) Error: ..../project/src/component.tsx(1,20): semantic error TS2307: Cannot find module './component.module.css' or its corresponding type declarations.

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