-
Notifications
You must be signed in to change notification settings - Fork 27.4k
chore(npm): Make modules Browserify compatible #10732
Changes from 8 commits
907dae1
736f6c4
62b538c
706b0ce
156ca4c
b4a052d
5b5d50c
24dfc82
8f5bb24
e8b9b7a
1916264
b40fe18
ed8489a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -75,6 +75,37 @@ function prepare { | |
replaceJsonProp "bower.json" "angular.*" ".*" "$NEW_VERSION" | ||
replaceJsonProp "package.json" "version" ".*" "$NEW_VERSION" | ||
replaceJsonProp "package.json" "angular.*" ".*" "$NEW_VERSION" | ||
deleteJsonProp "package.json" "main" | ||
|
||
echo "-- Adding CommonJS index file" | ||
echo "require('./$repo');" > index.js | ||
echo "" >> index.js | ||
if [ $repo == "angular" ] | ||
then | ||
echo "module.exports = angular;" >> index.js | ||
else | ||
# convert to module names (angular-animate >> ngAnimate) | ||
suffix=`echo $repo | cut -c9-` | ||
first=`echo $suffix | cut -c1 | sed -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` | ||
tail=`echo $suffix | cut -c2-` | ||
|
||
if [ $repo != "angular-mocks" ] | ||
then | ||
echo "module.exports = 'ng$first$tail';" >> index.js | ||
else | ||
echo "exports.ngMock = 'ngMock';" >> index.js | ||
echo "exports.ngMockE2E = 'ngMockE2E';" >> index.js | ||
echo "exports.ngAnimateMock = 'ngAnimateMock';" >> index.js | ||
fi | ||
|
||
# add angular as a peer dependency | ||
deleteJsonProp "package.json" "peerDependencies" | ||
replaceInFile "package.json" "homepage\"\: \"http\:\/\/angularjs\.org\"$" "homepage\"\: \"http\:\/\/angularjs\.org\"," | ||
sed -i '' -e /^}/d "package.json" | ||
# have to use single line form so deleteJsonProp will work | ||
echo " \"peerDependencies\": { \"angular\": \"$NEW_VERSION\" }" >> package.json | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I highly recommend against using peerDependencies – npm/npm#5080 (comment) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, I mention their problems and uncertain future, but @caitp pointed out that since these would be locked to a specific version we shouldn't have any issues. I'm happy to remove it, but that means devs will need to explicitly install angular itself, along with the other modules they need. (Which seems fine, just pointing out.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. well, no, I wrote a comment originally but removed it because of issues with npm that kind of get in the way of it =) Basically, you need all the angular modules to be for the same version --- buuuuut, because npm does its own thing, every module can have its own versions of the same dependencies... so it doesn't really solve anything :( peer deps don't really help either =\ it's just one of those things ._. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Using That being said, say the word and I will delete that line. :) |
||
echo '}' >> package.json | ||
fi | ||
|
||
git add -A | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure to comment these lines clearly to indicate that you're transforming the repo name into a module name, alright?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, good idea.