build(language-service): support deep import bundling of language services (#14689)
This commit is contained in:
parent
41da5998cd
commit
2da3844673
20
build.sh
20
build.sh
@ -253,10 +253,14 @@ do
|
|||||||
(
|
(
|
||||||
cd ${SRCDIR}
|
cd ${SRCDIR}
|
||||||
echo "====== Rollup ${PACKAGE} index"
|
echo "====== Rollup ${PACKAGE} index"
|
||||||
../../../node_modules/.bin/rollup -i ${DEST_MODULE}/index.js -o ${JS_PATH}
|
if [[ -e rollup.config.js ]]; then
|
||||||
cat ${LICENSE_BANNER} > ${JS_PATH}.tmp
|
../../../node_modules/.bin/rollup -c rollup.config.js
|
||||||
cat ${JS_PATH} >> ${JS_PATH}.tmp
|
else
|
||||||
mv ${JS_PATH}.tmp ${JS_PATH}
|
../../../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
|
if ! [[ ${PACKAGE} == 'benchpress' ]]; then
|
||||||
rm -f ${DEST_MODULE}/index.*
|
rm -f ${DEST_MODULE}/index.*
|
||||||
@ -277,7 +281,7 @@ do
|
|||||||
echo "====== Minifying UMD/ES5"
|
echo "====== Minifying UMD/ES5"
|
||||||
$UGLIFYJS -c --screw-ie8 --comments -o ${UMD_ES5_MIN_PATH} ${UMD_ES5_MIN_PATH}
|
$UGLIFYJS -c --screw-ie8 --comments -o ${UMD_ES5_MIN_PATH} ${UMD_ES5_MIN_PATH}
|
||||||
### END Minification ###
|
### END Minification ###
|
||||||
else
|
elif [[ -e rollup-umd.config.js ]]; then
|
||||||
# For packages not running through babel, use the UMD/ES5 config
|
# For packages not running through babel, use the UMD/ES5 config
|
||||||
echo "====== Rollup ${PACKAGE} index to UMD/ES5"
|
echo "====== Rollup ${PACKAGE} index to UMD/ES5"
|
||||||
../../../node_modules/.bin/rollup -c rollup-umd.config.js
|
../../../node_modules/.bin/rollup -c rollup-umd.config.js
|
||||||
@ -287,8 +291,10 @@ do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f ${DISTDIR}/.babelrc
|
rm -f ${DISTDIR}/.babelrc
|
||||||
echo "====== Downleveling ES2015 to ESM/ES5"
|
if [[ -d ${DEST_MODULE} ]]; then
|
||||||
downlevelES2015 ${DEST_MODULE} ${JS_PATH} ${JS_PATH_ES5}
|
echo "====== Downleveling ES2015 to ESM/ES5"
|
||||||
|
downlevelES2015 ${DEST_MODULE} ${JS_PATH} ${JS_PATH_ES5}
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -d testing ]]; then
|
if [[ -d testing ]]; then
|
||||||
echo "====== Rollup ${PACKAGE} testing"
|
echo "====== Rollup ${PACKAGE} testing"
|
||||||
|
8
modules/@angular/compiler/tsconfig-2015.json
Normal file
8
modules/@angular/compiler/tsconfig-2015.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"extends": "./tsconfig-build",
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "es2015",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"outDir": "../../../dist/esm/compiler"
|
||||||
|
}
|
||||||
|
}
|
13
modules/@angular/core/tsconfig-2015.json
Normal file
13
modules/@angular/core/tsconfig-2015.json
Normal file
@ -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"
|
||||||
|
]
|
||||||
|
}
|
@ -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"
|
|
||||||
}
|
|
@ -2,10 +2,9 @@
|
|||||||
"name": "@angular/language-service",
|
"name": "@angular/language-service",
|
||||||
"version": "0.0.0-PLACEHOLDER",
|
"version": "0.0.0-PLACEHOLDER",
|
||||||
"description": "Angular - language services",
|
"description": "Angular - language services",
|
||||||
"main": "./bundles/language-service.umd.js",
|
"main": "bundles/language-service.umd.js",
|
||||||
"module": "./@angular/language-service.es5.js",
|
"module": "index.js",
|
||||||
"es2015": "./@angular/language-service.js",
|
"typings": "index.d.ts",
|
||||||
"typings": "./typings/language-service.d.ts",
|
|
||||||
"author": "angular",
|
"author": "angular",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
84
modules/@angular/language-service/rollup.config.js
Normal file
84
modules/@angular/language-service/rollup.config.js
Normal file
@ -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()]
|
||||||
|
}
|
@ -25,7 +25,7 @@
|
|||||||
"rootDir": ".",
|
"rootDir": ".",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"inlineSources": true,
|
"inlineSources": true,
|
||||||
"target": "es2015",
|
"target": "es5",
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"lib": ["es2015", "dom"]
|
"lib": ["es2015", "dom"]
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user