diff --git a/.babelrc b/.babelrc deleted file mode 100644 index a170d0cd8c..0000000000 --- a/.babelrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "plugins": ["transform-es2015-modules-umd"], - "presets": ["es2015"] -} diff --git a/build.sh b/build.sh index 25c47d28fb..eabc9a431c 100755 --- a/build.sh +++ b/build.sh @@ -54,33 +54,24 @@ for ARG in "$@"; do done getPackageContents() { - echo "{\"typings\": \"../typings/${2}/${2}.d.ts\", \"main\": \"../bundles/${1}-${2}.umd.js\", \"module\": \"../@angular/${1}/${2}.es5.js\", \"es2015\": \"../@angular/${1}/${2}.js\"}" + echo "{\"typings\": \"../typings/${2}/${3:-$2}.d.ts\", \"main\": \"../bundles/${1}-${2}.umd.js\", \"module\": \"../@angular/${1}/${2}.es5.js\", \"es2015\": \"../@angular/${1}/${2}.js\"}" } -containsElement () { - local e - for e in "${@:2}"; do - [[ "$e" == "$1" ]] && return 0; - done - return 1 +####################################### +# Downlevel ES2015 to ESM/ES5 +# Arguments: +# param1 - Destination folder +# param2 - Input path +# param3 - Output path +# Returns: +# None +####################################### +downlevelES2015() { + echo '{"presets": [ ["es2015", { "modules": false }] ], "compact": true }' > ${1}/.babelrc + $BABELJS ${2} -o ${3} + rm -f ${1}/.babelrc } -NON_MODULE=( - platform-browser -) - -moveTypings() { - # $1 == Source copy root (/src or /testing) - # $2 == Final destination directory - rsync -a --exclude=*.js* ${1} ${2} -} - -cleanTypings() { - # $1 == Source root (where index.d.ts file is, for instance) - # $2 == Source copy root (/src or /typings) - rm -f ${1}/index.* - rm -rf ${2} -} VERSION="${VERSION_PREFIX}${VERSION_SUFFIX}" ROUTER_VERSION="${ROUTER_VERSION_PREFIX}${VERSION_SUFFIX}" echo "====== BUILDING: Version ${VERSION} (Router ${ROUTER_VERSION})" @@ -152,7 +143,7 @@ do DEST_MODULE=${DESTDIR}/@angular DEST_BUNDLES=${DESTDIR}/bundles - # ESM/ES6 + # ESM/2015 JS_PATH=${DEST_MODULE}/${PACKAGE}.js JS_PATH_ES5=${DEST_MODULE}/${PACKAGE}.es5.js JS_TESTING_PATH=${DEST_MODULE}/${PACKAGE}/testing.js @@ -187,11 +178,15 @@ do rm -rf ${DESTDIR} - echo "====== [${PACKAGE}]: COMPILING: ${TSC} --skipImportRename -p ${SRCDIR}/tsconfig-build.json" + # When .babelrc file exists, the dist package will have ES2015 sources, ESM/ES5, and UMD bundles. Because of a bug + # preventing the @angular/compiler package from running through this pipeline, we have to manually check for the Compiler + # package as well. The tsconfig-build.json defaults to building to the root of the package dist dir, but when + # outputting ES2015 then bundling from there, built files should go to the DEST_MODULE folder. + echo "====== [${PACKAGE}]: COMPILING: ${TSC} -p ${SRCDIR}/tsconfig-build.json" if [[ -e ${SRCDIR}/.babelrc || ${PACKAGE} == "compiler" ]]; then - $TSC --skipImportRename -p ${SRCDIR}/tsconfig-build.json -outDir ${DEST_MODULE} + $TSC -p ${SRCDIR}/tsconfig-build.json -outDir ${DEST_MODULE} else - $TSC --skipImportRename -p ${SRCDIR}/tsconfig-build.json + $TSC -p ${SRCDIR}/tsconfig-build.json fi echo "====== Move ${PACKAGE} typings" @@ -264,55 +259,54 @@ do mv ${JS_PATH}.tmp ${JS_PATH} if ! [[ ${PACKAGE} == 'benchpress' ]]; then - cleanTypings ${DEST_MODULE} ${DEST_MODULE}/src + rm -f ${DEST_MODULE}/index.* + rm -rf ${DEST_MODULE}/src fi if [[ -e ${DESTDIR}/.babelrc ]]; then - echo "====== Downleveling ${PACKAGE} to ES5/UMD" + echo "====== Downleveling ES2015 to UMD/ES5" $BABELJS ${JS_PATH} -o ${UMD_ES5_PATH} ### Minification ### - echo "====== Minifying JavaScript" + echo "====== Minifying ES2015" $BABILI ${JS_PATH} -o ${UMD_ES5_MIN_PATH} - echo "====== Downleveling min JavaScript to ES5/UMD" + echo "====== Downleveling minified ES2015 to UMD/ES5" $BABELJS ${UMD_ES5_MIN_PATH} -o ${UMD_ES5_MIN_PATH} - echo "====== Minifying ${PACKAGE}" + echo "====== Minifying UMD/ES5" $UGLIFYJS -c --screw-ie8 --comments -o ${UMD_ES5_MIN_PATH} ${UMD_ES5_MIN_PATH} ### END Minification ### else - # For packages not running through babel, use the es5/umd config - echo "====== Rollup ${PACKAGE} index to UMD" + # For packages not running through babel, use the UMD/ES5 config + echo "====== Rollup ${PACKAGE} index to UMD/ES5" ../../../node_modules/.bin/rollup -c rollup-umd.config.js [[ -d ${DESTDIR}/es5 ]] && rm -rf ${DESTDIR}/es5 - echo "====== Minifying UMD ${PACKAGE}" + echo "====== Minifying UMD/ES5" $UGLIFYJS -c --screw-ie8 --comments -o ${UMD_ES5_MIN_PATH} ${UMD_ES5_PATH} fi rm -f ${DISTDIR}/.babelrc - cp ${ROOTDIR}/.babelrc ${DEST_MODULE}/.babelrc - $BABELJS ${JS_PATH} -o ${JS_PATH_ES5} + echo "====== Downleveling ES2015 to ESM/ES5" + downlevelES2015 ${DEST_MODULE} ${JS_PATH} ${JS_PATH_ES5} if [[ -d testing ]]; then echo "====== Rollup ${PACKAGE} testing" ../../../node_modules/.bin/rollup -i ${DESTDIR}/testing/index.js -o ${DESTDIR}/testing.tmp.js - echo "====== Downleveling ${PACKAGE} TESTING to ES5/UMD" + echo "====== Downleveling ${PACKAGE} TESTING to UMD/ES5" [[ -e ${SRCDIR}/.babelrc-testing ]] && cp ${SRCDIR}/.babelrc-testing ${DESTDIR}/.babelrc $BABELJS ${DESTDIR}/testing.tmp.js -o ${UMD_TESTING_ES5_PATH} rm -f ${DESTDIR}/.babelrc echo "====== Move ${PACKAGE} testing typings" rsync -a --exclude=*.js --exclude=*.js.map ${DESTDIR}/testing/ ${DESTDIR}/typings/testing - mv ${DESTDIR}/typings/testing/index.d.ts ${DESTDIR}/typings/testing/testing.d.ts - mv ${DESTDIR}/typings/testing/index.metadata.json ${DESTDIR}/typings/testing/testing.metadata.json rm -rf ${DESTDIR}/testing mkdir ${DESTDIR}/testing && [[ -d ${DEST_MODULE}/${PACKAGE} ]] || mkdir ${DEST_MODULE}/${PACKAGE} - getPackageContents "${PACKAGE}" "testing" > ${DESTDIR}/testing/package.json + getPackageContents "${PACKAGE}" "testing" "index" > ${DESTDIR}/testing/package.json mv ${DESTDIR}/testing.tmp.js ${JS_TESTING_PATH} $BABELJS ${JS_TESTING_PATH} -o ${JS_TESTING_PATH_ES5} @@ -326,7 +320,7 @@ do rm -f ${DEST_MODULE}/static.* ../../../node_modules/.bin/rollup -i ${DESTDIR}/static/static.js -o ${DESTDIR}/static.tmp.js - echo "====== Downleveling ${PACKAGE} STATIC to ES5/UMD" + echo "====== Downleveling ${PACKAGE} STATIC to UMD/ES5" [[ -e ${SRCDIR}/.babelrc-static ]] && cp ${SRCDIR}/.babelrc-static ${DESTDIR}/.babelrc $BABELJS ${DESTDIR}/static.tmp.js -o ${UMD_STATIC_ES5_PATH} rm -f ${DESTDIR}/.babelrc @@ -353,7 +347,7 @@ do rm -f ${DEST_MODULE}/upgrade.* ../../../node_modules/.bin/rollup -i ${DESTDIR}/upgrade/upgrade.js -o ${DESTDIR}/upgrade.tmp.js - echo "====== Downleveling ${PACKAGE} UPGRADE to ES5/UMD" + echo "====== Downleveling ${PACKAGE} UPGRADE to UMD/ES5" [[ -e ${SRCDIR}/.babelrc-upgrade ]] && cp ${SRCDIR}/.babelrc-upgrade ${DESTDIR}/.babelrc $BABELJS ${DESTDIR}/upgrade.tmp.js -o ${UMD_UPGRADE_ES5_PATH} rm -f ${DESTDIR}/.babelrc @@ -399,8 +393,6 @@ do echo "====== Move ${PACKAGE} animations testing typings" rsync -a --exclude=*.js --exclude=*.js.map ${DESTDIR}/animations/testing/ ${DESTDIR}/typings/animations/testing - mv ${DESTDIR}/typings/animations/testing/index.d.ts ${DESTDIR}/typings/animations/testing/testing.d.ts - mv ${DESTDIR}/typings/animations/testing/index.metadata.json ${DESTDIR}/typings/animations/testing/testing.metadata.json rm -rf ${DESTDIR}/animations @@ -409,7 +401,7 @@ do getPackageContents "${PACKAGE}" "animations" > ${DESTDIR}/animations/package.json - echo '{"typings": "../../typings/animations/testing/testing.d.ts", "main": "../../bundles/platform-browser-animations-testing.umd.js", "module": "../../@angular/platform-browser/animations/testing.es5.js", "es2015": "../../@angular/platform-browser/animations/testing.js"}' > ${DESTDIR}/animations/testing/package.json + echo '{"typings": "../../typings/animations/testing/index.d.ts", "main": "../../bundles/platform-browser-animations-testing.umd.js", "module": "../../@angular/platform-browser/animations/testing.es5.js", "es2015": "../../@angular/platform-browser/animations/testing.js"}' > ${DESTDIR}/animations/testing/package.json mv ${DESTDIR}/animations.tmp.js ${JS_ANIMATIONS_PATH} $BABELJS ${JS_ANIMATIONS_PATH} -o ${JS_ANIMATIONS_PATH_ES5} @@ -426,17 +418,18 @@ do cat ${UMD_ANIMATIONS_TESTING_ES5_PATH} >> ${UMD_ANIMATIONS_TESTING_ES5_PATH}.tmp mv ${UMD_ANIMATIONS_TESTING_ES5_PATH}.tmp ${UMD_ANIMATIONS_TESTING_ES5_PATH} fi + + for FILE in ${DEST_MODULE}/public_api*; do + rm -f ${FILE} + done + ) 2>&1 | grep -v "as external dependency" fi ( echo "====== VERSION: Updating version references" - if [[ -e ${SRCDIR}/.babelrc ]]; then - cd ${DEST_MODULE} - else - cd ${DESTDIR} - fi + cd ${DESTDIR} echo "====== EXECUTE: perl -p -i -e \"s/0\.0\.0\-PLACEHOLDER/${VERSION}/g\" $""(grep -ril 0\.0\.0\-PLACEHOLDER .)" perl -p -i -e "s/0\.0\.0\-PLACEHOLDER/${VERSION}/g" $(grep -ril 0\.0\.0\-PLACEHOLDER .) < /dev/null 2> /dev/null echo "====== EXECUTE: perl -p -i -e \"s/0\.0\.0\-ROUTERPLACEHOLDER/${ROUTER_VERSION}/g\" $""(grep -ril 0\.0\.0\-ROUTERPLACEHOLDER .)" diff --git a/integration/README.md b/integration/README.md index 19a11b70f4..1ae678187b 100644 --- a/integration/README.md +++ b/integration/README.md @@ -43,7 +43,7 @@ See the `package.json` of the test(s) you're debugging, to see which dist/ folde Then run the right `tsc --watch` command to keep those dist folders up-to-date, for example: ``` -$ ./node_modules/.bin/tsc -p modules/@angular/core/tsconfig-build.json --outDir dist/packages-dist/core --watch +$ ./node_modules/.bin/tsc -p modules/@angular/core/tsconfig-build.json --watch ``` Now you can run the integration test, it will re-install from the dist/ folder on each run. diff --git a/modules/@angular/.babelrc b/modules/@angular/.babelrc deleted file mode 100755 index 9897749da4..0000000000 --- a/modules/@angular/.babelrc +++ /dev/null @@ -1,5 +0,0 @@ -{ - "presets": [ - ["es2015", { "modules": false }] - ] -} diff --git a/modules/@angular/animations/.babelrc b/modules/@angular/animations/.babelrc index e7447c2788..9133fb5629 100644 --- a/modules/@angular/animations/.babelrc +++ b/modules/@angular/animations/.babelrc @@ -10,5 +10,5 @@ }, "exactGlobals": true }]], - "moduleId": "@angular/animation" + "moduleId": "@angular/animations" } diff --git a/modules/@angular/animations/.babelrc-testing b/modules/@angular/animations/.babelrc-testing deleted file mode 100644 index f7a9afe4ce..0000000000 --- a/modules/@angular/animations/.babelrc-testing +++ /dev/null @@ -1,14 +0,0 @@ - -{ - "presets": ["es2015"], - "plugins": [["transform-es2015-modules-umd", { - "globals": { - "@angular/core": "ng.core", - "@angular/animations": "ng.animations", - "rxjs/Observable": "Rx", - "rxjs/Subject": "Rx" - }, - "exactGlobals": true - }]], - "moduleId": "@angular/animation/testing" -} diff --git a/modules/@angular/benchpress/tsconfig-build.json b/modules/@angular/benchpress/tsconfig-build.json index d38ab2450a..8cd835afda 100644 --- a/modules/@angular/benchpress/tsconfig-build.json +++ b/modules/@angular/benchpress/tsconfig-build.json @@ -18,7 +18,6 @@ // don't auto-discover @types/node, it results in a /// { + options?: ts.CompilerOptions): Promise { try { let projectDir = project; // project is vinyl like file object @@ -117,7 +117,7 @@ export function main( const tsickleCompilerHostOptions: tsickle.Options = { googmodule: false, untyped: true, - convertIndexImportShorthand: !skipImportRename && + convertIndexImportShorthand: ngOptions.target === ts.ScriptTarget.ES2015, // This covers ES6 too }; @@ -172,19 +172,13 @@ export function main( // CLI entry point if (require.main === module) { - let args = process.argv.slice(2); - let idx = args.indexOf('--skipImportRename'); - let skipImportRename = false; - if (idx !== -1) { - args.splice(idx, 1); - skipImportRename = true; - } + const args = process.argv.slice(2); let {options, fileNames, errors} = (ts as any).parseCommandLine(args); check(errors); const project = options.project || '.'; // TODO(alexeagle): command line should be TSC-compatible, remove "CliOptions" here const cliOptions = new CliOptions(require('minimist')(args)); - main(project, cliOptions, null, options, skipImportRename) + main(project, cliOptions, null, options) .then((exitCode: any) => process.exit(exitCode)) .catch((e: any) => { console.error(e.stack); diff --git a/tools/gulp-tasks/public-api.js b/tools/gulp-tasks/public-api.js index 613eb89bc0..36c3897aca 100644 --- a/tools/gulp-tasks/public-api.js +++ b/tools/gulp-tasks/public-api.js @@ -1,8 +1,7 @@ const entrypoints = [ - 'dist/packages-dist/core/typings/core.d.ts', - 'dist/packages-dist/core/typings/testing/testing.d.ts', + 'dist/packages-dist/core/typings/core.d.ts', 'dist/packages-dist/core/typings/testing/index.d.ts', 'dist/packages-dist/common/typings/common.d.ts', - 'dist/packages-dist/common/typings/testing/testing.d.ts', + 'dist/packages-dist/common/typings/testing/index.d.ts', // The API surface of the compiler is currently unstable - all of the important APIs are exposed // via @angular/core, @angular/platform-browser or @angular/platform-browser-dynamic instead. //'dist/packages-dist/compiler/index.d.ts', @@ -10,19 +9,18 @@ const entrypoints = [ 'dist/packages-dist/upgrade/typings/upgrade.d.ts', 'dist/packages-dist/upgrade/typings/static/static.d.ts', 'dist/packages-dist/platform-browser/typings/platform-browser.d.ts', - 'dist/packages-dist/platform-browser/typings/testing/testing.d.ts', + 'dist/packages-dist/platform-browser/typings/testing/index.d.ts', 'dist/packages-dist/platform-browser-dynamic/typings/platform-browser-dynamic.d.ts', - 'dist/packages-dist/platform-browser-dynamic/typings/testing/testing.d.ts', + 'dist/packages-dist/platform-browser-dynamic/typings/testing/index.d.ts', 'dist/packages-dist/platform-webworker/typings/platform-webworker.d.ts', 'dist/packages-dist/platform-webworker-dynamic/typings/platform-webworker-dynamic.d.ts', 'dist/packages-dist/platform-server/typings/platform-server.d.ts', - 'dist/packages-dist/platform-server/typings/testing/testing.d.ts', - 'dist/packages-dist/http/typings/http.d.ts', - 'dist/packages-dist/http/typings/testing/testing.d.ts', + 'dist/packages-dist/platform-server/typings/testing/index.d.ts', + 'dist/packages-dist/http/typings/http.d.ts', 'dist/packages-dist/http/typings/testing/index.d.ts', 'dist/packages-dist/forms/typings/forms.d.ts', 'dist/packages-dist/router/typings/router.d.ts', 'dist/packages-dist/animations/typings/animations.d.ts', 'dist/packages-dist/platform-browser/typings/animations/animations.d.ts', - 'dist/packages-dist/platform-browser/typings/animations/testing/testing.d.ts' + 'dist/packages-dist/platform-browser/typings/animations/testing/index.d.ts' ]; const publicApiDir = 'tools/public_api_guard'; diff --git a/tools/public_api_guard/animation/typings/animation.d.ts b/tools/public_api_guard/animation/typings/animation.d.ts deleted file mode 100644 index e28fa46570..0000000000 --- a/tools/public_api_guard/animation/typings/animation.d.ts +++ /dev/null @@ -1,86 +0,0 @@ -/** @experimental */ -export declare function animate(timings: string | number, styles?: AnimationStyleMetadata | AnimationKeyframesSequenceMetadata): AnimationAnimateMetadata; - -/** @experimental */ -export declare class Animation { - constructor(input: AnimationMetadata | AnimationMetadata[]); - buildTimelines(startingStyles: StyleData | StyleData[], destinationStyles: StyleData | StyleData[]): AnimationTimelineInstruction[]; -} - -/** @experimental */ -export interface AnimationGroupMetadata extends AnimationMetadata { - steps: AnimationMetadata[]; -} - -/** @experimental */ -export interface AnimationKeyframesSequenceMetadata extends AnimationMetadata { - steps: AnimationStyleMetadata[]; -} - -/** @experimental */ -export declare class AnimationModule { -} - -/** @experimental */ -export interface AnimationSequenceMetadata extends AnimationMetadata { - steps: AnimationMetadata[]; -} - -/** @experimental */ -export interface AnimationStateMetadata extends AnimationMetadata { - name: string; - styles: AnimationStyleMetadata; -} - -/** @experimental */ -export interface AnimationStyleMetadata extends AnimationMetadata { - offset: number; - styles: StyleData[]; -} - -/** @experimental */ -export interface AnimationTransitionMetadata extends AnimationMetadata { - animation: AnimationMetadata; - expr: string | ((fromState: string, toState: string) => boolean); -} - -/** @experimental */ -export declare class AnimationTrigger implements Trigger { - name: string; - states: { - [stateName: string]: StyleData; - }; - transitionFactories: AnimationTransitionFactory[]; - constructor(name: string, states: { - [stateName: string]: StyleData; - }, _transitionAsts: AnimationTransitionMetadata[]); - matchTransition(currentState: any, nextState: any): AnimationTransitionInstruction; -} - -/** @experimental */ -export declare const AUTO_STYLE = "*"; - -/** @experimental */ -export declare function group(steps: AnimationMetadata[]): AnimationGroupMetadata; - -/** @experimental */ -export declare function keyframes(steps: AnimationStyleMetadata[]): AnimationKeyframesSequenceMetadata; - -/** @experimental */ -export declare function sequence(steps: AnimationMetadata[]): AnimationSequenceMetadata; - -/** @experimental */ -export declare function state(name: string, styles: AnimationStyleMetadata): AnimationStateMetadata; - -/** @experimental */ -export declare function style(tokens: { - [key: string]: string | number; -} | Array<{ - [key: string]: string | number; -}>): AnimationStyleMetadata; - -/** @experimental */ -export declare function transition(stateChangeExpr: string | ((fromState: string, toState: string) => boolean), steps: AnimationMetadata | AnimationMetadata[]): AnimationTransitionMetadata; - -/** @experimental */ -export declare function trigger(name: string, definitions: AnimationMetadata[]): AnimationTrigger; diff --git a/tools/public_api_guard/common/typings/testing/testing.d.ts b/tools/public_api_guard/common/typings/testing/index.d.ts similarity index 100% rename from tools/public_api_guard/common/typings/testing/testing.d.ts rename to tools/public_api_guard/common/typings/testing/index.d.ts diff --git a/tools/public_api_guard/compiler/typings/testing/testing.d.ts b/tools/public_api_guard/compiler/typings/testing/index.d.ts similarity index 100% rename from tools/public_api_guard/compiler/typings/testing/testing.d.ts rename to tools/public_api_guard/compiler/typings/testing/index.d.ts diff --git a/tools/public_api_guard/core/typings/testing/testing.d.ts b/tools/public_api_guard/core/typings/testing/index.d.ts similarity index 100% rename from tools/public_api_guard/core/typings/testing/testing.d.ts rename to tools/public_api_guard/core/typings/testing/index.d.ts diff --git a/tools/public_api_guard/http/typings/testing/testing.d.ts b/tools/public_api_guard/http/typings/testing/index.d.ts similarity index 100% rename from tools/public_api_guard/http/typings/testing/testing.d.ts rename to tools/public_api_guard/http/typings/testing/index.d.ts diff --git a/tools/public_api_guard/platform-browser-dynamic/typings/testing/testing.d.ts b/tools/public_api_guard/platform-browser-dynamic/typings/testing/index.d.ts similarity index 100% rename from tools/public_api_guard/platform-browser-dynamic/typings/testing/testing.d.ts rename to tools/public_api_guard/platform-browser-dynamic/typings/testing/index.d.ts diff --git a/tools/public_api_guard/platform-browser/typings/animations/testing/testing.d.ts b/tools/public_api_guard/platform-browser/typings/animations/testing/index.d.ts similarity index 100% rename from tools/public_api_guard/platform-browser/typings/animations/testing/testing.d.ts rename to tools/public_api_guard/platform-browser/typings/animations/testing/index.d.ts diff --git a/tools/public_api_guard/platform-browser/typings/testing/testing.d.ts b/tools/public_api_guard/platform-browser/typings/testing/index.d.ts similarity index 100% rename from tools/public_api_guard/platform-browser/typings/testing/testing.d.ts rename to tools/public_api_guard/platform-browser/typings/testing/index.d.ts diff --git a/tools/public_api_guard/platform-server/typings/testing/testing.d.ts b/tools/public_api_guard/platform-server/typings/testing/index.d.ts similarity index 100% rename from tools/public_api_guard/platform-server/typings/testing/testing.d.ts rename to tools/public_api_guard/platform-server/typings/testing/index.d.ts