threepointone / ratpack

ready. set. go!
197 stars 10 forks source link

Install packages when it sees new require #6

Open KyleAMathews opened 7 years ago

KyleAMathews commented 7 years ago

E.g. writing quick bit of code and you realize you want lodash and ratpack installs that in the background for you.

Probably can just use https://github.com/ericclemmons/npm-install-webpack-plugin

threepointone commented 7 years ago

yes, I have my eye on an auto install experience, installing to a 'global' folder, and periodically updating it.
the iffy thing is how to do it 'locally', and /or whether it's even required.

threepointone commented 7 years ago

Should I just include lodash specifically by default? Any others?

KyleAMathews commented 7 years ago

Lodash by default makes sense. Using yarn would make local install just as fast (almost) as a global pool.

On Wed, Jan 4, 2017, 12:08 PM Sunil Pai notifications@github.com wrote:

Should I just include lodash specifically by default? Any others?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/threepointone/ratpack/issues/6#issuecomment-270458050, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEVh1hUK8eUq59EYMygdsiyDuVmc-Sjks5rO-5GgaJpZM4La6np .

rreusser commented 7 years ago

My only feedback/concern would be to wonder what makes lodash special. I don't mean that in any negative way; just that I wonder what special preference means. Does it make lodash somehow simpler to use than other modules?

threepointone commented 7 years ago

Nothing specific, just as special as React I would imagine.

Really thinking the right solution is to have a GUI like atom's pane backed by a 'global' node_modules folder.

JCB-K commented 7 years ago

What about a node_modules folder per directory, installed in a temp location? In some situations you'd still want some kind of package file though, e.g. if you want to specify a version for a package. So let's say you have a a file in users/me/Desktop/test.js that looks like this:

import package from 'myPackage'

It would

This way you're not messing up the user's file system, but you also avoid a global package hell. Thoughts?

threepointone commented 7 years ago

it already uses 'local' node_modules, following node's resolution algo, so that's good.

the global package hell thing is something I do want to step into, specifically because that's the usecase here - libs that you'll commonly use across projects and / or experiments.

mind you, this would be global to just ratpack itself, not 'everything'.

JCB-K commented 7 years ago

Yeah I realise it uses local node_modules, but wouldn't it be nice to keep these abstracted away from the user's file system? Because right now you have to install node_modules yourself, which ratpack could fairly easily take care of behind the scenes.

I suppose there's a use case for global ratpack node_modules. It'll be hard to implement in a problem-free way, but if it works out it'll be super useful.

threepointone commented 7 years ago

you've given me a couple of ideas. I'll try a prototype or two and get back when I have something to share. thanks!

threepointone commented 7 years ago

question - what's the difference between installing to /tmp/ratpack/users/me/desktop/node_modules vs /tmp/ratpack/node_modules in either case, how/when would I update the version of the lib on disk? or when should I delete the lib?

JCB-K commented 7 years ago

The difference would only be noticeable when /users/me/desktop/package.json exists - it would effectively be used as a version manager. But I suppose all files run without a local package.json could be installed to /tmp/ratpack/node_modules, since you'll be defaulting to the latest version then. Updating: at runtime? Deleting: not sure, don't really have experience of desktop development. But I guess it could do garbage cleaning after a week or so.

threepointone commented 7 years ago

ok, how's this as a first step. with a flag (which will be an 'auto install dependencies' button in the ui or something), I'll install dependencies to ~/.ratpack/node_modules, and for now just document it somewhere. I'll expect users to manually update (or downgrade!) modules in that dir, and you can wipe it out to start afresh. This way you can install global dependencies by hand too, if you feel like it. even without auto install, it'll be a good way to have 'defaults' for the system.