Skip to content
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

Dependencies not working when add UglifyJsPlugin plugin into webpack #38

Closed
Sangd8 opened this issue Oct 12, 2015 · 3 comments
Closed

Comments

@Sangd8
Copy link

Sangd8 commented Oct 12, 2015

Here my webpack.config.js

var webpack = require("webpack");
module.exports = {
  devtool: 'sourcemap',
  output: {
    filename: 'bundle.js'//,
    //path: './build'
  },
  plugins:[
    new webpack.optimize.UglifyJsPlugin()
  ],
  module: {
    preLoaders: [{
      test:    /\.js$/,
      exclude: [/app\/lib/, /node_modules/],
      loader:  'jshint!jscs'
    }],
    postLoaders: [
      { test: /\.js$/, exclude: [/app\/lib/, /node_modules/], loader: 'babel' },
      { test: /\.html$/, loader: 'raw' },
      { test: /\.styl$/, loader: 'style!css!stylus' },
      { test: /\.css$/, loader: 'style!css' }
    ]
  }
};

Here the error:

Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:modulerr] Failed to instantiate module app.components due to:
Error: [$injector:modulerr] Failed to instantiate module home due to:
Error: [$injector:unpr] Unknown provider: e

Here my home module:

import angular from 'angular';
import uiRouter from 'angular-ui-router';
import ngSanitize from 'angular-sanitize';
import homeComponent from './home.component';

let homeModule = angular.module('home', [
  uiRouter,
  ngSanitize
])

.config(($stateProvider, $urlRouterProvider) => {
  $urlRouterProvider.otherwise('/');

  $stateProvider
    .state('home', {
      url: '/',
      template: '<home></home>'
    });
})

.directive('home', homeComponent);

export default homeModule;
@fesor
Copy link
Collaborator

fesor commented Oct 14, 2015

Because you need to provide dependency annotations:

javascript
export default class FooService {
constructor(depA, depB) {}
}

FooService.$inject = ['depA', 'depB'];


Of you could use ngAnnotate: https://www.npmjs.com/package/ng-annotate-webpack-plugin

Also please read notes about using [ngAnnotate with ES2015](https://github.com/olov/ng-annotate#es6-and-typescript-support) and use `ng-strict-di` directive for release builds.

@fesor
Copy link
Collaborator

fesor commented Nov 1, 2015

Please also read the following discussion: #39

@fesor
Copy link
Collaborator

fesor commented Nov 25, 2015

Closing since #64 is merged

@fesor fesor closed this as completed Nov 25, 2015
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

2 participants