Skip to content

Imported variables aren't replaced in exports if followed by a comma #424

Closed
@chrisdoble

Description

@chrisdoble

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

Bug

What is the current behavior?

If an exported value contains a reference to an imported value followed by a comma, the reference to the imported value isn't replaced.

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

See chrisdoble/css-loader-bug.

What is the expected behavior?

In the example repository above, I expected the first occurrence of the color variable to be replaced with the value of the color variable.

Please mention other relevant information such as your webpack version, Node.js version and Operating System.

webpack: 2.2.1
Node.js: 7.6.0
OS: OS X 10.10.5

I believe this issue is caused by incorrect tokenisation here, e.g.

> "0 0 color, 0 0 color".split(/(\S+)/)
["", "0", " ", "0", " ", "color,", " ", "0", " ", "0", " ", "color", ""]

Note that the first occurrence of the color variable includes a trailing comma which will cause the import lookup to fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions