Skip to content
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

fix: package builds respect --private option #1433

Merged

Conversation

benpryke
Copy link
Contributor

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Feb 24, 2022

🦋 Changeset detected

Latest commit: e38289a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
modular-scripts Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coveralls
Copy link
Collaborator

coveralls commented Feb 24, 2022

Coverage Status

Coverage decreased (-28.1%) to 0.0% when pulling e38289a on benpryke:feature/fix-package-private-build into f423c00 on jpmorganchase:main.

@LukeSheard
Copy link
Contributor

Created a changeset, will merge once checks have completed again.

@LukeSheard
Copy link
Contributor

@benpryke Although, just seen there's no test to cover this case. Can we add one?

Copy link
Contributor

@cristiano-belloni cristiano-belloni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (and I agree with #1433 (comment))

@benpryke
Copy link
Contributor Author

benpryke commented Mar 1, 2022

I tried running the test suite locally with no changes, and a large number of tests fail. I think about 10 suites and 55 individual tests failed altogether. Specifically, the test suite that I wanted to add to, build.test.ts fails completely. I tried clean install of node_modules just to confirm I didn't have a dirty state and had the same experience.

Is some additional setup required? I couldn't see any docs to suggest that. If this is actually broken right now, I'd rather not fix the world for a one-line patch, but I don't disagree that there's a gap for a couple of cross-package build tests.

@cristiano-belloni
Copy link
Contributor

cristiano-belloni commented Mar 1, 2022

Is some additional setup required? I couldn't see any docs to suggest that. If this is actually broken right now, I'd rather not fix the world for a one-line patch, but I don't disagree that there's a gap for a couple of cross-package build tests.

Hi Ben, unfortunately my laptop is out of order atm and I'm waiting for it to be fixed so I can't try, but for me no additional step was required to run the tests, apart from the usual yarn and yarn build at the root level. Github Actions run the whole test suite on each PR commit and merging is disallowed if the tests are not passing, so it's unlikely that they are broken (although there might be a bug that's triggered only in your system).

Could you try to tun them with CI=true? Could you also take a look at what is breaking exactly? I know, for example, that tests will fail if the repository has an uncommitted change, because of the way we wrap "atomic" commands executed on our test packages. It has bitten me more than once (for example) when running yarn results in a modification of yarn.lock.

@LukeSheard
Copy link
Contributor

@benpryke make sure you're running yarn test - I've raised a PR to clarify reasoning for this.

if (
includePrivate ||
packageJsons[importedPackage].private !== true
) {
localImports[importedPackage] = packageJsons[importedPackage]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe let's add a console warning here if we are in the case where we includePrivate and also hit this branch?

Copy link
Contributor Author

@benpryke benpryke Mar 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's perfectly reasonable to break projects down into multiple packages that it wouldn't make sense to publish on their own, so I don't think a warning is warranted every time someone builds a project that relies on unpublished packages in this way. Maybe you're thinking about this in a different way?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The use case of building a package for publishing implies that all the dependencies are being published and maybe worth considering if a packages should be public or not. I wouldn’t expect anyone to be using the private flag for building on packages which aren’t being published.

Given that private package building is opt in I would put a warning to show that the package being built is depending on other pieces which would need to be build opt in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a distinction between publishing the source and building a distribution. The private field is simply a way of specifying that a package should not be published standalone and implies nothing about the build process or how it's otherwise used.

I presume users will most commonly add the private flag after encountering a build failure where they used private package dependencies in their project.

Given the above, it still strikes me as odd to repeatedly display a warning for something the user has opted into.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest we merge as-is and split out a new feature of debug logging that would be useful for notice kind of messages like this.

@LukeSheard
Copy link
Contributor

LGTM apart from my one comment.

@benpryke benpryke merged commit 7489071 into jpmorganchase:main Mar 22, 2022
@github-actions github-actions bot mentioned this pull request Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants