Skip to content

css modules do not support extends in dev env: TypeError: Cannot redefine property: $style #1449

Closed
@wmzy

Description

@wmzy

Version

15.4.0

Reproduction link

https://see.below

Steps to reproduce

  1. Create project by vue-cli
  2. Create two components and mount the `Bar``.
    Foo:
......
<style module lang="scss">
.root {
  color: red;
}
</style>

Bar:

<template>
  <div :class="$style.root">
      There should be black.
  </div>
</template>

<script>
import GameCard from './GameCard.vue';

export default {
  extends: Foo
};
</script>
<style module lang="scss">
.root {
  color: black;
}
</style>
  1. Run npm run serve.

What is expected?

No error and the color is black.

What is actually happening?

TypeError: Cannot redefine property: $style


I think here should be:

        Object.defineProperty(this, ${name}, {
          configurable: true, // !
          get: function () {
            return cssModules[${name}]
          }
        })

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions