Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simpler codegen #559

Merged
merged 8 commits into from
May 4, 2017
Merged

Simpler codegen #559

merged 8 commits into from
May 4, 2017

Conversation

Rich-Harris
Copy link
Member

Something I snuck into #525 — if an expression in a deindent template literal is falsy, it will a) ignore it and b) remove the preceding whitespace. This makes it much easier to write codegen code that actually resembles the output — it's far more compact and (I think) easier to follow.

Have also updated deindent so that if an expression is an array, it gets joined (with a newline separator) automatically, reducing noise.

Some of the && expressions in this PR probably shouldn't be inlined the way they are, but at least this gives us a bit more flexibility to find the most readable approach.

@codecov-io
Copy link

codecov-io commented May 3, 2017

Codecov Report

Merging #559 into master will decrease coverage by 0.21%.
The diff coverage is 95.65%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #559      +/-   ##
==========================================
- Coverage    88.2%   87.98%   -0.22%     
==========================================
  Files          95       95              
  Lines        2933     2855      -78     
==========================================
- Hits         2587     2512      -75     
+ Misses        346      343       -3
Impacted Files Coverage Δ
src/generators/dom/visitors/EachBlock.js 100% <ø> (+1.26%) ⬆️
src/utils/deindent.js 100% <100%> (ø) ⬆️
src/utils/CodeBuilder.js 89.36% <100%> (+0.47%) ⬆️
...rc/generators/dom/visitors/Element/EventHandler.js 100% <100%> (ø) ⬆️
src/generators/server-side-rendering/index.js 100% <100%> (ø) ⬆️
src/generators/dom/index.js 97.56% <100%> (-0.82%) ⬇️
src/generators/dom/visitors/Element/meta/Window.js 75% <75%> (+0.39%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c712ad5...d8364f6. Read the comment docs.

@evs-chris
Copy link
Contributor

FWIW, that's much easier for me to follow, and offspring have robbed me of a fair amount of my diminishing brain power 😃. It's kinda like debugging with source maps vs without.

@Rich-Harris Rich-Harris changed the title [WIP] Simpler codegen Simpler codegen May 4, 2017
@Rich-Harris
Copy link
Member Author

Yep, feels much nicer! And a good bit less code

@Rich-Harris Rich-Harris merged commit 3a7f7e2 into master May 4, 2017
@Rich-Harris Rich-Harris deleted the simpler-codegen branch May 4, 2017 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants