Skip to content

Adding backbone to dependencies causes underscore error #53

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

Open
grantnorwood opened this issue Sep 30, 2015 · 1 comment
Open

Adding backbone to dependencies causes underscore error #53

grantnorwood opened this issue Sep 30, 2015 · 1 comment

Comments

@grantnorwood
Copy link

grantnorwood commented Sep 30, 2015

When adding "bower": ['backbone'] to a js dependency, I'm getting the following error in my browser console as soon as the libs.js is loaded: "Uncaught TypeError: Cannot read property 'extend' of undefined" where _ is what is undefined.

However, I can properly use _ from the browser console, so underscore.js is indeed loaded.

Here's my manifest.json:

{
  "dependencies": {
    "main.js": {
      "files": [
        "scripts/includes/**/*.js",
        "scripts/main.js"
      ],
      "main": true
    },
    "jquery.js": {
      "bower": ["jquery"]
    },
    "libs.js": {
      "bower": [
        "modernizr",
        "foundation",
        "backbone"
      ]
    },
    "main.css": {
      "files": [
        "styles/main.scss"
      ]
    },
    "editor-style.css": {
      "files": [
        "styles/editor-style.scss"
      ]
    }
  },
  "config": {
    "devUrl": "https://dev.example.com"
  },
  "paths": {
    "source": "assets/",
    "dist": "dist/",
    "bower" : "bower_components/"
  }
}

Any idea why _ would be undefined when simply including/injecting the backbone bower dependency?

Thanks!
gkn

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/27069834-adding-backbone-to-dependencies-causes-underscore-error?utm_campaign=plugin&utm_content=tracker%2F8853550&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F8853550&utm_medium=issues&utm_source=github).
@grantnorwood
Copy link
Author

Update: The following manifest.json does load up Backbone and Underscore correctly, but only works when pointing directly to the backbone.min.js file with external: true. Additionally, even though the backbone script is referenced from the libs.js file I want to export, it is actually included in main.js.

{
  "dependencies": {
    "main.js": {
      "files": [
        "scripts/includes/**/*.js",
        "scripts/main.js"
      ],
      "main": true
    },
    "jquery.js": {
      "bower": ["jquery"]
    },
    "libs.js": {
      "files": [
        "bower_components/backbone/backbone.min.js"
      ],
      "external": true,
      "bower": [
        "modernizr",
        "foundation"
      ]
    },
    "main.css": {
      "files": [
        "styles/main.scss"
      ]
    },
    "editor-style.css": {
      "files": [
        "styles/editor-style.scss"
      ]
    }
  },
  "config": {
    "devUrl": "https://example.com"
  },
  "paths": {
    "source": "assets/",
    "dist": "dist/",
    "bower" : "bower_components/"
  }
}

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

No branches or pull requests

1 participant