microbundle icon indicating copy to clipboard operation
microbundle copied to clipboard

Issue Emotion.js, "illegal escape sequence in your template literal"

Open fcisio opened this issue 4 years ago • 3 comments

Hi, I'm having trouble when building components that use Emotion's template literal syntax.

export const Component = styled.div`
  background-color: 'blue';
  
  &:hover {
    background-color: 'red';
  }
`

I get the error log:

You have illegal escape sequence in your template literal, most likely inside content's property value. Because you write your CSS inside a JavaScript string you actually have to do double escaping, so for example "content: '\00d7';" should become "content: '\00d7';".

You can read more about this here


Technically, using @emotion/babel-plugin, should fix it; see this thread

Nothing seems to work, and I haven't encountered this issue using webpack on other projects.

My babel.config.js does seem to be used by microbundle, so I don't know why I have this issue.

fcisio avatar Mar 20 '21 01:03 fcisio

I don't think Microbundle uses babel.config.js, only .babelrc.

developit avatar Mar 20 '21 16:03 developit

It doesn't seem to work either for me wi .babelrc.

fcisio avatar Mar 22 '21 14:03 fcisio

Hi @fcisio!

Sorry to hear you're running into an issue. To help us best begin debugging the underlying cause, it is incredibly helpful if you're able to create a minimal reproduction. This is a simplified example of the issue that makes it clear and obvious what the issue is and how we can begin to debug it.

If you're up for it, we'd very much appreciate if you could provide a minimal reproduction and we'll be able to take another look.

wardpeet avatar Mar 26 '21 07:03 wardpeet