diff --git a/build.sh b/build.sh index eabc9a431c..148c22b5f0 100755 --- a/build.sh +++ b/build.sh @@ -253,10 +253,14 @@ do ( cd ${SRCDIR} echo "====== Rollup ${PACKAGE} index" - ../../../node_modules/.bin/rollup -i ${DEST_MODULE}/index.js -o ${JS_PATH} - cat ${LICENSE_BANNER} > ${JS_PATH}.tmp - cat ${JS_PATH} >> ${JS_PATH}.tmp - mv ${JS_PATH}.tmp ${JS_PATH} + if [[ -e rollup.config.js ]]; then + ../../../node_modules/.bin/rollup -c rollup.config.js + else + ../../../node_modules/.bin/rollup -i ${DEST_MODULE}/index.js -o ${JS_PATH} + cat ${LICENSE_BANNER} > ${JS_PATH}.tmp + cat ${JS_PATH} >> ${JS_PATH}.tmp + mv ${JS_PATH}.tmp ${JS_PATH} + fi if ! [[ ${PACKAGE} == 'benchpress' ]]; then rm -f ${DEST_MODULE}/index.* @@ -277,7 +281,7 @@ do echo "====== Minifying UMD/ES5" $UGLIFYJS -c --screw-ie8 --comments -o ${UMD_ES5_MIN_PATH} ${UMD_ES5_MIN_PATH} ### END Minification ### - else + elif [[ -e rollup-umd.config.js ]]; then # 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 @@ -287,8 +291,10 @@ do fi rm -f ${DISTDIR}/.babelrc - echo "====== Downleveling ES2015 to ESM/ES5" - downlevelES2015 ${DEST_MODULE} ${JS_PATH} ${JS_PATH_ES5} + if [[ -d ${DEST_MODULE} ]]; then + echo "====== Downleveling ES2015 to ESM/ES5" + downlevelES2015 ${DEST_MODULE} ${JS_PATH} ${JS_PATH_ES5} + fi if [[ -d testing ]]; then echo "====== Rollup ${PACKAGE} testing" diff --git a/modules/@angular/compiler/tsconfig-2015.json b/modules/@angular/compiler/tsconfig-2015.json new file mode 100644 index 0000000000..d5c44ac302 --- /dev/null +++ b/modules/@angular/compiler/tsconfig-2015.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig-build", + "compilerOptions": { + "module": "es2015", + "moduleResolution": "node", + "outDir": "../../../dist/esm/compiler" + } +} diff --git a/modules/@angular/core/tsconfig-2015.json b/modules/@angular/core/tsconfig-2015.json new file mode 100644 index 0000000000..8df66c0e98 --- /dev/null +++ b/modules/@angular/core/tsconfig-2015.json @@ -0,0 +1,13 @@ +{ + "extends": "./tsconfig-build", + "compilerOptions": { + "module": "es2015", + "moduleResolution": "node", + "outDir": "../../../dist/esm/core" + }, + "files": [ + "index.ts", + "../../../node_modules/zone.js/dist/zone.js.d.ts", + "../../system.d.ts" + ] +} diff --git a/modules/@angular/language-service/.babelrc b/modules/@angular/language-service/.babelrc deleted file mode 100644 index 3ffb3baf4a..0000000000 --- a/modules/@angular/language-service/.babelrc +++ /dev/null @@ -1,14 +0,0 @@ - -{ - "presets": ["es2015"], - "plugins": [["transform-es2015-modules-umd", { - "globals": { - "@angular/language-service": "ng.language_service", - "typescript": "ts", - "path": "path", - "fs": "fs" - }, - "exactGlobals": true - }]], - "moduleId": "@angular/language-service" -} diff --git a/modules/@angular/language-service/package.json b/modules/@angular/language-service/package.json index 1ee930f2db..423de65b92 100644 --- a/modules/@angular/language-service/package.json +++ b/modules/@angular/language-service/package.json @@ -2,10 +2,9 @@ "name": "@angular/language-service", "version": "0.0.0-PLACEHOLDER", "description": "Angular - language services", - "main": "./bundles/language-service.umd.js", - "module": "./@angular/language-service.es5.js", - "es2015": "./@angular/language-service.js", - "typings": "./typings/language-service.d.ts", + "main": "bundles/language-service.umd.js", + "module": "index.js", + "typings": "index.d.ts", "author": "angular", "license": "MIT", "repository": { diff --git a/modules/@angular/language-service/rollup.config.js b/modules/@angular/language-service/rollup.config.js new file mode 100644 index 0000000000..e0dd6213d7 --- /dev/null +++ b/modules/@angular/language-service/rollup.config.js @@ -0,0 +1,84 @@ +/** + * @license + * Copyright Google Inc. All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.io/license + */ + +import commonjs from 'rollup-plugin-commonjs'; +import * as path from 'path'; + +var m = /^\@angular\/((\w|\-)+)(\/(\w|\d|\/|\-)+)?$/; +var location = normalize('../../../dist/packages-dist') + '/'; +var rxjsLocation = normalize('../../../node_modules/rxjs'); +var esm = 'esm/'; + +var locations = { + 'tsc-wrapped': normalize('../../../dist/tools/@angular') + '/', + 'compiler-cli': normalize('../../../dist/esm') + '/', + 'compiler': normalize('../../../dist/esm') + '/', + 'core': normalize('../../../dist/esm') + '/' +}; + +var esm_suffixes = {}; + +function normalize(fileName) { + return path.resolve(__dirname, fileName); +} + +function resolve(id, from) { + // console.log('Resolve id:', id, 'from', from) + if (id == '@angular/tsc-wrapped') { + // Hack to restrict the import to not include the index of @angular/tsc-wrapped so we don't + // rollup tsickle. + return locations['tsc-wrapped'] + 'tsc-wrapped/src/collector.js'; + } + var match = m.exec(id); + if (match) { + var packageName = match[1]; + var esm_suffix = esm_suffixes[packageName] || ''; + var loc = locations[packageName] || location; + var r = loc + esm_suffix + packageName + (match[3] || '/index') + '.js'; + // console.log('** ANGULAR MAPPED **: ', r); + return r; + } + if (id && id.startsWith('rxjs/')) { + const resolved = `${rxjsLocation}${id.replace('rxjs', '')}.js`; + return resolved; + } +} + +var banner = ` +var $deferred, $resolved, $provided; +function $getModule(name) { return $provided[name] || require(name); } +function define(modules, cb) { $deferred = { modules: modules, cb: cb }; } +module.exports = function(provided) { + if ($resolved) return $resolved; + var result = {}; + $provided = Object.assign({}, provided || {}, { exports: result }); + $deferred.cb.apply(this, $deferred.modules.map($getModule)); + $resolved = result; + return result; +} +`; + +export default { + entry: '../../../dist/packages-dist/language-service/index.js', + dest: '../../../dist/packages-dist/language-service/bundles/language-service.umd.js', + format: 'amd', + moduleName: 'ng.language_service', + exports: 'named', + external: [ + 'fs', + 'path', + 'typescript', + ], + globals: { + 'typescript': 'ts', + 'path': 'path', + 'fs': 'fs', + }, + banner: banner, + plugins: [{resolveId: resolve}, commonjs()] +} diff --git a/modules/@angular/language-service/tsconfig-build.json b/modules/@angular/language-service/tsconfig-build.json index 25a3bdc89e..1b5d2d5d15 100644 --- a/modules/@angular/language-service/tsconfig-build.json +++ b/modules/@angular/language-service/tsconfig-build.json @@ -25,7 +25,7 @@ "rootDir": ".", "sourceMap": true, "inlineSources": true, - "target": "es2015", + "target": "es5", "skipLibCheck": true, "lib": ["es2015", "dom"] },