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

Unable to require components with a prefix e.g. js-, npm- in the repo name #428

Open
jameslnewell opened this issue Jan 20, 2015 · 3 comments

Comments

@jameslnewell
Copy link

Hi,

I've finally found some time to play with Duo. It looks like there are some neat improvements over Component!

However, I use prefixes in my repo names so at a glance I know what language/environment they're written for. Component coped with the prefixes but Duo looks like it doesn't support them?

e.g.

  • repo name: digitaledgeit/js-control-model-binding

  • component name: control-model-binding

  • require stmt: require('control-model-binding')

  • the containing component.json:

    {
    "name": "my-app",
    "dependencies": {
    "digitaledgeit/js-control-model-binding" : "1.2.3"
    }
    }

Would this be difficult to add via a plugin? What methods in duo.js would I need to look at?

Thanks.

@stephenmathieson
Copy link
Contributor

yeah, duo doesn't support component.json's name property. there's currently no way to build a plugin for this :/

@jameslnewell
Copy link
Author

I had a bit of a hack and was able to get it working by overriding and copy/paste/modifying the duo.dependency method. If it fails to resolve a package name it tries to resolve it again with a prefix. This is obviously a bit slower and will break whenever the method internals are updated in duo.

    // `dep` is a remote dependency
    var pkg = this.package(dep, file);
    if (!pkg) {
        dep = 'js-'+dep;
        pkg = this.package(dep, file);
        if (!pkg) {
            debug('1: %s: cannot resolve "%s"', file.id, dep);
            return false;
        }
    }

ty. 😞

@stephenmathieson
Copy link
Contributor

yeah, that's a bit of a hack :p

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

No branches or pull requests

2 participants