From 54acc74fdbe27a4ea99eb776c3abcfef7dcb6769 Mon Sep 17 00:00:00 2001 From: Dan Bucholtz Date: Mon, 27 Mar 2017 16:42:01 -0500 Subject: [PATCH] refactor(packaging): points to es5 code with es2015 import/header, points to umd cod points to es5 code with es2015 import/header, points to umd code, points to pure es2015 code --- scripts/gulp/constants.ts | 2 +- scripts/gulp/tasks/build.ts | 30 +++++++++++++++--------------- scripts/npm/package.json | 3 ++- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/scripts/gulp/constants.ts b/scripts/gulp/constants.ts index d266752d1b7..05fe33b5508 100644 --- a/scripts/gulp/constants.ts +++ b/scripts/gulp/constants.ts @@ -31,7 +31,7 @@ export const DIST_BUILD_ROOT = join(DIST_ROOT, PACKAGE_NAME); export const DIST_BUNDLE_ROOT = join(DIST_BUILD_ROOT, BUNDLES); export const DIST_BUILD_UMD_ROOT = join(DIST_BUILD_ROOT, UMD_MODULE); export const DIST_BUILD_UMD_BUNDLE_ENTRYPOINT = join(DIST_BUILD_ROOT, INDEX_JS); -export const DIST_BUILD_ESM_ROOT = join(DIST_BUILD_ROOT, 'esm'); +export const DIST_BUILD_ES2015_ROOT = join(DIST_BUILD_ROOT, 'es2015'); export const DIST_VENDOR_ROOT = join(DIST_ROOT, VENDOR_NAME); export const NODE_MODULES_ROOT = join(PROJECT_ROOT, NODE_MODULES); export const SCRIPTS_ROOT = join(PROJECT_ROOT, SCRIPTS_NAME); diff --git a/scripts/gulp/tasks/build.ts b/scripts/gulp/tasks/build.ts index 213b4448243..eb9fe066efa 100644 --- a/scripts/gulp/tasks/build.ts +++ b/scripts/gulp/tasks/build.ts @@ -1,5 +1,5 @@ import { task } from 'gulp'; -import { DIST_BUILD_ROOT, DIST_BUILD_ESM_ROOT, DIST_BUILD_UMD_ROOT, ES5, ES_2015, PROJECT_ROOT, UMD_MODULE } from '../constants'; +import { DIST_BUILD_ROOT, DIST_BUILD_ES2015_ROOT, DIST_BUILD_UMD_ROOT, ES5, ES_2015, PROJECT_ROOT, UMD_MODULE } from '../constants'; import { copySourceToDest, createTempTsConfig, deleteFiles, runNgc, runTsc } from '../util'; @@ -45,39 +45,39 @@ export function buildIonicAngularUmdTsc(excludeSpec: boolean, stripDebug: boolea export function buildIonicAngularEsm(stripDebug: boolean, done: Function) { - const stream = copySourceToDest(DIST_BUILD_ESM_ROOT, true, true, stripDebug); + const stream = copySourceToDest(DIST_BUILD_ROOT, true, true, stripDebug); stream.on('end', () => { // the source files are copied, copy over a tsconfig from - createTempTsConfig(['./**/*.ts'], ES_2015, ES_2015, `${PROJECT_ROOT}/tsconfig.json`, `${DIST_BUILD_ESM_ROOT}/tsconfig.json`); - runNgc(`${DIST_BUILD_ESM_ROOT}/tsconfig.json`, (err) => { + createTempTsConfig(['./**/*.ts'], ES5, ES_2015, `${PROJECT_ROOT}/tsconfig.json`, `${DIST_BUILD_ROOT}/tsconfig.json`); + runNgc(`${DIST_BUILD_ROOT}/tsconfig.json`, (err) => { if (err) { done(err); return; } // clean up any .ts files that remain as well as ngc metadata - deleteFiles([`${DIST_BUILD_ESM_ROOT}/**/*.ts`, - `${DIST_BUILD_ESM_ROOT}/node_modules`, - `${DIST_BUILD_ESM_ROOT}/tsconfig.json`, - `!${DIST_BUILD_ESM_ROOT}/**/*.d.ts`], done); + deleteFiles([`${DIST_BUILD_ROOT}/**/*.ts`, + `${DIST_BUILD_ROOT}/node_modules`, + `${DIST_BUILD_ROOT}/tsconfig.json`, + `!${DIST_BUILD_ROOT}/**/*.d.ts`], done); }); }); } export function buildIonicPureEs6(stripDebug: boolean, done: Function) { - const stream = copySourceToDest(DIST_BUILD_ROOT, true, true, stripDebug); + const stream = copySourceToDest(DIST_BUILD_ES2015_ROOT, true, true, stripDebug); stream.on('end', () => { // the source files are copied, copy over a tsconfig from - createTempTsConfig(['./**/*.ts'], ES_2015, ES_2015, `${PROJECT_ROOT}/tsconfig.json`, `${DIST_BUILD_ROOT}/tsconfig.json`); - runNgc(`${DIST_BUILD_ROOT}/tsconfig.json`, (err) => { + createTempTsConfig(['./**/*.ts'], ES_2015, ES_2015, `${PROJECT_ROOT}/tsconfig.json`, `${DIST_BUILD_ES2015_ROOT}/tsconfig.json`); + runNgc(`${DIST_BUILD_ES2015_ROOT}/tsconfig.json`, (err) => { if (err) { done(err); return; } // clean up any .ts files that remain as well as ngc metadata - deleteFiles([`${DIST_BUILD_ROOT}/**/*.ts`, - `${DIST_BUILD_ROOT}/node_modules`, - `${DIST_BUILD_ROOT}/tsconfig.json`, - `!${DIST_BUILD_ROOT}/**/*.d.ts`], done); + deleteFiles([`${DIST_BUILD_ES2015_ROOT}/**/*.ts`, + `${DIST_BUILD_ES2015_ROOT}/node_modules`, + `${DIST_BUILD_ES2015_ROOT}/tsconfig.json`, + `!${DIST_BUILD_ES2015_ROOT}/**/*.d.ts`], done); }); }); } diff --git a/scripts/npm/package.json b/scripts/npm/package.json index 399464767f4..9695a98556b 100644 --- a/scripts/npm/package.json +++ b/scripts/npm/package.json @@ -8,8 +8,9 @@ "url": "https://github.com/driftyco/ionic.git" }, "license": "MIT", - "main": "esm/index.js", + "main": "umd/index.js", "module": "index.js", + "es2015": "es2015/index.js", "peerDependencies": { "@angular/common": "", "@angular/compiler": "",