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

feat: onlyBuiltDependenciesFile #7167

Merged
merged 12 commits into from
Oct 7, 2023
Merged

feat: onlyBuiltDependenciesFile #7167

merged 12 commits into from
Oct 7, 2023

Conversation

zkochan
Copy link
Member

@zkochan zkochan commented Oct 6, 2023

close #7137

TODO:

  • update plugin-commands-rebuild

@zkochan zkochan marked this pull request as ready for review October 6, 2023 23:48
@zkochan zkochan requested a review from a team October 6, 2023 23:48
@@ -44,6 +47,10 @@ export function getOptionsFromRootManifest (manifest: ProjectManifest): {
// @ts-expect-error
settings['onlyBuiltDependencies'] = onlyBuiltDependencies
}
if (onlyBuiltDependenciesFile) {
// @ts-expect-error
Copy link
Member

@gluxon gluxon Oct 7, 2023

Choose a reason for hiding this comment

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

nitpick: Extracting the interface returned from getOptionsFromRootManifest would be a bit more TypeScript idiomatic. It also allows the // @ts-expect-error to be removed, which can unexpectedly hide other compile errors unrelated to indexing that happen in the future.

export interface OptionsFromRootManifest {
  allowedDeprecatedVersions?: AllowedDeprecatedVersions
  allowNonAppliedPatches?: boolean
  overrides?: Record<string, string>
  neverBuiltDependencies?: string[]
  onlyBuiltDependencies?: string[]
  onlyBuiltDependenciesFile?: string
  packageExtensions?: Record<string, PackageExtension>
  patchedDependencies?: Record<string, string>
  peerDependencyRules?: PeerDependencyRules
}

export function getOptionsFromRootManifest (
  manifestDir: string,
  manifest: ProjectManifest
): OptionsFromRootManifest { /* ... */ }

And then further down:

const settings: OptionsFromRootManifest = {
  allowedDeprecatedVersions,
  allowNonAppliedPatches,
  overrides,
  neverBuiltDependencies,
  packageExtensions,
  peerDependencyRules,
  patchedDependencies,
}
if (onlyBuiltDependencies) {
  settings['onlyBuiltDependencies'] = onlyBuiltDependencies
}
if (onlyBuiltDependenciesFile) {
  settings['onlyBuiltDependenciesFile'] = path.join(manifestDir, onlyBuiltDependenciesFile)
}

@@ -53,6 +54,7 @@ export async function buildModules (
warn,
}
const chunks = buildSequence(depGraph, rootDepPaths)
const allowBuild = opts.allowBuild ?? (() => true)
Copy link
Member

Choose a reason for hiding this comment

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

Nice. I like the abstraction of allowBuild to avoid propagating the concept of onlyBuiltDependenciesFile down to this lower level component.

@@ -1004,7 +1004,8 @@ const _installInContext: InstallFunction = async (projects, ctx, opts) => {
} = await resolveDependencies(
projects,
{
allowBuild: createAllowBuildFunction(opts),
// In the next major allow build should be just () => true here always
allowBuild: opts.onlyBuiltDependenciesFile ? () => true : createAllowBuildFunction({ onlyBuiltDependencies: opts.onlyBuiltDependencies, neverBuiltDependencies: opts.neverBuiltDependencies }),
Copy link
Member

Choose a reason for hiding this comment

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

I might be missing something. If opts.onlyBuiltDependenciesFile is non-null, we'll want to call createAllowBuildFunction, is that right? It currently evaluates to () => true instead.

Or is this intentional and the usage of opts.onlyBuiltDependenciesFile opts into the default behavior in the next major version, which would be to always return () => true?

Copy link
Member Author

Choose a reason for hiding this comment

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

Or is this intentional and the usage of opts.onlyBuiltDependenciesFile opts into the default behavior in the next major version, which would be to always return () => true?

yes, correct

zkochan added a commit to pnpm/components that referenced this pull request Oct 7, 2023
* feat: specifying allowed build list via a json file

* bump

ref pnpm/pnpm#7167
Copy link
Member

@gluxon gluxon left a comment

Choose a reason for hiding this comment

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

Thanks for the updates!

@zkochan zkochan merged commit d774a31 into main Oct 7, 2023
12 of 14 checks passed
@zkochan zkochan deleted the feat/7137 branch October 7, 2023 22:50
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.

Support providing onlyBuiltDependencies list in a separate JSON file
2 participants