diff --git a/app/client/src/workers/Evaluation/handlers/jsLibrary.ts b/app/client/src/workers/Evaluation/handlers/jsLibrary.ts index 7a9359c0ae..0295bb396b 100644 --- a/app/client/src/workers/Evaluation/handlers/jsLibrary.ts +++ b/app/client/src/workers/Evaluation/handlers/jsLibrary.ts @@ -4,6 +4,7 @@ import { } from "@appsmith/constants/messages"; import difference from "lodash/difference"; import type { Def } from "tern"; +import { invalidEntityIdentifiers } from "workers/common/DependencyMap/utils"; import { JSLibraries, libraryReservedIdentifiers, @@ -145,7 +146,9 @@ export function installLibrary(request: EvalWorkerSyncRequest) { //Reserve accessor names. for (const acc of accessor) { + //we have to update invalidEntityIdentifiers as well libraryReservedIdentifiers[acc] = true; + invalidEntityIdentifiers[acc] = true; } return { success: true, defs, accessor }; @@ -165,7 +168,9 @@ export function uninstallLibrary(request: EvalWorkerSyncRequest) { //@ts-expect-error ignore self[key] = undefined; } + //we have to update invalidEntityIdentifiers as well delete libraryReservedIdentifiers[key]; + delete invalidEntityIdentifiers[key]; } return { success: true }; } catch (e) { @@ -189,7 +194,9 @@ export function loadLibraries(request: EvalWorkerSyncRequest) { const keysAfter = Object.keys(self); const newKeys = difference(keysAfter, keysBefore); for (const key of newKeys) { + //we have to update invalidEntityIdentifiers as well libraryReservedIdentifiers[key] = true; + invalidEntityIdentifiers[key] = true; } JSLibraries.push(...data); return { success: !message, message }; diff --git a/app/client/src/workers/common/DependencyMap/utils.ts b/app/client/src/workers/common/DependencyMap/utils.ts index 9c1a9a5d5c..8150126909 100644 --- a/app/client/src/workers/common/DependencyMap/utils.ts +++ b/app/client/src/workers/common/DependencyMap/utils.ts @@ -56,7 +56,7 @@ export const extractInfoFromBinding = ( const { references } = extractIdentifierInfoFromCode( script, self.evaluationVersion, - { ...invalidEntityIdentifiers, ...libraryReservedIdentifiers }, + invalidEntityIdentifiers, ); return extractInfoFromReferences(references, allPaths); }; @@ -214,10 +214,11 @@ export const mergeArrays = (currentArr: T[], updateArr: T[]): T[] => { * they can refer to potentially dynamic entities. * Eg. "appsmith" */ -const invalidEntityIdentifiers: Record = { +export const invalidEntityIdentifiers: Record = { ...JAVASCRIPT_KEYWORDS, ...APPSMITH_GLOBAL_FUNCTIONS, ...DEDICATED_WORKER_GLOBAL_SCOPE_IDENTIFIERS, + ...libraryReservedIdentifiers, }; export function listEntityDependencies( diff --git a/app/client/src/workers/common/JSLibrary/resetJSLibraries.ts b/app/client/src/workers/common/JSLibrary/resetJSLibraries.ts index a048a0d365..b25dc300b2 100644 --- a/app/client/src/workers/common/JSLibrary/resetJSLibraries.ts +++ b/app/client/src/workers/common/JSLibrary/resetJSLibraries.ts @@ -4,6 +4,7 @@ import parser from "fast-xml-parser"; import forge from "node-forge"; import { defaultLibraries } from "./index"; import { JSLibraries, libraryReservedIdentifiers } from "./index"; +import { invalidEntityIdentifiers } from "../DependencyMap/utils"; const defaultLibImplementations = { lodash: _, @@ -29,7 +30,9 @@ export function resetJSLibraries() { // @ts-expect-error: Types are not available self[key] = undefined; } + //we have to update invalidEntityIdentifiers as well delete libraryReservedIdentifiers[key]; + delete invalidEntityIdentifiers[key]; } JSLibraries.forEach((library) => {