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

dependencies in the manifest as straight up aliases #240

Open
ianstormtaylor opened this issue Aug 22, 2014 · 6 comments
Open

dependencies in the manifest as straight up aliases #240

ianstormtaylor opened this issue Aug 22, 2014 · 6 comments

Comments

@ianstormtaylor
Copy link
Contributor

Just thinking out loud here, but I think it would be cool if dependencies in the manifest was literally just an alias dictionary instead of having the keys be important themselves in terms of resolving dependencies. By that I mean that currently we have this:

{
  "component/clone": "*"
}

But instead it we had this:

{
  "clone": "component/clone@*"
}

Then in a package.json we could also do:

{
  "clone": "*"
}

And then in our source we can do:

var clone = require('clone');

In both Duo and npm lands. Basically it gives us the power to not have to try/catch requires just because npm names aren't aliasable.


One downside is that not all cases are covered:

var Emitter = require('emitter');
var Emitter = require('events').EventEmitter;

Another downside is that it might not be able to be done and keep backwards compatibility for the existing components out there?

@matthewmueller
Copy link
Contributor

Haha we tried this exact same thing in NPM: npm/npm#3014

I think our manifest approach is better, but I definitely wish they would allow this feature in NPM. Especially since, it's like realllly close.

@ianstormtaylor
Copy link
Contributor Author

I guess, disregarding npm, was just thinking that if we have the keys in dependencies be straight up aliases, then we are basically giving the user full control over how they use them in their codebase. Otherwise, right now it seems like you can on require('name') what the component itself has chosen to be named?

So if someone had a component on Bitbucket as thing/events-component and on GitHub as component/events then the aliases would make that a non-issue, because the left-hand side is the alias and the right-hand side is the actual location to resolve from.

Does that make sense?

@micky2be
Copy link

+1
This will fix the issue #301 :)

@FremyCompany
Copy link

I would love to have this, too. I've my own build system right now in https://github.com/FremyCompany/css-grid-polyfill/ where I can name individual files with aliases. If I were to move to "duo" then I would split into more repositories, about one per file, but it may be good to be able to keep the aliases.

See https://github.com/FremyCompany/css-grid-polyfill/blob/master/src/css-grid/polyfill.js#L9 for an example of how it works to hot-link the shared 'https://github.com/FremyCompany/css-grid-polyfill/blob/master/src/core/css-cascade.js' file from the 'css-grid' project right now.

@matthewmueller
Copy link
Contributor

I've changed my mind on this one. I think the browser field in Browserify solves this really nicely and we should just support that.

https://gist.github.com/defunctzombie/4339901
https://github.com/defunctzombie/node-browser-resolve

@FremyCompany
Copy link

That looks great, and would solve my "issue" perfectly :-)

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

4 participants