Skip to content

2.1.14 breaks build with jquery 2.1.0 #704

Closed

Description

@adammiller

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']
    }
  }
});

Activity

  1. tonymalatanos commented on Jul 28, 2014

    @tonymalatanos

    +1 using jQuery v1.11.1

  2. facundocabrera commented on Jul 28, 2014

    @facundocabrera

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

  3. added this to the 2.1.15 milestone on Jul 30, 2014
  4. jrburke commented on Jul 30, 2014

    @jrburke
    Member

    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

  5. adammiller commented on Aug 5, 2014

    @adammiller
    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.

  6. tonymalatanos commented on Aug 5, 2014

    @tonymalatanos

    @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.

  7. gfranko commented on Aug 5, 2014

    @gfranko

    @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.

  8. jrburke commented on Sep 7, 2014

    @jrburke
    Member

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions