-
-
Notifications
You must be signed in to change notification settings - Fork 948
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
Conversation
@@ -44,6 +47,10 @@ export function getOptionsFromRootManifest (manifest: ProjectManifest): { | |||
// @ts-expect-error | |||
settings['onlyBuiltDependencies'] = onlyBuiltDependencies | |||
} | |||
if (onlyBuiltDependenciesFile) { | |||
// @ts-expect-error |
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.
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) |
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.
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 }), |
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.
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
?
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.
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
* feat: specifying allowed build list via a json file * bump ref pnpm/pnpm#7167
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.
Thanks for the updates!
close #7137
TODO: