2

I am including angular js from the google cdn via a script tag on the index page.

I have the following in my package.json:

"browserify": {
    "transform": [
        "browserify-shim"
    ]
  },
  "browserify-shim": {
      "angular": "global:angular",
      "systemjs": "global:System",
      "jquery": "global:$"
  },

I am also using grunt-browserify with multiple output bundles:

app: {
    src: "./src/main.js",
    dest: "./src/bundles/app.bundle.js"
},
login: {
    src: "./src/login/login.module.js",
    dest: "./src/bundles/login.bundle.js"
},
signup: {
    src: "./src/signup/signup.module.js",
    dest: "./src/bundles/signup.bundle.js"
},
main: {
    src: "./src/main/main.module.js",
    dest: "./src/bundles/main.bundle.js"
},

The issue I am running into is that the angular source is being included in one of my output files despite browserify-shim being configured to use global:angular.

I am using the the following modules:

"browserify": "^13.0.0",
"browserify-shim": "^3.8.12",
"grunt-browserify": "^4.0.1",
YPCrumble
  • 26,610
  • 23
  • 107
  • 172
raygerrard
  • 812
  • 11
  • 13
  • The problem isn't with your `browserify` or `browserify-shim` config at least as shown above - that should work fine. Could be an issue with your settings for grunt-browserify. Best way to solve these issues is to fork a repo like [this one](https://github.com/YPCrumble/browserify-shim-grunt-browserify) and add your specific config to a very simple version of your grunt build that only includes the necessary components. The bug should be easy to find then. – YPCrumble Jan 29 '16 at 17:29

1 Answers1

0

You need config the external option

app: {
  options: {
    external: [
      './src/login/login.module.js',
      './src/signup/signup.module.js',
      './src/main/main.module.js'
    ]
  }
}