Skip to content
This repository has been archived by the owner on Aug 2, 2018. It is now read-only.

support npm? #193

Open
ianstormtaylor opened this issue Aug 18, 2014 · 7 comments
Open

support npm? #193

ianstormtaylor opened this issue Aug 18, 2014 · 7 comments

Comments

@ianstormtaylor
Copy link
Contributor

Just wanted to open this to jot down the way I think about this, and see if you guys even think it's possible or not, since I'm less familiar with the internals. I was thinking it would be really badass if when Duo was launched it support Component, Bower and Browserify packages out of the box (obviously not required, but it would still blow people's minds I think).

Right now we require dependencies as:

var require('component/emitter');

Which we can think of Go-style as shorthand for:

var require('github.com/component/emitter');

We can think about that "default" as being implicitly defined in the component.json, as something like:

{
  "name": "my-component",
  "defaultRemote": "github.com",
  "dependencies": { ... }
}

So if we wanted to grab a package straight from NPM instead, we would do:

var require('npmjs.org/lodash');

And that would internally use a different install adapter to download the tarball. And when it downloaded the package, it would need a step to swap the package.json dependencies into a component.json that also set the remote to npmjs.org like so:

{
  "name": "my-component",
  "defaultRemote": "npmjs.org",
  "dependencies": { ... }
}

So that when resolving child-dependencies we know which remote we should be looking to when no remote is specified outright. Then the npm install adapter could just have a simple catch for native modules that swaps in the standard browserify shims?

I think with all of those pieces in place, all of the npm-logic is able to be quarantined into just living in the single install adapter? Does that make sense?

@anthonyshort
Copy link

Would be pretty amazing if this could work. You'd need to include all the built-in crap that Browserify adds, like shims for all the node globals and libraries.

@ianstormtaylor
Copy link
Contributor Author

Yup, we could depend directly on the file from browserify with:

var builtins = require('browserify/builtins.js');

Or even use browserify on the npm package directly so we don't have to manage it at all maybe.

@cristiandouce
Copy link

Or maybe just let gulp-browserify do the browserifying thing out? Now that Duo supports gulp...

@stephenmathieson
Copy link
Contributor

related: #7 #39

@matthewmueller
Copy link
Contributor

@ianstormtaylor i think that's on the right track. I'm not really sure about the implementation details of this kind of task. We'd also have to resolve from the package.json instead of the component.json. It'd be a pretty big task I think.

I probably won't be the one making this happen, at least not right now. But I'd support any initiative to get this up and running.

Or maybe just let gulp-browserify do the browserifying thing out? Now that Duo supports gulp...

I wish it was this simple :-/. I think the package managers will conflict with each other though. Worth testing out!

@zeke
Copy link

zeke commented Aug 28, 2014

I'm just dipping my toes into the duo stream, but this project looks awesome!

I work for npm now, so let me know if I can help somehow.

@thelinuxlich
Copy link

+1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants