1- import { basename , dirname , join , relative } from 'path' ;
1+ import { dirname , join , relative } from 'path' ;
22import { Logger } from '../logger/logger' ;
33import * as Constants from '../util/constants' ;
4- import { changeExtension , escapeStringForRegex } from '../util/helpers' ;
4+ import { changeExtension , convertFilePathToNgFactoryPath , escapeStringForRegex } from '../util/helpers' ;
55import { TreeShakeCalcResults } from '../util/interfaces' ;
66
77export function calculateUnusedComponents ( dependencyMap : Map < string , Set < string > > ) : TreeShakeCalcResults {
@@ -71,43 +71,24 @@ function processImportTree(dependencyMap: Map<string, Set<string>>, importee: st
7171}
7272
7373function calculateUnusedIonicProviders ( dependencyMap : Map < string , Set < string > > ) {
74- const ACTION_SHEET_CONTROLLER = join ( process . env [ Constants . ENV_VAR_IONIC_ANGULAR_DIR ] , 'components' , 'action-sheet' , 'action-sheet-controller.js' ) ;
75- const ACTION_SHEET_COMPONENT_FACTORY = join ( process . env [ Constants . ENV_VAR_IONIC_ANGULAR_DIR ] , 'components' , 'action-sheet' , 'action-sheet-component.ngfactory.js' ) ;
7674
77- const ALERT_CONTROLLER = join ( process . env [ Constants . ENV_VAR_IONIC_ANGULAR_DIR ] , 'components' , 'alert' , 'alert-controller.js' ) ;
78- const ALERT_COMPONENT_FACTORY = join ( process . env [ Constants . ENV_VAR_IONIC_ANGULAR_DIR ] , 'components' , 'alert' , 'alert-component.ngfactory.js' ) ;
7975
80- const LOADING_CONTROLLER = join ( process . env [ Constants . ENV_VAR_IONIC_ANGULAR_DIR ] , 'components' , 'loading' , 'loading-controller.js' ) ;
81- const LOADING_COMPONENT_FACTORY = join ( process . env [ Constants . ENV_VAR_IONIC_ANGULAR_DIR ] , 'components' , 'loading' , 'loading-component.ngfactory.js' ) ;
82-
83- const MODAL_CONTROLLER = join ( process . env [ Constants . ENV_VAR_IONIC_ANGULAR_DIR ] , 'components' , 'modal' , 'modal-controller.js' ) ;
84- const MODAL_COMPONENT_FACTORY = join ( process . env [ Constants . ENV_VAR_IONIC_ANGULAR_DIR ] , 'components' , 'modal' , 'modal-component.ngfactory.js' ) ;
85-
86- const PICKER_CONTROLLER = join ( process . env [ Constants . ENV_VAR_IONIC_ANGULAR_DIR ] , 'components' , 'picker' , 'picker-controller.js' ) ;
87- const PICKER_COMPONENT_FACTORY = join ( process . env [ Constants . ENV_VAR_IONIC_ANGULAR_DIR ] , 'components' , 'picker' , 'picker-component.ngfactory.js' ) ;
88-
89- const POPOVER_CONTROLLER = join ( process . env [ Constants . ENV_VAR_IONIC_ANGULAR_DIR ] , 'components' , 'popover' , 'popover-controller.js' ) ;
90- const POPOVER_COMPONENT_FACTORY = join ( process . env [ Constants . ENV_VAR_IONIC_ANGULAR_DIR ] , 'components' , 'popover' , 'popover-component.ngfactory.js' ) ;
91-
92- const TOAST_CONTROLLER = join ( process . env [ Constants . ENV_VAR_IONIC_ANGULAR_DIR ] , 'components' , 'toast' , 'toast-controller.js' ) ;
93- const TOAST_COMPONENT_FACTORY = join ( process . env [ Constants . ENV_VAR_IONIC_ANGULAR_DIR ] , 'components' , 'toast' , 'toast-component.ngfactory.js' ) ;
94-
95- processIonicProviders ( dependencyMap , ACTION_SHEET_CONTROLLER ) ;
96- processIonicProviders ( dependencyMap , ALERT_CONTROLLER ) ;
97- processIonicProviders ( dependencyMap , LOADING_CONTROLLER ) ;
98- processIonicProviders ( dependencyMap , MODAL_CONTROLLER ) ;
99- processIonicProviders ( dependencyMap , PICKER_CONTROLLER ) ;
100- processIonicProviders ( dependencyMap , POPOVER_CONTROLLER ) ;
101- processIonicProviders ( dependencyMap , TOAST_CONTROLLER ) ;
76+ processIonicProviders ( dependencyMap , process . env [ Constants . ENV_ACTION_SHEET_CONTROLLER_PATH ] ) ;
77+ processIonicProviders ( dependencyMap , process . env [ Constants . ENV_ALERT_CONTROLLER_PATH ] ) ;
78+ processIonicProviders ( dependencyMap , process . env [ Constants . ENV_LOADING_CONTROLLER_PATH ] ) ;
79+ processIonicProviders ( dependencyMap , process . env [ Constants . ENV_MODAL_CONTROLLER_PATH ] ) ;
80+ processIonicProviders ( dependencyMap , process . env [ Constants . ENV_PICKER_CONTROLLER_PATH ] ) ;
81+ processIonicProviders ( dependencyMap , process . env [ Constants . ENV_POPOVER_CONTROLLER_PATH ] ) ;
82+ processIonicProviders ( dependencyMap , process . env [ Constants . ENV_TOAST_CONTROLLER_PATH ] ) ;
10283
10384 // check if the controllers were deleted, if so, purge the component too
104- processIonicProviderComponents ( dependencyMap , ACTION_SHEET_CONTROLLER , ACTION_SHEET_COMPONENT_FACTORY ) ;
105- processIonicProviderComponents ( dependencyMap , ALERT_CONTROLLER , ALERT_COMPONENT_FACTORY ) ;
106- processIonicProviderComponents ( dependencyMap , LOADING_CONTROLLER , LOADING_COMPONENT_FACTORY ) ;
107- processIonicProviderComponents ( dependencyMap , MODAL_CONTROLLER , MODAL_COMPONENT_FACTORY ) ;
108- processIonicProviderComponents ( dependencyMap , PICKER_CONTROLLER , PICKER_COMPONENT_FACTORY ) ;
109- processIonicProviderComponents ( dependencyMap , POPOVER_CONTROLLER , POPOVER_COMPONENT_FACTORY ) ;
110- processIonicProviderComponents ( dependencyMap , TOAST_CONTROLLER , TOAST_COMPONENT_FACTORY ) ;
85+ processIonicProviderComponents ( dependencyMap , process . env [ Constants . ENV_ACTION_SHEET_CONTROLLER_PATH ] , process . env [ Constants . ENV_ACTION_SHEET_COMPONENT_FACTORY_PATH ] ) ;
86+ processIonicProviderComponents ( dependencyMap , process . env [ Constants . ENV_ALERT_CONTROLLER_PATH ] , process . env [ Constants . ENV_ALERT_COMPONENT_FACTORY_PATH ] ) ;
87+ processIonicProviderComponents ( dependencyMap , process . env [ Constants . ENV_LOADING_CONTROLLER_PATH ] , process . env [ Constants . ENV_LOADING_COMPONENT_FACTORY_PATH ] ) ;
88+ processIonicProviderComponents ( dependencyMap , process . env [ Constants . ENV_MODAL_CONTROLLER_PATH ] , process . env [ Constants . ENV_MODAL_COMPONENT_FACTORY_PATH ] ) ;
89+ processIonicProviderComponents ( dependencyMap , process . env [ Constants . ENV_PICKER_CONTROLLER_PATH ] , process . env [ Constants . ENV_PICKER_COMPONENT_FACTORY_PATH ] ) ;
90+ processIonicProviderComponents ( dependencyMap , process . env [ Constants . ENV_POPOVER_CONTROLLER_PATH ] , process . env [ Constants . ENV_POPOVER_COMPONENT_FACTORY_PATH ] ) ;
91+ processIonicProviderComponents ( dependencyMap , process . env [ Constants . ENV_TOAST_CONTROLLER_PATH ] , process . env [ Constants . ENV_TOAST_COMPONENT_FACTORY_PATH ] ) ;
11192}
11293
11394function processIonicProviderComponents ( dependencyMap : Map < string , Set < string > > , providerPath : string , componentPath : string ) {
@@ -119,10 +100,7 @@ function processIonicProviderComponents(dependencyMap: Map<string, Set<string>>,
119100
120101function getAppModuleNgFactoryPath ( ) {
121102 const appNgModulePath = process . env [ Constants . ENV_APP_NG_MODULE_PATH ] ;
122- const directory = dirname ( appNgModulePath ) ;
123- const extensionlessFileName = basename ( appNgModulePath , '.js' ) ;
124- const ngFactoryFileName = extensionlessFileName + '.ngfactory.js' ;
125- return join ( directory , ngFactoryFileName ) ;
103+ return convertFilePathToNgFactoryPath ( appNgModulePath ) ;
126104}
127105
128106function processIonicProviders ( dependencyMap : Map < string , Set < string > > , providerPath : string ) {
0 commit comments