22# Runs "npm package" in all modules. This will produce a "dist/" directory in each module.
33# Then, calls pack-collect.sh to merge all outputs into a root ./pack directory, which is
44# later read by bundle-beta.sh.
5- set -e
5+ set -eu
66export PATH=$PWD /node_modules/.bin:$PATH
77export NODE_OPTIONS=" --max-old-space-size=4096 ${NODE_OPTIONS:- } "
88root=$PWD
@@ -11,15 +11,33 @@ distdir="$PWD/dist"
1111rm -fr ${distdir}
1212mkdir -p ${distdir}
1313
14- scopes=$( lerna ls 2> /dev/null | grep -v " (private)" | cut -d" " -f1 | xargs -n1 -I{} echo " --scope {}" | tr " \n" " " )
14+ # Split out jsii and non-jsii packages. Jsii packages will be built all at once.
15+ # Non-jsii packages will be run individually.
16+ echo " Collecting package list..." >&2
17+ scripts/list-packages $TMPDIR /jsii.txt $TMPDIR /nonjsii.txt
1518
16- # Run the "cdk-package" script in all modules. For jsii modules, this invokes jsii-pacmak which generates and builds multi-language
17- # outputs. For non-jsii module, it will just run "npm pack" and place the output in dist/npm
18- # (which is similar to how pacmak outputs it).
19- lerna run ${scopes} --sort --concurrency=1 --stream package
19+ # Return lerna scopes from a package list
20+ function lerna_scopes() {
21+ while [[ " ${1:- } " != " " ]]; do
22+ echo " --scope $1 "
23+ shift
24+ done
25+ }
26+
27+ echo " Packaging jsii modules" >&2
28+
29+ # Jsii packaging (all at once using jsii-pacmak)
30+ jsii-pacmak \
31+ --verbose \
32+ --outdir $distdir / \
33+ $( cat $TMPDIR /jsii.txt)
34+
35+ # Non-jsii packaging, which means running 'package' in every individual
36+ # module and rsync'ing the result to the shared dist directory.
37+ echo " Packaging non-jsii modules" >&2
38+ lerna run $( lerna_scopes $( cat $TMPDIR /nonjsii.txt) ) --sort --concurrency=1 --stream package
2039
21- # Collect dist/ from all modules into the root dist/
22- for dir in $( find packages -name dist | grep -v node_modules) ; do
40+ for dir in $( find packages -name dist | grep -v node_modules | grep -v run-wrappers) ; do
2341 echo " Merging ${dir} into ${distdir} "
2442 rsync -av $dir / ${distdir} /
2543done
0 commit comments