{"action":"closed","issue":{"url":"https://api.github.com/repos/thlorenz/browserify-shim/issues/205","labels_url":"https://api.github.com/repos/thlorenz/browserify-shim/issues/205/labels{/name}","comments_url":"https://api.github.com/repos/thlorenz/browserify-shim/issues/205/comments","events_url":"https://api.github.com/repos/thlorenz/browserify-shim/issues/205/events","html_url":"https://github.com/thlorenz/browserify-shim/issues/205","id":126690141,"number":205,"title":"browserify-shim failed on signalR lib","user":{"login":"felixbillon","id":6213796,"avatar_url":"https://avatars.githubusercontent.com/u/6213796?v=3","gravatar_id":"","url":"https://api.github.com/users/felixbillon","html_url":"https://github.com/felixbillon","followers_url":"https://api.github.com/users/felixbillon/followers","following_url":"https://api.github.com/users/felixbillon/following{/other_user}","gists_url":"https://api.github.com/users/felixbillon/gists{/gist_id}","starred_url":"https://api.github.com/users/felixbillon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/felixbillon/subscriptions","organizations_url":"https://api.github.com/users/felixbillon/orgs","repos_url":"https://api.github.com/users/felixbillon/repos","events_url":"https://api.github.com/users/felixbillon/events{/privacy}","received_events_url":"https://api.github.com/users/felixbillon/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/thlorenz/browserify-shim/labels/awaiting%20response","name":"awaiting response","color":"fbca04"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-01-14T16:25:03Z","updated_at":"2016-01-15T15:58:49Z","closed_at":"2016-01-15T15:58:49Z","body":"Hi everyone,\r\n\r\nI'm using gulp + browserify to bundle my source but i got always the same error : *jQuery was not found. Please ensure jQuery is referenced before the SignalR client JavaScript file.* SignalR get $ = undefined...\r\n\r\nI split my source into two bundle : vendor and app. Vendor bundle get lib's id from packages.json and the bundle require it. App bundle get main entry and i passe id's lib to this bundle with bundle.external.\r\n\r\nHere my packages.json :\r\n\r\n      \"browser\": {\r\n        \"angular-notify\": \"./node_modules/angular-notify/dist/angular-notify.js\",\r\n        \"angular-i18n\": \"./node_modules/angular-i18n/angular-locale_fr.js\",\r\n        \"jquery\": \"./node_modules/jquery/dist/jquery.js\",\r\n        \"signalR\": \"./node_modules/ms-signalr-client/jquery.signalr-2.2.0.js\",\r\n        \"moment\": \"./node_modules/moment/moment.js\",\r\n        \"moment-business\": \"./Scripts/Vendor/js/moment-business.js\"\r\n      },\r\n      \"browserify\": {\r\n        \"transform\": [\r\n          \"browserify-shim\"\r\n        ]\r\n      },\r\n      \"browserify-shim\": {\r\n        \"jquery\": \"$\",\r\n        \"signalR\": {\r\n          \"depends\": [\r\n            \"jquery:jQuery\"\r\n          ]\r\n        },\r\n        \"moment\": \"moment\"\r\n      }\r\n\r\nHere my gulp taks :\r\n\r\n    'use strict';\r\n    \r\n    import gulp from 'gulp';\r\n    import gulpLoadPlugins from 'gulp-load-plugins';\r\n    import browserify from 'browserify';\r\n    import browserifyInc from 'browserify-incremental';\r\n    import ngHtml2Js from 'browserify-ng-html2js';\r\n    import shim from 'browserify-shim';\r\n    import xtend from 'xtend';\r\n    import tsify from 'tsify';\r\n    import babelify from 'babelify';\r\n    import minifyify from 'minifyify';\r\n    import source from 'vinyl-source-stream';\r\n    import buffer from 'vinyl-buffer';\r\n    import browserSync from 'browser-sync';\r\n    import packageJson from './package.json';\r\n    \r\n    const $ = gulpLoadPlugins();\r\n    let bs = browserSync.create();\r\n    \r\n    let dependenciesCss = [\r\n      'bootstrap',\r\n      'font-awesome',\r\n      'animate.css'\r\n    ];\r\n    \r\n    let externalDependenciesjs = [\r\n      'signalR',\r\n      'moment-business'\r\n    ];\r\n    \r\n    let dependenciesJs = Object.keys(packageJson.dependencies).filter(\r\n      key => (\r\n        dependenciesCss.every(\r\n          libCssName => (key.trim() !== libCssName)\r\n        )\r\n      )\r\n    );\r\n   \r\n    dependenciesJs = dependenciesJs.concat(externalDependenciesjs);\r\n    \r\n    /*************************************\r\n     *          SCRIPTS (build)          *\r\n     *************************************/\r\n    \r\n    let extensions = ['.js', '.json', '.ts'];\r\n    \r\n    let bundler = browserify(xtend(browserifyInc.args, {\r\n        entries: 'Scripts/App/app.ts',\r\n        debug: true,\r\n        extensions,\r\n        cache: {},\r\n        packageCache: {},\r\n        fullPaths: true\r\n      }))\r\n      .external(dependenciesJs)\r\n      .plugin(tsify, {\r\n        target: 'es6'\r\n      })\r\n      .transform(babelify.configure({\r\n        extensions,\r\n      }))\r\n      .plugin(minifyify, {\r\n        map: 'app.min.js.map',\r\n        output: 'Scripts/Dist/app.min.js.map'\r\n      });\r\n    \r\n    \r\n    function compile() {\r\n    \r\n      bundler.on('log', $.util.log);\r\n    \r\n      browserifyInc(bundler, {\r\n        cacheFile: './.tmp/browserify-cache.json'\r\n      });\r\n    \r\n      $.util.log('Bundling JS ...');\r\n    \r\n      return bundler.bundle()\r\n        .pipe($.plumber({\r\n          errorHandler: browserifyError\r\n        }))\r\n        .on('error', browserifyError)\r\n        .pipe(source('app.min.js'))\r\n        .pipe(buffer())\r\n        .pipe($.size({\r\n          title: 'scripts'\r\n        }))\r\n        .pipe(gulp.dest('Scripts/Dist'))\r\n        .pipe($.if(bs.active, bs.stream({\r\n          once: true\r\n        })));\r\n    }\r\n    \r\n    let bundlerVendor = browserify(xtend(browserifyInc.args, {\r\n        debug: true,\r\n        extensions,\r\n        cache: {},\r\n        packageCache: {},\r\n        fullPaths: true\r\n      }))\r\n      .require(dependenciesJs)\r\n      .plugin(minifyify, {\r\n        map: 'vendor.min.js.map',\r\n        output: 'Scripts/Dist/vendor.min.js.map'\r\n      });\r\n    \r\n    function compileVendor() {\r\n    \r\n      bundlerVendor.on('log', $.util.log);\r\n    \r\n      browserifyInc(bundlerVendor, {\r\n        cacheFile: './.tmp/browserify-vendor-cache.json'\r\n      });\r\n    \r\n      $.util.log('Bundling vendor JS ...');\r\n    \r\n      return bundlerVendor.bundle()\r\n        .pipe($.plumber({\r\n          errorHandler: browserifyError\r\n        }))\r\n        .on('error', browserifyError)\r\n        .pipe(source('vendor.min.js'))\r\n        .pipe(buffer())\r\n        .pipe($.size({\r\n          title: 'scripts vendor'\r\n        }))\r\n        .pipe(gulp.dest('Scripts/Dist'))\r\n        .pipe($.if(bs.active, bs.stream({\r\n          once: true\r\n        })));\r\n    }\r\n    \r\n    function browserifyError(err) {\r\n      error(err);\r\n      this.end();\r\n    }\r\n\r\nI already try to use browserify-shim transform with option global but this not work too.  "}}