diff --git a/packages/compartment-mapper/src/node-modules.js b/packages/compartment-mapper/src/node-modules.js index 1c5cff649b..056070f12a 100644 --- a/packages/compartment-mapper/src/node-modules.js +++ b/packages/compartment-mapper/src/node-modules.js @@ -566,7 +566,7 @@ const graphPackages = async ( * @param {Graph} graph * @param {Set} tags - build tags about the target environment * for selecting relevant exports, e.g., "browser" or "node". - * @param {object} policy + * @param {object|undefined} policy * @returns {CompartmentMapDescriptor} */ const translateGraph = ( diff --git a/packages/compartment-mapper/src/policy-format.js b/packages/compartment-mapper/src/policy-format.js index 8484b4b6f8..a439f89045 100644 --- a/packages/compartment-mapper/src/policy-format.js +++ b/packages/compartment-mapper/src/policy-format.js @@ -122,7 +122,7 @@ export const assertPackagePolicy = (allegedPackagePolicy, path, url) => { const packagePolicy = Object(allegedPackagePolicy); assert( allegedPackagePolicy === packagePolicy && !isArray(allegedPackagePolicy), - `${path} must be an object, got ${allegedPackagePolicy}${inUrl}`, + `${path} must be an object, got ${q(allegedPackagePolicy)}${inUrl}`, ); const { packages, diff --git a/packages/compartment-mapper/src/policy.js b/packages/compartment-mapper/src/policy.js index ac2502b97c..79d7ef1eb2 100644 --- a/packages/compartment-mapper/src/policy.js +++ b/packages/compartment-mapper/src/policy.js @@ -17,7 +17,7 @@ import { isAllowingEverything, } from './policy-format.js'; -const { entries, values, assign, keys, freeze } = Object; +const { create, entries, values, assign, keys, freeze } = Object; const q = JSON.stringify; /** @@ -138,7 +138,7 @@ export const getPolicyForPackage = (namingKit, policy) => { return policy.resources[canonicalName]; } else { // Allow skipping policy entries for packages with no powers. - return {}; + return create(null); } };