From a004add108883340bd196a95ba38063e4600397a Mon Sep 17 00:00:00 2001 From: Asim Hussain Date: Mon, 3 Apr 2017 23:38:49 -0600 Subject: [PATCH] Step 10 - Remove AngularJS --- .bowerrc | 3 -- README.md | 11 ++++++ bower.json | 34 ------------------- package.json | 11 ------ src/.bowerrc | 3 -- src/app/ajs-upgraded-providers.ts | 34 ------------------- src/app/app.main.ts | 22 ------------ src/app/components/person-create.component.ts | 4 +-- src/app/components/person-edit.component.ts | 3 +- src/app/components/person-list.component.ts | 11 +----- src/app/components/search.component.ts | 10 ------ src/app/main.ts | 17 ---------- src/app/services/contact.service.ts | 11 ++---- 13 files changed, 16 insertions(+), 158 deletions(-) delete mode 100644 .bowerrc delete mode 100644 bower.json delete mode 100644 src/.bowerrc delete mode 100644 src/app/ajs-upgraded-providers.ts delete mode 100644 src/app/app.main.ts diff --git a/.bowerrc b/.bowerrc deleted file mode 100644 index 93b1c0a..0000000 --- a/.bowerrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "directory": "src/libs" -} \ No newline at end of file diff --git a/README.md b/README.md index ce48ffc..a0a82d2 100644 --- a/README.md +++ b/README.md @@ -132,3 +132,14 @@ The application is a simple contacts application where you can search, create or - We replace `UIRouterState` with `Router` instead of `this.$state.go(...)` we use `this.router.navigate([...])` - We add the `RouterModule` to `NgModule` and provide the routes. +### Step 10 - Remove AngularJS + +If we refer to AngularJS anywhere via an import this will be pulled into the final build by webpack, so we go through the code and make sure all references to AngularJS are removed. + +- Search for and remove `import * as angular from "angular";` as well as all downgrade code. +- Remove `ajs-upgraded-providers.ts` and all usages +- Remove angular imports from `main.ts` +- Remove `app.main.ts` +- Remove AngularJS packages from `package.json` +- Remove `bower.json` and delete libs folder + diff --git a/bower.json b/bower.json deleted file mode 100644 index 6556c7f..0000000 --- a/bower.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "ng1-migrate", - "description": "", - "main": "index.js", - "authors": [ - "Asim Hussain " - ], - "license": "ISC", - "homepage": "", - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "app/libs", - "test", - "tests" - ], - "dependencies": { - "angular": "1.4.0", - "angular-animate": "1.4.0", - "angular-auto-validate": "^1.19.6", - "angular-ladda": "^0.4.3", - "angular-resource": "1.4.0", - "angular-strap": "^2.3.12", - "AngularJS-Toaster": "angularjs-toaster#^2.1.0", - "bootstrap": "3.3.2", - "bootstrap-additions": "0.3.1", - "font-awesome": "4.3.0", - "jquery": "2.1.3", - "ngInfiniteScroll": "1.2.1", - "angular-ui-router": "ui-router#^0.4.2", - "angular-spinner": "^1.0.1" - } -} diff --git a/package.json b/package.json index dbc0691..71727cc 100644 --- a/package.json +++ b/package.json @@ -26,20 +26,10 @@ "zone.js": "^0.8.4", "reflect-metadata": "^0.1.10", - "angular": "^1.6.2", - "angular-animate": "^1.6.2", - "angular-auto-validate": "^1.19.0", - "angular-ladda": "^0.4.3", - "angular-resource": "^1.6.2", - "angular-strap": "^2.3.12", - "angularjs-toaster": "^2.1.0", "bootstrap": "3.3.2", "bootstrap-additions": "0.3.1", "font-awesome": "4.3.0", "jquery": "2.1.3", - "ng-infinite-scroll": "1.2.1", - "angular-ui-router": "^0.4.2", - "angular-spinner": "^1.0.1", "angular2-toaster": "^2.0.0", "angular2-infinite-scroll": "^0.3.3", @@ -47,7 +37,6 @@ "spin.js": "^2.3.2" }, "devDependencies": { - "@types/angular": "^1.6.2", "@types/spin.js": "^2.3.0", "bower": "^1.8.0", "json-server": "^0.9.6", diff --git a/src/.bowerrc b/src/.bowerrc deleted file mode 100644 index 1a4d0c7..0000000 --- a/src/.bowerrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "directory": "libs" -} \ No newline at end of file diff --git a/src/app/ajs-upgraded-providers.ts b/src/app/ajs-upgraded-providers.ts deleted file mode 100644 index 9069249..0000000 --- a/src/app/ajs-upgraded-providers.ts +++ /dev/null @@ -1,34 +0,0 @@ -import {OpaqueToken} from "@angular/core"; -export const Toaster = new OpaqueToken("Toaster"); - -export function toasterServiceFactory(i: any) { - return i.get('toaster'); -} -export const toasterServiceProvider = { - provide: Toaster, - useFactory: toasterServiceFactory, - deps: ['$injector'] -}; - -export const UIRouterState = new OpaqueToken("UIRouterState"); - -export function uiRouterStateServiceFactory(i: any) { - return i.get('$state'); -} -export const uiRouterStateProvider = { - provide: UIRouterState, - useFactory: uiRouterStateServiceFactory, - deps: ['$injector'] -}; - - -export const UIRouterStateParams = new OpaqueToken("UIRouterStateParams"); - -export function uiRouterStateParamsServiceFactory(i: any) { - return i.get('$stateParams'); -} -export const uiRouterStateParamsProvider = { - provide: UIRouterStateParams, - useFactory: uiRouterStateParamsServiceFactory, - deps: ['$injector'] -}; \ No newline at end of file diff --git a/src/app/app.main.ts b/src/app/app.main.ts deleted file mode 100644 index 5f15b5e..0000000 --- a/src/app/app.main.ts +++ /dev/null @@ -1,22 +0,0 @@ -import * as angular from 'angular'; - -angular.module('codecraft', [ - 'ngResource', - 'infinite-scroll', - 'angularSpinner', - 'jcs-autoValidate', - 'angular-ladda', - 'mgcrea.ngStrap', - 'toaster', - 'ngAnimate', - 'ui.router' -]).config(function ($httpProvider, $resourceProvider, laddaProvider, $datepickerProvider) { - laddaProvider.setOption({ - style: 'expand-right' - }); - angular.extend($datepickerProvider.defaults, { - dateFormat: 'd/M/yyyy', - autoclose : true - }); -}); - diff --git a/src/app/components/person-create.component.ts b/src/app/components/person-create.component.ts index ceecff4..4817376 100644 --- a/src/app/components/person-create.component.ts +++ b/src/app/components/person-create.component.ts @@ -1,6 +1,4 @@ -import * as angular from "angular"; - -import {Component, Inject} from "@angular/core"; +import {Component} from "@angular/core"; import {Router} from "@angular/router"; import {ContactService} from "../services/contact.service"; diff --git a/src/app/components/person-edit.component.ts b/src/app/components/person-edit.component.ts index a723630..a808023 100644 --- a/src/app/components/person-edit.component.ts +++ b/src/app/components/person-edit.component.ts @@ -1,7 +1,6 @@ -import {Component, Inject} from "@angular/core"; +import {Component} from "@angular/core"; import {Router, ActivatedRoute} from "@angular/router"; import {ContactService} from "../services/contact.service"; -import {UIRouterStateParams, UIRouterState} from "../ajs-upgraded-providers"; @Component({ diff --git a/src/app/components/person-list.component.ts b/src/app/components/person-list.component.ts index 0a7ba00..edd56d7 100644 --- a/src/app/components/person-list.component.ts +++ b/src/app/components/person-list.component.ts @@ -1,6 +1,4 @@ -import * as angular from 'angular'; import {Component} from "@angular/core"; -import {downgradeComponent} from "@angular/upgrade/static"; import {ContactService} from "../services/contact.service"; @Component({ @@ -39,11 +37,4 @@ export class PersonListComponent { console.log("loadMore"); this.contacts.loadMore(); } -} - - -angular - .module('codecraft') - .directive('personList', downgradeComponent({ - component: PersonListComponent - }) as angular.IDirectiveFactory); \ No newline at end of file +} \ No newline at end of file diff --git a/src/app/components/search.component.ts b/src/app/components/search.component.ts index 8e4ea63..2555847 100644 --- a/src/app/components/search.component.ts +++ b/src/app/components/search.component.ts @@ -1,7 +1,4 @@ -import * as angular from 'angular'; - import {Component} from "@angular/core"; -import {downgradeComponent} from "@angular/upgrade/static"; import {ContactService} from "../services/contact.service"; import { FormGroup, @@ -64,10 +61,3 @@ export class SearchComponent { }); } } - - -angular - .module('codecraft') - .directive('search', downgradeComponent({ - component: SearchComponent - }) as angular.IDirectiveFactory); \ No newline at end of file diff --git a/src/app/main.ts b/src/app/main.ts index 994f65f..d30b883 100644 --- a/src/app/main.ts +++ b/src/app/main.ts @@ -1,21 +1,4 @@ -import 'angular'; -import 'angular-resource'; -import 'angular-animate'; -import 'ng-infinite-scroll'; -import 'angular-spinner'; -import 'angular-auto-validate/dist/jcs-auto-validate'; -import 'angular-ladda'; -import 'angular-strap'; -import 'angularjs-toaster'; -import 'angular-ui-router'; - import 'reflect-metadata'; - -import './app.main'; -import './services'; -import './pipes'; -import './components'; -import './app.routes'; import './polyfills.ts'; import './rxjs-operators.ts'; diff --git a/src/app/services/contact.service.ts b/src/app/services/contact.service.ts index a9ce902..30e26a5 100644 --- a/src/app/services/contact.service.ts +++ b/src/app/services/contact.service.ts @@ -1,7 +1,4 @@ -import * as angular from 'angular'; - -import {Injectable, Inject} from "@angular/core"; -import {downgradeInjectable} from '@angular/upgrade/static'; +import {Injectable} from "@angular/core"; import {Contact} from "./contact.resource"; import {ToasterService} from 'angular2-toaster'; @@ -108,8 +105,4 @@ export class ContactService { }); }; -} - -angular - .module('codecraft') - .factory('ContactService', downgradeInjectable(ContactService)); \ No newline at end of file +} \ No newline at end of file