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

Commit

Permalink
refactor(config): remove deprecated configuration options
Browse files Browse the repository at this point in the history
  • Loading branch information
danbucholtz committed Sep 6, 2017
1 parent fbf58de commit fbad33f
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 116 deletions.
17 changes: 1 addition & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,10 @@ npm run build --rollup ./config/rollup.config.js

| Config File | package.json Config | Cmd-line Flag |
|-------------|---------------------|-----------------------|
| Babili | `ionic_use_experimental_babili` | `--babili` |
| CleanCss | `ionic_cleancss` | `--cleancss` or `-e` |
| Copy | `ionic_copy` | `--copy` or `-y` |
| Closure | `ionic_closure` | `--closure` or `-l` |
| Generator | `ionic_generator` | `--generator` or `-g` |
| NGC | `ionic_ngc` | `--ngc` or `-n` |
| Rollup | `ionic_rollup` | `--rollup` or `-r` |
| Sass | `ionic_sass` | `--sass` or `-s` |
| TSLint | `ionic_tslint` | `--tslint` or `-i` |
| UglifyJS | `ionic_uglifyjs` | `--uglifyjs` or `-u` |
Expand Down Expand Up @@ -131,14 +128,8 @@ npm run build --rollup ./config/rollup.config.js
| bail on lint error | `ionic_bail_on_lint_error` | `--bailOnLintError` | `null` | Set to `true` to make stand-alone lint commands fail with non-zero status code |
| enable type checking during lint | `ionic_type_check_on_lint` | `--typeCheckOnLint` | `null` | Set to `true` to enable [type checking](https://palantir.github.io/tslint/usage/type-checking) during lint |
| write AoT files to disk | `ionic_aot_write_to_disk` | `--aotWriteToDisk` | `null` | Set to `true` to write files to disk for debugging |
| print dependency tree | `ionic_print_original_dependency_tree` | `--printOriginalDependencyTree` | `null` | Set to `true` to print out the original dependency tree calculated during the optimize step |
| print modified dependency tree | `ionic_print_modified_dependency_tree` | `--printModifiedDependencyTree` | `null` | Set to `true` to print out the modified dependency tree after purging unused modules |
| print webpack dependency tree | `ionic_print_webpack_dependency_tree` | `--printWebpackDependencyTree` | `null` | Set to `true` to print out a dependency tree after running Webpack |
| parse deeplink config | `ionic_parse_deeplinks` | `--parseDeepLinks` | `true` | Parses and extracts data from the `@IonicPage` decorator |
| manual tree shaking | `ionic_manual_treeshaking` | `--manualTreeshaking` | `true` | Set to `true` to purge unused Ionic components/code |
| purge decorators | `ionic_purge_decorators` | `--purgeDecorators` | `true` | Set to `true` to purge unneeded decorators to improve tree shakeability of code |
| experimental closure compiler | `ionic_use_experimental_closure` | `--useExperimentalClosure` | `null` | Set to `true` to use closure compiler to minify the final bundle |
| experimental babili | `ionic_use_experimental_babili` | `--useExperimentalBabili` | `null` | Set to `true` to use babili to minify es2015 code |
| convert bundle to ES5 | `ionic_build_to_es5` | `--buildToEs5` | `true` | Convert bundle to ES5 for for production deployments |
| default watch timeout | `ionic_start_watch_timeout` | `--startWatchTimeout` | `3000` | Milliseconds controlling the default watch timeout |
| choose the polyfill | `ionic_polyfill_name` | `--polyfillName` | `polyfills` | Change with polyfills.modern or polyfills.ng (all options)[https://github.com/driftyco/ionic/tree/master/scripts/polyfill] |
Expand Down Expand Up @@ -179,14 +170,8 @@ These environment variables are automatically set to [Node's `process.env`](http
| `IONIC_BAIL_ON_LINT_ERROR` | Boolean determining whether to exit with a non-zero status code on error |
| `IONIC_TYPE_CHECK_ON_LINT` | Boolean determining whether to type check code during lint or not |
| `IONIC_AOT_WRITE_TO_DISK` | `--aotWriteToDisk` | `null` | Set to `true` to write files to disk for debugging |
| `IONIC_PRINT_ORIGINAL_DEPENDENCY_TREE` | boolean to print out the original dependency tree calculated during the optimize step |
| `IONIC_PRINT_MODIFIED_DEPENDENCY_TREE` | boolean to print out the modified dependency tree after purging unused modules |
| `IONIC_PRINT_WEBPACK_DEPENDENCY_TREE` | boolean to print out a dependency tree after running Webpack |
| `IONIC_PARSE_DEEPLINKS` | boolean to enable parsing the Ionic 3.x deep links API for lazy loading |
| `IONIC_MANUAL_TREESHAKING` | boolean to enable purging unused Ionic components/code |
| `IONIC_PURGE_DECORATORS` | boolean to enable purging unneeded decorators from source code |
| `IONIC_USE_EXPERIMENTAL_CLOSURE` | boolean to enable use of closure compiler to minify the final bundle |
| `IONIC_USE_EXPERIMENTAL_BABILI` | boolean to enable use of babili to minify es2015 code |
| `IONIC_BUILD_TO_ES5` | boolean to enable converting bundle to ES5 for for production deployments |
| `IONIC_START_WATCH_TIMEOUT` | Milliseconds controlling the default watch timeout |

Expand Down Expand Up @@ -240,7 +225,7 @@ npm run lint --bailOnLintError true
- [Ionic Framework](https://ionicframework.com/)
- [TypeScript Compiler](https://www.typescriptlang.org/)
- [Angular Compiler (NGC)](https://github.com/angular/angular/tree/master/modules/%40angular/compiler-cli)
- [Rollup Module Bundler](https://rollupjs.org/)
- [Webpack Module Bundler](https://webpack.js.org/)
- Ionic Component Sass
- [Node Sass](https://www.npmjs.com/package/node-sass)
- [Autoprefixer](https://github.com/postcss/autoprefixer)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ionic/app-scripts",
"version": "2.1.4",
"version": "2.1.4-201709061759",
"description": "Scripts for Ionic Projects",
"homepage": "https://ionicframework.com/",
"author": "Ionic Team <[email protected]> (https://ionic.io)",
Expand Down
59 changes: 0 additions & 59 deletions src/util/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,12 @@ describe('config', () => {
expect(fakeConfig[Constants.ENV_APP_NG_MODULE_CLASS]).toEqual('AppModule');
expect(fakeConfig[Constants.ENV_GLOB_UTIL]).toEqual(join(fakeConfig[Constants.ENV_VAR_APP_SCRIPTS_DIR], 'dist', 'util', 'glob-util.js'));
expect(fakeConfig[Constants.ENV_CLEAN_BEFORE_COPY]).toBeFalsy();
expect(fakeConfig[Constants.ENV_CLOSURE_JAR]).toEqual(join(fakeConfig[Constants.ENV_VAR_APP_SCRIPTS_DIR], 'bin', 'closure-compiler.jar'));
expect(fakeConfig[Constants.ENV_OUTPUT_JS_FILE_NAME]).toEqual('main.js');
expect(fakeConfig[Constants.ENV_OUTPUT_CSS_FILE_NAME]).toEqual('main.css');
expect(fakeConfig[Constants.ENV_WEBPACK_FACTORY]).toEqual(join(fakeConfig[Constants.ENV_VAR_APP_SCRIPTS_DIR], 'dist', 'webpack', 'ionic-webpack-factory.js'));
expect(fakeConfig[Constants.ENV_WEBPACK_LOADER]).toEqual(join(fakeConfig[Constants.ENV_VAR_APP_SCRIPTS_DIR], 'dist', 'webpack', 'loader.js'));
expect(fakeConfig[Constants.ENV_OPTIMIZATION_LOADER]).toEqual(join(fakeConfig[Constants.ENV_VAR_APP_SCRIPTS_DIR], 'dist', 'webpack', 'optimization-loader.js'));
expect(fakeConfig[Constants.ENV_AOT_WRITE_TO_DISK]).toBeFalsy();
expect(fakeConfig[Constants.ENV_PRINT_ORIGINAL_DEPENDENCY_TREE]).toBeFalsy();
expect(fakeConfig[Constants.ENV_PRINT_MODIFIED_DEPENDENCY_TREE]).toBeFalsy();
expect(fakeConfig[Constants.ENV_PRINT_WEBPACK_DEPENDENCY_TREE]).toBeFalsy();
expect(fakeConfig[Constants.ENV_TYPE_CHECK_ON_LINT]).toBeFalsy();
expect(fakeConfig[Constants.ENV_BAIL_ON_LINT_ERROR]).toBeFalsy();
Expand Down Expand Up @@ -162,11 +159,6 @@ describe('config', () => {
expect(fakeConfig[Constants.ENV_TOAST_COMPONENT_FACTORY_PATH]).toEqual(join(context.ionicAngularDir, 'components', 'toast', 'toast-component.ngfactory.js'));

expect(fakeConfig[Constants.ENV_PARSE_DEEPLINKS]).toBeTruthy();
expect(fakeConfig[Constants.ENV_PURGE_DECORATORS]).toBeTruthy();
expect(fakeConfig[Constants.ENV_MANUAL_TREESHAKING]).toBeTruthy();

expect(fakeConfig[Constants.ENV_USE_EXPERIMENTAL_CLOSURE]).toBeFalsy();
expect(fakeConfig[Constants.ENV_USE_EXPERIMENTAL_BABILI]).toBeFalsy();
expect(fakeConfig[Constants.ENV_BUILD_TO_ES5]).toEqual('true');
expect(context.bundler).toEqual('webpack');
});
Expand Down Expand Up @@ -303,42 +295,6 @@ describe('config', () => {

describe('config.bundlerStrategy', () => {

it('should get rollup by full arg', () => {
config.addArgv('--rollup');
config.addArgv('my.rollup.confg.js');
const bundler = config.bundlerStrategy(context);
expect(bundler).toEqual('rollup');
});

it('should get rollup by short arg', () => {
config.addArgv('-r');
config.addArgv('my.rollup.confg.js');
const bundler = config.bundlerStrategy(context);
expect(bundler).toEqual('rollup');
});

it('should get rollup by bundler arg', () => {
config.addArgv('--bundler');
config.addArgv('rollup');
const bundler = config.bundlerStrategy(context);
expect(bundler).toEqual('rollup');
});

it('should get rollup by env var', () => {
config.setProcessEnv({
ionic_bundler: 'rollup'
});
config.setAppPackageJsonData({ config: { ionic_bundler: 'rollup' } });
const bundler = config.bundlerStrategy(context);
expect(bundler).toEqual('rollup');
});

it('should get rollup by package.json config', () => {
config.setAppPackageJsonData({ config: { ionic_bundler: 'rollup' } });
const bundler = config.bundlerStrategy(context);
expect(bundler).toEqual('rollup');
});

it('should get webpack with invalid env var', () => {
config.setProcessEnv({
ionic_bundler: 'bobsBundler'
Expand All @@ -347,21 +303,6 @@ describe('config', () => {
expect(bundler).toEqual('webpack');
});

it('should get rollup by env var', () => {
config.setProcessEnv({
ionic_bundler: 'rollup'
});
config.setAppPackageJsonData({ config: { ionic_bundler: 'rollup' } });
const bundler = config.bundlerStrategy(context);
expect(bundler).toEqual('rollup');
});

it('should get rollup by package.json config', () => {
config.setAppPackageJsonData({ config: { ionic_bundler: 'rollup' } });
const bundler = config.bundlerStrategy(context);
expect(bundler).toEqual('rollup');
});

it('should get webpack by default', () => {
const bundler = config.bundlerStrategy(context);
expect(bundler).toEqual('webpack');
Expand Down
32 changes: 1 addition & 31 deletions src/util/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,6 @@ export function generateContext(context?: BuildContext): BuildContext {
setProcessEnvVar(Constants.ENV_CLEAN_BEFORE_COPY, cleanBeforeCopy);
Logger.debug(`cleanBeforeCopy set to ${cleanBeforeCopy}`);

const closureCompilerJarPath = join(getProcessEnvVar(Constants.ENV_VAR_APP_SCRIPTS_DIR), 'bin', 'closure-compiler.jar');
setProcessEnvVar(Constants.ENV_CLOSURE_JAR, closureCompilerJarPath);
Logger.debug(`closureCompilerJarPath set to ${closureCompilerJarPath}`);

context.outputJsFileName = getConfigValue(context, '--outputJsFileName', null, Constants.ENV_OUTPUT_JS_FILE_NAME, Constants.ENV_OUTPUT_JS_FILE_NAME.toLowerCase(), 'main.js');
setProcessEnvVar(Constants.ENV_OUTPUT_JS_FILE_NAME, context.outputJsFileName);
Logger.debug(`outputJsFileName set to ${context.outputJsFileName}`);
Expand Down Expand Up @@ -249,18 +245,9 @@ export function generateContext(context?: BuildContext): BuildContext {
setProcessEnvVar(Constants.ENV_AOT_WRITE_TO_DISK, aotWriteToDisk);
Logger.debug(`aotWriteToDisk set to ${aotWriteToDisk}`);

const printOriginalDependencyTree = getConfigValue(context, '--printOriginalDependencyTree', null, Constants.ENV_PRINT_ORIGINAL_DEPENDENCY_TREE, Constants.ENV_PRINT_ORIGINAL_DEPENDENCY_TREE.toLowerCase(), null);
setProcessEnvVar(Constants.ENV_PRINT_ORIGINAL_DEPENDENCY_TREE, printOriginalDependencyTree);
Logger.debug(`printOriginalDependencyTree set to ${printOriginalDependencyTree}`);

const printModifiedDependencyTree = getConfigValue(context, '--printModifiedDependencyTree', null, Constants.ENV_PRINT_MODIFIED_DEPENDENCY_TREE, Constants.ENV_PRINT_MODIFIED_DEPENDENCY_TREE.toLowerCase(), null);
setProcessEnvVar(Constants.ENV_PRINT_MODIFIED_DEPENDENCY_TREE, printModifiedDependencyTree);
Logger.debug(`printModifiedDependencyTree set to ${printModifiedDependencyTree}`);

const printWebpackDependencyTree = getConfigValue(context, '--printWebpackDependencyTree', null, Constants.ENV_PRINT_WEBPACK_DEPENDENCY_TREE, Constants.ENV_PRINT_WEBPACK_DEPENDENCY_TREE.toLowerCase(), null);
setProcessEnvVar(Constants.ENV_PRINT_WEBPACK_DEPENDENCY_TREE, printWebpackDependencyTree);
Logger.debug(`printWebpackDependencyTree set to ${printWebpackDependencyTree}`);

const typeCheckOnLint = getConfigValue(context, '--typeCheckOnLint', null, Constants.ENV_TYPE_CHECK_ON_LINT, Constants.ENV_TYPE_CHECK_ON_LINT.toLowerCase(), null);
setProcessEnvVar(Constants.ENV_TYPE_CHECK_ON_LINT, typeCheckOnLint);
Logger.debug(`typeCheckOnLint set to ${typeCheckOnLint}`);
Expand Down Expand Up @@ -342,27 +329,10 @@ export function generateContext(context?: BuildContext): BuildContext {
setProcessEnvVar(Constants.ENV_PARSE_DEEPLINKS, parseDeepLinks);
Logger.debug(`parseDeepLinks set to ${parseDeepLinks}`);

const purgeDecorators = getConfigValue(context, '--purgeDecorators', null, Constants.ENV_PURGE_DECORATORS, Constants.ENV_PURGE_DECORATORS.toLowerCase(), 'true');
setProcessEnvVar(Constants.ENV_PURGE_DECORATORS, purgeDecorators);
Logger.debug(`purgeDecorators set to ${purgeDecorators}`);

const manualTreeshaking = getConfigValue(context, '--manualTreeshaking', null, Constants.ENV_MANUAL_TREESHAKING, Constants.ENV_MANUAL_TREESHAKING.toLowerCase(), 'true');
setProcessEnvVar(Constants.ENV_MANUAL_TREESHAKING, manualTreeshaking);
Logger.debug(`manualTreeshaking set to ${manualTreeshaking}`);

/* Experimental Flags */
const useExperimentalClosure = getConfigValue(context, '--useExperimentalClosure', null, Constants.ENV_USE_EXPERIMENTAL_CLOSURE, Constants.ENV_USE_EXPERIMENTAL_CLOSURE.toLowerCase(), null);
setProcessEnvVar(Constants.ENV_USE_EXPERIMENTAL_CLOSURE, useExperimentalClosure);
Logger.debug(`useExperimentalClosure set to ${useExperimentalClosure}`);

const useExperimentalBabili = getConfigValue(context, '--useExperimentalBabili', null, Constants.ENV_USE_EXPERIMENTAL_BABILI, Constants.ENV_USE_EXPERIMENTAL_BABILI.toLowerCase(), null);
setProcessEnvVar(Constants.ENV_USE_EXPERIMENTAL_BABILI, useExperimentalBabili);
Logger.debug(`useExperimentalBabili set to ${useExperimentalBabili}`);

// default stand-alone builds to default to es5
// if closure is being used, don't worry about this as it already automatically converts to ES5

const buildToEs5 = getConfigValue(context, '--buildToEs5', null, Constants.ENV_BUILD_TO_ES5, Constants.ENV_BUILD_TO_ES5.toLowerCase(), useExperimentalClosure ? null : 'true');
const buildToEs5 = getConfigValue(context, '--buildToEs5', null, Constants.ENV_BUILD_TO_ES5, Constants.ENV_BUILD_TO_ES5.toLowerCase(), 'true');
setProcessEnvVar(Constants.ENV_BUILD_TO_ES5, buildToEs5);
Logger.debug(`buildToEs5 set to ${buildToEs5}`);

Expand Down
9 changes: 0 additions & 9 deletions src/util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export const ENV_DIRECTIVES_NG_MODULE_PATH = 'IONIC_DIRECTIVES_NG_MODULE_PATH';

export const ENV_GLOB_UTIL = 'IONIC_GLOB_UTIL';
export const ENV_CLEAN_BEFORE_COPY = 'IONIC_CLEAN_BEFORE_COPY';
export const ENV_CLOSURE_JAR = 'IONIC_CLOSURE_JAR';
export const ENV_READ_CONFIG_JSON = 'IONIC_READ_CONFIG_JSON';
export const ENV_OUTPUT_JS_FILE_NAME = 'IONIC_OUTPUT_JS_FILE_NAME';
export const ENV_OUTPUT_CSS_FILE_NAME = 'IONIC_OUTPUT_CSS_FILE_NAME';
Expand All @@ -82,18 +81,10 @@ export const ENV_DISABLE_LOGGING = 'IONIC_DISABLE_LOGGING';
export const ENV_START_WATCH_TIMEOUT = 'IONIC_START_WATCH_TIMEOUT';
export const ENV_NG_MODULE_FILE_NAME_SUFFIX = 'IONIC_NG_MODULE_FILENAME_SUFFIX';
export const ENV_POLYFILL_FILE_NAME = 'IONIC_POLYFILL_FILE_NAME';

export const ENV_PRINT_ORIGINAL_DEPENDENCY_TREE = 'IONIC_PRINT_ORIGINAL_DEPENDENCY_TREE';
export const ENV_PRINT_MODIFIED_DEPENDENCY_TREE = 'IONIC_PRINT_MODIFIED_DEPENDENCY_TREE';
export const ENV_PRINT_WEBPACK_DEPENDENCY_TREE = 'IONIC_PRINT_WEBPACK_DEPENDENCY_TREE';
export const ENV_PARSE_DEEPLINKS = 'IONIC_PARSE_DEEPLINKS';
export const ENV_PURGE_DECORATORS = 'IONIC_PURGE_DECORATORS';
export const ENV_MANUAL_TREESHAKING = 'IONIC_MANUAL_TREESHAKING';

/* Flags for experimental stuff */

export const ENV_USE_EXPERIMENTAL_CLOSURE = 'IONIC_USE_EXPERIMENTAL_CLOSURE';
export const ENV_USE_EXPERIMENTAL_BABILI = 'IONIC_USE_EXPERIMENTAL_BABILI';

/* Providers */
export const ENV_ACTION_SHEET_CONTROLLER_CLASSNAME = 'IONIC_ACTION_SHEET_CONTROLLER_CLASSNAME';
Expand Down

0 comments on commit fbad33f

Please sign in to comment.