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(compartment-mapper): Dev implied by development condition only for entry package #2641

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions packages/compartment-mapper/src/node-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ const graphPackage = async (
for (const name of Object.keys(optionalDependencies)) {
optionals.add(name);
}
if (dev !== undefined && dev !== null ? dev : conditions.has('development')) {
if (dev) {
assign(allDependencies, devDependencies);
}

Expand Down Expand Up @@ -849,7 +849,7 @@ const makeLanguageOptions = ({
/**
* @param {ReadFn | ReadPowers | MaybeReadPowers} readPowers
* @param {string} packageLocation
* @param {Set<string>} conditions
* @param {Set<string>} conditionsOption
* @param {object} packageDescriptor
* @param {string} moduleSpecifier
* @param {CompartmentMapForNodeModulesOptions} [options]
Expand All @@ -858,22 +858,29 @@ const makeLanguageOptions = ({
export const compartmentMapForNodeModules = async (
readPowers,
packageLocation,
conditions,
conditionsOption,
packageDescriptor,
moduleSpecifier,
options = {},
) => {
const { dev = undefined, commonDependencies = {}, policy } = options;
const { dev = false, commonDependencies = {}, policy } = options;
const { maybeRead, canonical } = unpackReadPowers(readPowers);
const languageOptions = makeLanguageOptions(options);

const conditions = new Set(conditionsOption || []);

// dev is only set for the entry package, and implied by the development
// condition.
// The dev option is deprecated in favor of using conditions, since that
// covers more intentional behaviors of the development mode.

const graph = await graphPackages(
maybeRead,
canonical,
packageLocation,
conditions,
packageDescriptor,
dev,
dev || (conditions && conditions.has('development')),
Copy link
Contributor

@boneskull boneskull Nov 21, 2024

Choose a reason for hiding this comment

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

conditions is never falsy

commonDependencies,
languageOptions,
);
Expand Down
Loading