Skip to content
This repository has been archived by the owner on May 1, 2023. It is now read-only.

Commit

Permalink
feat(build): add webpack with ES2015 modules
Browse files Browse the repository at this point in the history
Massive changes to bundle vendor and app libs using webpack, using
ES2015 modules (import). The resources, js and css, are loaded from
the folder "build"; html files, the templates, are not bundled.

This step helps the migration towards Angular.

To contribute the developer needs to watch the changes with the
command "npm run watch", creating new bundle files.

Known issues:

- crosshair disabled in candles chart due to d3 event and techan
issues in ES2015 module compatibility
  • Loading branch information
albertosantini committed Feb 18, 2017
1 parent 28861e4 commit 19e07a5
Show file tree
Hide file tree
Showing 114 changed files with 2,181 additions and 2,184 deletions.
1 change: 1 addition & 0 deletions build/app.bundle.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions build/app.bundle.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions build/app.bundle.js.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions build/vendor.bundle.css

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions build/vendor.bundle.js

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ module.exports = config => {
frameworks: ["mocha", "chai"],

files: [
"node_modules/angular/angular.js",

"build/vendor.bundle.js",
"node_modules/angular-mocks/angular-mocks.js",

"src/client/app/**/*.module.js",
"src/client/app/**/*.js"
"build/app.bundle.js",
"src/client/app/**/*.spec.js"
],

exclude: [
Expand Down
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,23 @@
"electron": "electron .",
"lint": "eslint main.js karma.conf.js src/**/*.js",
"karma": "karma start --single-run",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"webpack": "webpack",
"watch": "webpack --watch"
},
"devDependencies": {
"conventional-changelog-cli": "^1.2.0",
"css-loader": "^0.26.1",
"eslint": "^3.15.0",
"eslint-plugin-angular": "^1.6.1",
"extract-text-webpack-plugin": "^2.0.0-rc.3",
"mocha": "^3.2.0",
"chai": "^3.5.0",
"karma": "^1.4.1",
"karma-mocha": "^1.3.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.0.0"
"karma-chrome-launcher": "^2.0.0",
"uglify-js": "mishoo/UglifyJS2#harmony",
"webpack": "^2.2.1"
}
}
5 changes: 4 additions & 1 deletion src/client/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
parserOptions:
sourceType: "module"

env:
browser: true
mocha: true
Expand Down Expand Up @@ -42,7 +45,7 @@ rules:
angular/no-cookiestore: "error"
angular/no-jquery-angularelement: "error"
angular/no-private-call: "error"
angular/no-service-method: "error"
angular/no-service-method: "off"
angular/no-services: ["error", ["$http", "$resource", "Restangular"]]
angular/on-watch: "error"
angular/rest-service: "off"
Expand Down
16 changes: 5 additions & 11 deletions src/client/app/common/app.component.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
"use strict";
import { AppController } from "./app.controller";

{
const app = {
templateUrl: "app/common/app.html",
controller: "AppController"
};

angular
.module("common")
.component("app", app);
}
export const appComponent = {
templateUrl: "app/common/app.html",
controller: AppController
};
63 changes: 27 additions & 36 deletions src/client/app/common/app.config.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,38 @@
"use strict";
export function appConfig($httpProvider, $locationProvider) {
const interceptors = $httpProvider.interceptors;

{
angular
.module("common")
.config(config);
interceptors.push(["$q", "$rootScope", ($q, $rootScope) => {
let nLoadings = 0;

config.$inject = ["$httpProvider", "$locationProvider"];
function config($httpProvider, $locationProvider) {
const interceptors = $httpProvider.interceptors;
return {
request(request) {
nLoadings += 1;

interceptors.push(["$q", "$rootScope", ($q, $rootScope) => {
let nLoadings = 0;
$rootScope.isLoadingView = true;

return {
request(request) {
nLoadings += 1;
return request;
},

$rootScope.isLoadingView = true;

return request;
},

response(response) {
nLoadings -= 1;
if (nLoadings === 0) {
$rootScope.isLoadingView = false;
}

return response;
},
response(response) {
nLoadings -= 1;
if (nLoadings === 0) {
$rootScope.isLoadingView = false;
}

responseError(response) {
nLoadings -= 1;
if (!nLoadings) {
$rootScope.isLoadingView = false;
}
return response;
},

return $q.reject(response);
responseError(response) {
nLoadings -= 1;
if (!nLoadings) {
$rootScope.isLoadingView = false;
}
};
}]);

$locationProvider.html5Mode(true);
}
return $q.reject(response);
}
};
}]);

$locationProvider.html5Mode(true);
}
appConfig.$inject = ["$httpProvider", "$locationProvider"];
28 changes: 10 additions & 18 deletions src/client/app/common/app.controller.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
"use strict";

{
angular
.module("common")
.controller("AppController", AppController);

AppController.$inject = [];
function AppController() {
const vm = this;

vm.tabSelectedIndex = 0;
export class AppController {
$onInit() {
this.tabSelectedIndex = 0;
}

vm.next = () => {
vm.tabSelectedIndex = Math.min(vm.tabSelectedIndex + 1, 6);
};
vm.previous = () => {
vm.tabSelectedIndex = Math.max(vm.tabSelectedIndex - 1, 0);
};
next() {
this.tabSelectedIndex = Math.min(this.tabSelectedIndex + 1, 6);
}

previous() {
this.tabSelectedIndex = Math.max(this.tabSelectedIndex - 1, 0);
}
}
AppController.$inject = [];
19 changes: 14 additions & 5 deletions src/client/app/common/app.module.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
"use strict";
import "./app.css";

angular
.module("common", [
"ngMaterial"
]);
import angular from "angular";
import material from "angular-material";

import { appComponent } from "./app.component";
import { appConfig } from "./app.config";

export const app = angular
.module("common.app", [
material
])
.component("app", appComponent)
.config(appConfig)
.name;
9 changes: 9 additions & 0 deletions src/client/app/common/common.module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import angular from "angular";

import { app } from "./app.module";

export const common = angular
.module("common", [
app
])
.name;
6 changes: 6 additions & 0 deletions src/client/app/components/account/account.component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { AccountController } from "./account.controller";

export const accountComponent = {
templateUrl: "app/components/account/account.html",
controller: AccountController
};
10 changes: 10 additions & 0 deletions src/client/app/components/account/account.controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export class AccountController {
constructor(AccountService) {
this.AccountService = AccountService;
}

$onInit() {
this.account = this.AccountService.getAccount();
}
}
AccountController.$inject = ["AccountsService"];
18 changes: 0 additions & 18 deletions src/client/app/components/account/account.js

This file was deleted.

12 changes: 9 additions & 3 deletions src/client/app/components/account/account.module.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
"use strict";
import angular from "angular";

angular
.module("components.account", []);
import { accountComponent } from "./account.component";
import { AccountsService } from "./accounts.service";

export const account = angular
.module("components.account", [])
.component("account", accountComponent)
.service("AccountsService", AccountsService)
.name;
Loading

0 comments on commit 19e07a5

Please sign in to comment.