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

2.1.14 breaks build with jquery 2.1.0 #704

Closed
adammiller opened this issue Jul 17, 2014 · 7 comments
Closed

2.1.14 breaks build with jquery 2.1.0 #704

adammiller opened this issue Jul 17, 2014 · 7 comments
Milestone

Comments

@adammiller
Copy link

I have a project that was using r.js v2.1.11 without problem that suddenly is having the jquery define call overloaded with a blank function when built with r.js v2.1.14.

This little guy right here is being written to the output file directly after jquery is included:

define("jquery", function(){});

Not good. If I manually delete that, everything works as it did back with r.js v2.1.11.

Here's my config:

// Set the require.js configuration for your application.
require.config({

  // Initialize the application with the main application file.
  deps: [
    'jquery',
    'main'
  ],

  paths: {
    // JavaScript folders.
    libs: '../libs',
    plugins: '../plugins',

    // Libraries.
    jquery: '../libs/jquery',
    Modernizr: '../libs/Modernizr',
    videojs: '../libs/video',
    backbone: '../libs/backbone',
    underscore: '../libs/underscore',
    easing: '../libs/easing',
    director: '../libs/director',
    soundmanager: '../libs/soundmanager2',

    transition: '../plugins/jquery.transition',
    modal: '../plugins/jquery.modal',
    deparam: '../plugins/jquery.deparam',
    slick: '../plugins/slick'
  },

  shim: {

    scrollTo: {
      deps: ['jquery']
    },

    modal: {
      deps: ['jquery', 'transition']
    },

    deparam: {
      deps: ['jquery']
    },

    slick: {
      deps: ['jquery']
    }
  }
});
@tonymalatanos
Copy link

+1 using jQuery v1.11.1

@facundocabrera
Copy link

Try adding the shim settings for jQuery and recheck that empty function. In my personal case was the only way to fix that problem.

@jrburke jrburke added this to the 2.1.15 milestone Jul 30, 2014
@jrburke
Copy link
Member

jrburke commented Jul 30, 2014

I am curious how this fails. While the optimizer should not write out the extra define, as long as jQuery's internal define('jquery'... is run first, the first registration wins.

I tried with this sample project using stock 2.1.1 and 1.11.1 jQuery and they both worked even though they had the extra define() in there.

Are you custom-building jQuery perhaps? Trying to figure out why the test case above still works while yours does not.

I'm going to put this in the 2.1.15 bucket to see about avoiding writing out the extra define, but also curious to know how I can get a project that fails instead of it just being an extra define that does nothing.

As to cause of the extra define() write, it could be related to the UMD detection that 2.1.12-2.1.14 tries to do. Possibly relevant bug, requirejs/requirejs#1133

@adammiller
Copy link
Author

Completely stock jQuery. That was one of the first things I tested, and went and downloaded a fresh build of jQuery v2.1.0 and added that to my project.

I didn't realize the first define should win out. I figured any subsequent define calls would overwrite the first one.

@tonymalatanos
Copy link

@jrburke I'm not sure if you'd concern yourself with this specific issue or not, but my issue is related to using amdclean in my project. amdclean will rewrite define("jquery", function(){}); as jquery = undefined;. Having this happen immediately have jquery is properly defined is certainly problematic.

Sticking with r.js v2.1.13 is my current workaround. I know you probably don't concern yourself too much with specific incompatibilities with other build tools; however, I would suggest that the added empty define() by r.js v2.1.14 is a regression needing a lookover independent of my particular issue.

@gfranko
Copy link

gfranko commented Aug 5, 2014

@tonymalatanos Make sure to set the Require.js skipModuleInsertion option to true. By default, Require.js creates a define() wrapper for files that are not wrapped in a define() and this can cause issues with AMDclean.

@jrburke jrburke closed this as completed in c19a655 Sep 7, 2014
@jrburke
Copy link
Member

jrburke commented Sep 7, 2014

Fixed on master, will be part of 2.1.15. If a fix is needed before release (may still be another week before a release) then current master snapshot can be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
5 participants