Skip to content
This repository was archived by the owner on Aug 28, 2026. It is now read-only.
This repository was archived by the owner on Aug 28, 2026. It is now read-only.

CSS Modules: error when composing imported class #533

Closed

Description

@OliverJAsh

Do you want to request a feature or report a bug? bug

What is the current behavior?
Error when composing imported class.

If the current behavior is a bug, please provide the steps to reproduce.

@value colors: './colors.css';

.foo {
    composes: text from colors;
}
/* colors.css */
.text {
    color: yellow;
}

webpack config:

module.exports = {
    entry: './src/main.css',
    output: {
        filename: './target/main.css',
    },
    module: {
        rules: [
            {
                test: /\.css$/,
                use: [
                    'style-loader',
                    {
                        loader: 'css-loader',
                        options: {
                            modules: true,
                        },
                    },
                ]
            }
        ]
    }
}

Gives error:

ERROR in ./~/css-loader?{"modules":true}!./src/main.css
Module build failed: referenced class name "text" in composes not found (4:5)

  2 |
  3 | .foo {
> 4 |     composes: text from colors;
    |     ^
  5 | }
  6 |

Full test case at https://github.com/OliverJAsh/postcss-modules-values-test. After cloning:

yarn
webpack

What is the expected behavior?
No error.

If this is a feature request, what is motivation or use case for changing the behavior?

Please mention other relevant information such as your webpack version, Node.js version and Operating System.
webpack 2.5.1
css-loader 0.28.1

Activity

  1. OliverJAsh commented on May 16, 2017

    @OliverJAsh
    ContributorAuthor

    After more digging:

    • when the class name you're composing with is the same as the class name you're composing from, you get error Module build failed: referenced class name "from" in composes not found
    • when the class name is not the same, you get error Module build failed: referenced class name "COMPOSED_CLASS_NAME" in composes not found, where COMPOSED_CLASS_NAME is the composed class name.
  2. added 2 commits that reference this issue on May 16, 2017
    f52aea7
    0b72923
  3. added this to the milestone on May 22, 2017
  4. modified the milestone: on May 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions