rtsao / csjs

:sparkles: Modular, scoped CSS with ES6
MIT License
576 stars 32 forks source link

Use simple lexical analysis instead of regex #47

Closed rtsao closed 7 years ago

rtsao commented 8 years ago

See: https://github.com/rtsao/csjs/issues/39

This is a pretty significant refactor. Scoping is now based on tokenization, which based on early benchmarks, should speed things up significantly. Lexer is based on the lexer from https://github.com/brettstimmerman/mensch but modified to be faster and avoid doing work we don't need for CSJS

Remaining items:

This would also be an opportunity to do something like: https://github.com/rtsao/csjs/issues/34 and https://github.com/rtsao/csjs/issues/25

neurosnap commented 8 years ago

Did you ever consider using postcss for scoping the CSS?

rtsao commented 8 years ago

Yes, originally I looked at postcss but it's a pretty heavy dependency. I wanted csjs to be really lightweight so when I realized I could do the basics with simple regex and replacement, I went with that approach.

The lexer in this PR is very optimized for the concerns of csjs so it should be faster than other more general parsing solutions that need to account for the entirety of CSS.

rtsao commented 7 years ago

Closing for now as this is isn't going to happen in the near term. This needs to be investigated further, though.