Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
El Gar
Apr 12, 2007

Hey Trophy...

Combat Pretzel posted:

How do you go about developing multiple interdependent modules at once? So far I've been npm linking thinks. But for debugging an upcoming Electron feature (and other things), I've been running a private repo via verdaccio and installing the other projects the proper way (which also allows deduping). But that's sure a pain in the rear end when you're working on two things at once across the modules.

Can I "overwrite" modules in the module tree by npm linking after installing them as dependency?

The "state of the art" right now is to use workspaces to solve this very problem. Think of it like setting up an environment where all of the workspace dependencies are "linked" into the root project by default.



Yep it's one of these.

Adbot
ADBOT LOVES YOU

El Gar
Apr 12, 2007

Hey Trophy...

N.Z.'s Champion posted:

Yep. Just make sure the version numbers are exactly same or else NPM won't find it and it will try to download it from NPMJS.com

docs...NPM or Yarn

if the workspace version is in range of any dependency request in your entire package tree it will be used


ETA: your root project will also always get the workspace no matter what you have defined in your dependencies, version is ignored in this case.

El Gar fucked around with this message at 15:00 on Jun 28, 2023

El Gar
Apr 12, 2007

Hey Trophy...

M31 posted:

In Bun/Deno/Webworkers the basic HTTP server just takes a (req: Request) -> Response function. Does anybody know if there is something similar in Node that I'm overlooking, or some NPM package that implements this?

Unless I'm missing something you just described node's http/https server.

El Gar
Apr 12, 2007

Hey Trophy...

M31 posted:

Ah, sorry, should have been more explicit. The Node one uses Node specific request/response objects, while the other runtimes use the standardized ones (the same ones that are used in the fetch api)

Node.js has had the fetch api since somewhere in v17 so anything v18 and above is gonna have it. If you're doing client requests just use that. If you're building an http/https server yeah find a framework you like.

El Gar
Apr 12, 2007

Hey Trophy...

In all likelihood it just wasn't on the radar. Focus was on making it a very basic iterator like Map. All of the methods there are either specific to basic Set functionality (has, add, clear, delete) or came with it being an iterator (forEach, entries, keys, values)

Arrays in JS don't have intersection either so there wasn't any sort of parity to try to keep there.

Fwiw "[...x]" re-casts your entire set as an array in memory. Iterate through the Set itself and conditionally add to a new Set if this is something you're actually wanting to do in your code.

El Gar
Apr 12, 2007

Hey Trophy...

teen phone cutie posted:

just installed our node_modules with bun instead of npm and it was 1.7 seconds vs. 14

are you loving kidding me?

Global cache w/ the packages already un-tarred and the files hard linked in. You're sharing your node_modules with every other installation on your hard drive, that's the tradeoff.

El Gar
Apr 12, 2007

Hey Trophy...

necrotic posted:

No. That’s how pnp or whatever works too, if I remember right.

Yes pnpm works the same way.

huhu posted:

Why is this so wrong?

Nothing inherently wrong with this it's just a different way of doing things. It's up to you to decide if you're ok with it.

smackfu posted:

A decent number of packages broke when yarn did it but that was years ago so I would think most stuff can deal with a shared location now.

Yarn has a "pnp" mode still it's just not the default.

npm has one too but it still untars the package from the cache and each project is in isolation from the next, untarred packages are in a local ".store/" directory inside node_modules.

Adbot
ADBOT LOVES YOU

El Gar
Apr 12, 2007

Hey Trophy...

Please also note how the example given there is declaring typescript as a peerDependency. This is more important than folks may realize, because it tells npm et al that typescript needs to live alongside your package in that version, not just as a subdependency. One reason for this is because in a typical typescript app, if you have multiple versions of typescript in your tree you get some unexpected breakages. Peer dependencies are an attempt to mitigate this because npm will warn if there is an incompatibility between peerDependencies, whereas with normal ones it will just put whatever version works into your packages subdependencies. They don't totally solve the problem, and the end-user needs to do their own due diligence to make sure only one copy of typescript is in their tree, but setting it as a peerDependency makes that job easier and is more helpful to the community in general.

This is also why it's best to still use ranges, even if you're setting an upper bound. If you pin to a specific typescript version it is virtually impossible to deduplicate typescript unless every single dependency in your tree has that exact version in range. If even one other pins to a different version you're either out of luck or have to start implementing overrides.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply