I managed to migrate our AngularjS 1.3.15 project from Gulp to Webpack 4, and now I'm trying to organize all our huge 5000+ line files into separate files. The problem is that I have no idea how exactly to export an AngularJS controller or directive etc. as to be easily imported into an index.js file, so that can be imported to our main.js file.
Example, one of our huge files starts with the angular.module and then a controller, like this:
(function () {
angular.module('AppName', ['app.services'])
.controller('SomeCtrl', ['Session', 'Api', '$scope',
function (Session, Api, $scope) {
let init = function () {
console.log('Stuff');
};
init();
}])
This is then followed by a factory:
.factory('GlobalChart', [function () {
let self = this;
self.containerWidth = 210;
self.containerHeight = 210;
self.width = 150;
self.height = 150;
self.radius = Math.min(self.width, self.height) / 2;
return this;
}])
Followed by a directive:
.directive('reportTopbar', ['$window',
function ($window) {
return {
templateUrl: 'views/someview.html?v=' + GLOBAL_VERSION,
transclude: false,
scope: {
data: '='
},
link: function (scope, element, attrs, ctrl) {
// code here
},
};
}])
Following this last example there's just a bunch of directives, and everything is in this huge file, hence the need to organize this so that it's maintainable.
So what exactly would be the correct way to export all these?