Skip to content

Braces inside comments inside values fail to parse #39

@suskin

Description

@suskin

Hey guys!

This is related to reworkcss/css#24 .

I have some library css files which I'm bundling, and they have comments with braces inside of the values of some properties. Here's an example:

.a {
  background: blue /* This is { blue } */;
}

When I try to atomify this file, I get an error. The one I see with the example above looks like this:

         Error: /Users/danielsuskin/Documents/Code/site/atomify-css/test/fixtures/css/a-with-inline-comment.css:4:1: missing '{'
           at error (/Users/danielsuskin/Documents/Code/site/atomify-css/node_modules/rework/node_modules/css/lib/parse/index.js:64:15)
           at declarations (/Users/danielsuskin/Documents/Code/site/atomify-css/node_modules/rework/node_modules/css/lib/parse/index.js:241:25)
           at rule (/Users/danielsuskin/Documents/Code/site/atomify-css/node_modules/rework/node_modules/css/lib/parse/index.js:554:21)
           at rules (/Users/danielsuskin/Documents/Code/site/atomify-css/node_modules/rework/node_modules/css/lib/parse/index.js:111:70)
           at stylesheet (/Users/danielsuskin/Documents/Code/site/atomify-css/node_modules/rework/node_modules/css/lib/parse/index.js:81:16)
           at module.exports (/Users/danielsuskin/Documents/Code/site/atomify-css/node_modules/rework/node_modules/css/lib/parse/index.js:558:20)
           at rework (/Users/danielsuskin/Documents/Code/site/atomify-css/node_modules/rework/index.js:27:21)
           at applyRework (/Users/danielsuskin/Documents/Code/site/atomify-css/css.js:43:15)
           at /Users/danielsuskin/Documents/Code/site/atomify-css/css.js:36:22
           at Array.forEach (native)

With my library css, I get one more like Error: property missing ':'

Anyway, I was originally planning to fix this by adding the option to pass configuration into rework, so that you could set silent: true, but that just resulted in this output:

.a {
  background: blue /* This is { blue;
}

Which isn't really right. So I figured I'd start by filing an issue. The above is happening for me with the latest atomify-css.

Do you guys have any ideas about the best way to handle css files containing this type of comment?

Thanks!
Daniel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions