Modern SPAs without bundlers, CDNs, or Node.js
11–20 of 170 posts
Re: Modern SPAs without bundlers, CDNs, or Node.js
#12I also sometimes enjoy this approach of starting from absolutely nothing. Instead of taking the path of starting with DOM manipulation and then going to a framework as necessary, I've kept really trying to make raw web components work, but kept finding that I wanted just a little bit more. I managed to get the more I wanted -- sensible template interpolation with event binding -- boiled down to a tag function in 481…
function $E(t,p,c) {
const el=document.createElement(t)
Object.assign(el,p)
el.append(...c)
return el
}
Usage: const button = $E('button', {onclick: () => alert('click!')}, [
$E('img', {src: '/assets/icon-lightbulb.png'}, []),
'Ding!',
])
(With thanks to 'goranmoomin: https://news.ycombinator.com/item?id=23590750)Re: Modern SPAs without bundlers, CDNs, or Node.js
#13The problem with writing a shell script to fetch and download NPM packages is that it won't do so in parallel. I'm sure that's fine if you only depend on one or two packages, but dependency explosion is practically a feature of the NPM ecosystem, and that'll stretch the script runtime. Not to mention fetching packages that you already downloaded, and no compatibility with outside tooling like Dependabot for automatic…
Re: Modern SPAs without bundlers, CDNs, or Node.js
#14Not strong on the frontend that's why genuinely curious.
Re: Modern SPAs without bundlers, CDNs, or Node.js
#15One trick I've used is to `npm install` my dependencies as normal but bundle them with esbuild, while also generating a typescript definition file. This gives me one file I can import in vanilla JS but also lets me check my JS with typescript.
Re: Modern SPAs without bundlers, CDNs, or Node.js
#16Re: Modern SPAs without bundlers, CDNs, or Node.js
#17Re: Modern SPAs without bundlers, CDNs, or Node.js
#18edit: In the same vein; cross-linking to "Writing JavaScript without a build system (jvns.ca)" https://news.ycombinator.com/item?id=34825676
Re: Modern SPAs without bundlers, CDNs, or Node.js
#19Re: Modern SPAs without bundlers, CDNs, or Node.js
#20UPD:
- Preact template: https://github.com/wizzard0/naked-preact
- node/browser TypeScript loader: https://github.com/wizzard0/t348-loader