Skip to content

Commit

Permalink
chore(): upgrade from ng-packager v2.0.0 to v2.4.1 (#1137)
Browse files Browse the repository at this point in the history
* chore(): upgrade from ng-packager v2.0.0 to v2.4.1

* refactor(): echo message change

* fix(): test travis script changes

* fix(): test mod travis-script

* fix(): test mod travis-script

* fix(): test mod travis-script

* fix(): test mod travis-script

* fix(): test mod travis-script

* fix(): test mod travis-script

* fix(): test mod travis-script

* fix(): test mod travis-script

* fix(): test mod travis-script

* fix(): upgrade ng-packagr to v2.4.2 to resolve npm installation bug ng-packagr/ng-packagr#754
  • Loading branch information
stevenov7 authored and emoralesb05 committed Apr 12, 2018
1 parent 2a7e5e7 commit 6d2d741
Show file tree
Hide file tree
Showing 4 changed files with 338 additions and 100 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"karma-jasmine": "^1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-phantomjs-launcher": "1.0.1",
"ng-packagr": "2.0.0",
"ng-packagr": "2.4.2",
"node-sass": "3.8.0",
"pa11y": "^5.0.0-beta.5",
"protractor": "~5.1.0",
Expand Down
75 changes: 6 additions & 69 deletions scripts/build-release
Original file line number Diff line number Diff line change
@@ -1,83 +1,19 @@
#!/usr/bin/env bash
set -e

###################
# START: BUILD @covalent/core primary and secondary entrypoints
###################

# HACK START - common
# (Remove in future): used to resolve ng-packagr current lack of support for Intra-package dependencies between entry points && ability to override tsconfig:
# this hack builds common using ng-packagr to generate @covalent/core/common and puts it into the projects root 'node_modules'
# https://github.com/dherges/ng-packagr/issues/379 && https://github.com/dherges/ng-packagr/issues/256
# Reason for hack: we need these missing features because we use '/common' between multiple entry points both primary and secondary
# and ng-packagr currently doesn't support it. So for now we are going to create/build the package that contains
# @covalent/core/common just by itself, we will then copy the generated './deploy/platform' that was generated into
# our projects root './node_modules' and then in the respective modules/components under /core we will replaces '../common/*'
# with '@covalent/core/common'. Now when we run ng-packagr on the whole /core suit when it see's '@covalent/core/common' it will
# take it from our root's './node_modules' instead of trying to find its intra-package dependency '../common' like before (which is
# not there because of ng-packagr build alogrithm changing the filepath). So this hack resolve
# the issue for ng-packagr but it bring up an issue when trying to serve the app with 'npm run serve'
# we also had to add inside the roots tsconfig.json a new path for the core's secondary entrypoints '"@covalent/core/*": ["./platform/core/*"],'
# because we are not using a relative path anymore '../common'.

# clean up first if building again
rm -rf ./node_modules/@covalent/core
rm -rf ./src/platform/node_modules
rm -rf ./deploy
rm -rf ./src/platform/.td_build_common

echo 'Creating @covalent/core/common secondary entrypoint hack'
cd ./src/platform
mkdir .td_build_common
# move files to build only '@covalent/core/common' into its own build station to not cause other secondary entry points to build
cp -r ./core/common .td_build_common/
cp ./core/ng-package.js .td_build_common/
cp ./core/index.ts .td_build_common/
cd .td_build_common

# create necessary files for building @covalent/core/common
echo '{ "name": "@covalent/core" }' > package.json
echo "export * from './common';" > public-api.ts
echo "export * from './public-api';" > index.ts

# regex replace as needed for specific build of @covalent/core/common
if [ "$(uname)" == "Darwin" ]; then
# Do under Mac OS X platform
sed -i '' 's/..\/..\/..\/deploy\/platform/.\/deploy\/platform/' ng-package.js
else
sed -i 's/..\/..\/..\/deploy\/platform/.\/deploy\/platform/' ng-package.js
fi

../../../node_modules/.bin/ng-packagr -p ng-package.js

# move completed build over to root node_modules as @covalent/core/*
cp -r ./deploy/platform/core ../../../node_modules/@covalent/

# kill build station don't need it anymore
rm -rf ../.td_build_common
cd ../../..
echo 'Completed @covalent/core/common secondary entrypoint hack'
# HACK END - common

# Steps to package '@covalent/core' and it's children '@covalent/core/*'
echo 'Creating @covalent/core @covalent/core/* build'
# BUILD: @covalent/core primary entrypoint
./node_modules/.bin/ng-packagr -p src/platform/core/ng-package.js
# move over additional required files manually that ng-packagr doesn't do automatically
echo 'Compiling and moving moving some requried files not handled by ng-packagr files'

echo 'Compiling and moving moving some requried files not handled by ng-packagr'
gulp move-required-core-files
gulp compile-core-sass
echo 'Completed compiling and moving moving some requried files not handled by ng-packagr files'

# HACK (Remove in future): remove remnants of @covalent/core/common see script/ng-packagr-common for details
rm -rf ./node_modules/@covalent/core
echo 'Completed @covalent/core @covalent/core/* build'
echo 'Completed compiling and moving moving some requried files not handled by ng-packagr'

###################
# END: BUILD @covalent/core primary and secondary entrypoints
###################


# HACK (Remove in future): used to resolve ng-packagr current lack of support for Intra-package dependencies between entry points && ability to override tsconfig:
# HACK (Remove in future): used to resolve ng-packagr current lack of support for Intra-package dependencies between primary entry points
# HACK START
mkdir -p src/platform/node_modules/@covalent
cp -r deploy/platform/core src/platform/node_modules/@covalent
Expand All @@ -94,5 +30,6 @@ cp -r deploy/platform/core src/platform/node_modules/@covalent

# HACK (Remove in future): remove remnants of platform/node_modules was used for building purposes
rm -rf src/platform/node_modules

# Need to move required file after ng-packagr runs because ng-packagr overrides primary entrypoint folders
gulp move-additional-platform-files
3 changes: 2 additions & 1 deletion src/platform/ng-package-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ module.exports =
"@covalent/http": "covalent.http",
"@covalent/markdown": "covalent.markdown"
}
}
},
"whitelistedNonPeerDependencies": ["."],
};
Loading

0 comments on commit 6d2d741

Please sign in to comment.