2

Angular 1.5.8, Webpack 2.1.0-beta.25

I'm getting an error that angular is undefined when I try to use it with webpack. I've tried to load angular as an external and as part of the package as detailed here: Webpack ProvidePlugin vs externals?

I've added this code at my entry point to test:

import * as angular from 'angular';
// import angular from 'angular'; <!-- have tried this too

angular.module('test', []);

I can hold my mouse over the line of code in the debugger and it seems to be able to find angular. Yet once I hit F10 I get the error.

enter image description here

enter image description here

My webpack.common.config:

    externals: {
        jquery: 'jQuery',
        window: 'window',
        angular: 'angular'
    },

      new webpack.ProvidePlugin({
          $: 'jquery',
          angular: 'angular',
          _: 'lodash',
          moment: 'moment'
      }),

Index.html (when providing externally):

<body id="bootstrap-overrides">

    <sb-app></sb-app>

    <script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <script src="//cdnjs.cloudflare.com/ajax/libs/slideout/0.1.11/slideout.min.js"></script>
    <script type="text/javascript" src="polyfills.bundle.js"></script>
    <script type="text/javascript" src="vendor.bundle.js"></script>
    <script type="text/javascript" src="sbMain.bundle.js"></script>

</body>

sbMain.bundle.js is where the error is occuring, even though it's loaded last (angular is first)

Community
  • 1
  • 1
Ryan Langton
  • 6,294
  • 15
  • 53
  • 103

0 Answers0