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}
|
||||
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"
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"extends": "./tsconfig-build",
|
||||
"compilerOptions": {
|
||||
"module": "es2015",
|
||||
"moduleResolution": "node",
|
||||
"outDir": "../../../dist/esm/compiler"
|
||||
}
|
||||
}
|
|
@ -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",
|
||||
"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": {
|
||||
|
|
|
@ -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": ".",
|
||||
"sourceMap": true,
|
||||
"inlineSources": true,
|
||||
"target": "es2015",
|
||||
"target": "es5",
|
||||
"skipLibCheck": true,
|
||||
"lib": ["es2015", "dom"]
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue