Live data from Hacker News

Writing JavaScript without a build system

jvns.ca

81–90 of 187 posts

Re: Writing JavaScript without a build system

#81

I'm in the same camp and never want to run a build process for JavaScript ever again. I've been slowly improving https://dlitejs.com/ which is a minimal (5kB minified + gzipped) JavaScript framework which works great loaded from unpkg. It's pretty crazy to see how lean a framework can be nowadays (even with two-way binding, directives, and event binding) when leveraging newer standards like Web Components and the Sha…

Web Components suck, Custom Elements is where it’s at ;)

Just leave out the attachShadow.

Re: Writing JavaScript without a build system

#82
Vue.js seems to be the natural choice for progressive JavaScript Apps without a build system.

We've also removed npm build systems from our newest .NET Project templates which uses JavaScript, Import Modules to progressively enhance Razor Pages Apps, which I've also written about in:

"Simple, Modern JavaScript"

https://vue-mjs.web-templates.io/blog/javascript

As you have access to full Vue 3 you're still highly productive being able to use Vue 3's Composition API and Plugins & Components which are able to be loaded directly in the browser.

We're still using TypeScript definitions for enabling static analysis benefits for external libraries but have switched to JSDoc type annotations for App code to avoid any runtime transpilation.

Re: Writing JavaScript without a build system

#83
post #33

Getting older projects to run was a huge pain for me when I started working with JavaScript, but I have found two easy steps to get around this: 1. Use nvm + an .nvmrc file in your project to pin the major version of Node.js you are using. I recently got a five year old Node 8 project up and running with no issues using this method. 2. Try to avoid packages that has binary dependencies (like node-sass). 99% of binary…

nvm is slow when changing directories, fnm is a fast drop-in replacement

Re: Writing JavaScript without a build system

#85

Earlier quoted context omitted.

So no compile time checks and no runtime checks? What would the advantage of types be?

With decent dev tooling, you are getting edit-time checks equivalent to compile-time checks (the only difference is that there is no compilation after the checking), so there’s no loss. The advantage of compile-time checking has nothing to do with “compile time” except that compile time is inherently before runtime, and edit time is even earlier.

The fact that you can't run without passing the checks is an advantage to compile time checks in some particular (social) contexts, although a disadvantage in others.

Re: Writing JavaScript without a build system

#87

If anyone's looking for something like a framework that works with buildless workflows you might check out the project I work on: Lit ( https://lit.dev ) Lit gives you reactive components, declarative HTML templates, runtime encapsulated DOM and styles, interoperability with frameworks and HTML via web components, and a lot more - with no required build tools at all. We take great care to make sure our libraries are…

I've been looking for a modern JS library that doesn't require a build step, and I've always skipped over Lit because I thought it depended on a build until this comment.

Is there any documentation about using it without a build? All the documentation and tutorials seem to assume a build step. I've found several different "getting started" entrypoints on the site, and they all begin with "npm install" and "import {LitElement, html} from 'lit';" which won't work without a build step, correct?

Re: Writing JavaScript without a build system

#88
post #87

If anyone's looking for something like a framework that works with buildless workflows you might check out the project I work on: Lit ( https://lit.dev ) Lit gives you reactive components, declarative HTML templates, runtime encapsulated DOM and styles, interoperability with frameworks and HTML via web components, and a lot more - with no required build tools at all. We take great care to make sure our libraries are…

I've been looking for a modern JS library that doesn't require a build step, and I've always skipped over Lit because I thought it depended on a build until this comment. Is there any documentation about using it without a build? All the documentation and tutorials seem to assume a build step. I've found several different "getting started" entrypoints on the site, and they all begin with "npm install" and "import {Li…

Some of this depends on what you consider a build step. I generally don't consider installing from npm a build step. I also don't really consider rewriting import specifiers a build step - it's just locating files on disk.

Regardless, we do have some workflows for completely "tool-less" (or local-tool-less).

- We publish bundles to jsDelivr: https://lit.dev/docs/getting-started/#use-bundles

- You can import directly from JS module CDNs like unpkg.com, ie:

    import {LitElement, html} from 'https://unpkg.com/lit@2.6.1/index.js?module';
Ultimately we're not really dogmatic about things and support a wide variety of tools. The thing we care about is that tool-less development is possible, and that you can use standard semantics and tools with no special configuration (ie, regular Node resolution is all that's required locally, we stick to standard ES2020).

Re: Writing JavaScript without a build system

#89
I just simply do not use anything for my single page web apps that requires build. I still use build on production but strictly for bundling / minification. So far no problems.

Also I do not really use any frameworks. Just some libraries with particular functionality when needed.

Re: Writing JavaScript without a build system

#90

Use Vite and don't look back. It's so refreshing compared to Webpack.

You’re missing the entire point. That’s still a build process and still has additional overhead for both development and deployment.

In black and white terms, sure, it’s still a build process, but I second the recommendation to try Vite - the overhead is minimal and the expressive power build chains enable more than justify the overhead. I say this as someone who still writes plenty of vanilla JavaScript and was long reticent to adopt build chains into my workflow.

In this case the A in YAGNI stands for “Are”.

Post reply on HN