browserify + browserify-shim angular global

265 views Asked by At

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",
1

There are 1 answers

0
Bruno Araujo Marques On

You need config the external option

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