Code Monkey home page Code Monkey logo

Comments (4)

hawkrives avatar hawkrives commented on July 19, 2024

I'll make a pull request later.

from blendid.

hawkrives avatar hawkrives commented on July 19, 2024

Except that, having located the offending require('underscore'), I find myself at a loss as to what purpose it serves.

There's a comment in package.json that goes:

The following 'underscore' example demonstrates exposing a module included by another module. If you were to npm install underscore separately and require('underscore'), you'd end up with two copies in your bundle. The one you installed, and the one that shipped with another package (backbone in this example). This is an edge case and should rarely happen.

The 'plugin' example makes that file requireable with require('plugin'), and available to browserify-shim as 'plugin' on line 30.

If I understand this correctly, it's saying that ... well, I haven't actually figured it out. How would backbone be installing its own copy of underscore without npm or bower?

I guess I'm asking, what purpose does this aliasing of underscore to backbone/node_modules/underscore accomplish?

from blendid.

greypants avatar greypants commented on July 19, 2024

so when you npm install backbone, it brings its own copy of underscore with it. You can see it if you open up node_modules/backbone - you'll see underscore in there. If the only thing you required in a js file was backbone, and you opened up the compiled file, you'd see backbone.js AND underscore.js in the bundle. If you also npm install underscore, and require 'underscore', you'd end up with backbone's copy + the copy you installed from npm. It's an edge case I ran into, and I thought I'd call it out here. I know it's not super clear though. I may end up yanking that example since most people just get confused by it. Make sense?

from blendid.

hawkrives avatar hawkrives commented on July 19, 2024

That does make sense now.

...

It also sheds more light on your comment the other day. Thanks for the followup!

from blendid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.