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

jquery path configuration breaks jquery plugin. #15

Open
clmath opened this issue Jan 13, 2015 · 3 comments
Open

jquery path configuration breaks jquery plugin. #15

clmath opened this issue Jan 13, 2015 · 3 comments
Assignees

Comments

@clmath
Copy link
Member

clmath commented Jan 13, 2015

For example this problem appears when you mix code using the dist version of jquery and code using the jquery plugin.

To load the dist version of jQuery with requirejs you need something like:

requirejs.config({
    paths: {
        "jquery": "jquery/dist/jquery.min"
    }
});

Then, if the jquery plugin is used before the dist jquery is loaded, the jquery plugin will try to get the jquery module foo at jquery/dist/jquery.min/src/foo.js (since the jquery globals are not set yet).

I don't see an easy way to solve this. Maybe @wkeese have an idea on this ?

PS: issue encountered by @edchat.

edit: if jquery is loaded before the use of the jquery plugin, it's ok because the globals are set and the plugin returns them.

@wkeese
Copy link
Member

wkeese commented Jan 13, 2015

I don't even understand what you are doing. If you want to use the "dist version" of jquery you should load it via an explicit <script> tag.

If you want to load jquery through requirejs, then it should be handled like any other package: installed via bower and optionally minified/built into a layer using the ibm-js builder.

Can you give a more complete code example?

@clmath
Copy link
Member Author

clmath commented Jan 14, 2015

If you want to use the "dist version" of jquery you should load it via an explicit <script> tag.

Some user will use requirejs to load the build version of jquery and then load scripts that depends on it.
This is documented in requirejs documentation with sample like this:

requirejs.config({
    shim: {
        'jquery.colorize': {
            deps: ['jquery'],
            exports: 'jQuery.fn.colorize'
        },
        'jquery.scroll': {
            deps: ['jquery'],
            exports: 'jQuery.fn.scroll'
        },
        'backbone.layoutmanager': {
            deps: ['backbone']
            exports: 'Backbone.LayoutManager'
        }
    }
});

In this case, the user don't know which parts of jquery colorize depends on, so he cannot use the jquery plugin and needs to load the whole library at once.

@wkeese
Copy link
Member

wkeese commented Jan 14, 2015

OK. Well, I'm not sure how you want to fix that. The initial approach for the jquery plugin was to make every app manually do something like

requirejs.config({
    paths: {
        "jquery": "jquery/dist/jquery"
    }
});

The fancy code currently in the jquery plugin (which IIRC internally calls requirejs.config()) is trying to avoid that cumbersome requirement.

@cjolif cjolif added this to the 0.5.0 milestone Jan 15, 2015
@cjolif cjolif modified the milestones: 0.6.0, 0.5.0 Jan 27, 2015
@cjolif cjolif added the 1-low label Feb 12, 2015
@clmath clmath removed this from the 0.6.0 milestone Nov 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants