Forked from malte-wessel/browserify-replace-underscore-with-lodash-globally.md
          
        
    
          Last active
          August 29, 2015 14:23 
        
      - 
      
 - 
        
Save jdeagle/f0b5a5e026318aff2fc6 to your computer and use it in GitHub Desktop.  
Revisions
- 
        
malte-wessel revised this gist
Sep 17, 2014 . 2 changed files with 3 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,7 +24,7 @@ browserify({ These days, `underscore`, `backbone` and `backbone.marionette` support CommonJS. Shimming these packages is not necessary anymore. But that also means, that you have no control over the package's dependencies. Luckily, there exists a browserify transform called [aliasify](https://github.com/benbria/aliasify). This package will transform the require paths of your **local modules**. If you want the transform to operate on your whole bundle, you need to use it directly within your browserify task, since you can not configure global transforms in a `package.json` like you can with ordinary transforms. Have a look at `browserify-task.js`. The aliasify transform is applied globally. The aliasify transform can still be configurated within your `package.json`. Note: the browserify transform field should not contain aliasify, since it will only operate on your *local modules*. If you want to replace all of the underscore requires with lodash, you can configure aliasify like: ```json This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ var browserify = require('gulp-browserify'), aliasify = require('aliasify'); var bundler = browserify({ // Configure browserify  - 
        
malte-wessel revised this gist
Sep 17, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -24,7 +24,7 @@ browserify({ These days, `underscore`, `backbone` and `backbone.marionette` support CommonJS. Shimming these packages is not necessary anymore. But that also means, that you have no control over the package's dependencies. Luckily, there exists a browserify transform called [aliasify](https://github.com/benbria/aliasify). This package will transform the require paths of your **local modules**. If you want the transform to operate on your whole bundle, you need to use it directly within your browserify task, since you can not configure global transforms in a `package.json` like you can with ordinary transforms. Have a look at `browserify-task.js`. The aliasify transform is applied globally. The aliasify transform can still be configurated within your `package.json`. Note: the browserify transform field should not contain aliasify, since it will only be used on *local modules*. If you want to replace all of the underscore requires with lodash, you can configure aliasify like: ```json  - 
        
malte-wessel revised this gist
Sep 17, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ If you are using `backbone` (and `backbone.marionette`) in a `browserify` managed project, you will likely run into issues with `underscore` (at least if you manage your dependencies with npm). Each package, that has underscore as a dependency, will require its own version of `underscore` (making your bundle file contain multiple versions of `underscore`). **Back in the days**, you could shim `backbone` and `underscore` like: ```javascript  - 
        
malte-wessel renamed this gist
Sep 17, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. - 
        
malte-wessel revised this gist
Sep 17, 2014 . 1 changed file with 6 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,10 @@ var browserify = require('gulp-browserify'); var bundler = browserify({ // Configure browserify }); bundler // Global aliases (e.g. replaces underscore with lodash) .transform({global: true}, aliasify) .bundle();  - 
        
malte-wessel revised this gist
Sep 17, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,7 +22,7 @@ browserify({ ``` These days, `underscore`, `backbone` and `backbone.marionette` support CommonJS. Shimming these packages is not necessary anymore. But that also means, that you have no control over the package's dependencies. Luckily, there exists a browserify transform called [aliasify](https://github.com/benbria/aliasify). This package will transform the require paths of your **local modules**. If you want the transform to operate on your whole bundle, you need to use it directly within your browserify task, since you can not configure global transforms in a `package.json` like you can with ordinary transforms. Have a look at `browserify-task.js`. The aliasify transform is applied globally. The aliasify transform can still be configurated within your `package.json`. Note: the browserify transform field should not contain the aliasify, since it will only be used for *local modules*.  - 
        
malte-wessel renamed this gist
Sep 17, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. - 
        
malte-wessel revised this gist
Sep 17, 2014 . No changes.There are no files selected for viewing
 - 
        
malte-wessel renamed this gist
Sep 17, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. - 
        
malte-wessel revised this gist
Sep 17, 2014 . 2 changed files with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,6 +16,7 @@ browserify({ 'underscore': '_' } } } } }); ``` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,6 +3,6 @@ var bundler = browserify({ }); bundler // Global aliases (e.g. replaces underscore with lodash) .transform({global: true}, aliasify) .bundle();  - 
        
malte-wessel revised this gist
Sep 17, 2014 . 1 changed file with 6 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,11 +27,13 @@ Have a look at `browserify-task.js`. The aliasify transform is applied globally. If you want to replace all of the underscore requires with lodash, you can configure aliasify like: ```json { "aliasify": { "aliases": { "underscore": "./node_modules/lodash/dist/lodash.underscore.js" } } } ```  - 
        
malte-wessel revised this gist
Sep 17, 2014 . 1 changed file with 12 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,7 +21,17 @@ browserify({ ``` These days, `underscore`, `backbone` and `backbone.marionette` support CommonJS. Shimming these packages is not necessary anymore. But that also means, that you have no control over the package's dependencies. Luckily, there exists a browserify transform called [aliasify](https://github.com/benbria/aliasify). This package will transform the require paths for your **local modules**. If you want the transform to operate on your whole bundle, you need to use it directly within your browserify task, since you can not configure global transforms in a `package.json` like you can with ordinary transforms. Have a look at `browserify-task.js`. The aliasify transform is applied globally. The aliasify transform can still be configurated within your `package.json`. Note: the browserify transform field should not contain the aliasify, since it will only be used for *local modules*. If you want to replace all of the underscore requires with lodash, you can configure aliasify like: ```json "aliasify": { "aliases": { "underscore": "./node_modules/lodash/dist/lodash.underscore.js" } }, ```  - 
        
