cujojs / curl

curl.js is small, fast, extensible module loader that handles AMD, CommonJS Modules/1.1, CSS, HTML/text, and legacy scripts.
https://github.com/cujojs/curl/wiki
Other
1.88k stars 216 forks source link

Proposal for new combined paths/packages config format #235

Open unscriptable opened 11 years ago

unscriptable commented 11 years ago

We've been thinking that the paths and packages configuration syntax is bulky. It's also not clear to new devs which to use: paths or packages?

This new syntax would make it succint to declare the two most common types of packages: those like when.js and those like jquery:

packages: { 

    // a typical package wherein the ancillary modules 
    // are siblings to the main module
    when: 'packages/when/when',

    // a typical mega-module-just-wrapped-in-amd package
    jquery: 'packages/jquery1.9.1/jquery.min',

    // a package whose modules are in a sub folder
    funky: {
        main: 'packages/funky3.1/funky',
        modules: './lib'
    },

    // back-compat with current syntax
    wire: {
        location: 'packages/wire',
        main: 'wire'
    }
}

We could offer the back-compat syntax by sniffing for the existence of location.

Thoughts?

gehan commented 11 years ago

That looks great @unscriptable, would make things a lot simpler. Would making declaring jQuery, poly, curl packages a lot cleaner

I assume you could still used paths if you wanted to?

unscriptable commented 11 years ago

I was hoping we remove paths. I guess we should keep it for cross-loader compat and back compat. :)

briancavalier commented 11 years ago

Yeah, cross/back-compat seems like the only good reason to keep it, imho.

gehan commented 11 years ago

I wouldn't use it now! However it's standard with other libs I assume

teehemkay commented 10 years ago

Nice!

+1 on the simplified packages syntax. +1 on keeping paths for 'for cross-loader compat and back compat' :-)