-
Notifications
You must be signed in to change notification settings - Fork 83
chore: Fix package build scripts for git-deps and npm-link symlinks #746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
`prepublishOnly` is an old lifecycle hook created to aid in the transition from prepublish to prepare. Documentation: https://docs.npmjs.com/misc/scripts#prepublish-and-prepare TL;DR: prepare runs before packing and on bare npm-installs. That is, in order for a package to do building/compiling when it is installed as a git-dep (where prepublish _does not run_), one must use `prepare`. This also applies for when a package is symlinked using npm-link. In order to ensure the package is built and can be consumed by the linked dependant, the build must occur via `prepare`. It's also worth noting that `prepare` runs _before_ `prepublish`; so the build step is guaranteed to be complete prior to the prepublish script; for, say, running tests.
The top-level package defined clean and build scripts that were expected to run the (surprise!) clean and build steps of each package. However, most packages named their build step 'tsc' instead of 'build', and virtually none of them had 'clean' as a separate step.
It's frequently necessary to run npm-pack when validating the package tarball is created correctly. This ensures the tarballs are themselves ignored from git. (Keeping user-specific ignores, but those shouldn't be in a repo ignore. User-specific ignores that are OS or IDE specific should be in the user's own ignore file.)
LICENSE, CHANGELOG, README and package.json files are included in tarball automatically.
* master: Leverage rollup's --config* feature for choosing bundles (#477)
# Conflicts: # packages/datafile-manager/package.json # packages/optimizely-sdk/package.json
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.
- Optimizely-sdk/package.json may not need some default files in configuration, such as README and package.json
Otherwise LGTM!
opti-jnguyen
approved these changes
Mar 16, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
This PR is copied from #481. It was contributed by @jasonkarns a couple of years ago. I just pulled his changes, merged master and resolved conflicts.
Summary
Main change:
prepublishOnly
is the wrong lifecycle script for building/compiling. prepublishOnly does not run during install for git-deps; nor does it run when a package is being symlinked via npm-link. The correct script isprepare
.This PR:
build
so as to be run properly by the top levellerna run build
script.clean
is defined and exposed such thatlerna run clean
works properlybuild
is invoked duringprepare
lifecycle hook (packing, publishing, git-installing, npm-linking)npm test
being run duringprepublishOnly
package.json#files
array (license, changelog, readme, and package.json files are included automatically)Test plan
No code changes