Skip to content
Merged
Changes from 1 commit
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
31 changes: 29 additions & 2 deletions app/client/src/workers/Evaluation/handlers/jsLibrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,37 @@ export async function installLibrary(
// Find keys add that were installed to the global scope.
const keysAfterInstallation = Object.keys(self);

accessors.push(
...difference(keysAfterInstallation, envKeysBeforeInstallation),
const differentiatingKeys = difference(
keysAfterInstallation,
envKeysBeforeInstallation,
);

if (differentiatingKeys[differentiatingKeys.length - 1] === "default") {
Comment thread
AmanAgarwal041 marked this conversation as resolved.
Outdated
// Changing default export to library specific name
const uniqueName = generateUniqueAccessor(
url,
takenAccessors,
takenNamesMap,
);

// mapping default functionality to library name accessor
self[uniqueName] = self["default"];
// removing default from differentiating keys
differentiatingKeys.pop();
// deleting the reference of default key from the self object
delete self["default"];
Comment thread
AmanAgarwal041 marked this conversation as resolved.
// mapping all the references of differentiating keys from the self object to the self[uniqueName] key object
differentiatingKeys.map((key) => {
self[uniqueName][key] = self[key];
// deleting the references from the self object
delete self[key];
Comment thread
AmanAgarwal041 marked this conversation as resolved.
Outdated
});
Comment thread
rishabhrathod01 marked this conversation as resolved.
// pushing the uniqueName to the accessor array
accessors.push(uniqueName);
} else {
accessors.push(...differentiatingKeys);
}

/**
* Check the list of installed library to see if their values have changed.
* This is to check if the newly installed library overwrites an already existing one
Expand Down