Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some browserify transform config issue? #59

Open
ganchenkor opened this issue Oct 3, 2014 · 15 comments
Open

Some browserify transform config issue? #59

ganchenkor opened this issue Oct 3, 2014 · 15 comments

Comments

@ganchenkor
Copy link

http://requirebin.com/?gist=bfdb60970710de06aebc
For some reason it can't resolve and assign Backbone.$ = $
while if I test it locally it works
https://github.com/ganchenkor/marionette-browserify (It uses default browserify, NOT browserify-cdn)

wdjwlbqqlegghrce4iegr3yye0epxapcgqaa0lycopo

@ganchenkor
Copy link
Author

I do remember I had this problem when I was trying to use debowerify transform and backbone module was in bower_components

@kumavis
Copy link
Collaborator

kumavis commented Oct 3, 2014

The offending line is
Marionette.Deferred = Backbone.$.Deferred; in backbone.marionette
Marionette is getting a different Backbone object than you are above. So it does not have jq set. Not sure why it gets a different object, seems like the versions match ("1.1.2").

@kumavis
Copy link
Collaborator

kumavis commented Oct 3, 2014

i wonder if there is a good way to get the equivalent of npm ls from browserifyCDN

@max-mapper
Copy link
Owner

there is no browserify section in this package.json https://github.com/ganchenkor/marionette-browserify/blob/master/package.json so browserify-cdn isn't running anything

@ganchenkor
Copy link
Author

@maxogden - That is true You are right, I'm not using browserify-cdn in my repo.
I meant that with default browserify it works.
The only solution that I can see to make Marionette app work in RequireBin if there was a way to apply shims before using require 'someLib' (that would be FEATURE REQUEST)
Support for CoffeeScript via coffeeify transport would be nice too(I have example of it in my repo)
Example:

(function(root, factory) {
    var $ = require('jquery');
    var Backbone = require('backbone');
    Backbone.$ = $;
    var Marionette = require('backbone.marionette');
    var Radio = require('backbone.radio');
    var _ = require('lodash');
    module.exports = factory(Marionette, Radio, _);
}(this, function(Marionette, Radio, _) {
  'use strict';

  Marionette.Application.prototype._initChannel = function () {
    this.channelName = _.result(this, 'channelName') || 'global';
    this.channel = _.result(this, 'channel') || Radio.channel(this.channelName);
  }
}));

in this shim I
1)resolve $ dependency
2)substitute underscore with lodash
3)substitute wreqr with backbone.radio

Is it possible to make a feature in requirebin to use shims for packages BEFORE they are required?

@max-mapper
Copy link
Owner

@ganchenkor
Copy link
Author

I'm familiar how to use browserify transforms. How can I use it in http://requirebin.com ? We don't have access to package.json in Front End
Nor we have any other way to use transforms in http://requirebin.com

@max-mapper
Copy link
Owner

@ganchenkor requirebin doesn't actually browserify the code from the editor in the requirebin web app, it only browserifies all of the require()'d dependencies. so you'd have to e.g. add a transform section to https://github.com/ganchenkor/marionette-browserify/blob/master/package.json to have a browserify transform run on that module

@ganchenkor
Copy link
Author

I don't have any problems in my repo. I can't load Marionette in Requirebin. That's all

@jamesplease
Copy link

For the record, we're aware of this issue over in Marionette. We weren't including jQuery, because Backbone should be including it – but it doesn't. In a future release, though, we plan to make the jQuery dependency explicit within Marionette.

So this should be less about making Marionette work / debugging Marionette, and more about if this is a feature that requirebin should have.

@ganchenkor
Copy link
Author

That's what I'm trying to say. Thank you @jmeas

@max-mapper
Copy link
Owner

The only way to support this with the current implementation of requirebin would be to publish https://github.com/ganchenkor/marionette-browserify to npm with the corrent transforms in it's package.json. That way when you require('marionette-browserify') it will run whatever transforms are in the package.json.

Otherwise we'd need to first make requirebin browserify the editor code and then add a feature on top of that that let the user install and run transforms during that browserification. I think this would be a lot of work so it's likely not going to get done unless someone here wants to take it on.

@ganchenkor
Copy link
Author

Ok https://github.com/ganchenkor/marionette-browserify Done with this repo. Tonight will publish it on npm so we can use that in requirebin. Thank you @maxogden. But anyways, I will put that on my list to-do to see if I can find some time to learn source code of requirebin and suggest pull request for implementing custom browserify transforms.

@ganchenkor
Copy link
Author

@ganchenkor
Copy link
Author

I just applied shim instead of using browserify-transports.
I just don't understand why it doesn't work with applied shim right inside of requirebin.
Theoretically, it should work.

@ganchenkor ganchenkor reopened this Oct 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants