Skip to content

Conversation

@flibbles
Copy link
Contributor

@flibbles flibbles commented Jan 7, 2026

As a part of #9549, @pmario was concerned that including NPM specific code in boot.js was inappropriate. He's probably right, However, there is a bunch of other NPM and Node.js specific code already there. This is a naive and initial proposal for how that code could be removed and placed into a boot/bootnode.js file so that it:

  • Could free up about 500 lines of code that would no longer have to be sent to browser clients.
  • Chop up boot.js in a meaningful way and make it smaller
  • And of course, provide a place where NPM package importing would be more appropriate. (If we don't decide to put it in tiddlywiki.js)

This is a draft for discussion. Currently, this PR works, but all it's doing is yanking a block of node specific code out and putting it into another file, and then boot.js imports that file. This way is entirely backward incompatible.

However, if we're willing to be a little backward incompatible, this could be a much better solution.

  • Right now, bootnode.js is wrapped in a method that takes $tw as an argument, because it's still needed, but it probably shouldn't be.
    • Most $tw uses are utility calls like $tw.utils.each, which we don't have to use here. This is code that will ONLY run on Node.js, so we could safely use the array forEach method and such.
    • There are some accesses to $tw.config settings, but I'd say those should all be moved into bootnode.js too. They're all completely specific to Node.
    • There are a few other util methods called, like $tw.utils.getFileExtensionInfo, but I'd probably just copy them and make simpler implementations.
  • I'd honestly like to move ALL node specific stuff into $tw.node instead of $tw. As far as I can tell, $tw.node is just an empty object anyway, so it'd be perfect, and this would do much better sandboxing.

Thoughts? This PR took me 10 minutes to make, so it's no big deal if we don't want to deal with this for 5.4.0. I'm mostly proposing this because it would provide a way to introduce the NPM stuff without clogging up the standalone wiki even more.

@netlify
Copy link

netlify bot commented Jan 7, 2026

Deploy Preview for tiddlywiki-previews ready!

Name Link
🔨 Latest commit a5f57a9
🔍 Latest deploy log https://app.netlify.com/projects/tiddlywiki-previews/deploys/695f14b477732a00085c92b6
😎 Deploy Preview https://deploy-preview-9557--tiddlywiki-previews.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link

github-actions bot commented Jan 7, 2026

Confirmed: flibbles has already signed the Contributor License Agreement (see contributing.md)

@github-actions
Copy link

github-actions bot commented Jan 7, 2026

📊 Build Size Comparison: empty.html

Branch Size
Base (master) 2451.4 KB
PR 2453.8 KB

Diff: ⬆️ Increase: +2.4 KB


⚠️ Change Note Status

This PR appears to contain code changes but doesn't include a change note.

Please add a change note by creating a .tid file in editions/tw5.com/tiddlers/releasenotes/<version>/

📚 Documentation: Release Notes and Changes

💡 Note: If this is a documentation-only change, you can ignore this message.

@flibbles
Copy link
Contributor Author

flibbles commented Jan 7, 2026

Wow. No less than 5 emails just flooded my inbox.

Added header to boot/bootnode.js
@flibbles
Copy link
Contributor Author

I'm already trying to fight for two other PRs to go in that I need a lot more than this optional one. I'm picking my battles.

@flibbles flibbles closed this Jan 13, 2026
@github-project-automation github-project-automation bot moved this from Needs feedback to Done in Planning for v5.4.0 Jan 13, 2026
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.

2 participants