question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Experimental preprocessor using existing parsers

See original GitHub issue

In the past day, I’ve put a small proof of concept of a refactor of this project to reuse the Svelte & Windi parsers. You can find it here grenierdev/svelte-windicss-preprocess.

<div class="min-h-screen bg-gray-100" />
stays
<div class="min-h-screen bg-gray-100" />

<div class="bg-white font-light sm:hover:(bg-gray-100 font-medium)" />
becomes
<div class="bg-white font-light sm:hover:bg-gray-100 sm:hover:font-medium" />

<div class="flex px-{a} lg:px-{b}" />
becomes
<div class="flex px-{a} lg:px-{b}" />
                    ^---------^------------------------- intact, author will need to add style
                                                         manually for all possible values of {a}
                                                         and {b}

<div class="bg-white font-light sm:hover:(bg-gray-{b} font-medium)" />
becomes
<div class="bg-white font-light sm:hover:bg-gray-{b} sm:hover:font-medium" />
                                                 ^------ intact, author will need to add style
                                                         manually for all possible values of {b}

<div class={`px-3 py-${c + 2 - 10} sm:(text-gray-${d} text-sm font-medium)`} />
becomes
<div class={`px-3 py-${c + 2 - 10} sm:text-gray-${d} sm:text-sm sm:font-medium`} />
                     ^--------------------------^------- intact, author will need to add style
                                                         manually for all possible values of 
                                                         {c + 2 - 10} and {d}

All of which could be passed to something described in https://github.com/windicss/svelte-windicss-preprocess/issues/35#issuecomment-790940288 (using WindiCSS at runtime).

Still just a proof of concept and does not yet cover all the features, namely the class directive.

Could be worth discussing?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
alexanderniebuhrcommented, Mar 5, 2021

We have to evaluate all trade-offs in detail, before doing changes in that scale. I will look into your prototype in more detail during the weekend. I still think a combination of both would be the best fit here, but I will check!

1reaction
grenierdevcommented, Mar 5, 2021

I’ve wrap the whole markup function with console.time/timeEnd.

On my simple project, here are the timings

client\views\Empty.svelte: 6.251ms
client\App.svelte: 14.022ms
client\Workbench.svelte: 4.612ms
client\Layout.svelte: 30.093ms

I did the same with v3.0.0-beta.1

client\views\Empty.svelte: 1.976ms
client\App.svelte: 8.723ms
client\Workbench.svelte: 1.212ms
client\Layout.svelte: 10.923ms

I’m running this on Win10 with a 24cpu/32Gb ram on a M.2 SSD 6Gbps, node v14.15.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Parsing All of C by Taming the Preprocessor
and 520,000 macros for code expansion. In this paper, we present a new tool for parsing all of C, in- cluding arbitrary preprocessor...
Read more >
Parsing Combinatory Categorial Grammar with Answer Set ...
In this work we propose and implement a new approach to CCG parsing that relies on a prominent knowledge representation formalism, answer set ......
Read more >
The application of JavaCC to develop a C/C++ preprocessor
used to generate parsers in Java. With JavaCC, we developed a universal C/C++ preprocessor. which runs on any computer platform with a Java ......
Read more >
Better Binarization for the CKY Parsing - ACL Anthology
Therefore we propose a novel binariza- tion method utilizing rich information learnt from training corpus (Section 5). Experimental results show that our ...
Read more >
Training a Parser for Machine Translation Reordering
We present experiments on translation from English to three Subject-Object-. Verb (SOV) languages,1 because those require ex- tensive syntactic reordering to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found