jspm / registry

The jspm registry and package.json override service
https://jspm.io
229 stars 255 forks source link

Backbone #190

Open guybedford opened 9 years ago

guybedford commented 9 years ago

I just tried Backbone and it seemed to be loading fine for me in the browser.

@jason can you explain the code you were using that wasn't working. It would be great to look into it.

guybedford commented 9 years ago

Tried:

jspm install backbone -o "{ format: 'global' }"

Then that doesn't work because "_" isn't defined So we need to ensure underscore is acting like a global which means

jspm install underscore -o "{ format: 'global' }"

etc?

speigg commented 9 years ago

I'm running into this problem while trying to make an override for another library. I believe jspm should support a shim option that allows a global namespace to be mapped to a dependency. So... something like:

// shim something:
{
    "imports": {
       "_": "underscore",
       "$": "jquery"
    }
}

This is the same semantics as the webpack imports loader: http://webpack.github.io/docs/shimming-modules.html

For now, I guess making underscore a global is a quick fix, although its not a good solution in the long run. The imports semantics above is much more flexible (i.e, what if there are two completely unrelated dependencies that each expose themselves on the _ namespace? What if a global package has a dependency on another package in the jspm registry? Making the format global isn't going to work every time, I think)

speigg commented 9 years ago

Another option is to override the deps syntax somehow:

// shim something:
{
    "deps": [
       "three",
       {"_": "underscore"},
       {"$": "jquery"}
    ]
}

However I feel like a separate imports syntax is cleaner.

guybedford commented 9 years ago

@speigg yes this feature is planned at https://github.com/systemjs/systemjs/issues/148.

speigg commented 9 years ago

Great!