@teambit/workspace 0.0.701 → 0.0.702
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/component-tree.widget.tsx +1 -1
- package/dist/component-tree.widget.js +1 -1
- package/dist/component-tree.widget.js.map +1 -1
- package/dist/on-component-events.d.ts +1 -1
- package/dist/workspace-component/workspace-component-loader.js +1 -1
- package/dist/workspace-component/workspace-component-loader.js.map +1 -1
- package/package-tar/teambit-workspace-0.0.702.tgz +0 -0
- package/package.json +32 -32
- package/{preview-1649129006696.js → preview-1649215446132.js} +2 -2
- package/tsconfig.json +4 -3
- package/workspace-component/workspace-component-loader.ts +1 -1
- package/package-tar/teambit-workspace-0.0.701.tgz +0 -0
|
@@ -12,7 +12,7 @@ export class ComponentTreeWidget implements ComponentTreeNode {
|
|
|
12
12
|
const lanes = useLanesContext();
|
|
13
13
|
|
|
14
14
|
const isInCurrentLane = useMemo(() => {
|
|
15
|
-
return workspaceComponent?.id && lanes?.
|
|
15
|
+
return workspaceComponent?.id && lanes?.isInViewedLane(workspaceComponent.id);
|
|
16
16
|
}, [lanes?.viewedLane, workspaceComponent?.id]);
|
|
17
17
|
|
|
18
18
|
if (!workspaceComponent) return null;
|
|
@@ -70,7 +70,7 @@ class ComponentTreeWidget {
|
|
|
70
70
|
const workspaceComponent = workspace.getComponent(component.id);
|
|
71
71
|
const lanes = (0, _lanesUi().useLanesContext)();
|
|
72
72
|
const isInCurrentLane = (0, _react().useMemo)(() => {
|
|
73
|
-
return (workspaceComponent === null || workspaceComponent === void 0 ? void 0 : workspaceComponent.id) && (lanes === null || lanes === void 0 ? void 0 : lanes.
|
|
73
|
+
return (workspaceComponent === null || workspaceComponent === void 0 ? void 0 : workspaceComponent.id) && (lanes === null || lanes === void 0 ? void 0 : lanes.isInViewedLane(workspaceComponent.id));
|
|
74
74
|
}, [lanes === null || lanes === void 0 ? void 0 : lanes.viewedLane, workspaceComponent === null || workspaceComponent === void 0 ? void 0 : workspaceComponent.id]);
|
|
75
75
|
if (!workspaceComponent) return null;
|
|
76
76
|
return /*#__PURE__*/_react().default.createElement(_componentUi().ComponentStatusResolver, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["component-tree.widget.tsx"],"names":["ComponentTreeWidget","component","workspace","WorkspaceContext","workspaceComponent","getComponent","id","lanes","isInCurrentLane","viewedLane","status","issuesCount"],"mappings":";;;;;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;AAEO,MAAMA,mBAAN,CAAuD;AAAA;AAAA,oDACnD,CAAC;AAAEC,MAAAA;AAAF,KAAD,KAA2C;AAClD,YAAMC,SAAS,GAAG,yBAAWC,oCAAX,CAAlB;AACA,YAAMC,kBAAkB,GAAGF,SAAS,CAACG,YAAV,CAAuBJ,SAAS,CAACK,EAAjC,CAA3B;AACA,YAAMC,KAAK,GAAG,iCAAd;AAEA,YAAMC,eAAe,GAAG,sBAAQ,MAAM;AACpC,eAAO,CAAAJ,kBAAkB,SAAlB,IAAAA,kBAAkB,WAAlB,YAAAA,kBAAkB,CAAEE,EAApB,MAA0BC,KAA1B,aAA0BA,KAA1B,uBAA0BA,KAAK,
|
|
1
|
+
{"version":3,"sources":["component-tree.widget.tsx"],"names":["ComponentTreeWidget","component","workspace","WorkspaceContext","workspaceComponent","getComponent","id","lanes","isInCurrentLane","isInViewedLane","viewedLane","status","issuesCount"],"mappings":";;;;;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;AAEO,MAAMA,mBAAN,CAAuD;AAAA;AAAA,oDACnD,CAAC;AAAEC,MAAAA;AAAF,KAAD,KAA2C;AAClD,YAAMC,SAAS,GAAG,yBAAWC,oCAAX,CAAlB;AACA,YAAMC,kBAAkB,GAAGF,SAAS,CAACG,YAAV,CAAuBJ,SAAS,CAACK,EAAjC,CAA3B;AACA,YAAMC,KAAK,GAAG,iCAAd;AAEA,YAAMC,eAAe,GAAG,sBAAQ,MAAM;AACpC,eAAO,CAAAJ,kBAAkB,SAAlB,IAAAA,kBAAkB,WAAlB,YAAAA,kBAAkB,CAAEE,EAApB,MAA0BC,KAA1B,aAA0BA,KAA1B,uBAA0BA,KAAK,CAAEE,cAAP,CAAsBL,kBAAkB,CAACE,EAAzC,CAA1B,CAAP;AACD,OAFuB,EAErB,CAACC,KAAD,aAACA,KAAD,uBAACA,KAAK,CAAEG,UAAR,EAAoBN,kBAApB,aAAoBA,kBAApB,uBAAoBA,kBAAkB,CAAEE,EAAxC,CAFqB,CAAxB;AAIA,UAAI,CAACF,kBAAL,EAAyB,OAAO,IAAP;AAEzB,0BACE,+BAAC,sCAAD;AACE,QAAA,MAAM,EAAEA,kBAAkB,CAACO,MAD7B;AAEE,QAAA,WAAW,EAAEP,kBAAkB,CAACQ,WAFlC;AAGE,QAAA,eAAe,EAAEJ;AAHnB,QADF;AAOD,KAnB2D;AAAA;;AAAA","sourcesContent":["import { ComponentTreeNode, ComponentTreeNodeProps } from '@teambit/component-tree';\nimport { ComponentStatusResolver } from '@teambit/component.ui.component-status-resolver';\nimport React, { useContext, useMemo } from 'react';\n\nimport { useLanesContext } from '@teambit/lanes.ui.lanes';\nimport { WorkspaceContext } from './ui/workspace/workspace-context';\n\nexport class ComponentTreeWidget implements ComponentTreeNode {\n widget = ({ component }: ComponentTreeNodeProps) => {\n const workspace = useContext(WorkspaceContext);\n const workspaceComponent = workspace.getComponent(component.id);\n const lanes = useLanesContext();\n\n const isInCurrentLane = useMemo(() => {\n return workspaceComponent?.id && lanes?.isInViewedLane(workspaceComponent.id);\n }, [lanes?.viewedLane, workspaceComponent?.id]);\n\n if (!workspaceComponent) return null;\n\n return (\n <ComponentStatusResolver\n status={workspaceComponent.status}\n issuesCount={workspaceComponent.issuesCount}\n isInCurrentLane={isInCurrentLane}\n />\n );\n };\n}\n"]}
|
|
@@ -11,4 +11,4 @@ export declare type OnComponentEventResult = {
|
|
|
11
11
|
extensionId: string;
|
|
12
12
|
results: SerializableResults;
|
|
13
13
|
};
|
|
14
|
-
export declare type OnComponentLoad = (component: Component) => Promise<AspectData>;
|
|
14
|
+
export declare type OnComponentLoad = (component: Component) => Promise<AspectData | undefined>;
|
|
@@ -423,7 +423,7 @@ class WorkspaceComponentLoader {
|
|
|
423
423
|
async upsertExtensionData(component, extension, data) {
|
|
424
424
|
const existingExtension = component.state.config.extensions.findExtension(extension);
|
|
425
425
|
|
|
426
|
-
if (existingExtension) {
|
|
426
|
+
if (existingExtension && data) {
|
|
427
427
|
// Only merge top level of extension data
|
|
428
428
|
Object.assign(existingExtension.data, data);
|
|
429
429
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["workspace-component-loader.ts"],"names":["WorkspaceComponentLoader","constructor","workspace","logger","dependencyResolver","envs","componentsCache","maxSize","componentsCacheForCapsule","getMany","ids","forCapsule","idsWithoutEmpty","errors","longProcessLogger","createLongProcessLogger","length","componentsP","id","logProgress","toString","get","catch","err","isComponentNotExistsError","push","undefined","components","forEach","consumer","isLegacy","console","warn","filteredComponents","end","getInvalid","loadComponent","_legacy","ConsumerComponent","isComponentInvalidByErrorType","componentId","legacyComponent","useCache","storeInCache","bitIdWithVersion","bitmapIdsFromCurrentLane","version","changeVersion","fromCache","getFromCache","consumerComponent","getConsumerComponent","updatedId","ComponentID","fromLegacy","scope","component","loadOne","addMultipleEnvsIssueIfNeeded","saveInCache","getIfExist","getAllEnvsConfiguredOnComponent","envIds","map","env","state","issues","getOrCreate","IssuesClasses","MultipleEnvs","data","clearCache","deleteAll","clearComponentCache","idStr","delete","componentFromScope","MissingBitMapComponent","extensions","componentExtensions","extensionsFromConsumerComponent","ExtensionDataList","extensionDataList","mergeConfigs","filterRemovedExtensions","State","Config","mainFile","createAspectList","ComponentFS","fromVinyls","files","dependencies","workspaceComponent","WorkspaceComponent","head","tags","executeLoadSlot","newComponentFromState","set","isEqual","loadComponentForCapsule","debug","name","message","ComponentNotFound","ComponentNotFoundInPath","entries","onComponentLoadSlot","toArray","promises","extension","onLoad","upsertExtensionData","envsData","getEnvSystemDescriptor","policy","mergeVariantPolicies","config","extractDepsFromLegacy","depResolverData","serialize","EnvsAspect","DependencyResolverAspect","Promise","all","updatedAspectList","aspects","TagMap","existingExtension","findExtension","Object","assign","getDataEntry","ExtensionDataEntry"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AA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D,iBAA1B;AACA,WAAOtE,SAAP;AACD;;AAEO0C,EAAAA,qBAAqB,CAAChF,EAAD,EAAkB+C,KAAlB,EAA2C;AACtE,WAAO,KAAI6B,wCAAJ,EAAuB5E,EAAvB,EAA2B,IAA3B,EAAiC+C,KAAjC,EAAwC,KAAI+D,mBAAJ,GAAxC,EAAsD,KAAK9H,SAA3D,CAAP;AACD;;AAEgC,QAAnB+G,mBAAmB,CAACzD,SAAD,EAAuBuD,SAAvB,EAA0CzC,IAA1C,EAAqD;AACpF,UAAM2D,iBAAiB,GAAGzE,SAAS,CAACS,KAAV,CAAgBqD,MAAhB,CAAuBxC,UAAvB,CAAkCoD,aAAlC,CAAgDnB,SAAhD,CAA1B;;AACA,QAAIkB,iBAAJ,EAAuB;AACrB;AACAE,MAAAA,MAAM,CAACC,MAAP,CAAcH,iBAAiB,CAAC3D,IAAhC,EAAsCA,IAAtC;AACA;AACD;;AACDd,IAAAA,SAAS,CAACS,KAAV,CAAgBqD,MAAhB,CAAuBxC,UAAvB,CAAkCrD,IAAlC,CAAuC,MAAM,KAAK4G,YAAL,CAAkBtB,SAAlB,EAA6BzC,IAA7B,CAA7C;AACD;;AAEyB,QAAZ+D,YAAY,CAACtB,SAAD,EAAoBzC,IAApB,EAA+E;AACvG;AACA,WAAO,KAAIgE,4BAAJ,EAAuB5G,SAAvB,EAAkCA,SAAlC,EAA6CqF,SAA7C,EAAwDrF,SAAxD,EAAmE4C,IAAnE,CAAP;AACD;;AAzQmC","sourcesContent":["import { Component, ComponentFS, ComponentID, Config, InvalidComponent, State, TagMap } from '@teambit/component';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';\nimport mapSeries from 'p-map-series';\nimport { compact, uniq } from 'lodash';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport { MissingBitMapComponent } from '@teambit/legacy/dist/consumer/bit-map/exceptions';\nimport { getLatestVersionNumber } from '@teambit/legacy/dist/utils';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { ComponentNotFound } from '@teambit/legacy/dist/scope/exceptions';\nimport { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { Logger } from '@teambit/logger';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config';\nimport { getMaxSizeForComponents, InMemoryCache } from '@teambit/legacy/dist/cache/in-memory-cache';\nimport { createInMemoryCache } from '@teambit/legacy/dist/cache/cache-factory';\nimport ComponentNotFoundInPath from '@teambit/legacy/dist/consumer/component/exceptions/component-not-found-in-path';\nimport { Workspace } from '../workspace';\nimport { WorkspaceComponent } from './workspace-component';\n\nexport class WorkspaceComponentLoader {\n private componentsCache: InMemoryCache<Component>; // cache loaded components\n private componentsCacheForCapsule: InMemoryCache<Component>; // cache loaded components for capsule, must not use the cache for the workspace\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private dependencyResolver: DependencyResolverMain,\n private envs: EnvsMain\n ) {\n this.componentsCache = createInMemoryCache({ maxSize: getMaxSizeForComponents() });\n this.componentsCacheForCapsule = createInMemoryCache({ maxSize: getMaxSizeForComponents() });\n }\n\n async getMany(ids: Array<ComponentID>, forCapsule = false): Promise<Component[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: { id: ComponentID; err: Error }[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n const componentsP = mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n return this.get(id, forCapsule).catch((err) => {\n if (this.isComponentNotExistsError(err)) {\n errors.push({\n id,\n err,\n });\n return undefined;\n }\n throw err;\n });\n });\n const components = await componentsP;\n errors.forEach((err) => {\n if (!this.workspace.consumer.isLegacy) {\n this.logger.console(`failed loading component ${err.id.toString()}, see full error in debug.log file`);\n }\n this.logger.warn(`failed loading component ${err.id.toString()}`, err.err);\n });\n // remove errored components\n const filteredComponents: Component[] = compact(components);\n longProcessLogger.end();\n return filteredComponents;\n }\n\n async getInvalid(ids: Array<ComponentID>): Promise<InvalidComponent[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: InvalidComponent[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n await mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n try {\n await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n if (ConsumerComponent.isComponentInvalidByErrorType(err)) {\n errors.push({\n id,\n err,\n });\n return;\n }\n throw err;\n }\n });\n return errors;\n }\n\n async get(\n componentId: ComponentID,\n forCapsule = false,\n legacyComponent?: ConsumerComponent,\n useCache = true,\n storeInCache = true\n ): Promise<Component> {\n const bitIdWithVersion: BitId = getLatestVersionNumber(\n this.workspace.consumer.bitmapIdsFromCurrentLane,\n componentId._legacy\n );\n const id = bitIdWithVersion.version ? componentId.changeVersion(bitIdWithVersion.version) : componentId;\n const fromCache = this.getFromCache(id, forCapsule);\n if (fromCache && useCache) {\n return fromCache;\n }\n const consumerComponent = legacyComponent || (await this.getConsumerComponent(id, forCapsule));\n // in case of out-of-sync, the id may changed during the load process\n const updatedId = consumerComponent ? ComponentID.fromLegacy(consumerComponent.id, id.scope) : id;\n const component = await this.loadOne(updatedId, consumerComponent);\n if (storeInCache) {\n this.addMultipleEnvsIssueIfNeeded(component); // it's in storeInCache block, otherwise, it wasn't fully loaded\n this.saveInCache(component, forCapsule);\n }\n return component;\n }\n\n async getIfExist(componentId: ComponentID) {\n try {\n return await this.get(componentId);\n } catch (err: any) {\n if (this.isComponentNotExistsError(err)) {\n return undefined;\n }\n throw err;\n }\n }\n\n private addMultipleEnvsIssueIfNeeded(component: Component) {\n const envs = this.envs.getAllEnvsConfiguredOnComponent(component);\n const envIds = uniq(envs.map((env) => env.id));\n if (envIds.length < 2) {\n return;\n }\n component.state.issues.getOrCreate(IssuesClasses.MultipleEnvs).data = envIds;\n }\n\n clearCache() {\n this.componentsCache.deleteAll();\n this.componentsCacheForCapsule.deleteAll();\n }\n clearComponentCache(id: ComponentID) {\n const idStr = id.toString();\n this.componentsCache.delete(idStr);\n this.componentsCacheForCapsule.delete(idStr);\n }\n\n private async loadOne(id: ComponentID, consumerComponent?: ConsumerComponent) {\n const componentFromScope = await this.workspace.scope.get(id);\n if (!consumerComponent) {\n if (!componentFromScope) throw new MissingBitMapComponent(id.toString());\n return componentFromScope;\n }\n const { extensions } = await this.workspace.componentExtensions(id, componentFromScope);\n const extensionsFromConsumerComponent = consumerComponent.extensions || new ExtensionDataList();\n // Merge extensions added by the legacy code in memory (for example data of dependency resolver)\n const extensionDataList = ExtensionDataList.mergeConfigs([\n extensionsFromConsumerComponent,\n extensions,\n ]).filterRemovedExtensions();\n\n // temporarily mutate consumer component extensions until we remove all direct access from legacy to extensions data\n // TODO: remove this once we remove all direct access from legacy code to extensions data\n consumerComponent.extensions = extensionDataList;\n\n const state = new State(\n new Config(consumerComponent.mainFile, extensionDataList),\n await this.workspace.createAspectList(extensionDataList),\n ComponentFS.fromVinyls(consumerComponent.files),\n consumerComponent.dependencies,\n consumerComponent\n );\n if (componentFromScope) {\n // Removed by @gilad. do not mutate the component from the scope\n // componentFromScope.state = state;\n // const workspaceComponent = WorkspaceComponent.fromComponent(componentFromScope, this.workspace);\n const workspaceComponent = new WorkspaceComponent(\n componentFromScope.id,\n componentFromScope.head,\n state,\n componentFromScope.tags,\n this.workspace\n );\n return this.executeLoadSlot(workspaceComponent);\n }\n return this.executeLoadSlot(this.newComponentFromState(id, state));\n }\n\n private saveInCache(component: Component, forCapsule: boolean): void {\n if (forCapsule) {\n this.componentsCacheForCapsule.set(component.id.toString(), component);\n } else {\n this.componentsCache.set(component.id.toString(), component);\n }\n }\n\n /**\n * make sure that not only the id-str match, but also the legacy-id.\n * this is needed because the ComponentID.toString() is the same whether or not the legacy-id has\n * scope-name, as it includes the defaultScope if the scope is empty.\n * as a result, when out-of-sync is happening and the id is changed to include scope-name in the\n * legacy-id, the component is the cache has the old id.\n */\n private getFromCache(id: ComponentID, forCapsule: boolean): Component | undefined {\n const fromCache = forCapsule\n ? this.componentsCacheForCapsule.get(id.toString())\n : this.componentsCache.get(id.toString());\n if (fromCache && fromCache.id._legacy.isEqual(id._legacy)) {\n return fromCache;\n }\n return undefined;\n }\n\n private async getConsumerComponent(id: ComponentID, forCapsule = false): Promise<ConsumerComponent | undefined> {\n try {\n return forCapsule\n ? // eslint-disable-next-line @typescript-eslint/return-await\n await this.workspace.consumer.loadComponentForCapsule(id._legacy)\n : // eslint-disable-next-line @typescript-eslint/return-await\n await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n // don't return undefined for any error. otherwise, if the component is invalid (e.g. main\n // file is missing) it returns the model component later unexpectedly, or if it's new, it\n // shows MissingBitMapComponent error incorrectly.\n if (this.isComponentNotExistsError(err)) {\n this.logger.debug(\n `failed loading component \"${id.toString()}\" from the workspace due to \"${err.name}\" error\\n${err.message}`\n );\n return undefined;\n }\n throw err;\n }\n }\n\n private isComponentNotExistsError(err: Error): boolean {\n return (\n err instanceof ComponentNotFound ||\n err instanceof MissingBitMapComponent ||\n err instanceof ComponentNotFoundInPath\n );\n }\n\n private async executeLoadSlot(component: Component) {\n const entries = this.workspace.onComponentLoadSlot.toArray();\n const promises = entries.map(async ([extension, onLoad]) => {\n const data = await onLoad(component);\n return this.upsertExtensionData(component, extension, data);\n });\n\n // Special load events which runs from the workspace but should run from the correct aspect\n // TODO: remove this once those extensions dependent on workspace\n const envsData = await this.workspace.getEnvSystemDescriptor(component);\n\n // Move to deps resolver main runtime once we switch ws<> deps resolver direction\n const policy = await this.dependencyResolver.mergeVariantPolicies(component.config.extensions);\n const dependencies = await this.dependencyResolver.extractDepsFromLegacy(component, policy);\n\n const depResolverData = {\n dependencies,\n policy: policy.serialize(),\n };\n\n promises.push(this.upsertExtensionData(component, EnvsAspect.id, envsData));\n promises.push(this.upsertExtensionData(component, DependencyResolverAspect.id, depResolverData));\n\n await Promise.all(promises);\n\n // Update the aspect list to have changes happened during the on load slot (new data added above)\n const updatedAspectList = await this.workspace.createAspectList(component.state.config.extensions);\n component.state.aspects = updatedAspectList;\n return component;\n }\n\n private newComponentFromState(id: ComponentID, state: State): Component {\n return new WorkspaceComponent(id, null, state, new TagMap(), this.workspace);\n }\n\n private async upsertExtensionData(component: Component, extension: string, data: any) {\n const existingExtension = component.state.config.extensions.findExtension(extension);\n if (existingExtension) {\n // Only merge top level of extension data\n Object.assign(existingExtension.data, data);\n return;\n }\n component.state.config.extensions.push(await this.getDataEntry(extension, data));\n }\n\n private async getDataEntry(extension: string, data: { [key: string]: any }): Promise<ExtensionDataEntry> {\n // TODO: @gilad we need to refactor the extension data entry api.\n return new ExtensionDataEntry(undefined, undefined, extension, undefined, data);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["workspace-component-loader.ts"],"names":["WorkspaceComponentLoader","constructor","workspace","logger","dependencyResolver","envs","componentsCache","maxSize","componentsCacheForCapsule","getMany","ids","forCapsule","idsWithoutEmpty","errors","longProcessLogger","createLongProcessLogger","length","componentsP","id","logProgress","toString","get","catch","err","isComponentNotExistsError","push","undefined","components","forEach","consumer","isLegacy","console","warn","filteredComponents","end","getInvalid","loadComponent","_legacy","ConsumerComponent","isComponentInvalidByErrorType","componentId","legacyComponent","useCache","storeInCache","bitIdWithVersion","bitmapIdsFromCurrentLane","version","changeVersion","fromCache","getFromCache","consumerComponent","getConsumerComponent","updatedId","ComponentID","fromLegacy","scope","component","loadOne","addMultipleEnvsIssueIfNeeded","saveInCache","getIfExist","getAllEnvsConfiguredOnComponent","envIds","map","env","state","issues","getOrCreate","IssuesClasses","MultipleEnvs","data","clearCache","deleteAll","clearComponentCache","idStr","delete","componentFromScope","MissingBitMapComponent","extensions","componentExtensions","extensionsFromConsumerComponent","ExtensionDataList","extensionDataList","mergeConfigs","filterRemovedExtensions","State","Config","mainFile","createAspectList","ComponentFS","fromVinyls","files","dependencies","workspaceComponent","WorkspaceComponent","head","tags","executeLoadSlot","newComponentFromState","set","isEqual","loadComponentForCapsule","debug","name","message","ComponentNotFound","ComponentNotFoundInPath","entries","onComponentLoadSlot","toArray","promises","extension","onLoad","upsertExtensionData","envsData","getEnvSystemDescriptor","policy","mergeVariantPolicies","config","extractDepsFromLegacy","depResolverData","serialize","EnvsAspect","DependencyResolverAspect","Promise","all","updatedAspectList","aspects","TagMap","existingExtension","findExtension","Object","assign","getDataEntry","ExtensionDataEntry"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,wBAAN,CAA+B;AACe;AACU;AAC7DC,EAAAA,WAAW,CACDC,SADC,EAEDC,MAFC,EAGDC,kBAHC,EAIDC,IAJC,EAKT;AAAA,SAJQH,SAIR,GAJQA,SAIR;AAAA,SAHQC,MAGR,GAHQA,MAGR;AAAA,SAF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,GAAxC,EAAsD,KAAK9H,SAA3D,CAAP;AACD;;AAEgC,QAAnB+G,mBAAmB,CAACzD,SAAD,EAAuBuD,SAAvB,EAA0CzC,IAA1C,EAAqD;AACpF,UAAM2D,iBAAiB,GAAGzE,SAAS,CAACS,KAAV,CAAgBqD,MAAhB,CAAuBxC,UAAvB,CAAkCoD,aAAlC,CAAgDnB,SAAhD,CAA1B;;AACA,QAAIkB,iBAAiB,IAAI3D,IAAzB,EAA+B;AAC7B;AACA6D,MAAAA,MAAM,CAACC,MAAP,CAAcH,iBAAiB,CAAC3D,IAAhC,EAAsCA,IAAtC;AACA;AACD;;AACDd,IAAAA,SAAS,CAACS,KAAV,CAAgBqD,MAAhB,CAAuBxC,UAAvB,CAAkCrD,IAAlC,CAAuC,MAAM,KAAK4G,YAAL,CAAkBtB,SAAlB,EAA6BzC,IAA7B,CAA7C;AACD;;AAEyB,QAAZ+D,YAAY,CAACtB,SAAD,EAAoBzC,IAApB,EAA+E;AACvG;AACA,WAAO,KAAIgE,4BAAJ,EAAuB5G,SAAvB,EAAkCA,SAAlC,EAA6CqF,SAA7C,EAAwDrF,SAAxD,EAAmE4C,IAAnE,CAAP;AACD;;AAzQmC","sourcesContent":["import { Component, ComponentFS, ComponentID, Config, InvalidComponent, State, TagMap } from '@teambit/component';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { ExtensionDataList } from '@teambit/legacy/dist/consumer/config/extension-data';\nimport mapSeries from 'p-map-series';\nimport { compact, uniq } from 'lodash';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport { MissingBitMapComponent } from '@teambit/legacy/dist/consumer/bit-map/exceptions';\nimport { getLatestVersionNumber } from '@teambit/legacy/dist/utils';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { ComponentNotFound } from '@teambit/legacy/dist/scope/exceptions';\nimport { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { Logger } from '@teambit/logger';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { ExtensionDataEntry } from '@teambit/legacy/dist/consumer/config';\nimport { getMaxSizeForComponents, InMemoryCache } from '@teambit/legacy/dist/cache/in-memory-cache';\nimport { createInMemoryCache } from '@teambit/legacy/dist/cache/cache-factory';\nimport ComponentNotFoundInPath from '@teambit/legacy/dist/consumer/component/exceptions/component-not-found-in-path';\nimport { Workspace } from '../workspace';\nimport { WorkspaceComponent } from './workspace-component';\n\nexport class WorkspaceComponentLoader {\n private componentsCache: InMemoryCache<Component>; // cache loaded components\n private componentsCacheForCapsule: InMemoryCache<Component>; // cache loaded components for capsule, must not use the cache for the workspace\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private dependencyResolver: DependencyResolverMain,\n private envs: EnvsMain\n ) {\n this.componentsCache = createInMemoryCache({ maxSize: getMaxSizeForComponents() });\n this.componentsCacheForCapsule = createInMemoryCache({ maxSize: getMaxSizeForComponents() });\n }\n\n async getMany(ids: Array<ComponentID>, forCapsule = false): Promise<Component[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: { id: ComponentID; err: Error }[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n const componentsP = mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n return this.get(id, forCapsule).catch((err) => {\n if (this.isComponentNotExistsError(err)) {\n errors.push({\n id,\n err,\n });\n return undefined;\n }\n throw err;\n });\n });\n const components = await componentsP;\n errors.forEach((err) => {\n if (!this.workspace.consumer.isLegacy) {\n this.logger.console(`failed loading component ${err.id.toString()}, see full error in debug.log file`);\n }\n this.logger.warn(`failed loading component ${err.id.toString()}`, err.err);\n });\n // remove errored components\n const filteredComponents: Component[] = compact(components);\n longProcessLogger.end();\n return filteredComponents;\n }\n\n async getInvalid(ids: Array<ComponentID>): Promise<InvalidComponent[]> {\n const idsWithoutEmpty = compact(ids);\n const errors: InvalidComponent[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('loading components', ids.length);\n await mapSeries(idsWithoutEmpty, async (id: ComponentID) => {\n longProcessLogger.logProgress(id.toString());\n try {\n await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n if (ConsumerComponent.isComponentInvalidByErrorType(err)) {\n errors.push({\n id,\n err,\n });\n return;\n }\n throw err;\n }\n });\n return errors;\n }\n\n async get(\n componentId: ComponentID,\n forCapsule = false,\n legacyComponent?: ConsumerComponent,\n useCache = true,\n storeInCache = true\n ): Promise<Component> {\n const bitIdWithVersion: BitId = getLatestVersionNumber(\n this.workspace.consumer.bitmapIdsFromCurrentLane,\n componentId._legacy\n );\n const id = bitIdWithVersion.version ? componentId.changeVersion(bitIdWithVersion.version) : componentId;\n const fromCache = this.getFromCache(id, forCapsule);\n if (fromCache && useCache) {\n return fromCache;\n }\n const consumerComponent = legacyComponent || (await this.getConsumerComponent(id, forCapsule));\n // in case of out-of-sync, the id may changed during the load process\n const updatedId = consumerComponent ? ComponentID.fromLegacy(consumerComponent.id, id.scope) : id;\n const component = await this.loadOne(updatedId, consumerComponent);\n if (storeInCache) {\n this.addMultipleEnvsIssueIfNeeded(component); // it's in storeInCache block, otherwise, it wasn't fully loaded\n this.saveInCache(component, forCapsule);\n }\n return component;\n }\n\n async getIfExist(componentId: ComponentID) {\n try {\n return await this.get(componentId);\n } catch (err: any) {\n if (this.isComponentNotExistsError(err)) {\n return undefined;\n }\n throw err;\n }\n }\n\n private addMultipleEnvsIssueIfNeeded(component: Component) {\n const envs = this.envs.getAllEnvsConfiguredOnComponent(component);\n const envIds = uniq(envs.map((env) => env.id));\n if (envIds.length < 2) {\n return;\n }\n component.state.issues.getOrCreate(IssuesClasses.MultipleEnvs).data = envIds;\n }\n\n clearCache() {\n this.componentsCache.deleteAll();\n this.componentsCacheForCapsule.deleteAll();\n }\n clearComponentCache(id: ComponentID) {\n const idStr = id.toString();\n this.componentsCache.delete(idStr);\n this.componentsCacheForCapsule.delete(idStr);\n }\n\n private async loadOne(id: ComponentID, consumerComponent?: ConsumerComponent) {\n const componentFromScope = await this.workspace.scope.get(id);\n if (!consumerComponent) {\n if (!componentFromScope) throw new MissingBitMapComponent(id.toString());\n return componentFromScope;\n }\n const { extensions } = await this.workspace.componentExtensions(id, componentFromScope);\n const extensionsFromConsumerComponent = consumerComponent.extensions || new ExtensionDataList();\n // Merge extensions added by the legacy code in memory (for example data of dependency resolver)\n const extensionDataList = ExtensionDataList.mergeConfigs([\n extensionsFromConsumerComponent,\n extensions,\n ]).filterRemovedExtensions();\n\n // temporarily mutate consumer component extensions until we remove all direct access from legacy to extensions data\n // TODO: remove this once we remove all direct access from legacy code to extensions data\n consumerComponent.extensions = extensionDataList;\n\n const state = new State(\n new Config(consumerComponent.mainFile, extensionDataList),\n await this.workspace.createAspectList(extensionDataList),\n ComponentFS.fromVinyls(consumerComponent.files),\n consumerComponent.dependencies,\n consumerComponent\n );\n if (componentFromScope) {\n // Removed by @gilad. do not mutate the component from the scope\n // componentFromScope.state = state;\n // const workspaceComponent = WorkspaceComponent.fromComponent(componentFromScope, this.workspace);\n const workspaceComponent = new WorkspaceComponent(\n componentFromScope.id,\n componentFromScope.head,\n state,\n componentFromScope.tags,\n this.workspace\n );\n return this.executeLoadSlot(workspaceComponent);\n }\n return this.executeLoadSlot(this.newComponentFromState(id, state));\n }\n\n private saveInCache(component: Component, forCapsule: boolean): void {\n if (forCapsule) {\n this.componentsCacheForCapsule.set(component.id.toString(), component);\n } else {\n this.componentsCache.set(component.id.toString(), component);\n }\n }\n\n /**\n * make sure that not only the id-str match, but also the legacy-id.\n * this is needed because the ComponentID.toString() is the same whether or not the legacy-id has\n * scope-name, as it includes the defaultScope if the scope is empty.\n * as a result, when out-of-sync is happening and the id is changed to include scope-name in the\n * legacy-id, the component is the cache has the old id.\n */\n private getFromCache(id: ComponentID, forCapsule: boolean): Component | undefined {\n const fromCache = forCapsule\n ? this.componentsCacheForCapsule.get(id.toString())\n : this.componentsCache.get(id.toString());\n if (fromCache && fromCache.id._legacy.isEqual(id._legacy)) {\n return fromCache;\n }\n return undefined;\n }\n\n private async getConsumerComponent(id: ComponentID, forCapsule = false): Promise<ConsumerComponent | undefined> {\n try {\n return forCapsule\n ? // eslint-disable-next-line @typescript-eslint/return-await\n await this.workspace.consumer.loadComponentForCapsule(id._legacy)\n : // eslint-disable-next-line @typescript-eslint/return-await\n await this.workspace.consumer.loadComponent(id._legacy);\n } catch (err: any) {\n // don't return undefined for any error. otherwise, if the component is invalid (e.g. main\n // file is missing) it returns the model component later unexpectedly, or if it's new, it\n // shows MissingBitMapComponent error incorrectly.\n if (this.isComponentNotExistsError(err)) {\n this.logger.debug(\n `failed loading component \"${id.toString()}\" from the workspace due to \"${err.name}\" error\\n${err.message}`\n );\n return undefined;\n }\n throw err;\n }\n }\n\n private isComponentNotExistsError(err: Error): boolean {\n return (\n err instanceof ComponentNotFound ||\n err instanceof MissingBitMapComponent ||\n err instanceof ComponentNotFoundInPath\n );\n }\n\n private async executeLoadSlot(component: Component) {\n const entries = this.workspace.onComponentLoadSlot.toArray();\n const promises = entries.map(async ([extension, onLoad]) => {\n const data = await onLoad(component);\n return this.upsertExtensionData(component, extension, data);\n });\n\n // Special load events which runs from the workspace but should run from the correct aspect\n // TODO: remove this once those extensions dependent on workspace\n const envsData = await this.workspace.getEnvSystemDescriptor(component);\n\n // Move to deps resolver main runtime once we switch ws<> deps resolver direction\n const policy = await this.dependencyResolver.mergeVariantPolicies(component.config.extensions);\n const dependencies = await this.dependencyResolver.extractDepsFromLegacy(component, policy);\n\n const depResolverData = {\n dependencies,\n policy: policy.serialize(),\n };\n\n promises.push(this.upsertExtensionData(component, EnvsAspect.id, envsData));\n promises.push(this.upsertExtensionData(component, DependencyResolverAspect.id, depResolverData));\n\n await Promise.all(promises);\n\n // Update the aspect list to have changes happened during the on load slot (new data added above)\n const updatedAspectList = await this.workspace.createAspectList(component.state.config.extensions);\n component.state.aspects = updatedAspectList;\n return component;\n }\n\n private newComponentFromState(id: ComponentID, state: State): Component {\n return new WorkspaceComponent(id, null, state, new TagMap(), this.workspace);\n }\n\n private async upsertExtensionData(component: Component, extension: string, data: any) {\n const existingExtension = component.state.config.extensions.findExtension(extension);\n if (existingExtension && data) {\n // Only merge top level of extension data\n Object.assign(existingExtension.data, data);\n return;\n }\n component.state.config.extensions.push(await this.getDataEntry(extension, data));\n }\n\n private async getDataEntry(extension: string, data: { [key: string]: any }): Promise<ExtensionDataEntry> {\n // TODO: @gilad we need to refactor the extension data entry api.\n return new ExtensionDataEntry(undefined, undefined, extension, undefined, data);\n }\n}\n"]}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/workspace",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.702",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/workspace/workspace",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.workspace",
|
|
8
8
|
"name": "workspace",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.702"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"lodash": "4.17.21",
|
|
@@ -39,47 +39,47 @@
|
|
|
39
39
|
"@teambit/bit-error": "0.0.394",
|
|
40
40
|
"@teambit/component-id": "0.0.402",
|
|
41
41
|
"@teambit/legacy-bit-id": "0.0.399",
|
|
42
|
-
"@teambit/logger": "0.0.
|
|
43
|
-
"@teambit/scope": "0.0.
|
|
44
|
-
"@teambit/cli": "0.0.
|
|
45
|
-
"@teambit/isolator": "0.0.
|
|
46
|
-
"@teambit/component-tree": "0.0.
|
|
42
|
+
"@teambit/logger": "0.0.558",
|
|
43
|
+
"@teambit/scope": "0.0.702",
|
|
44
|
+
"@teambit/cli": "0.0.466",
|
|
45
|
+
"@teambit/isolator": "0.0.702",
|
|
46
|
+
"@teambit/component-tree": "0.0.490",
|
|
47
47
|
"@teambit/component.ui.component-status-resolver": "0.0.492",
|
|
48
|
-
"@teambit/lanes.ui.lanes": "0.0.
|
|
48
|
+
"@teambit/lanes.ui.lanes": "0.0.32",
|
|
49
49
|
"@teambit/harmony.modules.resolved-component": "0.0.484",
|
|
50
|
-
"@teambit/dependency-resolver": "0.0.
|
|
51
|
-
"@teambit/compiler": "0.0.
|
|
52
|
-
"@teambit/component": "0.0.
|
|
53
|
-
"@teambit/graphql": "0.0.
|
|
54
|
-
"@teambit/aspect-loader": "0.0.
|
|
55
|
-
"@teambit/bundler": "0.0.
|
|
56
|
-
"@teambit/community": "0.0.
|
|
57
|
-
"@teambit/envs": "0.0.
|
|
58
|
-
"@teambit/pubsub": "0.0.
|
|
59
|
-
"@teambit/ui": "0.0.
|
|
60
|
-
"@teambit/variants": "0.0.
|
|
61
|
-
"@teambit/component-issues": "0.0.
|
|
62
|
-
"@teambit/config": "0.0.
|
|
50
|
+
"@teambit/dependency-resolver": "0.0.702",
|
|
51
|
+
"@teambit/compiler": "0.0.702",
|
|
52
|
+
"@teambit/component": "0.0.702",
|
|
53
|
+
"@teambit/graphql": "0.0.702",
|
|
54
|
+
"@teambit/aspect-loader": "0.0.702",
|
|
55
|
+
"@teambit/bundler": "0.0.702",
|
|
56
|
+
"@teambit/community": "0.0.14",
|
|
57
|
+
"@teambit/envs": "0.0.702",
|
|
58
|
+
"@teambit/pubsub": "0.0.702",
|
|
59
|
+
"@teambit/ui": "0.0.702",
|
|
60
|
+
"@teambit/variants": "0.0.562",
|
|
61
|
+
"@teambit/component-issues": "0.0.50",
|
|
62
|
+
"@teambit/config": "0.0.479",
|
|
63
63
|
"@teambit/harmony.modules.requireable-component": "0.0.484",
|
|
64
|
-
"@teambit/importer": "0.0.
|
|
64
|
+
"@teambit/importer": "0.0.131",
|
|
65
65
|
"@teambit/workspace.modules.match-pattern": "0.0.489",
|
|
66
|
-
"@teambit/component.ui.component-drawer": "0.0.
|
|
66
|
+
"@teambit/component.ui.component-drawer": "0.0.10",
|
|
67
67
|
"@teambit/design.ui.tree": "0.0.5",
|
|
68
|
-
"@teambit/ui-foundation.ui.side-bar": "0.0.
|
|
69
|
-
"@teambit/command-bar": "0.0.
|
|
68
|
+
"@teambit/ui-foundation.ui.side-bar": "0.0.529",
|
|
69
|
+
"@teambit/command-bar": "0.0.702",
|
|
70
70
|
"@teambit/component.ui.component-filters": "0.0.2",
|
|
71
71
|
"@teambit/design.ui.surfaces.menu.link-item": "0.0.379",
|
|
72
|
-
"@teambit/graph": "0.0.
|
|
73
|
-
"@teambit/react-router": "0.0.
|
|
74
|
-
"@teambit/sidebar": "0.0.
|
|
72
|
+
"@teambit/graph": "0.0.702",
|
|
73
|
+
"@teambit/react-router": "0.0.702",
|
|
74
|
+
"@teambit/sidebar": "0.0.702",
|
|
75
75
|
"@teambit/ui-foundation.ui.main-dropdown": "0.0.486",
|
|
76
76
|
"@teambit/ui-foundation.ui.menu": "0.0.486",
|
|
77
77
|
"@teambit/ui-foundation.ui.react-router.slot-router": "0.0.488",
|
|
78
78
|
"@teambit/ui-foundation.ui.tree.drawer": "0.0.499",
|
|
79
79
|
"@teambit/toolbox.time.time-format": "0.0.483",
|
|
80
80
|
"@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.487",
|
|
81
|
-
"@teambit/component-descriptor": "0.0.
|
|
82
|
-
"@teambit/deprecation": "0.0.
|
|
81
|
+
"@teambit/component-descriptor": "0.0.30",
|
|
82
|
+
"@teambit/deprecation": "0.0.702",
|
|
83
83
|
"@teambit/ui-foundation.ui.constants.z-indexes": "0.0.487",
|
|
84
84
|
"@teambit/ui-foundation.ui.buttons.collapser": "0.0.194",
|
|
85
85
|
"@teambit/ui-foundation.ui.corner": "0.0.495",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
},
|
|
107
107
|
"peerDependencies": {
|
|
108
108
|
"@apollo/client": "^3.0.0",
|
|
109
|
-
"@teambit/legacy": "1.0.
|
|
109
|
+
"@teambit/legacy": "1.0.244",
|
|
110
110
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
111
111
|
"react": "^16.8.0 || ^17.0.0"
|
|
112
112
|
},
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
"react": "-"
|
|
135
135
|
},
|
|
136
136
|
"peerDependencies": {
|
|
137
|
-
"@teambit/legacy": "1.0.
|
|
137
|
+
"@teambit/legacy": "1.0.244",
|
|
138
138
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
139
139
|
"react": "^16.8.0 || ^17.0.0"
|
|
140
140
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@0.0.
|
|
2
|
-
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@0.0.
|
|
1
|
+
export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@0.0.702/dist/workspace.composition.js')]
|
|
2
|
+
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@0.0.702/dist/workspace.docs.mdx')]
|
package/tsconfig.json
CHANGED
|
@@ -10,22 +10,23 @@
|
|
|
10
10
|
"target": "es2015",
|
|
11
11
|
"module": "commonjs",
|
|
12
12
|
"jsx": "react",
|
|
13
|
+
"allowJs": true,
|
|
14
|
+
"composite": true,
|
|
13
15
|
"declaration": true,
|
|
14
16
|
"sourceMap": true,
|
|
15
17
|
"skipLibCheck": true,
|
|
18
|
+
"outDir": "dist",
|
|
16
19
|
"moduleResolution": "node",
|
|
17
20
|
"esModuleInterop": true,
|
|
21
|
+
"rootDir": ".",
|
|
18
22
|
"resolveJsonModule": true,
|
|
19
|
-
"composite": true,
|
|
20
23
|
"emitDeclarationOnly": true,
|
|
21
|
-
"outDir": "dist",
|
|
22
24
|
"experimentalDecorators": true,
|
|
23
25
|
"emitDecoratorMetadata": true,
|
|
24
26
|
"allowSyntheticDefaultImports": true,
|
|
25
27
|
"strictPropertyInitialization": false,
|
|
26
28
|
"strict": true,
|
|
27
29
|
"noImplicitAny": false,
|
|
28
|
-
"rootDir": ".",
|
|
29
30
|
"preserveConstEnums": true
|
|
30
31
|
},
|
|
31
32
|
"exclude": [
|
|
@@ -272,7 +272,7 @@ export class WorkspaceComponentLoader {
|
|
|
272
272
|
|
|
273
273
|
private async upsertExtensionData(component: Component, extension: string, data: any) {
|
|
274
274
|
const existingExtension = component.state.config.extensions.findExtension(extension);
|
|
275
|
-
if (existingExtension) {
|
|
275
|
+
if (existingExtension && data) {
|
|
276
276
|
// Only merge top level of extension data
|
|
277
277
|
Object.assign(existingExtension.data, data);
|
|
278
278
|
return;
|
|
Binary file
|