malte-wessel revised this gist
Sep 17, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ If you are using `backbone` (and `backbone.marionette`) in a project, you will likely run into issues with `underscore` (at least if you manage your dependencies with npm). Each package, that has underscore as a dependency, will require its own version of `underscore` (making your bundle file contain multiple versions of `underscore`). **Back in the days**, you could shim `backbone` and `underscore` like: ```javascript  - 
        
malte-wessel revised this gist
Sep 17, 2014 . 1 changed file with 20 additions and 14 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,21 +1,27 @@ If you are using `backbone` (and `backbone.marionette`) in a project, you will likely run into issues with `underscore` (at least if you manage your dependencies with npm). Each package, that has underscore as a dependency, will require its own version of `underscore` (making your bundle file contain multiple versions of `underscore`), *Back in the days*, you could shim `backbone` and `underscore` like: ```javascript browserify({ shim: { 'underscore': { path: './node_modules/underscore/underscore.js', exports: '_' }, 'backbone': { path: './node_modules/backbone/backbone.js', exports: 'Backbone', depends: { 'jquery': '$', 'underscore': '_' } } } }); ``` These days, `underscore`, `backbone` and `backbone.marionette` support CommonJS. Shimming these packages is not necessary anymore. But that also means, that you have no control over the package's dependencies. Luckily, there exists a browserify transform called [aliasify](https://github.com/benbria/aliasify). This package will transform the require paths for your *local modules*. If you want the transform to operate on your whole bundle, you need to use it directly within your browserify task, since you can not configure global transforms in a `package.json` like you can with ordinary transforms. Have a look at `browserify-task.js`. The aliasify transform is applied globally.  - 
        
malte-wessel renamed this gist
Sep 17, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. - 
        
malte-wessel created this gist
Sep 17, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ var bundler = browserify({ // Configure browserify }); bundler // Global aliases (e.g. replaces underscore with lodash) .transform({global: true}, aliasify) .bundle(); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ { "browserify": { "transform": [] }, "aliasify": { "aliases": { "underscore": "./node_modules/lodash/dist/lodash.underscore.js" } }, "dependencies": { "backbone": "^1.1.2", "backbone.marionette": "^2.2.0", "backbone.wreqr": "^1.3.1", "jquery": "^2.1.1", "lodash": "^2.4.1", }, "devDependencies": { "aliasify": "^1.4.0", "browserify": "^5.11.1", } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ If you are using backbone (and backbone.marionette) in a project, you will likely run into issues with underscore (at least if you manage your dependencies with npm). Each package, that has underscore as a dependency, will require its own version of underscore (making your bundle file contain multiple versions of underscore), *Back in the days*, you could shim backbone and underscore like: ```javascript browserify({ shim: { 'underscore': { path: './node_modules/underscore/underscore.js', exports: '_' }, 'backbone': { path: './node_modules/backbone/backbone.js', exports: 'Backbone', depends: { 'jquery': '$', 'underscore': '_' } } } });