News for hackers. Stuff that matters.
Re:WMR – Tiny all-in-one development tool for modern web apps by Xenograph on Thursday December 03, 2020 @11:45AM (#25290858)
> If you'd like ESLint to be set up for you, add --eslint to the command. Note: this will use 150mb of disk space.

This is insane. No wonder they were motivated to create a minimal development tool. How could a CLI linter require 150 MB of disk?

Re:WMR – Tiny all-in-one development tool for modern web apps by developit on Thursday December 03, 2020 @02:13PM (#25293170)
tbh I think a good chunk of that size is babel-parser, which we're looking into removing from the preact ESLint preset. Still quite a difference though.
Re:WMR – Tiny all-in-one development tool for modern web apps by franga2000 on Friday December 04, 2020 @03:11AM (#25300158)
Still, that's just a parser, right? An entire Python installation can fit in that space - parser, interpreter, stdlib and package manager. (and I'm sure many others too, python is just what I'm familiar with)
Re:WMR – Tiny all-in-one development tool for modern web apps by developit on Friday December 11, 2020 @11:27PM (#25395545)
Oh I totally agree it's strange, haha. The cost tends to be magnified in Node land since everything is a million files.
Re:WMR – Tiny all-in-one development tool for modern web apps by corytheboyd on Thursday December 03, 2020 @11:24AM (#25290506)
Looks neat, but why is this a thing?

> import "packages" from npm without installation

IIRC rollup does the same thing by default. This project mentions it uses rollup so maybe that’s where it’s coming from.

Using npx to run executables also does this IIRC.

And I never want it, especially if I have to opt-out. I want there to be friction to adding dependencies, it should be a carefully considered process.

Otherwise, would be curious to see how this stacks up against a moderately sized application build using webpack or vanilla rollup too. To see that, we will just need adoption over time, will keep an eye on the project!

Update: It’s not rollup that auto-installs packages, I was confusing it with parcel.

Re:WMR – Tiny all-in-one development tool for modern web apps by cprecioso on Thursday December 03, 2020 @11:36AM (#25290704)
Rollup doesn’t import automatically, Parcel does.

`npx`’s specific use case, though, is specifically to run scripts that you haven’t installed - else you’d use `yarn/npm run whatever`.

Re:WMR – Tiny all-in-one development tool for modern web apps by corytheboyd on Thursday December 03, 2020 @11:47AM (#25290892)
D’oh you’re completely right about rollup vs parcel. I always get them confused because I trialed them simultaneously :p

Huh, I wasn’t aware of that being the primary use case of npx. I assumed the primary use case was to be sugar on top of ‘./node_modules/.bin/*’, which the documentation seems to lead with too (https://github.com/npm/npx)

They immediately call out auto-installation as a feature after that, but apparently there is a ‘—no-install’ flag you can use too. I guess I would have expected this to be opt-in through ‘—auto-install’ or something is all.

Re:WMR – Tiny all-in-one development tool for modern web apps by eyelidlessness on Thursday December 03, 2020 @02:34PM (#25293483)
I’m honestly astonished that this is a selling point. Sure, fewer steps sounds nice... but in addition to your (correct) point about friction when adding dependencies, it’s also a security and compatibility nightmare. And it likely makes using tools like typescript an exercise in frustration if it’s even possible.

Edit: I’d also add that npx has all of the same problems multiplied by being even less frictionful.

Re:WMR – Tiny all-in-one development tool for modern web apps by corytheboyd on Thursday December 03, 2020 @02:41PM (#25293619)
I didn’t realize it installed packages automatically until I tried running my application in another environment where it crashed due to a missing package. When I found out why I was a bit upset :P

This is terrible, if you forget to add the package to your manifest, what, is the expected behavior that you just run the latest version always? Why would you want that in a production environment ever? Especially when the package manager is RIGHT THERE and already solves the problem in a well understood way. Huge step backwards IMO

Re:WMR – Tiny all-in-one development tool for modern web apps by developit on Thursday December 03, 2020 @04:13PM (#25295036)
It's designed for rapid prototyping. You can just use npm or yarn and ignore this feature though, it's entirely optional.

FWIW the surface area for security issues here is far smaller than npx or similar tools, because WMR only writes JS/CSS/TS files to disk, and doesn't execute package scripts (where most vulnerabilities reside).

Re:WMR – Tiny all-in-one development tool for modern web apps by chrisweekly on Thursday December 03, 2020 @08:28PM (#25297905)
Yeah, pnpm helps fix a related issue wherein flat node_modules (ie, npm or yarn) can lead to the existence of undeclared dependencies. Check it out if you care about proper dependency mgmt.
Re:WMR – Tiny all-in-one development tool for modern web apps by eyelidlessness on Friday December 04, 2020 @12:32AM (#25299345)
It’s very much on my list. I was really gunning for yarn 2 for some greenfield projects but after finding its awful rough edges I looked more at pnpm and it feels much more in line with what I want.
Re:WMR – Tiny all-in-one development tool for modern web apps by brundolf on Thursday December 03, 2020 @12:46PM (#25291876)
For those like me who missed it in the title: this is only for Preact, which is part of what allows it to be so comprehensive. Preact is cool, but "all-in-one development tool for modern web apps" may be overselling the scope a little bit
Re:WMR – Tiny all-in-one development tool for modern web apps by developit on Thursday December 03, 2020 @02:15PM (#25293203)
Hmm - it's not actually specific to Preact, it's just built by the Preact team and we use Preact in the docs. We are missing a bunch of documentation that would have made this clearer though, which I apologize for. While there are some optimizations for Preact in WMR, it can be used for vanilla JavaScript / Lit / Vue / Svelte / etc just fine.
Re:WMR – Tiny all-in-one development tool for modern web apps by BadInformatics on Thursday December 03, 2020 @05:44PM (#25296346)
Can you talk more about how WMR fits into the morass of Snowpack, Vite, Rome, Parcel etc.? The self-contained aspect looks great, but I'm at a loss as to how this doesn't also add more entropy into the pool of "next-gen" JS build tools (and thus more analysis paralysis for webdevs)...
Re:WMR – Tiny all-in-one development tool for modern web apps by developit on Friday December 11, 2020 @11:34PM (#25395591)
The tooling space isn't broad enough to allow for differentiation across the board, so we have a number of tools that are working to validate/popularize a subset of functionality on top of the basics.

WMR's unique take is basically to be instant in every possible way, and to provide an ideal substrate for us to build and show Preact features that rely on bundler semantics. We have maintained a Webpack-based build tool for Preact for a while, and wanted to explore what a total re-think would look like. We also spent a while building out new pieces of the bundler that fit this model better than repurposing existing generalized tooling. This is one of the reasons WMR builds as fast as it does despite doing so much optimization work - it's designed around a singular goal and we allowed for very limited compromise.

I think that after a few years we will see a corresponding consolidation of the tools you mentioned, as the dust settles on this newer dev/prod split paradigm and it's effect on the bundler plugin ecosystem.

Re:WMR – Tiny all-in-one development tool for modern web apps by brundolf on Thursday December 03, 2020 @02:32PM (#25293458)
I assume features like prerendering HTML must only work for Preact though, right? That requires some significant assumptions about the codebase (compared to tools like Babel and Webpack). Also, hot reloading seems to only work for Preact components (based on the wording)
Re:WMR – Tiny all-in-one development tool for modern web apps by developit on Thursday December 03, 2020 @04:17PM (#25295106)
We've only shipped a helper library for Preact, but the Prerendering is actually generic. Some folks are working on helpers for other frameworks. The "API" is just a function exported from your first script tag:

export async function prerender(data) { return { html: "<h1>hi</h1>", links: ["/other-page"] } }

Hot reloading is a similar story, it's the same API as Vite and Snowpack:

if (import.meta.hot) import.meta.hot.accept(({ module }) => { do stuff }));

Re:WMR – Tiny all-in-one development tool for modern web apps by mssundaram on Thursday December 03, 2020 @04:00PM (#25294830)
How do I use this for Typescript and TSX? I see a few mentions of Typescript in the code (e.g. a transform plugin) but no guidance on how to set it up
Re:WMR – Tiny all-in-one development tool for modern web apps by developit on Thursday December 03, 2020 @04:16PM (#25295081)
It's built-in, just change the file extension to `.tsx` or create a new file with that extension.
Re:WMR – Tiny all-in-one development tool for modern web apps by mssundaram on Thursday December 03, 2020 @04:32PM (#25295358)
I tried renaming public/index.js to public/index.tsx and get "./public/index.js - File not found" in the build watcher. Of course the index.html is still referencing the index.js file - what do I need to do?

Edit: It does work for e.g. pages/about/index.js to rename to index.tsx - so maybe it's just the main index that won't work as Typescript?

Also it looks like there is no default definition provided for imported CSS modules - the import resolves to a string so "styles.about" doesn't compile

Re:WMR – Tiny all-in-one development tool for modern web apps by developit on Thursday December 03, 2020 @04:40PM (#25295506)
You need to change the HTML to point to the tsx file too:

<script type="module" src="./index.tsx"></script>

There are ambient TS definitions for CSS Modules, it just had a bug in 1.0.0 - fix is merged and will be released shortly.

Re:WMR – Tiny all-in-one development tool for modern web apps by mssundaram on Thursday December 03, 2020 @04:43PM (#25295552)
Thank you!
Re:WMR – Tiny all-in-one development tool for modern web apps by phaedryx on Thursday December 03, 2020 @01:27PM (#25292519)
I'm out of the loop, what does WMR stand for?
Re:WMR – Tiny all-in-one development tool for modern web apps by charcuterie on Thursday December 03, 2020 @01:31PM (#25292575)
Wet module replacement
Re:WMR – Tiny all-in-one development tool for modern web apps by jessaustin on Thursday December 03, 2020 @05:50PM (#25296434)
Wasn't that a Cardi B song?