Skip to content

Commit

Permalink
fix(compartment-mapper): Turn empty policy into a null-prototype object
Browse files Browse the repository at this point in the history
  • Loading branch information
naugtur committed Dec 12, 2023
1 parent d19afd2 commit db2545b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/compartment-mapper/src/node-modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ const graphPackages = async (
* @param {Graph} graph
* @param {Set<string>} 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 = (
Expand Down
2 changes: 1 addition & 1 deletion packages/compartment-mapper/src/policy-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions packages/compartment-mapper/src/policy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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);
}
};

Expand Down

0 comments on commit db2545b

Please sign in to comment.