Replies: 3 comments 4 replies
-
|
A couple months back, I started getting serious about learning JS properly. I'm still only maybe 50% of the way through learning all that I want to. In the meantime, I'm happy to have help getting things steered in the right direction by someone with more experience. :) Re CodeMirror, I believe I ran into the same thing. I'm totally open to the rest of your suggestions.
These were just me imposing my prior programming preferences on the JS code as an act of rebellion. But I've grown up a little and I'm okay with standardizing on whatever the prevalent JS practices of 2024 are. (Minus adding a bundler or whatever, if it can be avoided.) |
Beta Was this translation helpful? Give feedback.
-
|
Lack of a bundler turns out to be a blocker for using CodeMirror themes, which is necessary for fully correct dark mode support. What you'd normally do is import Maybe this is possible and I couldn't figure it out, but that in itself is a signal. |
Beta Was this translation helpful? Give feedback.
-
|
Just to let you know, this hasn't fallen off my radar... I've been making slow but steady progress getting more up to speed on modern JS and development practices while working on another project. Once that one is more or less functional, I plan to circle back to Silicon to refactor a few things based on your suggestions plus some features that I've been wanting to add. I don't know how long that will take but I just wanted to note that I wouldn't be at all offended if you wanted to fork Silicon in order to make progress on your own improvements without my limited availability holding you up. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Replacing requirejs with native module imports
I took a quick crack at removing the requirejs dependency and using import maps to get CodeMirror. It didn't work. It seems possible to import CodeMirror from esm.sh, but requiring a third party CDN seems like a non-starter.
It's possible CodeMirror will eventually publish a natively-importable bundle. Until then, requirejs it is.
However, it probably makes sense to use import maps and native module imports for the internal JS files, rather than stacking up
<script>tags.Single entry point
If you have a single
main.jsfile that is added to every page, it's easier to work on the JS without needing to inspect the HTML templates to see which scripts are imported. The JS functions all operate on specific elements on the page, so it shouldn't be dangerous to over-include stuff.Formatter
Everybody has idiosyncratic formatting preferences. As the repo owner, you can enforce your own by adding a
.prettierrc. I'd be happy to write one for you to fit your needs. Do you have any rules in mind or could we just apply the default settings and let it reformat a bit? (It looks like.editorconfigwants your JS to use 2-space indents but it uses 4-space, I assume 4 is the right answer?)Camel case
I haven't seen a JS project that uses snake case in years. :-) Are you open to camel case just to reduce the likelihood that someone goes against the style out of sheer muscle memory?
Beta Was this translation helpful? Give feedback.
All reactions