Skip to content

Conversation

@jwoertink
Copy link
Member

Purpose

Fixes #1783

Description

No clue if this is a good idea or not 😅 This would be considered a breaking change, but in theory, should be easy to update existing apps....

The idea here is that when you have an API only Lucky app, and have no need for any sort of HTML pages/components, then by removing these files, you should see a (small) performance increase in compilation time.

In my very limited testing, I saw compilation time drop by several seconds. Granted, my app takes well over 2 minutes to compile, so it wasn't much... but I figure in the case of smaller apps, this may be the difference between getting distracted when writing specs, and being productive.

If all works correctly, you would just need to add this for existing apps that need HTML

require "lucky"
require "lucky/html"

Checklist

  • - An issue already exists detailing the issue/or feature request that this PR fixes
  • - All specs are formatted with crystal tool format spec src
  • - Inline documentation has been added and/or updated
  • - Lucky builds on docker with ./script/setup
  • - All builds and specs pass on docker with ./script/test

@jwoertink jwoertink added the BREAKING CHANGE This will cause a breaking change label Nov 7, 2025
@jwoertink
Copy link
Member Author

jwoertink commented Nov 8, 2025

Testing on a fresh 2 fresh apps. This one is an API only app where I've added the require "lucky/html" in and taken it out... but can you guess which one is which?

~/Sites/zzz_garbage_api is 📦 v0.1.0 via 🔮 v1.18.2 took 5s
❯ time crystal build src/start_server.cr

real	0m4.518s
user	0m4.124s
sys	0m1.057s

~/Sites/zzz_garbage_api is 📦 v0.1.0 via 🔮 v1.18.2 took 4s
❯ time crystal build src/start_server.cr

real	0m4.516s
user	0m4.146s
sys	0m1.026s

~/Sites/zzz_garbage_api is 📦 v0.1.0 via 🔮 v1.18.2 took 4s
❯ time crystal build src/start_server.cr

real	0m4.851s
user	0m7.041s
sys	0m1.298s

~/Sites/zzz_garbage_api is 📦 v0.1.0 via 🔮 v1.18.2 took 4s
❯ time crystal build src/start_server.cr

real	0m4.360s
user	0m4.163s
sys	0m0.866s

~/Sites/zzz_garbage_api is 📦 v0.1.0 via 🔮 v1.18.2 took 4s
❯ time crystal build src/start_server.cr

real	0m4.603s
user	0m4.189s
sys	0m1.081s

~/Sites/zzz_garbage_api is 📦 v0.1.0 via 🔮 v1.18.2 took 4s
❯ time crystal build src/start_server.cr

real	0m4.800s
user	0m7.051s
sys	0m1.237s

Here's a fresh Web app. Both of these are pulling in this branch.

~/Sites/zzz_garbage is 📦 v0.1.0 via  v24.11.0 via 🔮 v1.18.2
❯ time crystal build src/start_server.cr

real	0m5.328s
user	0m7.195s
sys	0m1.309s

~/Sites/zzz_garbage is 📦 v0.1.0 via  v24.11.0 via 🔮 v1.18.2 took 5s
❯ time crystal build src/start_server.cr

real	0m5.099s
user	0m4.709s
sys	0m1.153s

~/Sites/zzz_garbage is 📦 v0.1.0 via  v24.11.0 via 🔮 v1.18.2 took 5s
❯ time crystal build src/start_server.cr

real	0m5.139s
user	0m4.750s
sys	0m1.176s

~/Sites/zzz_garbage is 📦 v0.1.0 via  v24.11.0 via 🔮 v1.18.2 took 5s
❯ time crystal build src/start_server.cr

real	0m5.064s
user	0m4.727s
sys	0m1.111s

Really, it feels almost negligible... at least in development... lastly, just for funsies, here's a release build comparison.

full app with HTML

~/Sites/zzz_garbage is 📦 v0.1.0 via  v24.11.0 via 🔮 v1.18.2 took 5s
❯ time crystal build --release src/start_server.cr

real	0m44.987s
user	0m42.913s
sys	0m2.043s

api app without HTML

~/Sites/zzz_garbage_api is 📦 v0.1.0 via 🔮 v1.18.2 took 4s
❯ time crystal build --release src/start_server.cr

real	0m40.773s
user	0m38.912s
sys	0m1.727s

class Lucky::Paginator::BulmaNav < Lucky::BaseComponent
needs pages : Lucky::Paginator

@[Deprecated("Consider using Lucky::Paginator::SimpleNav or writing a custom component")]
Copy link
Contributor

@wout wout Nov 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it an idea to put those front-end framework-specific components in a separate shard? Or maybe just document them?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. I think just documenting them would be much better. Like recipes if you need. Then adding them into your project is easy and don't have to worry about outdated CSS framework versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BREAKING CHANGE This will cause a breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate if Actions are the cause of long compilcation times

3 participants