mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 04:14:21 +08:00
chore(build): change build process to publish es5 w/ es2015 import/export, umd, and pure es2015 versions
This commit is contained in:
@ -12,9 +12,9 @@ export const BUILD_NAME = 'build';
|
|||||||
export const SRC_NAME = 'src';
|
export const SRC_NAME = 'src';
|
||||||
export const VENDOR_NAME = 'vendor';
|
export const VENDOR_NAME = 'vendor';
|
||||||
export const NODE_MODULES = 'node_modules';
|
export const NODE_MODULES = 'node_modules';
|
||||||
export const COMMONJS_MODULE = 'commonjs';
|
export const UMD_MODULE = 'umd';
|
||||||
export const ES_MODULE = 'es2015';
|
export const ES_2015 = 'es2015';
|
||||||
|
export const ES5 = 'es5';
|
||||||
|
|
||||||
// File Paths
|
// File Paths
|
||||||
export const PROJECT_ROOT = join(__dirname, '../..');
|
export const PROJECT_ROOT = join(__dirname, '../..');
|
||||||
@ -24,7 +24,8 @@ export const DIST_ROOT = join(PROJECT_ROOT, DIST_NAME);
|
|||||||
export const DIST_E2E_ROOT = join(DIST_ROOT, E2E_NAME);
|
export const DIST_E2E_ROOT = join(DIST_ROOT, E2E_NAME);
|
||||||
export const DIST_E2E_COMPONENTS_ROOT = join(DIST_E2E_ROOT, COMPONENTS_NAME);
|
export const DIST_E2E_COMPONENTS_ROOT = join(DIST_E2E_ROOT, COMPONENTS_NAME);
|
||||||
export const DIST_BUILD_ROOT = join(DIST_ROOT, PACKAGE_NAME);
|
export const DIST_BUILD_ROOT = join(DIST_ROOT, PACKAGE_NAME);
|
||||||
export const DIST_BUILD_COMMONJS_ROOT = join(DIST_BUILD_ROOT, COMMONJS_MODULE);
|
export const DIST_BUILD_UMD_ROOT = join(DIST_BUILD_ROOT, UMD_MODULE);
|
||||||
|
export const DIST_BUILD_ES2015_ROOT = join(DIST_BUILD_ROOT, ES_2015);
|
||||||
export const DIST_VENDOR_ROOT = join(DIST_ROOT, VENDOR_NAME);
|
export const DIST_VENDOR_ROOT = join(DIST_ROOT, VENDOR_NAME);
|
||||||
export const NODE_MODULES_ROOT = join(PROJECT_ROOT, NODE_MODULES);
|
export const NODE_MODULES_ROOT = join(PROJECT_ROOT, NODE_MODULES);
|
||||||
export const SCRIPTS_ROOT = join(PROJECT_ROOT, SCRIPTS_NAME);
|
export const SCRIPTS_ROOT = join(PROJECT_ROOT, SCRIPTS_NAME);
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
import { task } from 'gulp';
|
import { task } from 'gulp';
|
||||||
import { COMMONJS_MODULE, DIST_BUILD_ROOT, DIST_BUILD_COMMONJS_ROOT, ES_MODULE } from '../constants';
|
import { DIST_BUILD_ROOT, DIST_BUILD_ES2015_ROOT, DIST_BUILD_UMD_ROOT, ES5, ES_2015, UMD_MODULE } from '../constants';
|
||||||
import { copySourceToDest, copySwiperToPath, createTempTsConfig, deleteFiles, runNgc} from '../util';
|
import { copySourceToDest, copySwiperToPath, createTempTsConfig, deleteFiles, runNgc} from '../util';
|
||||||
|
|
||||||
|
|
||||||
export function buildIonicAngularCommonJs(excludeSpec: boolean, done: Function) {
|
export function buildIonicAngularUmd(excludeSpec: boolean, done: Function) {
|
||||||
const stream = copySourceToDest(DIST_BUILD_COMMONJS_ROOT, excludeSpec, true);
|
const stream = copySourceToDest(DIST_BUILD_UMD_ROOT, excludeSpec, true);
|
||||||
stream.on('end', () => {
|
stream.on('end', () => {
|
||||||
// the source files are copied, copy over a tsconfig from
|
// the source files are copied, copy over a tsconfig from
|
||||||
createTempTsConfig(['./**/*.ts'], COMMONJS_MODULE, `${DIST_BUILD_COMMONJS_ROOT}/tsconfig.json`);
|
createTempTsConfig(['./**/*.ts'], ES5, UMD_MODULE, `${DIST_BUILD_UMD_ROOT}/tsconfig.json`);
|
||||||
runNgc(`${DIST_BUILD_COMMONJS_ROOT}/tsconfig.json`, (err) => {
|
runNgc(`${DIST_BUILD_UMD_ROOT}/tsconfig.json`, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
done(err);
|
done(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
copySwiperToPath(`${DIST_BUILD_COMMONJS_ROOT}/components/slides`, COMMONJS_MODULE);
|
copySwiperToPath(`${DIST_BUILD_UMD_ROOT}/components/slides`, UMD_MODULE);
|
||||||
// clean up any .ts files that remain as well as ngc metadata
|
// clean up any .ts files that remain as well as ngc metadata
|
||||||
deleteFiles([`${DIST_BUILD_COMMONJS_ROOT}/**/*.ts`,
|
deleteFiles([`${DIST_BUILD_UMD_ROOT}/**/*.ts`,
|
||||||
`${DIST_BUILD_COMMONJS_ROOT}/node_modules`,
|
`${DIST_BUILD_UMD_ROOT}/node_modules`,
|
||||||
`${DIST_BUILD_COMMONJS_ROOT}/tsconfig.json`,
|
`${DIST_BUILD_UMD_ROOT}/tsconfig.json`,
|
||||||
`!${DIST_BUILD_COMMONJS_ROOT}/**/*.d.ts`], done);
|
`!${DIST_BUILD_UMD_ROOT}/**/*.d.ts`], done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -28,13 +28,13 @@ export function buildIonicAngularEsm(done: Function) {
|
|||||||
const stream = copySourceToDest(DIST_BUILD_ROOT, true, true);
|
const stream = copySourceToDest(DIST_BUILD_ROOT, true, true);
|
||||||
stream.on('end', () => {
|
stream.on('end', () => {
|
||||||
// the source files are copied, copy over a tsconfig from
|
// the source files are copied, copy over a tsconfig from
|
||||||
createTempTsConfig(['./**/*.ts'], ES_MODULE, `${DIST_BUILD_ROOT}/tsconfig.json`);
|
createTempTsConfig(['./**/*.ts'], ES5, ES_2015, `${DIST_BUILD_ROOT}/tsconfig.json`);
|
||||||
runNgc(`${DIST_BUILD_ROOT}/tsconfig.json`, (err) => {
|
runNgc(`${DIST_BUILD_ROOT}/tsconfig.json`, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
done(err);
|
done(err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
copySwiperToPath(`${DIST_BUILD_ROOT}/components/slides`, ES_MODULE);
|
copySwiperToPath(`${DIST_BUILD_ROOT}/components/slides`, ES_2015);
|
||||||
// clean up any .ts files that remain as well as ngc metadata
|
// clean up any .ts files that remain as well as ngc metadata
|
||||||
deleteFiles([`${DIST_BUILD_ROOT}/**/*.ts`,
|
deleteFiles([`${DIST_BUILD_ROOT}/**/*.ts`,
|
||||||
`${DIST_BUILD_ROOT}/node_modules`,
|
`${DIST_BUILD_ROOT}/node_modules`,
|
||||||
@ -44,14 +44,36 @@ export function buildIonicAngularEsm(done: Function) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function buildIonicPureEs6(done: Function) {
|
||||||
|
const stream = copySourceToDest(DIST_BUILD_ES2015_ROOT, true, true);
|
||||||
|
stream.on('end', () => {
|
||||||
|
// the source files are copied, copy over a tsconfig from
|
||||||
|
createTempTsConfig(['./**/*.ts'], ES_2015, ES_2015, `${DIST_BUILD_ES2015_ROOT}/tsconfig.json`);
|
||||||
|
runNgc(`${DIST_BUILD_ES2015_ROOT}/tsconfig.json`, (err) => {
|
||||||
|
if (err) {
|
||||||
|
done(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
copySwiperToPath(`${DIST_BUILD_ES2015_ROOT}/components/slides`, ES_2015);
|
||||||
|
// clean up any .ts files that remain as well as ngc metadata
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/* this task builds out the necessary stuff for karma */
|
/* this task builds out the necessary stuff for karma */
|
||||||
task('compile.karma', (done: Function) => {
|
task('compile.karma', (done: Function) => {
|
||||||
buildIonicAngularCommonJs(false, done);
|
buildIonicAngularUmd(false, done);
|
||||||
});
|
});
|
||||||
|
|
||||||
/* this task builds out the ionic-angular (commonjs and esm) directories for release */
|
/* this task builds out the ionic-angular (commonjs and esm) directories for release */
|
||||||
task('compile.release', (done: Function) => {
|
task('compile.release', (done: Function) => {
|
||||||
buildIonicAngularEsm(() => {
|
buildIonicAngularEsm(() => {
|
||||||
buildIonicAngularCommonJs(true, done);
|
buildIonicAngularUmd(true, () => {
|
||||||
|
buildIonicPureEs6(done);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -14,7 +14,7 @@ import { obj } from 'through2';
|
|||||||
import * as VinylFile from 'vinyl';
|
import * as VinylFile from 'vinyl';
|
||||||
import { argv } from 'yargs';
|
import { argv } from 'yargs';
|
||||||
|
|
||||||
import { DIST_E2E_COMPONENTS_ROOT, DIST_E2E_ROOT, DIST_NAME, E2E_NAME, ES_MODULE, LOCAL_SERVER_PORT, PROJECT_ROOT, SCRIPTS_ROOT, SRC_COMPONENTS_ROOT, SRC_ROOT } from '../constants';
|
import { DIST_E2E_COMPONENTS_ROOT, DIST_E2E_ROOT, DIST_NAME, E2E_NAME, ES5, ES_2015, LOCAL_SERVER_PORT, PROJECT_ROOT, SCRIPTS_ROOT, SRC_COMPONENTS_ROOT, SRC_ROOT } from '../constants';
|
||||||
import { compileSass, copyFonts, createTempTsConfig, createTimestamp, deleteFiles, runNgc, setSassIonicVersion, writePolyfills } from '../util';
|
import { compileSass, copyFonts, createTempTsConfig, createTimestamp, deleteFiles, runNgc, setSassIonicVersion, writePolyfills } from '../util';
|
||||||
|
|
||||||
task('e2e', e2eBuild);
|
task('e2e', e2eBuild);
|
||||||
@ -110,7 +110,7 @@ function buildE2ETests(folderInfo: any, done: Function) {
|
|||||||
`./components/${folderInfo.componentName}/test/${folderInfo.componentTest}/entry.ts`,
|
`./components/${folderInfo.componentName}/test/${folderInfo.componentTest}/entry.ts`,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
createTempTsConfig(includeGlob, ES_MODULE, `${DIST_E2E_ROOT}/tsconfig.json`);
|
createTempTsConfig(includeGlob, ES5, ES_2015, `${DIST_E2E_ROOT}/tsconfig.json`);
|
||||||
runNgc(`${DIST_E2E_ROOT}/tsconfig.json`, (err) => {
|
runNgc(`${DIST_E2E_ROOT}/tsconfig.json`, (err) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
done(err);
|
done(err);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { COMMONJS_MODULE, ES_MODULE, NODE_MODULES_ROOT, PROJECT_ROOT, SRC_ROOT, SRC_COMPONENTS_ROOT } from './constants';
|
import { UMD_MODULE, ES_2015, NODE_MODULES_ROOT, PROJECT_ROOT, SRC_ROOT, SRC_COMPONENTS_ROOT } from './constants';
|
||||||
import { src, dest } from 'gulp';
|
import { src, dest } from 'gulp';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
@ -32,7 +32,7 @@ function getRootTsConfig(): any {
|
|||||||
return tsConfig;
|
return tsConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createTempTsConfig(includeGlob: string[], moduleType: String, pathToWriteFile: string): any {
|
export function createTempTsConfig(includeGlob: string[], target: string, moduleType: string, pathToWriteFile: string): any {
|
||||||
let config = getRootTsConfig();
|
let config = getRootTsConfig();
|
||||||
if (!config.compilerOptions) {
|
if (!config.compilerOptions) {
|
||||||
config.compilerOptions = {};
|
config.compilerOptions = {};
|
||||||
@ -43,6 +43,7 @@ export function createTempTsConfig(includeGlob: string[], moduleType: String, pa
|
|||||||
}
|
}
|
||||||
if (config.compilerOptions) {
|
if (config.compilerOptions) {
|
||||||
config.compilerOptions.module = moduleType;
|
config.compilerOptions.module = moduleType;
|
||||||
|
config.compilerOptions.target = target;
|
||||||
}
|
}
|
||||||
config.include = includeGlob;
|
config.include = includeGlob;
|
||||||
let json = JSON.stringify(config, null, 2);
|
let json = JSON.stringify(config, null, 2);
|
||||||
@ -121,9 +122,9 @@ export function copyFile(srcPath: string, destPath: string) {
|
|||||||
|
|
||||||
export function copySwiperToPath(distPath: string, moduleType: string) {
|
export function copySwiperToPath(distPath: string, moduleType: string) {
|
||||||
copyFile(`${SRC_COMPONENTS_ROOT}/slides/swiper-widget.d.ts`, `${distPath}/swiper-widget.d.ts`);
|
copyFile(`${SRC_COMPONENTS_ROOT}/slides/swiper-widget.d.ts`, `${distPath}/swiper-widget.d.ts`);
|
||||||
if (!moduleType || moduleType === COMMONJS_MODULE) {
|
if (!moduleType || moduleType === UMD_MODULE) {
|
||||||
copyFile(`${SRC_COMPONENTS_ROOT}/slides/swiper-widget.js`, `${distPath}/swiper-widget.js`);
|
copyFile(`${SRC_COMPONENTS_ROOT}/slides/swiper-widget.js`, `${distPath}/swiper-widget.js`);
|
||||||
} else if (moduleType === ES_MODULE) {
|
} else if (moduleType === ES_2015) {
|
||||||
copyFile(`${SRC_COMPONENTS_ROOT}/slides/swiper-widget.es2015.js`, `${distPath}/swiper-widget.js`);
|
copyFile(`${SRC_COMPONENTS_ROOT}/slides/swiper-widget.es2015.js`, `${distPath}/swiper-widget.js`);
|
||||||
} else {
|
} else {
|
||||||
copyFile(`${SRC_COMPONENTS_ROOT}/slides/swiper-widget.system.js`, `${distPath}/swiper-widget.system.js`);
|
copyFile(`${SRC_COMPONENTS_ROOT}/slides/swiper-widget.system.js`, `${distPath}/swiper-widget.system.js`);
|
||||||
|
@ -24,7 +24,7 @@ System.config({
|
|||||||
'@angular/http': 'vendor/@angular/http/bundles/http.umd.js',
|
'@angular/http': 'vendor/@angular/http/bundles/http.umd.js',
|
||||||
'@angular/forms': 'vendor/@angular/forms/bundles/forms.umd.js',
|
'@angular/forms': 'vendor/@angular/forms/bundles/forms.umd.js',
|
||||||
'rxjs': 'vendor/rxjs',
|
'rxjs': 'vendor/rxjs',
|
||||||
'ionic-angular': 'ionic-angular/commonjs'
|
'ionic-angular': 'ionic-angular/umd'
|
||||||
},
|
},
|
||||||
packages: {
|
packages: {
|
||||||
'ionic-angular': {
|
'ionic-angular': {
|
||||||
|
Reference in New Issue
Block a user