Live data from Hacker News

Writing JavaScript without a build system

jvns.ca

1–10 of 187 posts

Re: Writing JavaScript without a build system

#4
If you use Visual Studio Code and stick a jsconfig.json in the root of your project, you can use JSDoc comments (and .d.ts files if you want) to get build-free type checking using its internal version of TypeScript:

    {
      "compilerOptions": {
        "checkJs": true,
        "target": "es2020"
      }
    }

Re: Writing JavaScript without a build system

#5
Use npm to install libraries one time only.

Try to use as few dependencies as possible.

You don't need a framework--components are achievable without vue and react etc.

Server side rendering and VDom are really not needed for most projects.

Think of Programming in JavaScript, CSS and F5 rather than Typescript and SASS as the equivalent of Marcus Aurelius' Stoicism.

Re: Writing JavaScript without a build system

#7
Skipping a build system is my default for new JavaScript these days. The main suggestion I would add is using git submodules[0] for dependencies. It's a bit unwieldy and I always have to look up the syntax, but works pretty well.

You can have something like a `lib` directory in your project and place submodules for other projects in there. The dependencies need to provide some sort of a prebuilt artifact in the repo that you can import (or natively support ES Modules), but I've had good luck so far.

I'll also shout out jsdelivr[1] which is great for pulling dependencies directly from github.

[0]: https://git-scm.com/book/en/v2/Git-Tools-Submodules

[1]: https://www.jsdelivr.com/

Re: Writing JavaScript without a build system

#8
post #5

Use npm to install libraries one time only. Try to use as few dependencies as possible. You don't need a framework--components are achievable without vue and react etc. Server side rendering and VDom are really not needed for most projects. Think of Programming in JavaScript, CSS and F5 rather than Typescript and SASS as the equivalent of Marcus Aurelius' Stoicism.

JavaScript and CSS are to Stoicism as Typescript and SASS are to _____?

Re: Writing JavaScript without a build system

#9
post #6

All those extraneous elements to Javascript are a real turn-off. Python: batteries mostly included. Javascript: feels like you need to drag a dozen suitcases along anytime you embark on any non-trivial project.

Huh… in Python I feel like the tooling is largely missing.

Re: Writing JavaScript without a build system

#10
> I’d love more tips for no-build-system javascript

1. MDN has a comprehensive guide on JavaScript modules [0]

2. A build system free way to build interactive websites could be to combine libraries like htmx[1] and or lit[2] or just the sub package lit-html[3]. Or just go with native web components and a bit of AJAX.

[0] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guid...

[1] https://github.com/bigskysoftware/htmx

[2] https://github.com/lit/lit

[3] https://github.com/lit/lit/tree/main/packages/lit-html

Post reply on HN