Skip to content

Allow string entrypoints, add debug flag, and improve support for Docker#2031

Merged
jwoertink merged 9 commits intoluckyframework:mainfrom
wout:allow-string-entrypoints-and-add-debug-flag
Apr 4, 2026
Merged

Allow string entrypoints, add debug flag, and improve support for Docker#2031
jwoertink merged 9 commits intoluckyframework:mainfrom
wout:allow-string-entrypoints-and-add-debug-flag

Conversation

@wout
Copy link
Copy Markdown
Contributor

@wout wout commented Apr 4, 2026

Purpose

Description

Eternal reload loop

If the WS server wasn't available, it triggered onclose which did a reconnect, resulting in an eternal reconnect loop. It's now fixed by registering a successful connection first, and only attempting a reconnect if that flag was set to true.

Better support for docker development

Inside Docker Bun will need to listen to 0.0.0.0. That can now be done by using the listenHost option:

{
  "devServer": {
    "listenHost": "0.0.0.0"
  }
}

If no listenHost is defined, the host option will be used instead, which defaults to 127.0.0.1

String entry points

Bun treated the strings as arrays, so every character in the entrypoint string was considered to be an entry point. Now both arrays and strings are supported because it's an easy mistake to make.

The --debug flag

WebSocket client connection status logs are now behind the --debug flag. So you'll have now:

  • bun bake.js → builds assets without fingerprinting and minification
  • bun bake.js --dev → builds assets without fingerprinting and minification, and starts dev server
  • bun bake.js --dev --debug → dev server with WS connection info
  • bun bake.js --prod → builds assets with fingerprinting and minification
  • bun bake.js --dev --prod → dev server, but with fingerprinting and minification (a.k.a. production build in development)

The watchDirs config option

In the bun_bun_bundle Ruby gem we watch on app/assets, which naturally excludes all other files. On the Lucky side, we watched on src, including all Crystal files as well. Since assets in Lucky are not scoped to one directory, those individual directories needed to be configured.

We could have derived the watch dirs from the staticDirs + directory names of the entryPoints, but that's not watertight. Because what if someone configures entrypoints to be at src/js/entrypoints/app.js? Then none of the other JS files would be included. The current watchDirs config option sets good defaults for Lucky:

  • src/js
  • src/css
  • src/images
  • src/fonts

I think it's safe to assume that for 95% of the projects this config option won't need to be touched.

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

Comment on lines +38 to +40
def self.from_json(pull : JSON::PullParser) : Array(String)
case pull.kind
when .string? then [pull.read_string]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Clever. I was originally thinking it should have been an exception, but I think this actually fits better with the whole "action of least surprise" or whatever that saying is. I originally reached for a string without thinking 😅 so this works great!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I figured you wouldn't be the first. I would probably walk into that as well at some point😊

Copy link
Copy Markdown
Member

@jwoertink jwoertink left a comment

Choose a reason for hiding this comment

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

Good catch on that Docker connection issue. These fixes definitely help polish this up.

@wout
Copy link
Copy Markdown
Contributor Author

wout commented Apr 4, 2026

Your input was golden here. It pushed me down another rabbit hole of things that could go wrong, as you can see from the commits. 😬

@jwoertink jwoertink merged commit 8dd7adc into luckyframework:main Apr 4, 2026
8 of 9 checks passed
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.

Bun building with invalid EntryPoints returns some crazy output

2 participants