Skip to content

Commit 15e8d50

Browse files
jasonadenIgorMinar
authored andcommitted
build: roll up to named .js files rather than 'index.js' (angular#19190)
PR Close angular#19190
1 parent 6665d76 commit 15e8d50

File tree

95 files changed

+226
-190
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+226
-190
lines changed

build.sh

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -113,28 +113,34 @@ containsElement () {
113113
# Arguments:
114114
# param1 - Base source folder
115115
# param2 - Destination directory
116+
# param3 - Package name
117+
# param4 - Is sub directory
116118
# Returns:
117119
# None
118120
#######################################
119121
rollupIndex() {
120122
# Iterate over the files in this directory, rolling up each into ${2} directory
121-
local regex=".+/(.+)/index.js"
122-
in_file="${1}/index.js"
123-
out_file="${2}/index.js"
123+
in_file="${1}/${3}.js"
124+
if [ ${4:-} ]; then
125+
out_file="$(dropLast ${2})/${3}.js"
126+
else
127+
out_file="${2}/${3}.js"
128+
fi
124129

125130
BANNER_TEXT=`cat ${LICENSE_BANNER}`
126-
127131
if [[ -f ${in_file} ]]; then
128-
echo "=========== $ROLLUP -i ${in_file} -o ${out_file} -c ${ROOT_DIR}/rollup.config.js --sourcemap"
132+
echo "=========== $ROLLUP -i ${in_file} -o ${out_file} --sourcemap -f es --banner BANNER_TEXT >/dev/null 2>&1"
129133
$ROLLUP -i ${in_file} -o ${out_file} --sourcemap -f es --banner "$BANNER_TEXT" >/dev/null 2>&1
130134
fi
131135

132136
# Recurse for sub directories
133137
for DIR in ${1}/* ; do
138+
local sub_package=$(basename "${DIR}")
134139
isIgnoredDirectory ${DIR} && continue
135-
# NOTE: We need to re-run this regex and use the new match as Bash doesn't have closures
136-
if [[ "${DIR}/index.js" =~ $regex ]]; then
137-
rollupIndex ${DIR} ${2}/${BASH_REMATCH[1]}
140+
local regex=".+/(.+)/${sub_package}.js"
141+
if [[ "${DIR}/${sub_package}.js" =~ $regex ]]; then
142+
143+
rollupIndex ${DIR} ${2}/${BASH_REMATCH[1]} ${sub_package} true
138144
fi
139145
done
140146
}
@@ -218,8 +224,8 @@ compilePackage() {
218224
local package_name=$(basename "${2}")
219225
$NGC -p ${1}/tsconfig-build.json
220226
echo "====== Create ${1}/../${package_name}.d.ts re-export file for tsickle"
221-
echo "$(cat ${LICENSE_BANNER}) ${N} export * from './${package_name}/index'" > ${2}/../${package_name}.d.ts
222-
echo "{\"__symbolic\":\"module\",\"version\":3,\"metadata\":{},\"exports\":[{\"from\":\"./${package_name}/index\"}],\"flatModuleIndexRedirect\":true}" > ${2}/../${package_name}.metadata.json
227+
echo "$(cat ${LICENSE_BANNER}) ${N} export * from './${package_name}/${package_name}'" > ${2}/../${package_name}.d.ts
228+
echo "{\"__symbolic\":\"module\",\"version\":3,\"metadata\":{},\"exports\":[{\"from\":\"./${package_name}/${package_name}\"}],\"flatModuleIndexRedirect\":true}" > ${2}/../${package_name}.metadata.json
223229
fi
224230

225231
for DIR in ${1}/* ; do
@@ -265,10 +271,10 @@ compilePackageES5() {
265271
addNgcPackageJson() {
266272
for DIR in ${1}/* ; do
267273
[ -d "${DIR}" ] || continue
268-
# Confirm there is an index.d.ts and index.metadata.json file. If so, create
274+
# Confirm there is an ${PACKAGE}.d.ts and ${PACKAGE}.metadata.json file. If so, create
269275
# the package.json and recurse.
270-
if [[ -f ${DIR}/index.d.ts && -f ${DIR}/index.metadata.json ]]; then
271-
echo '{"typings": "index.d.ts"}' > ${DIR}/package.json
276+
if [[ -f ${DIR}/${PACKAGE}.d.ts && -f ${DIR}/${PACKAGE}.metadata.json ]]; then
277+
echo '{"typings": "${PACKAGE}.d.ts"}' > ${DIR}/package.json
272278
addNgcPackageJson ${DIR}
273279
fi
274280
done
@@ -284,6 +290,25 @@ updateVersionReferences() {
284290
)
285291
}
286292

293+
#######################################
294+
# Drops the last entry of a path. Similar to normalizing a path such as
295+
# /parent/child/.. to /parent.
296+
# Arguments:
297+
# param1 - Directory on which to drop the last item
298+
# Returns:
299+
# None
300+
#######################################
301+
302+
dropLast() {
303+
local last_item=$(basename ${1})
304+
local regex=local regex="(.+)/${last_item}"
305+
if [[ "${1}" =~ $regex ]]; then
306+
echo "${BASH_REMATCH[1]}"
307+
else
308+
echo "${1}"
309+
fi
310+
}
311+
287312
VERSION="${VERSION_PREFIX}${VERSION_SUFFIX}"
288313
echo "====== BUILDING: Version ${VERSION}"
289314

@@ -394,7 +419,7 @@ do
394419
OUT_DIR=${ROOT_OUT_DIR}/${PACKAGE}
395420
OUT_DIR_ESM5=${ROOT_OUT_DIR}/${PACKAGE}/esm5
396421
NPM_DIR=${PWD}/dist/packages-dist/${PACKAGE}
397-
ESM15_DIR=${NPM_DIR}/esm15
422+
ESM2015_DIR=${NPM_DIR}/esm2015
398423
ESM5_DIR=${NPM_DIR}/esm5
399424
BUNDLES_DIR=${NPM_DIR}/bundles
400425

@@ -418,11 +443,11 @@ do
418443
(
419444
cd ${SRC_DIR}
420445
echo "====== Rollup ${PACKAGE}"
421-
rollupIndex ${OUT_DIR} ${ESM15_DIR} ${ROOT_DIR}
446+
rollupIndex ${OUT_DIR} ${ESM2015_DIR} ${PACKAGE}
422447

423448
echo "====== Produce ESM5 version"
424449
compilePackageES5 ${SRC_DIR} ${OUT_DIR_ESM5} ${PACKAGE}
425-
rollupIndex ${OUT_DIR_ESM5} ${ESM5_DIR} ${ROOT_DIR}
450+
rollupIndex ${OUT_DIR_ESM5} ${ESM5_DIR} ${PACKAGE}
426451

427452
echo "====== Run rollup conversions on ${PACKAGE}"
428453
runRollup ${SRC_DIR}

integration/hello_world__closure/closure.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ node_modules/zone.js/dist/zone_externs.js
1515
--js node_modules/rxjs/**.js
1616

1717
--js node_modules/@angular/core/package.json
18-
--js node_modules/@angular/core/esm15/index.js
18+
--js node_modules/@angular/core/esm2015/core.js
1919
--js node_modules/@angular/core/src/testability/testability.externs.js
2020

2121
--js node_modules/@angular/common/package.json
22-
--js node_modules/@angular/common/esm15/index.js
22+
--js node_modules/@angular/common/esm2015/common.js
2323

2424
--js node_modules/@angular/platform-browser/package.json
25-
--js node_modules/@angular/platform-browser/esm15/index.js
25+
--js node_modules/@angular/platform-browser/esm2015/platform-browser.js
2626

2727
--module_resolution=node
2828
--package_json_entry_names es2015

integration/i18n/closure.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ node_modules/zone.js/dist/zone_externs.js
1818
--package_json_entry_names es2015
1919

2020
--js node_modules/@angular/core/package.json
21-
--js node_modules/@angular/core/esm15/index.js
21+
--js node_modules/@angular/core/esm2015/core.js
2222
--js node_modules/@angular/core/src/testability/testability.externs.js
2323

2424
--js node_modules/@angular/common/package.json
25-
--js node_modules/@angular/common/esm15/index.js
25+
--js node_modules/@angular/common/esm2015/common.js
2626

2727
--js node_modules/@angular/platform-browser/package.json
28-
--js node_modules/@angular/platform-browser/esm15/index.js
28+
--js node_modules/@angular/platform-browser/esm2015/platform-browser.js
2929

3030
--js built/**.js
3131
--entry_point=built/src/main
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@angular/animations/browser",
3-
"typings": "./index.d.ts",
3+
"typings": "./browser.d.ts",
44
"main": "../bundles/animations-browser.umd.js",
5-
"module": "../esm5/browser/index.js",
6-
"es2015": "../esm15/browser/index.js"
5+
"module": "../esm5/browser.js",
6+
"es2015": "../esm2015/browser.js"
77
}

packages/animations/browser/rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const globals = {
1616
};
1717

1818
export default {
19-
entry: '../../../dist/packages-dist/animations/esm5/browser/index.js',
19+
entry: '../../../dist/packages-dist/animations/esm5/browser.js',
2020
dest: '../../../dist/packages-dist/animations/bundles/animations-browser.umd.js',
2121
format: 'umd',
2222
exports: 'named',
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@angular/animations/browser/testing",
3-
"typings": "./index.d.ts",
3+
"typings": "./testing.d.ts",
44
"main": "../../bundles/platform-browser-animations-testing.umd.js",
5-
"module": "../../esm5/animations/testing/index.js",
6-
"es2015": "../../esm15/animations/testing/index.js"
5+
"module": "../../esm5/animations/testing.js",
6+
"es2015": "../../esm2015/animations/testing.js"
77
}

packages/animations/browser/testing/rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const globals = {
1717
};
1818

1919
export default {
20-
entry: '../../../../dist/packages-dist/animations/esm5/browser/testing/index.js',
20+
entry: '../../../../dist/packages-dist/animations/esm5/browser/testing.js',
2121
dest: '../../../../dist/packages-dist/animations/bundles/animations-browser-testing.umd.js',
2222
format: 'umd',
2323
exports: 'named',

packages/animations/browser/testing/tsconfig-build.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"angularCompilerOptions": {
2121
"annotateForClosureCompiler": true,
2222
"strictMetadataEmit": true,
23-
"flatModuleOutFile": "index.js",
23+
"flatModuleOutFile": "testing.js",
2424
"flatModuleId": "@angular/animations/browser/testing"
2525
}
2626
}

packages/animations/browser/tsconfig-build.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"angularCompilerOptions": {
2020
"annotateForClosureCompiler": true,
2121
"strictMetadataEmit": true,
22-
"flatModuleOutFile": "index.js",
22+
"flatModuleOutFile": "browser.js",
2323
"flatModuleId": "@angular/animations/browser"
2424
}
2525
}

packages/animations/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
"version": "0.0.0-PLACEHOLDER",
44
"description": "Angular - animations integration with web-animationss",
55
"main": "./bundles/animations.umd.js",
6-
"module": "./esm5/index.js",
7-
"es2015": "./esm15/index.js",
8-
"typings": "./index.d.ts",
6+
"module": "./esm5/animations.js",
7+
"es2015": "./esm2015/animations.js",
8+
"typings": "./animations.d.ts",
99
"author": "angular",
1010
"license": "MIT",
1111
"dependencies": {

0 commit comments

Comments
 (0)