@teambit/workspace 0.0.953 → 0.0.956

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.
@@ -37,7 +37,9 @@ export declare class GraphIdsFromFsBuilder {
37
37
  * we have the graph-dependencies from the last snap, so we prefer to use it whenever possible for performance reasons.
38
38
  * if we can't use it, we have to recursively load dependencies components and get the data from there.
39
39
  * to maximize the performance, we iterate the direct dependencies, if we find a dep with the same id in the graph,
40
- * then ask the graph for all its successors. otherwise, if it's not there, fallback to load the deps components.
40
+ * and that id is not in the workspace then ask the graph for all its successors. otherwise, if it's not there, or
41
+ * it's there but it's also in the workspace (which therefore can be modified), we recursively load the dep components
42
+ * and get its dependencies.
41
43
  */
42
44
  private processCompFromWorkspaceWithGraph;
43
45
  private addDepEdge;
@@ -168,13 +168,21 @@ class GraphIdsFromFsBuilder {
168
168
  * we have the graph-dependencies from the last snap, so we prefer to use it whenever possible for performance reasons.
169
169
  * if we can't use it, we have to recursively load dependencies components and get the data from there.
170
170
  * to maximize the performance, we iterate the direct dependencies, if we find a dep with the same id in the graph,
171
- * then ask the graph for all its successors. otherwise, if it's not there, fallback to load the deps components.
171
+ * and that id is not in the workspace then ask the graph for all its successors. otherwise, if it's not there, or
172
+ * it's there but it's also in the workspace (which therefore can be modified), we recursively load the dep components
173
+ * and get its dependencies.
172
174
  */
173
175
  async processCompFromWorkspaceWithGraph(graphFromScope, component) {
174
176
  const deps = await this.dependencyResolver.getComponentDependencies(component);
175
- const [depsInScopeGraph, depsNotInScopeGraph] = (0, _lodash().partition)(deps, dep => graphFromScope.hasNode(dep.componentId.toString()));
176
- const subGraphs = depsInScopeGraph.map(dep => graphFromScope.successorsSubgraph([dep.componentId.toString()]));
177
- this.graph.merge(subGraphs);
177
+ const workspaceIds = await this.workspace.listIds();
178
+ const [depsInScopeGraph, depsNotInScopeGraph] = (0, _lodash().partition)(deps, dep => graphFromScope.hasNode(dep.componentId.toString()) && !workspaceIds.find(id => id.isEqual(dep.componentId)));
179
+ const depsInScopeGraphIds = depsInScopeGraph.map(dep => dep.componentId.toString());
180
+ const depsInScopeGraphIdsNotCompleted = depsInScopeGraphIds.filter(id => !this.completed.includes(id));
181
+ if (depsInScopeGraphIdsNotCompleted.length) {
182
+ const subGraphs = graphFromScope.successorsSubgraph(depsInScopeGraphIdsNotCompleted);
183
+ this.graph.merge([subGraphs]);
184
+ this.completed.push(...depsInScopeGraphIdsNotCompleted);
185
+ }
178
186
  const allDepsIds = depsNotInScopeGraph.map(d => d.componentId);
179
187
  const idStr = component.id.toString();
180
188
  const allDependenciesComps = await this.loadManyComponents(allDepsIds, idStr);
@@ -1 +1 @@
1
- {"version":3,"names":["lifecycleToDepType","compDep","isExtension","lifecycle","Error","GraphIdsFromFsBuilder","constructor","workspace","logger","dependencyResolver","shouldThrowOnMissingDep","Graph","consumer","buildGraph","ids","debug","length","start","Date","now","components","loadManyComponents","processManyComponents","graph","depth","importObjects","allDependencies","mapSeries","component","processOneComponent","allDependenciesFlattened","flatten","workspaceIds","listIds","compOnWorkspaceOnly","filter","comp","find","id","isEqual","notImported","map","c","importedIds","includes","toString","withScope","_legacy","dep","hasScope","scopeComponentsImporter","scope","scopeImporter","importMany","BitIds","uniqFromArray","throwForDependencyNotFound","throwForSeederNotFound","reFetchUnBuiltVersion","preferDependencyGraph","push","idStr","completed","graphFromScope","getSavedGraphOfComponentIfExist","edges","isOnWorkspace","hasId","allDependenciesComps","processCompFromWorkspaceWithGraph","merge","deps","getComponentDependencies","allDepsIds","d","componentId","forEach","addDepEdge","depsInScopeGraph","depsNotInScopeGraph","partition","hasNode","subGraphs","successorsSubgraph","depId","warn","setEdge","Edge","componentsIds","dependenciesOf","fromCache","loadedComponents","get","setNode","Node","err","ComponentNotFound","ComponentNotFoundInScope","ScopeNotFound","BitError","error","compact"],"sources":["build-graph-ids-from-fs.ts"],"sourcesContent":["import mapSeries from 'p-map-series';\nimport { Graph, Node, Edge } from '@teambit/graph.cleargraph';\nimport { flatten, partition } from 'lodash';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport { Component, ComponentID } from '@teambit/component';\nimport BitIds from '@teambit/legacy/dist/bit-id/bit-ids';\nimport { ComponentDependency, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { CompIdGraph, DepEdgeType } from '@teambit/graph';\nimport { ComponentNotFound, ScopeNotFound } from '@teambit/legacy/dist/scope/exceptions';\nimport { ComponentNotFound as ComponentNotFoundInScope } from '@teambit/scope';\nimport compact from 'lodash.compact';\nimport { Logger } from '@teambit/logger';\nimport { BitError } from '@teambit/bit-error';\nimport { Workspace } from './workspace';\n\nexport function lifecycleToDepType(compDep: ComponentDependency): DepEdgeType {\n if (compDep.isExtension) return 'ext';\n switch (compDep.lifecycle) {\n case 'dev':\n return 'dev';\n case 'runtime':\n return 'prod';\n default:\n throw new Error(`lifecycle ${compDep.lifecycle} is not support`);\n }\n}\n\nexport class GraphIdsFromFsBuilder {\n private graph = new Graph<ComponentID, DepEdgeType>();\n private completed: string[] = [];\n private depth = 1;\n private consumer: Consumer;\n private loadedComponents: { [idStr: string]: Component } = {};\n private importedIds: string[] = [];\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private dependencyResolver: DependencyResolverMain,\n private shouldThrowOnMissingDep = true\n ) {\n this.consumer = this.workspace.consumer;\n }\n\n /**\n * create a graph with all dependencies and flattened dependencies of the given components.\n * the nodes are component-ids and the edges has a label of the dependency type.\n * to get some info about this the graph build take a look into build-graph-from-fs.buildGraph() docs.\n */\n async buildGraph(ids: ComponentID[]): Promise<Graph<ComponentID, DepEdgeType>> {\n this.logger.debug(`GraphIdsFromFsBuilder, buildGraph with ${ids.length} seeders`);\n const start = Date.now();\n const components = await this.loadManyComponents(ids);\n await this.processManyComponents(components);\n this.logger.debug(\n `GraphIdsFromFsBuilder, buildGraph with ${ids.length} seeders completed (${(Date.now() - start) / 1000} sec)`\n );\n return this.graph;\n }\n\n private async processManyComponents(components: Component[]) {\n this.logger.debug(\n `GraphIdsFromFsBuilder.processManyComponents depth ${this.depth}, ${components.length} components`\n );\n this.depth += 1;\n await this.importObjects(components);\n const allDependencies = await mapSeries(components, (component) => this.processOneComponent(component));\n const allDependenciesFlattened = flatten(allDependencies);\n if (allDependenciesFlattened.length) await this.processManyComponents(allDependenciesFlattened);\n }\n\n /**\n * only for components from the workspace that can be modified to add/remove dependencies, we need to make sure that\n * all their dependencies are imported.\n * once a component from scope is imported, we know that either we have its dependency graph or all flattened deps\n */\n private async importObjects(components: Component[]) {\n const workspaceIds = await this.workspace.listIds();\n const compOnWorkspaceOnly = components.filter((comp) => workspaceIds.find((id) => id.isEqual(comp.id)));\n const notImported = compOnWorkspaceOnly.map((c) => c.id).filter((id) => !this.importedIds.includes(id.toString()));\n const withScope = notImported.map((id) => id._legacy).filter((dep) => dep.hasScope());\n const scopeComponentsImporter = this.consumer.scope.scopeImporter;\n await scopeComponentsImporter.importMany({\n ids: BitIds.uniqFromArray(withScope),\n throwForDependencyNotFound: this.shouldThrowOnMissingDep,\n throwForSeederNotFound: this.shouldThrowOnMissingDep,\n reFetchUnBuiltVersion: false,\n preferDependencyGraph: true,\n });\n notImported.map((id) => this.importedIds.push(id.toString()));\n }\n\n private async processOneComponent(component: Component) {\n const idStr = component.id.toString();\n if (this.completed.includes(idStr)) return [];\n const graphFromScope = await this.workspace.getSavedGraphOfComponentIfExist(component);\n if (graphFromScope?.edges.length) {\n const isOnWorkspace = await this.workspace.hasId(component.id);\n if (isOnWorkspace) {\n const allDependenciesComps = await this.processCompFromWorkspaceWithGraph(graphFromScope, component);\n this.completed.push(idStr);\n return allDependenciesComps;\n }\n this.graph.merge([graphFromScope]);\n this.completed.push(idStr);\n return [];\n }\n\n const deps = await this.dependencyResolver.getComponentDependencies(component);\n const allDepsIds = deps.map((d) => d.componentId);\n const allDependenciesComps = await this.loadManyComponents(allDepsIds, idStr);\n\n deps.forEach((dep) => this.addDepEdge(idStr, dep));\n this.completed.push(idStr);\n\n return allDependenciesComps;\n }\n\n /**\n * this is tricky.\n * the component is in the workspace so it can be modified. dependencies can be added/removed/updated/downgraded.\n * we have the graph-dependencies from the last snap, so we prefer to use it whenever possible for performance reasons.\n * if we can't use it, we have to recursively load dependencies components and get the data from there.\n * to maximize the performance, we iterate the direct dependencies, if we find a dep with the same id in the graph,\n * then ask the graph for all its successors. otherwise, if it's not there, fallback to load the deps components.\n */\n private async processCompFromWorkspaceWithGraph(\n graphFromScope: CompIdGraph,\n component: Component\n ): Promise<Component[]> {\n const deps = await this.dependencyResolver.getComponentDependencies(component);\n const [depsInScopeGraph, depsNotInScopeGraph] = partition(deps, (dep) =>\n graphFromScope.hasNode(dep.componentId.toString())\n );\n const subGraphs = depsInScopeGraph.map((dep) => graphFromScope.successorsSubgraph([dep.componentId.toString()]));\n this.graph.merge(subGraphs);\n\n const allDepsIds = depsNotInScopeGraph.map((d) => d.componentId);\n const idStr = component.id.toString();\n const allDependenciesComps = await this.loadManyComponents(allDepsIds, idStr);\n deps.forEach((dep) => this.addDepEdge(idStr, dep));\n return allDependenciesComps;\n }\n\n private addDepEdge(idStr: string, dep: ComponentDependency) {\n const depId = dep.componentId;\n if (!this.graph.hasNode(depId.toString())) {\n if (this.shouldThrowOnMissingDep) {\n throw new Error(`buildOneComponent: missing node of ${depId.toString()}`);\n }\n this.logger.warn(`ignoring missing ${depId.toString()}`);\n return;\n }\n this.graph.setEdge(new Edge(idStr, depId.toString(), lifecycleToDepType(dep)));\n }\n\n private async loadManyComponents(componentsIds: ComponentID[], dependenciesOf?: string): Promise<Component[]> {\n const components = await mapSeries(componentsIds, async (comp) => {\n const idStr = comp.toString();\n const fromCache = this.loadedComponents[idStr];\n if (fromCache) return fromCache;\n try {\n const component = await this.workspace.get(comp);\n this.loadedComponents[idStr] = component;\n this.graph.setNode(new Node(idStr, component.id));\n return component;\n } catch (err: any) {\n if (\n err instanceof ComponentNotFound ||\n err instanceof ComponentNotFoundInScope ||\n err instanceof ScopeNotFound\n ) {\n if (dependenciesOf && !this.shouldThrowOnMissingDep) {\n this.logger.warn(\n `component ${idStr}, dependency of ${dependenciesOf} was not found. continuing without it`\n );\n return null;\n }\n throw new BitError(\n `error: component \"${idStr}\" was not found.\\nthis component is a dependency of \"${\n dependenciesOf || '<none>'\n }\" and is needed as part of the graph generation`\n );\n }\n if (dependenciesOf) this.logger.error(`failed loading dependencies of ${dependenciesOf}`);\n throw err;\n }\n });\n return compact(components);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGO,SAASA,kBAAkB,CAACC,OAA4B,EAAe;EAC5E,IAAIA,OAAO,CAACC,WAAW,EAAE,OAAO,KAAK;EACrC,QAAQD,OAAO,CAACE,SAAS;IACvB,KAAK,KAAK;MACR,OAAO,KAAK;IACd,KAAK,SAAS;MACZ,OAAO,MAAM;IACf;MACE,MAAM,IAAIC,KAAK,CAAE,aAAYH,OAAO,CAACE,SAAU,iBAAgB,CAAC;EAAC;AAEvE;AAEO,MAAME,qBAAqB,CAAC;EAOjCC,WAAW,CACDC,SAAoB,EACpBC,MAAc,EACdC,kBAA0C,EAC1CC,uBAAuB,GAAG,IAAI,EACtC;IAAA,KAJQH,SAAoB,GAApBA,SAAoB;IAAA,KACpBC,MAAc,GAAdA,MAAc;IAAA,KACdC,kBAA0C,GAA1CA,kBAA0C;IAAA,KAC1CC,uBAAuB,GAAvBA,uBAAuB;IAAA,+CAVjB,KAAIC,cAAK,GAA4B;IAAA,mDACvB,EAAE;IAAA,+CACh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CAAE,kCAAiCX,cAAe,EAAC,CAAC;QACzF,MAAMM,GAAG;MACX;IACF,CAAC,CAAC;IACF,OAAO,IAAAM,kBAAO,EAACjF,UAAU,CAAC;EAC5B;AACF;AAAC"}
1
+ {"version":3,"names":["lifecycleToDepType","compDep","isExtension","lifecycle","Error","GraphIdsFromFsBuilder","constructor","workspace","logger","dependencyResolver","shouldThrowOnMissingDep","Graph","consumer","buildGraph","ids","debug","length","start","Date","now","components","loadManyComponents","processManyComponents","graph","depth","importObjects","allDependencies","mapSeries","component","processOneComponent","allDependenciesFlattened","flatten","workspaceIds","listIds","compOnWorkspaceOnly","filter","comp","find","id","isEqual","notImported","map","c","importedIds","includes","toString","withScope","_legacy","dep","hasScope","scopeComponentsImporter","scope","scopeImporter","importMany","BitIds","uniqFromArray","throwForDependencyNotFound","throwForSeederNotFound","reFetchUnBuiltVersion","preferDependencyGraph","push","idStr","completed","graphFromScope","getSavedGraphOfComponentIfExist","edges","isOnWorkspace","hasId","allDependenciesComps","processCompFromWorkspaceWithGraph","merge","deps","getComponentDependencies","allDepsIds","d","componentId","forEach","addDepEdge","depsInScopeGraph","depsNotInScopeGraph","partition","hasNode","depsInScopeGraphIds","depsInScopeGraphIdsNotCompleted","subGraphs","successorsSubgraph","depId","warn","setEdge","Edge","componentsIds","dependenciesOf","fromCache","loadedComponents","get","setNode","Node","err","ComponentNotFound","ComponentNotFoundInScope","ScopeNotFound","BitError","error","compact"],"sources":["build-graph-ids-from-fs.ts"],"sourcesContent":["import mapSeries from 'p-map-series';\nimport { Graph, Node, Edge } from '@teambit/graph.cleargraph';\nimport { flatten, partition } from 'lodash';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport { Component, ComponentID } from '@teambit/component';\nimport BitIds from '@teambit/legacy/dist/bit-id/bit-ids';\nimport { ComponentDependency, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { CompIdGraph, DepEdgeType } from '@teambit/graph';\nimport { ComponentNotFound, ScopeNotFound } from '@teambit/legacy/dist/scope/exceptions';\nimport { ComponentNotFound as ComponentNotFoundInScope } from '@teambit/scope';\nimport compact from 'lodash.compact';\nimport { Logger } from '@teambit/logger';\nimport { BitError } from '@teambit/bit-error';\nimport { Workspace } from './workspace';\n\nexport function lifecycleToDepType(compDep: ComponentDependency): DepEdgeType {\n if (compDep.isExtension) return 'ext';\n switch (compDep.lifecycle) {\n case 'dev':\n return 'dev';\n case 'runtime':\n return 'prod';\n default:\n throw new Error(`lifecycle ${compDep.lifecycle} is not support`);\n }\n}\n\nexport class GraphIdsFromFsBuilder {\n private graph = new Graph<ComponentID, DepEdgeType>();\n private completed: string[] = [];\n private depth = 1;\n private consumer: Consumer;\n private loadedComponents: { [idStr: string]: Component } = {};\n private importedIds: string[] = [];\n constructor(\n private workspace: Workspace,\n private logger: Logger,\n private dependencyResolver: DependencyResolverMain,\n private shouldThrowOnMissingDep = true\n ) {\n this.consumer = this.workspace.consumer;\n }\n\n /**\n * create a graph with all dependencies and flattened dependencies of the given components.\n * the nodes are component-ids and the edges has a label of the dependency type.\n * to get some info about this the graph build take a look into build-graph-from-fs.buildGraph() docs.\n */\n async buildGraph(ids: ComponentID[]): Promise<Graph<ComponentID, DepEdgeType>> {\n this.logger.debug(`GraphIdsFromFsBuilder, buildGraph with ${ids.length} seeders`);\n const start = Date.now();\n const components = await this.loadManyComponents(ids);\n await this.processManyComponents(components);\n this.logger.debug(\n `GraphIdsFromFsBuilder, buildGraph with ${ids.length} seeders completed (${(Date.now() - start) / 1000} sec)`\n );\n return this.graph;\n }\n\n private async processManyComponents(components: Component[]) {\n this.logger.debug(\n `GraphIdsFromFsBuilder.processManyComponents depth ${this.depth}, ${components.length} components`\n );\n this.depth += 1;\n await this.importObjects(components);\n const allDependencies = await mapSeries(components, (component) => this.processOneComponent(component));\n const allDependenciesFlattened = flatten(allDependencies);\n if (allDependenciesFlattened.length) await this.processManyComponents(allDependenciesFlattened);\n }\n\n /**\n * only for components from the workspace that can be modified to add/remove dependencies, we need to make sure that\n * all their dependencies are imported.\n * once a component from scope is imported, we know that either we have its dependency graph or all flattened deps\n */\n private async importObjects(components: Component[]) {\n const workspaceIds = await this.workspace.listIds();\n const compOnWorkspaceOnly = components.filter((comp) => workspaceIds.find((id) => id.isEqual(comp.id)));\n const notImported = compOnWorkspaceOnly.map((c) => c.id).filter((id) => !this.importedIds.includes(id.toString()));\n const withScope = notImported.map((id) => id._legacy).filter((dep) => dep.hasScope());\n const scopeComponentsImporter = this.consumer.scope.scopeImporter;\n await scopeComponentsImporter.importMany({\n ids: BitIds.uniqFromArray(withScope),\n throwForDependencyNotFound: this.shouldThrowOnMissingDep,\n throwForSeederNotFound: this.shouldThrowOnMissingDep,\n reFetchUnBuiltVersion: false,\n preferDependencyGraph: true,\n });\n notImported.map((id) => this.importedIds.push(id.toString()));\n }\n\n private async processOneComponent(component: Component) {\n const idStr = component.id.toString();\n if (this.completed.includes(idStr)) return [];\n const graphFromScope = await this.workspace.getSavedGraphOfComponentIfExist(component);\n if (graphFromScope?.edges.length) {\n const isOnWorkspace = await this.workspace.hasId(component.id);\n if (isOnWorkspace) {\n const allDependenciesComps = await this.processCompFromWorkspaceWithGraph(graphFromScope, component);\n this.completed.push(idStr);\n return allDependenciesComps;\n }\n this.graph.merge([graphFromScope]);\n this.completed.push(idStr);\n return [];\n }\n\n const deps = await this.dependencyResolver.getComponentDependencies(component);\n const allDepsIds = deps.map((d) => d.componentId);\n const allDependenciesComps = await this.loadManyComponents(allDepsIds, idStr);\n\n deps.forEach((dep) => this.addDepEdge(idStr, dep));\n this.completed.push(idStr);\n\n return allDependenciesComps;\n }\n\n /**\n * this is tricky.\n * the component is in the workspace so it can be modified. dependencies can be added/removed/updated/downgraded.\n * we have the graph-dependencies from the last snap, so we prefer to use it whenever possible for performance reasons.\n * if we can't use it, we have to recursively load dependencies components and get the data from there.\n * to maximize the performance, we iterate the direct dependencies, if we find a dep with the same id in the graph,\n * and that id is not in the workspace then ask the graph for all its successors. otherwise, if it's not there, or\n * it's there but it's also in the workspace (which therefore can be modified), we recursively load the dep components\n * and get its dependencies.\n */\n private async processCompFromWorkspaceWithGraph(\n graphFromScope: CompIdGraph,\n component: Component\n ): Promise<Component[]> {\n const deps = await this.dependencyResolver.getComponentDependencies(component);\n const workspaceIds = await this.workspace.listIds();\n const [depsInScopeGraph, depsNotInScopeGraph] = partition(\n deps,\n (dep) =>\n graphFromScope.hasNode(dep.componentId.toString()) && !workspaceIds.find((id) => id.isEqual(dep.componentId))\n );\n\n const depsInScopeGraphIds = depsInScopeGraph.map((dep) => dep.componentId.toString());\n const depsInScopeGraphIdsNotCompleted = depsInScopeGraphIds.filter((id) => !this.completed.includes(id));\n if (depsInScopeGraphIdsNotCompleted.length) {\n const subGraphs = graphFromScope.successorsSubgraph(depsInScopeGraphIdsNotCompleted);\n this.graph.merge([subGraphs]);\n this.completed.push(...depsInScopeGraphIdsNotCompleted);\n }\n\n const allDepsIds = depsNotInScopeGraph.map((d) => d.componentId);\n const idStr = component.id.toString();\n const allDependenciesComps = await this.loadManyComponents(allDepsIds, idStr);\n deps.forEach((dep) => this.addDepEdge(idStr, dep));\n return allDependenciesComps;\n }\n\n private addDepEdge(idStr: string, dep: ComponentDependency) {\n const depId = dep.componentId;\n if (!this.graph.hasNode(depId.toString())) {\n if (this.shouldThrowOnMissingDep) {\n throw new Error(`buildOneComponent: missing node of ${depId.toString()}`);\n }\n this.logger.warn(`ignoring missing ${depId.toString()}`);\n return;\n }\n this.graph.setEdge(new Edge(idStr, depId.toString(), lifecycleToDepType(dep)));\n }\n\n private async loadManyComponents(componentsIds: ComponentID[], dependenciesOf?: string): Promise<Component[]> {\n const components = await mapSeries(componentsIds, async (comp) => {\n const idStr = comp.toString();\n const fromCache = this.loadedComponents[idStr];\n if (fromCache) return fromCache;\n try {\n const component = await this.workspace.get(comp);\n this.loadedComponents[idStr] = component;\n this.graph.setNode(new Node(idStr, component.id));\n return component;\n } catch (err: any) {\n if (\n err instanceof ComponentNotFound ||\n err instanceof ComponentNotFoundInScope ||\n err instanceof ScopeNotFound\n ) {\n if (dependenciesOf && !this.shouldThrowOnMissingDep) {\n this.logger.warn(\n `component ${idStr}, dependency of ${dependenciesOf} was not found. continuing without it`\n );\n return null;\n }\n throw new BitError(\n `error: component \"${idStr}\" was not found.\\nthis component is a dependency of \"${\n dependenciesOf || '<none>'\n }\" and is needed as part of the graph generation`\n );\n }\n if (dependenciesOf) this.logger.error(`failed loading dependencies of ${dependenciesOf}`);\n throw err;\n }\n });\n return compact(components);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGO,SAASA,kBAAkB,CAACC,OAA4B,EAAe;EAC5E,IAAIA,OAAO,CAACC,WAAW,EAAE,OAAO,KAAK;EACrC,QAAQD,OAAO,CAACE,SAAS;IACvB,KAAK,KAAK;MACR,OAAO,KAAK;IACd,KAAK,SAAS;MACZ,OAAO,MAAM;IACf;MACE,MAAM,IAAIC,KAAK,CAAE,aAAYH,OAAO,CAACE,SAAU,iBAAgB,CAAC;EAAC;AAEvE;AAEO,MAAME,qBAAqB,CAAC;EAOjCC,WAAW,CACDC,SAAoB,EACpBC,MAAc,EACdC,kBAA0C,EAC1CC,uBAAuB,GAAG,IAAI,EACtC;IAAA,KAJQH,SAAoB,GAApBA,SAAoB;IAAA,KACpBC,MAAc,GAAdA,MAAc;IAAA,KACdC,kBAA0C,GAA1CA,kBAA0C;IAAA,KAC1CC,uBAAuB,GAAvBA,uBAAuB;IAAA,+CAVj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nC,KAAK,EAAEjC,SAAS,CAACU,EAAE,CAAC,CAAC;QACjD,OAAOV,SAAS;MAClB,CAAC,CAAC,OAAOqE,GAAQ,EAAE;QACjB,IACEA,GAAG,YAAYC,+BAAiB,IAChCD,GAAG,YAAYE,0BAAwB,IACvCF,GAAG,YAAYG,2BAAa,EAC5B;UACA,IAAIT,cAAc,IAAI,CAAC,IAAI,CAACjF,uBAAuB,EAAE;YACnD,IAAI,CAACF,MAAM,CAAC+E,IAAI,CACb,aAAY1B,KAAM,mBAAkB8B,cAAe,uCAAsC,CAC3F;YACD,OAAO,IAAI;UACb;UACA,MAAM,KAAIU,oBAAQ,EACf,qBAAoBxC,KAAM,wDACzB8B,cAAc,IAAI,QACnB,iDAAgD,CAClD;QACH;QACA,IAAIA,cAAc,EAAE,IAAI,CAACnF,MAAM,CAAC8F,KAAK,CAAE,kCAAiCX,cAAe,EAAC,CAAC;QACzF,MAAMM,GAAG;MACX;IACF,CAAC,CAAC;IACF,OAAO,IAAAM,kBAAO,EAACnF,UAAU,CAAC;EAC5B;AACF;AAAC"}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@0.0.953/dist/workspace.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@0.0.953/dist/workspace.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@0.0.956/dist/workspace.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.workspace_workspace@0.0.956/dist/workspace.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -302,7 +302,7 @@ class Watcher {
302
302
  ignoreVersion: true
303
303
  }));
304
304
  if (!updatedComponentId) {
305
- // the component was removed
305
+ _logger().default.debug(`triggerCompChanges, the component ${componentId.toString()} was probably removed from .bitmap`);
306
306
  return [];
307
307
  }
308
308
  }
@@ -315,13 +315,10 @@ class Watcher {
315
315
  const compFiles = files.filter(filePath => {
316
316
  const relativeFile = this.getRelativePathLinux(filePath);
317
317
  const isCompFile = Boolean(componentMap.getFilesRelativeToConsumer().find(p => p === relativeFile));
318
- if (!isCompFile) {
319
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
320
- _logger().default.debug(`file ${filePath} is inside the component ${updatedComponentId.toString()} but configured to be ignored`);
321
- }
322
318
  return isCompFile;
323
319
  });
324
320
  if (!compFiles.length) {
321
+ _logger().default.debug(`the following files are part of the component ${componentId.toStringWithoutVersion()} but configured to be ignored:\n${files.join('\n')}'`);
325
322
  return [];
326
323
  }
327
324
  const buildResults = await this.executeWatchOperationsOnComponent(updatedComponentId, compFiles, true, initiator);
@@ -369,16 +366,20 @@ class Watcher {
369
366
  _logger().default.debug(`running OnComponentAdd hook for ${_chalk().default.bold(idStr)}`);
370
367
  this.pubsub.pub(_().WorkspaceAspect.id, this.creatOnComponentAddEvent(idStr, 'OnComponentAdd'));
371
368
  }
372
- let buildResults;
373
- try {
374
- buildResults = isChange ? await this.workspace.triggerOnComponentChange(componentId, files, initiator) : await this.workspace.triggerOnComponentAdd(componentId);
375
- } catch (err) {
376
- // do not exit the watch process on errors, just print them
377
- const msg = `found an issue during onComponentChange or onComponentAdd hooks`;
378
- _logger().default.error(msg, err);
379
- _logger().default.console(`\n${msg}: ${err.message || err}`);
380
- return [];
381
- }
369
+
370
+ // the try/catch is probably not needed here because this gets called by `handleChange()` which already has a try/catch
371
+ // I left it here commented out for now just in case, but it should be removed as soon as we're more confident
372
+
373
+ // let buildResults: OnComponentEventResult[];
374
+ // try {
375
+ const buildResults = isChange ? await this.workspace.triggerOnComponentChange(componentId, files, initiator) : await this.workspace.triggerOnComponentAdd(componentId);
376
+ // } catch (err: any) {
377
+ // // do not exit the watch process on errors, just print them
378
+ // const msg = `found an issue during onComponentChange or onComponentAdd hooks for ${idStr}`;
379
+ // logger.error(msg, err);
380
+ // logger.console(`\n${msg}: ${err.message || err}`);
381
+ // return [];
382
+ // }
382
383
  return buildResults;
383
384
  }
384
385
  creatOnComponentRemovedEvent(idStr) {
@@ -1 +1 @@
1
- {"version":3,"names":["DEBOUNCE_WAIT_MS","Watcher","constructor","workspace","pubsub","trackDirs","verbose","multipleWatchers","WatchQueue","consumer","watchAll","opts","msgs","watchOpts","pathsToWatch","getPathsToWatch","componentIds","Object","values","triggerOnPreWatch","createWatcher","watcher","fsWatcher","onStart","Promise","resolve","reject","process","env","BIT_LOG","onAll","on","onReady","filePath","startTime","Date","getTime","files","results","debounced","failureMsg","handleChange","initiator","duration","onChange","onAdd","p","onUnlink","err","onError","endsWith","BIT_MAP","bitMapChangesInProgress","buildResults","watchQueue","add","handleBitmapChanges","loader","stop","onIdle","componentId","getComponentIdByPath","logger","debug","compIdStr","toString","changedFilesPerComponent","push","sleep","triggerCompChanges","length","undefined","join","msg","error","console","message","ms","setTimeout","updatedComponentId","hasId","ids","listIds","find","id","isEqual","ignoreVersion","clearComponentCache","component","get","componentMap","state","_consumer","Error","compFiles","filter","relativeFile","getRelativePathLinux","isCompFile","Boolean","getFilesRelativeToConsumer","executeWatchOperationsOnComponent","previewsTrackDirs","_reloadConsumer","setTrackDirs","newDirs","difference","keys","removedDirs","addResults","mapSeries","dir","flat","triggerOnMultipleComponentsAdd","unwatch","executeWatchOperationsOnRemove","chalk","bold","pub","WorkspaceAspect","creatOnComponentRemovedEvent","triggerOnComponentRemove","isChange","isComponentWatchedExternally","idStr","creatOnComponentChangeEvent","creatOnComponentAddEvent","triggerOnComponentChange","triggerOnComponentAdd","OnComponentRemovedEvent","now","hook","OnComponentChangeEvent","OnComponentAddEvent","watcherData","m","_legacy","compilerId","trackDir","findTrackDirByFilePathRecursively","pathNormalizeToLinux","getPathRelativeToConsumer","parentDir","dirname","chokidar","watch","ignoreInitial","ignored","path","includes","sep","persistent","useFsEvents","componentsFromBitMap","bitMap","getAllComponents","all","map","bitId","rootDir","getRootDir","resolveComponentId","paths","pathsAbsolute","toAbsolutePath"],"sources":["watcher.ts"],"sourcesContent":["import { PubsubMain } from '@teambit/pubsub';\nimport { dirname, sep } from 'path';\nimport { difference } from 'lodash';\nimport { ComponentID } from '@teambit/component';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport loader from '@teambit/legacy/dist/cli/loader';\nimport { BIT_MAP } from '@teambit/legacy/dist/constants';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport logger from '@teambit/legacy/dist/logger/logger';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport mapSeries from 'p-map-series';\nimport chalk from 'chalk';\nimport { ChildProcess } from 'child_process';\nimport chokidar, { FSWatcher } from 'chokidar';\nimport ComponentMap from '@teambit/legacy/dist/consumer/bit-map/component-map';\nimport { PathLinux, PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';\nimport { CompilationInitiator } from '@teambit/compiler';\nimport { WorkspaceAspect } from '../';\nimport { OnComponentChangeEvent, OnComponentAddEvent, OnComponentRemovedEvent } from '../events';\nimport { Workspace } from '../workspace';\nimport { OnComponentEventResult } from '../on-component-events';\nimport { CheckTypes } from './check-types';\nimport { WatchQueue } from './watch-queue';\n\nexport type WatcherProcessData = { watchProcess: ChildProcess; compilerId: BitId; componentIds: BitId[] };\n\nexport type EventMessages = {\n onAll: Function;\n onStart: Function;\n onReady: Function;\n onChange: Function;\n onAdd: Function;\n onUnlink: Function;\n onError: Function;\n};\n\nexport type WatchOptions = {\n msgs?: EventMessages;\n initiator?: CompilationInitiator;\n verbose?: boolean; // print watch events to the console. (also ts-server events if spawnTSServer is true)\n spawnTSServer?: boolean; // needed for check types and extract API/docs.\n checkTypes?: CheckTypes; // if enabled, the spawnTSServer becomes true.\n preCompile?: boolean; // whether compile all components before start watching\n};\n\nconst DEBOUNCE_WAIT_MS = 100;\n\nexport class Watcher {\n private fsWatcher: FSWatcher;\n private changedFilesPerComponent: { [componentId: string]: string[] } = {};\n private watchQueue = new WatchQueue();\n private bitMapChangesInProgress = false;\n constructor(\n private workspace: Workspace,\n private pubsub: PubsubMain,\n private trackDirs: { [dir: PathLinux]: ComponentID } = {},\n private verbose = false,\n private multipleWatchers: WatcherProcessData[] = []\n ) {}\n\n get consumer(): Consumer {\n return this.workspace.consumer;\n }\n\n async watchAll(opts: WatchOptions) {\n const { msgs, ...watchOpts } = opts;\n // TODO: run build in the beginning of process (it's work like this in other envs)\n const pathsToWatch = await this.getPathsToWatch();\n const componentIds = Object.values(this.trackDirs);\n await this.workspace.triggerOnPreWatch(componentIds, watchOpts);\n await this.createWatcher(pathsToWatch);\n const watcher = this.fsWatcher;\n msgs?.onStart(this.workspace);\n\n return new Promise((resolve, reject) => {\n // prefix your command with \"BIT_LOG=*\" to see all watch events\n if (process.env.BIT_LOG) {\n // @ts-ignore\n if (msgs?.onAll) watcher.on('all', msgs?.onAll);\n }\n watcher.on('ready', () => {\n msgs?.onReady(this.workspace, this.trackDirs, this.verbose);\n });\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n watcher.on('change', async (filePath) => {\n const startTime = new Date().getTime();\n const { files, results, debounced, failureMsg } = await this.handleChange(filePath, opts?.initiator);\n if (debounced) {\n return;\n }\n const duration = new Date().getTime() - startTime;\n msgs?.onChange(files, results, this.verbose, duration, failureMsg);\n });\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n watcher.on('add', async (filePath) => {\n const startTime = new Date().getTime();\n const { files, results, debounced, failureMsg } = await this.handleChange(filePath, opts?.initiator);\n if (debounced) {\n return;\n }\n const duration = new Date().getTime() - startTime;\n msgs?.onAdd(files, results, this.verbose, duration, failureMsg);\n });\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n watcher.on('unlink', async (p) => {\n msgs?.onUnlink(p);\n await this.handleChange(p);\n });\n watcher.on('error', (err) => {\n msgs?.onError(err);\n reject(err);\n });\n });\n }\n\n /**\n * *** DEBOUNCING ***\n * some actions trigger multiple files changes at (almost) the same time. e.g. \"git pull\".\n * this causes some performance and instability issues. a debouncing mechanism was implemented to help with this.\n * the way how it works is that the first file of the same component starts the execution with a delay (e.g. 200ms).\n * if, in the meanwhile, another file of the same component was changed, it won't start a new execution, instead,\n * it'll only add the file to `this.changedFilesPerComponent` prop.\n * once the execution starts, it'll delete this component-id from the `this.changedFilesPerComponent` array,\n * indicating the next file-change to start a new execution.\n *\n * implementation wise, `lodash.debounce` doesn't help here, because:\n * A) it doesn't return the results, unless \"leading\" option is true. here, it must be false, otherwise, it'll start\n * the execution immediately.\n * B) it debounces the method regardless the param passes to it. so it'll disregard the component-id and will delay\n * other components undesirably.\n *\n * *** QUEUE ***\n * the debouncing helps to not execute the same component multiple times concurrently. however, multiple components\n * and .bitmap changes execution can still be processed concurrently.\n * the following example explains why this is an issue.\n * compA is changed in the .bitmap file from version 0.0.1 to 0.0.2. its files were changed as well.\n * all these changes get pulled at the same time by \"git pull\", as a result, the execution of compA and the .bitmap\n * happen at the same time.\n * during the execution of compA, the component id is parsed as compA@0.0.1, later, it asks for the Workspace for this\n * id. while the workspace is looking for this id, the .bitmap execution reloaded the consumer and changed all versions.\n * after this change, the workspace doesn't have this id anymore, which will trigger an error.\n * to ensure this won't happen, we keep a flag to indicate whether the .bitmap execution is running, and if so, all\n * other executions are paused until the queue is empty (this is done by awaiting for queue.onIdle).\n * once the queue is empty, we know the .bitmap process was done and the workspace has all new ids.\n * in the example above, at this stage, the id will be resolved to compA@0.0.2.\n * one more thing, the queue is configured to have concurrency of 1. to make sure two components are not processed at\n * the same time. (the same way is done when loading all components from the filesystem/scope).\n * this way we can also ensure that if compA was started before the .bitmap execution, it will complete before the\n * .bitmap execution starts.\n */\n private async handleChange(\n filePath: string,\n initiator?: CompilationInitiator\n ): Promise<{\n results: OnComponentEventResult[];\n files?: string[];\n failureMsg?: string;\n debounced?: boolean;\n }> {\n try {\n if (filePath.endsWith(BIT_MAP)) {\n this.bitMapChangesInProgress = true;\n const buildResults = await this.watchQueue.add(() => this.handleBitmapChanges());\n this.bitMapChangesInProgress = false;\n loader.stop();\n return { results: buildResults, files: [filePath] };\n }\n if (this.bitMapChangesInProgress) {\n await this.watchQueue.onIdle();\n }\n const componentId = this.getComponentIdByPath(filePath);\n if (!componentId) {\n const failureMsg = `file ${filePath} is not part of any component, ignoring it`;\n logger.debug(failureMsg);\n loader.stop();\n return { results: [], files: [filePath], failureMsg };\n }\n const compIdStr = componentId.toString();\n if (this.changedFilesPerComponent[compIdStr]) {\n this.changedFilesPerComponent[compIdStr].push(filePath);\n loader.stop();\n return { results: [], debounced: true };\n }\n this.changedFilesPerComponent[compIdStr] = [filePath];\n await this.sleep(DEBOUNCE_WAIT_MS);\n const files = this.changedFilesPerComponent[compIdStr];\n delete this.changedFilesPerComponent[compIdStr];\n\n const buildResults = await this.watchQueue.add(() => this.triggerCompChanges(componentId, files, initiator));\n const failureMsg = buildResults.length\n ? undefined\n : `files ${files.join(', ')} are inside the component ${compIdStr} but configured to be ignored`;\n loader.stop();\n return { results: buildResults, files, failureMsg };\n } catch (err: any) {\n const msg = `watcher found an error while handling ${filePath}`;\n logger.error(msg, err);\n logger.console(`${msg}, ${err.message}`);\n loader.stop();\n return { results: [], files: [filePath], failureMsg: err.message };\n }\n }\n\n private async sleep(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n\n /**\n * if a file was added/remove, once the component is loaded, it changes .bitmap, and then the\n * entire cache is invalidated and the consumer is reloaded.\n * when a file just changed, no need to reload the consumer, it is enough to just delete the\n * component from the cache (both, workspace and consumer)\n */\n private async triggerCompChanges(\n componentId: ComponentID,\n files: string[],\n initiator?: CompilationInitiator\n ): Promise<OnComponentEventResult[]> {\n let updatedComponentId: ComponentID | undefined = componentId;\n if (!(await this.workspace.hasId(componentId))) {\n // bitmap has changed meanwhile, which triggered `handleBitmapChanges`, which re-loaded consumer and updated versions\n // so the original componentId might not be in the workspace now, and we need to find the updated one\n const ids = await this.workspace.listIds();\n updatedComponentId = ids.find((id) => id.isEqual(componentId, { ignoreVersion: true }));\n if (!updatedComponentId) {\n // the component was removed\n return [];\n }\n }\n this.workspace.clearComponentCache(updatedComponentId);\n const component = await this.workspace.get(updatedComponentId);\n const componentMap: ComponentMap = component.state._consumer.componentMap;\n if (!componentMap) {\n throw new Error(\n `unable to find componentMap for ${updatedComponentId.toString()}, make sure this component is in .bitmap`\n );\n }\n const compFiles = files.filter((filePath) => {\n const relativeFile = this.getRelativePathLinux(filePath);\n const isCompFile = Boolean(componentMap.getFilesRelativeToConsumer().find((p) => p === relativeFile));\n if (!isCompFile) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n logger.debug(\n `file ${filePath} is inside the component ${updatedComponentId!.toString()} but configured to be ignored`\n );\n }\n return isCompFile;\n });\n if (!compFiles.length) {\n return [];\n }\n const buildResults = await this.executeWatchOperationsOnComponent(updatedComponentId, compFiles, true, initiator);\n return buildResults;\n }\n\n /**\n * if .bitmap changed, it's possible that a new component has been added. trigger onComponentAdd.\n */\n private async handleBitmapChanges(): Promise<OnComponentEventResult[]> {\n const previewsTrackDirs = { ...this.trackDirs };\n await this.workspace._reloadConsumer();\n await this.setTrackDirs();\n const newDirs: string[] = difference(Object.keys(this.trackDirs), Object.keys(previewsTrackDirs));\n const removedDirs: string[] = difference(Object.keys(previewsTrackDirs), Object.keys(this.trackDirs));\n const results: OnComponentEventResult[] = [];\n if (newDirs.length) {\n this.fsWatcher.add(newDirs);\n const addResults = await mapSeries(newDirs, async (dir) =>\n this.executeWatchOperationsOnComponent(this.trackDirs[dir], [], false)\n );\n results.push(...addResults.flat());\n await this.workspace.triggerOnMultipleComponentsAdd();\n }\n if (removedDirs.length) {\n await this.fsWatcher.unwatch(removedDirs);\n await mapSeries(removedDirs, (dir) => this.executeWatchOperationsOnRemove(previewsTrackDirs[dir]));\n }\n return results;\n }\n\n private async executeWatchOperationsOnRemove(componentId: ComponentID) {\n logger.debug(`running OnComponentRemove hook for ${chalk.bold(componentId.toString())}`);\n this.pubsub.pub(WorkspaceAspect.id, this.creatOnComponentRemovedEvent(componentId.toString()));\n await this.workspace.triggerOnComponentRemove(componentId);\n }\n\n private async executeWatchOperationsOnComponent(\n componentId: ComponentID,\n files: string[],\n isChange = true,\n initiator?: CompilationInitiator\n ): Promise<OnComponentEventResult[]> {\n if (this.isComponentWatchedExternally(componentId)) {\n // update capsule, once done, it automatically triggers the external watcher\n await this.workspace.get(componentId);\n return [];\n }\n const idStr = componentId.toString();\n\n if (isChange) {\n logger.debug(`running OnComponentChange hook for ${chalk.bold(idStr)}`);\n this.pubsub.pub(WorkspaceAspect.id, this.creatOnComponentChangeEvent(idStr, 'OnComponentChange'));\n } else {\n logger.debug(`running OnComponentAdd hook for ${chalk.bold(idStr)}`);\n this.pubsub.pub(WorkspaceAspect.id, this.creatOnComponentAddEvent(idStr, 'OnComponentAdd'));\n }\n\n let buildResults: OnComponentEventResult[];\n try {\n buildResults = isChange\n ? await this.workspace.triggerOnComponentChange(componentId, files, initiator)\n : await this.workspace.triggerOnComponentAdd(componentId);\n } catch (err: any) {\n // do not exit the watch process on errors, just print them\n const msg = `found an issue during onComponentChange or onComponentAdd hooks`;\n logger.error(msg, err);\n logger.console(`\\n${msg}: ${err.message || err}`);\n return [];\n }\n return buildResults;\n }\n\n private creatOnComponentRemovedEvent(idStr) {\n return new OnComponentRemovedEvent(Date.now(), idStr);\n }\n\n private creatOnComponentChangeEvent(idStr, hook) {\n return new OnComponentChangeEvent(Date.now(), idStr, hook);\n }\n\n private creatOnComponentAddEvent(idStr, hook) {\n return new OnComponentAddEvent(Date.now(), idStr, hook);\n }\n\n private isComponentWatchedExternally(componentId: ComponentID) {\n const watcherData = this.multipleWatchers.find((m) => m.componentIds.find((id) => id.isEqual(componentId._legacy)));\n if (watcherData) {\n logger.debug(`${componentId.toString()} is watched by ${watcherData.compilerId.toString()}`);\n return true;\n }\n return false;\n }\n\n private getComponentIdByPath(filePath: string): ComponentID | null {\n const relativeFile = this.getRelativePathLinux(filePath);\n const trackDir = this.findTrackDirByFilePathRecursively(relativeFile);\n if (!trackDir) {\n // the file is not part of any component. If it was a new component, or a new file of\n // existing component, then, handleBitmapChanges() should deal with it.\n return null;\n }\n return this.trackDirs[trackDir];\n }\n\n private getRelativePathLinux(filePath: string) {\n return pathNormalizeToLinux(this.consumer.getPathRelativeToConsumer(filePath));\n }\n\n private findTrackDirByFilePathRecursively(filePath: string): string | null {\n if (this.trackDirs[filePath]) return filePath;\n const parentDir = dirname(filePath);\n if (parentDir === filePath) return null;\n return this.findTrackDirByFilePathRecursively(parentDir);\n }\n\n private async createWatcher(pathsToWatch: string[]) {\n this.fsWatcher = chokidar.watch(pathsToWatch, {\n ignoreInitial: true,\n // Using the function way since the regular way not working as expected\n // It might be solved when upgrading to chokidar > 3.0.0\n // See:\n // https://github.com/paulmillr/chokidar/issues/773\n // https://github.com/paulmillr/chokidar/issues/492\n // https://github.com/paulmillr/chokidar/issues/724\n ignored: (path) => {\n // Ignore package.json temporarily since it cerates endless loop since it's re-written after each build\n if (path.includes(`${sep}node_modules${sep}`) || path.includes(`${sep}package.json`)) {\n return true;\n }\n return false;\n },\n persistent: true,\n useFsEvents: false,\n });\n }\n\n async setTrackDirs() {\n this.trackDirs = {};\n const componentsFromBitMap = this.consumer.bitMap.getAllComponents();\n await Promise.all(\n componentsFromBitMap.map(async (componentMap) => {\n const bitId = componentMap.id;\n const rootDir = componentMap.getRootDir();\n if (!rootDir) throw new Error(`${bitId.toString()} has no rootDir, which is invalid in Harmony`);\n const componentId = await this.workspace.resolveComponentId(bitId);\n this.trackDirs[rootDir] = componentId;\n })\n );\n }\n\n private async getPathsToWatch(): Promise<PathOsBasedAbsolute[]> {\n await this.setTrackDirs();\n const paths = [...Object.keys(this.trackDirs), BIT_MAP];\n const pathsAbsolute = paths.map((dir) => this.consumer.toAbsolutePath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,CAAC2J,cAAc,CAACrD,GAAG,CAAC,CAAC;IAC3E,OAAOoD,aAAa;EACtB;AACF;AAAC"}
1
+ {"version":3,"names":["DEBOUNCE_WAIT_MS","Watcher","constructor","workspace","pubsub","trackDirs","verbose","multipleWatchers","WatchQueue","consumer","watchAll","opts","msgs","watchOpts","pathsToWatch","getPathsToWatch","componentIds","Object","values","triggerOnPreWatch","createWatcher","watcher","fsWatcher","onStart","Promise","resolve","reject","process","env","BIT_LOG","onAll","on","onReady","filePath","startTime","Date","getTime","files","results","debounced","failureMsg","handleChange","initiator","duration","onChange","onAdd","p","onUnlink","err","onError","endsWith","BIT_MAP","bitMapChangesInProgress","buildResults","watchQueue","add","handleBitmapChanges","loader","stop","onIdle","componentId","getComponentIdByPath","logger","debug","compIdStr","toString","changedFilesPerComponent","push","sleep","triggerCompChanges","length","undefined","join","msg","error","console","message","ms","setTimeout","updatedComponentId","hasId","ids","listIds","find","id","isEqual","ignoreVersion","clearComponentCache","component","get","componentMap","state","_consumer","Error","compFiles","filter","relativeFile","getRelativePathLinux","isCompFile","Boolean","getFilesRelativeToConsumer","toStringWithoutVersion","executeWatchOperationsOnComponent","previewsTrackDirs","_reloadConsumer","setTrackDirs","newDirs","difference","keys","removedDirs","addResults","mapSeries","dir","flat","triggerOnMultipleComponentsAdd","unwatch","executeWatchOperationsOnRemove","chalk","bold","pub","WorkspaceAspect","creatOnComponentRemovedEvent","triggerOnComponentRemove","isChange","isComponentWatchedExternally","idStr","creatOnComponentChangeEvent","creatOnComponentAddEvent","triggerOnComponentChange","triggerOnComponentAdd","OnComponentRemovedEvent","now","hook","OnComponentChangeEvent","OnComponentAddEvent","watcherData","m","_legacy","compilerId","trackDir","findTrackDirByFilePathRecursively","pathNormalizeToLinux","getPathRelativeToConsumer","parentDir","dirname","chokidar","watch","ignoreInitial","ignored","path","includes","sep","persistent","useFsEvents","componentsFromBitMap","bitMap","getAllComponents","all","map","bitId","rootDir","getRootDir","resolveComponentId","paths","pathsAbsolute","toAbsolutePath"],"sources":["watcher.ts"],"sourcesContent":["import { PubsubMain } from '@teambit/pubsub';\nimport { dirname, sep } from 'path';\nimport { difference } from 'lodash';\nimport { ComponentID } from '@teambit/component';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport loader from '@teambit/legacy/dist/cli/loader';\nimport { BIT_MAP } from '@teambit/legacy/dist/constants';\nimport { Consumer } from '@teambit/legacy/dist/consumer';\nimport logger from '@teambit/legacy/dist/logger/logger';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport mapSeries from 'p-map-series';\nimport chalk from 'chalk';\nimport { ChildProcess } from 'child_process';\nimport chokidar, { FSWatcher } from 'chokidar';\nimport ComponentMap from '@teambit/legacy/dist/consumer/bit-map/component-map';\nimport { PathLinux, PathOsBasedAbsolute } from '@teambit/legacy/dist/utils/path';\nimport { CompilationInitiator } from '@teambit/compiler';\nimport { WorkspaceAspect } from '../';\nimport { OnComponentChangeEvent, OnComponentAddEvent, OnComponentRemovedEvent } from '../events';\nimport { Workspace } from '../workspace';\nimport { OnComponentEventResult } from '../on-component-events';\nimport { CheckTypes } from './check-types';\nimport { WatchQueue } from './watch-queue';\n\nexport type WatcherProcessData = { watchProcess: ChildProcess; compilerId: BitId; componentIds: BitId[] };\n\nexport type EventMessages = {\n onAll: Function;\n onStart: Function;\n onReady: Function;\n onChange: Function;\n onAdd: Function;\n onUnlink: Function;\n onError: Function;\n};\n\nexport type WatchOptions = {\n msgs?: EventMessages;\n initiator?: CompilationInitiator;\n verbose?: boolean; // print watch events to the console. (also ts-server events if spawnTSServer is true)\n spawnTSServer?: boolean; // needed for check types and extract API/docs.\n checkTypes?: CheckTypes; // if enabled, the spawnTSServer becomes true.\n preCompile?: boolean; // whether compile all components before start watching\n};\n\nconst DEBOUNCE_WAIT_MS = 100;\n\nexport class Watcher {\n private fsWatcher: FSWatcher;\n private changedFilesPerComponent: { [componentId: string]: string[] } = {};\n private watchQueue = new WatchQueue();\n private bitMapChangesInProgress = false;\n constructor(\n private workspace: Workspace,\n private pubsub: PubsubMain,\n private trackDirs: { [dir: PathLinux]: ComponentID } = {},\n private verbose = false,\n private multipleWatchers: WatcherProcessData[] = []\n ) {}\n\n get consumer(): Consumer {\n return this.workspace.consumer;\n }\n\n async watchAll(opts: WatchOptions) {\n const { msgs, ...watchOpts } = opts;\n // TODO: run build in the beginning of process (it's work like this in other envs)\n const pathsToWatch = await this.getPathsToWatch();\n const componentIds = Object.values(this.trackDirs);\n await this.workspace.triggerOnPreWatch(componentIds, watchOpts);\n await this.createWatcher(pathsToWatch);\n const watcher = this.fsWatcher;\n msgs?.onStart(this.workspace);\n\n return new Promise((resolve, reject) => {\n // prefix your command with \"BIT_LOG=*\" to see all watch events\n if (process.env.BIT_LOG) {\n // @ts-ignore\n if (msgs?.onAll) watcher.on('all', msgs?.onAll);\n }\n watcher.on('ready', () => {\n msgs?.onReady(this.workspace, this.trackDirs, this.verbose);\n });\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n watcher.on('change', async (filePath) => {\n const startTime = new Date().getTime();\n const { files, results, debounced, failureMsg } = await this.handleChange(filePath, opts?.initiator);\n if (debounced) {\n return;\n }\n const duration = new Date().getTime() - startTime;\n msgs?.onChange(files, results, this.verbose, duration, failureMsg);\n });\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n watcher.on('add', async (filePath) => {\n const startTime = new Date().getTime();\n const { files, results, debounced, failureMsg } = await this.handleChange(filePath, opts?.initiator);\n if (debounced) {\n return;\n }\n const duration = new Date().getTime() - startTime;\n msgs?.onAdd(files, results, this.verbose, duration, failureMsg);\n });\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n watcher.on('unlink', async (p) => {\n msgs?.onUnlink(p);\n await this.handleChange(p);\n });\n watcher.on('error', (err) => {\n msgs?.onError(err);\n reject(err);\n });\n });\n }\n\n /**\n * *** DEBOUNCING ***\n * some actions trigger multiple files changes at (almost) the same time. e.g. \"git pull\".\n * this causes some performance and instability issues. a debouncing mechanism was implemented to help with this.\n * the way how it works is that the first file of the same component starts the execution with a delay (e.g. 200ms).\n * if, in the meanwhile, another file of the same component was changed, it won't start a new execution, instead,\n * it'll only add the file to `this.changedFilesPerComponent` prop.\n * once the execution starts, it'll delete this component-id from the `this.changedFilesPerComponent` array,\n * indicating the next file-change to start a new execution.\n *\n * implementation wise, `lodash.debounce` doesn't help here, because:\n * A) it doesn't return the results, unless \"leading\" option is true. here, it must be false, otherwise, it'll start\n * the execution immediately.\n * B) it debounces the method regardless the param passes to it. so it'll disregard the component-id and will delay\n * other components undesirably.\n *\n * *** QUEUE ***\n * the debouncing helps to not execute the same component multiple times concurrently. however, multiple components\n * and .bitmap changes execution can still be processed concurrently.\n * the following example explains why this is an issue.\n * compA is changed in the .bitmap file from version 0.0.1 to 0.0.2. its files were changed as well.\n * all these changes get pulled at the same time by \"git pull\", as a result, the execution of compA and the .bitmap\n * happen at the same time.\n * during the execution of compA, the component id is parsed as compA@0.0.1, later, it asks for the Workspace for this\n * id. while the workspace is looking for this id, the .bitmap execution reloaded the consumer and changed all versions.\n * after this change, the workspace doesn't have this id anymore, which will trigger an error.\n * to ensure this won't happen, we keep a flag to indicate whether the .bitmap execution is running, and if so, all\n * other executions are paused until the queue is empty (this is done by awaiting for queue.onIdle).\n * once the queue is empty, we know the .bitmap process was done and the workspace has all new ids.\n * in the example above, at this stage, the id will be resolved to compA@0.0.2.\n * one more thing, the queue is configured to have concurrency of 1. to make sure two components are not processed at\n * the same time. (the same way is done when loading all components from the filesystem/scope).\n * this way we can also ensure that if compA was started before the .bitmap execution, it will complete before the\n * .bitmap execution starts.\n */\n private async handleChange(\n filePath: string,\n initiator?: CompilationInitiator\n ): Promise<{\n results: OnComponentEventResult[];\n files?: string[];\n failureMsg?: string;\n debounced?: boolean;\n }> {\n try {\n if (filePath.endsWith(BIT_MAP)) {\n this.bitMapChangesInProgress = true;\n const buildResults = await this.watchQueue.add(() => this.handleBitmapChanges());\n this.bitMapChangesInProgress = false;\n loader.stop();\n return { results: buildResults, files: [filePath] };\n }\n if (this.bitMapChangesInProgress) {\n await this.watchQueue.onIdle();\n }\n const componentId = this.getComponentIdByPath(filePath);\n if (!componentId) {\n const failureMsg = `file ${filePath} is not part of any component, ignoring it`;\n logger.debug(failureMsg);\n loader.stop();\n return { results: [], files: [filePath], failureMsg };\n }\n const compIdStr = componentId.toString();\n if (this.changedFilesPerComponent[compIdStr]) {\n this.changedFilesPerComponent[compIdStr].push(filePath);\n loader.stop();\n return { results: [], debounced: true };\n }\n this.changedFilesPerComponent[compIdStr] = [filePath];\n await this.sleep(DEBOUNCE_WAIT_MS);\n const files = this.changedFilesPerComponent[compIdStr];\n delete this.changedFilesPerComponent[compIdStr];\n\n const buildResults = await this.watchQueue.add(() => this.triggerCompChanges(componentId, files, initiator));\n const failureMsg = buildResults.length\n ? undefined\n : `files ${files.join(', ')} are inside the component ${compIdStr} but configured to be ignored`;\n loader.stop();\n return { results: buildResults, files, failureMsg };\n } catch (err: any) {\n const msg = `watcher found an error while handling ${filePath}`;\n logger.error(msg, err);\n logger.console(`${msg}, ${err.message}`);\n loader.stop();\n return { results: [], files: [filePath], failureMsg: err.message };\n }\n }\n\n private async sleep(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n\n /**\n * if a file was added/remove, once the component is loaded, it changes .bitmap, and then the\n * entire cache is invalidated and the consumer is reloaded.\n * when a file just changed, no need to reload the consumer, it is enough to just delete the\n * component from the cache (both, workspace and consumer)\n */\n private async triggerCompChanges(\n componentId: ComponentID,\n files: string[],\n initiator?: CompilationInitiator\n ): Promise<OnComponentEventResult[]> {\n let updatedComponentId: ComponentID | undefined = componentId;\n if (!(await this.workspace.hasId(componentId))) {\n // bitmap has changed meanwhile, which triggered `handleBitmapChanges`, which re-loaded consumer and updated versions\n // so the original componentId might not be in the workspace now, and we need to find the updated one\n const ids = await this.workspace.listIds();\n updatedComponentId = ids.find((id) => id.isEqual(componentId, { ignoreVersion: true }));\n if (!updatedComponentId) {\n logger.debug(`triggerCompChanges, the component ${componentId.toString()} was probably removed from .bitmap`);\n return [];\n }\n }\n this.workspace.clearComponentCache(updatedComponentId);\n const component = await this.workspace.get(updatedComponentId);\n const componentMap: ComponentMap = component.state._consumer.componentMap;\n if (!componentMap) {\n throw new Error(\n `unable to find componentMap for ${updatedComponentId.toString()}, make sure this component is in .bitmap`\n );\n }\n const compFiles = files.filter((filePath) => {\n const relativeFile = this.getRelativePathLinux(filePath);\n const isCompFile = Boolean(componentMap.getFilesRelativeToConsumer().find((p) => p === relativeFile));\n return isCompFile;\n });\n if (!compFiles.length) {\n logger.debug(\n `the following files are part of the component ${componentId.toStringWithoutVersion()} but configured to be ignored:\\n${files.join(\n '\\n'\n )}'`\n );\n return [];\n }\n const buildResults = await this.executeWatchOperationsOnComponent(updatedComponentId, compFiles, true, initiator);\n return buildResults;\n }\n\n /**\n * if .bitmap changed, it's possible that a new component has been added. trigger onComponentAdd.\n */\n private async handleBitmapChanges(): Promise<OnComponentEventResult[]> {\n const previewsTrackDirs = { ...this.trackDirs };\n await this.workspace._reloadConsumer();\n await this.setTrackDirs();\n const newDirs: string[] = difference(Object.keys(this.trackDirs), Object.keys(previewsTrackDirs));\n const removedDirs: string[] = difference(Object.keys(previewsTrackDirs), Object.keys(this.trackDirs));\n const results: OnComponentEventResult[] = [];\n if (newDirs.length) {\n this.fsWatcher.add(newDirs);\n const addResults = await mapSeries(newDirs, async (dir) =>\n this.executeWatchOperationsOnComponent(this.trackDirs[dir], [], false)\n );\n results.push(...addResults.flat());\n await this.workspace.triggerOnMultipleComponentsAdd();\n }\n if (removedDirs.length) {\n await this.fsWatcher.unwatch(removedDirs);\n await mapSeries(removedDirs, (dir) => this.executeWatchOperationsOnRemove(previewsTrackDirs[dir]));\n }\n return results;\n }\n\n private async executeWatchOperationsOnRemove(componentId: ComponentID) {\n logger.debug(`running OnComponentRemove hook for ${chalk.bold(componentId.toString())}`);\n this.pubsub.pub(WorkspaceAspect.id, this.creatOnComponentRemovedEvent(componentId.toString()));\n await this.workspace.triggerOnComponentRemove(componentId);\n }\n\n private async executeWatchOperationsOnComponent(\n componentId: ComponentID,\n files: string[],\n isChange = true,\n initiator?: CompilationInitiator\n ): Promise<OnComponentEventResult[]> {\n if (this.isComponentWatchedExternally(componentId)) {\n // update capsule, once done, it automatically triggers the external watcher\n await this.workspace.get(componentId);\n return [];\n }\n const idStr = componentId.toString();\n\n if (isChange) {\n logger.debug(`running OnComponentChange hook for ${chalk.bold(idStr)}`);\n this.pubsub.pub(WorkspaceAspect.id, this.creatOnComponentChangeEvent(idStr, 'OnComponentChange'));\n } else {\n logger.debug(`running OnComponentAdd hook for ${chalk.bold(idStr)}`);\n this.pubsub.pub(WorkspaceAspect.id, this.creatOnComponentAddEvent(idStr, 'OnComponentAdd'));\n }\n\n // the try/catch is probably not needed here because this gets called by `handleChange()` which already has a try/catch\n // I left it here commented out for now just in case, but it should be removed as soon as we're more confident\n\n // let buildResults: OnComponentEventResult[];\n // try {\n const buildResults = isChange\n ? await this.workspace.triggerOnComponentChange(componentId, files, initiator)\n : await this.workspace.triggerOnComponentAdd(componentId);\n // } catch (err: any) {\n // // do not exit the watch process on errors, just print them\n // const msg = `found an issue during onComponentChange or onComponentAdd hooks for ${idStr}`;\n // logger.error(msg, err);\n // logger.console(`\\n${msg}: ${err.message || err}`);\n // return [];\n // }\n return buildResults;\n }\n\n private creatOnComponentRemovedEvent(idStr) {\n return new OnComponentRemovedEvent(Date.now(), idStr);\n }\n\n private creatOnComponentChangeEvent(idStr, hook) {\n return new OnComponentChangeEvent(Date.now(), idStr, hook);\n }\n\n private creatOnComponentAddEvent(idStr, hook) {\n return new OnComponentAddEvent(Date.now(), idStr, hook);\n }\n\n private isComponentWatchedExternally(componentId: ComponentID) {\n const watcherData = this.multipleWatchers.find((m) => m.componentIds.find((id) => id.isEqual(componentId._legacy)));\n if (watcherData) {\n logger.debug(`${componentId.toString()} is watched by ${watcherData.compilerId.toString()}`);\n return true;\n }\n return false;\n }\n\n private getComponentIdByPath(filePath: string): ComponentID | null {\n const relativeFile = this.getRelativePathLinux(filePath);\n const trackDir = this.findTrackDirByFilePathRecursively(relativeFile);\n if (!trackDir) {\n // the file is not part of any component. If it was a new component, or a new file of\n // existing component, then, handleBitmapChanges() should deal with it.\n return null;\n }\n return this.trackDirs[trackDir];\n }\n\n private getRelativePathLinux(filePath: string) {\n return pathNormalizeToLinux(this.consumer.getPathRelativeToConsumer(filePath));\n }\n\n private findTrackDirByFilePathRecursively(filePath: string): string | null {\n if (this.trackDirs[filePath]) return filePath;\n const parentDir = dirname(filePath);\n if (parentDir === filePath) return null;\n return this.findTrackDirByFilePathRecursively(parentDir);\n }\n\n private async createWatcher(pathsToWatch: string[]) {\n this.fsWatcher = chokidar.watch(pathsToWatch, {\n ignoreInitial: true,\n // Using the function way since the regular way not working as expected\n // It might be solved when upgrading to chokidar > 3.0.0\n // See:\n // https://github.com/paulmillr/chokidar/issues/773\n // https://github.com/paulmillr/chokidar/issues/492\n // https://github.com/paulmillr/chokidar/issues/724\n ignored: (path) => {\n // Ignore package.json temporarily since it cerates endless loop since it's re-written after each build\n if (path.includes(`${sep}node_modules${sep}`) || path.includes(`${sep}package.json`)) {\n return true;\n }\n return false;\n },\n persistent: true,\n useFsEvents: false,\n });\n }\n\n async setTrackDirs() {\n this.trackDirs = {};\n const componentsFromBitMap = this.consumer.bitMap.getAllComponents();\n await Promise.all(\n componentsFromBitMap.map(async (componentMap) => {\n const bitId = componentMap.id;\n const rootDir = componentMap.getRootDir();\n if (!rootDir) throw new Error(`${bitId.toString()} has no rootDir, which is invalid in Harmony`);\n const componentId = await this.workspace.resolveComponentId(bitId);\n this.trackDirs[rootDir] = componentId;\n })\n );\n }\n\n private async getPathsToWatch(): Promise<PathOsBasedAbsolute[]> {\n await this.setTrackDirs();\n const paths = [...Object.keys(this.trackDirs), BIT_MAP];\n const pathsAbsolute = paths.map((dir) => this.consumer.toAbsolutePath(dir));\n return pathsAbsolute;\n }\n}\n"],"mappings":";;;;;;;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AC,EAAE;UACpF,OAAO,IAAI;QACb;QACA,OAAO,KAAK;MACd,CAAC;MACDC,UAAU,EAAE,IAAI;MAChBC,WAAW,EAAE;IACf,CAAC,CAAC;EACJ;EAEA,MAAMhD,YAAY,GAAG;IACnB,IAAI,CAACpG,SAAS,GAAG,CAAC,CAAC;IACnB,MAAMqJ,oBAAoB,GAAG,IAAI,CAACjJ,QAAQ,CAACkJ,MAAM,CAACC,gBAAgB,EAAE;IACpE,MAAMpI,OAAO,CAACqI,GAAG,CACfH,oBAAoB,CAACI,GAAG,CAAC,MAAOpE,YAAY,IAAK;MAC/C,MAAMqE,KAAK,GAAGrE,YAAY,CAACN,EAAE;MAC7B,MAAM4E,OAAO,GAAGtE,YAAY,CAACuE,UAAU,EAAE;MACzC,IAAI,CAACD,OAAO,EAAE,MAAM,IAAInE,KAAK,CAAE,GAAEkE,KAAK,CAAC9F,QAAQ,EAAG,8CAA6C,CAAC;MAChG,MAAML,WAAW,GAAG,MAAM,IAAI,CAACzD,SAAS,CAAC+J,kBAAkB,CAACH,KAAK,CAAC;MAClE,IAAI,CAAC1J,SAAS,CAAC2J,OAAO,CAAC,GAAGpG,WAAW;IACvC,CAAC,CAAC,CACH;EACH;EAEA,MAAc7C,eAAe,GAAmC;IAC9D,MAAM,IAAI,CAAC0F,YAAY,EAAE;IACzB,MAAM0D,KAAK,GAAG,CAAC,GAAGlJ,MAAM,CAAC2F,IAAI,CAAC,IAAI,CAACvG,SAAS,CAAC,EAAE8C,oBAAO,CAAC;IACvD,MAAMiH,aAAa,GAAGD,KAAK,CAACL,GAAG,CAAE9C,GAAG,IAAK,IAAI,CAACvG,QAAQ,CAAC4J,cAAc,CAACrD,GAAG,CAAC,CAAC;IAC3E,OAAOoD,aAAa;EACtB;AACF;AAAC"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/workspace",
3
- "version": "0.0.953",
3
+ "version": "0.0.956",
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.953"
9
+ "version": "0.0.956"
10
10
  },
11
11
  "dependencies": {
12
12
  "lodash": "4.17.21",
@@ -35,48 +35,48 @@
35
35
  "@teambit/base-ui.surfaces.split-pane.split-pane": "1.0.0",
36
36
  "@teambit/bit-error": "0.0.402",
37
37
  "@teambit/component-id": "0.0.425",
38
- "@teambit/lane-id": "0.0.156",
39
- "@teambit/component": "0.0.953",
40
- "@teambit/dependency-resolver": "0.0.953",
41
- "@teambit/logger": "0.0.731",
42
- "@teambit/scope": "0.0.953",
43
- "@teambit/graph": "0.0.953",
44
- "@teambit/cli": "0.0.638",
45
- "@teambit/isolator": "0.0.953",
46
- "@teambit/component-tree": "0.0.741",
38
+ "@teambit/lane-id": "0.0.159",
39
+ "@teambit/component": "0.0.956",
40
+ "@teambit/dependency-resolver": "0.0.956",
41
+ "@teambit/logger": "0.0.734",
42
+ "@teambit/scope": "0.0.956",
43
+ "@teambit/graph": "0.0.956",
44
+ "@teambit/cli": "0.0.641",
45
+ "@teambit/isolator": "0.0.956",
46
+ "@teambit/component-tree": "0.0.744",
47
47
  "@teambit/component.ui.component-status-resolver": "0.0.503",
48
- "@teambit/lanes.hooks.use-lanes": "0.0.102",
48
+ "@teambit/lanes.hooks.use-lanes": "0.0.105",
49
49
  "@teambit/harmony.modules.resolved-component": "0.0.491",
50
- "@teambit/compiler": "0.0.953",
51
- "@teambit/graphql": "0.0.953",
52
- "@teambit/aspect-loader": "0.0.953",
53
- "@teambit/bundler": "0.0.953",
54
- "@teambit/envs": "0.0.953",
55
- "@teambit/pubsub": "0.0.953",
56
- "@teambit/ui": "0.0.953",
57
- "@teambit/variants": "0.0.743",
50
+ "@teambit/compiler": "0.0.956",
51
+ "@teambit/graphql": "0.0.956",
52
+ "@teambit/aspect-loader": "0.0.956",
53
+ "@teambit/bundler": "0.0.956",
54
+ "@teambit/envs": "0.0.956",
55
+ "@teambit/pubsub": "0.0.956",
56
+ "@teambit/ui": "0.0.956",
57
+ "@teambit/variants": "0.0.746",
58
58
  "@teambit/component-issues": "0.0.84",
59
- "@teambit/config": "0.0.651",
59
+ "@teambit/config": "0.0.654",
60
60
  "@teambit/harmony.modules.requireable-component": "0.0.491",
61
61
  "@teambit/legacy-bit-id": "0.0.421",
62
62
  "@teambit/workspace.modules.match-pattern": "0.0.498",
63
- "@teambit/component.ui.component-drawer": "0.0.196",
63
+ "@teambit/component.ui.component-drawer": "0.0.199",
64
64
  "@teambit/design.ui.tree": "0.0.15",
65
- "@teambit/lanes.hooks.use-lane-components": "0.0.101",
66
- "@teambit/ui-foundation.ui.side-bar": "0.0.713",
67
- "@teambit/command-bar": "0.0.953",
68
- "@teambit/component.ui.component-filters.component-filter-context": "0.0.71",
69
- "@teambit/component.ui.component-filters.deprecate-filter": "0.0.71",
70
- "@teambit/component.ui.component-filters.env-filter": "0.0.77",
71
- "@teambit/component.ui.component-filters.show-main-filter": "0.0.64",
72
- "@teambit/sidebar": "0.0.953",
65
+ "@teambit/lanes.hooks.use-lane-components": "0.0.104",
66
+ "@teambit/ui-foundation.ui.side-bar": "0.0.716",
67
+ "@teambit/command-bar": "0.0.956",
68
+ "@teambit/component.ui.component-filters.component-filter-context": "0.0.74",
69
+ "@teambit/component.ui.component-filters.deprecate-filter": "0.0.74",
70
+ "@teambit/component.ui.component-filters.env-filter": "0.0.80",
71
+ "@teambit/component.ui.component-filters.show-main-filter": "0.0.67",
72
+ "@teambit/sidebar": "0.0.956",
73
73
  "@teambit/ui-foundation.ui.main-dropdown": "0.0.497",
74
74
  "@teambit/ui-foundation.ui.menu": "0.0.497",
75
75
  "@teambit/ui-foundation.ui.react-router.slot-router": "0.0.501",
76
76
  "@teambit/ui-foundation.ui.tree.drawer": "0.0.510",
77
77
  "@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.500",
78
- "@teambit/component-descriptor": "0.0.208",
79
- "@teambit/deprecation": "0.0.953",
78
+ "@teambit/component-descriptor": "0.0.211",
79
+ "@teambit/deprecation": "0.0.956",
80
80
  "@teambit/ui-foundation.ui.constants.z-indexes": "0.0.498",
81
81
  "@teambit/ui-foundation.ui.buttons.collapser": "0.0.206",
82
82
  "@teambit/ui-foundation.ui.corner": "0.0.507",
@@ -103,7 +103,7 @@
103
103
  "peerDependencies": {
104
104
  "react-router-dom": "^6.0.0",
105
105
  "@apollo/client": "^3.6.0",
106
- "@teambit/legacy": "1.0.419",
106
+ "@teambit/legacy": "1.0.423",
107
107
  "react": "^16.8.0 || ^17.0.0",
108
108
  "react-dom": "^16.8.0 || ^17.0.0"
109
109
  },
package/watch/watcher.ts CHANGED
@@ -223,7 +223,7 @@ export class Watcher {
223
223
  const ids = await this.workspace.listIds();
224
224
  updatedComponentId = ids.find((id) => id.isEqual(componentId, { ignoreVersion: true }));
225
225
  if (!updatedComponentId) {
226
- // the component was removed
226
+ logger.debug(`triggerCompChanges, the component ${componentId.toString()} was probably removed from .bitmap`);
227
227
  return [];
228
228
  }
229
229
  }
@@ -238,15 +238,14 @@ export class Watcher {
238
238
  const compFiles = files.filter((filePath) => {
239
239
  const relativeFile = this.getRelativePathLinux(filePath);
240
240
  const isCompFile = Boolean(componentMap.getFilesRelativeToConsumer().find((p) => p === relativeFile));
241
- if (!isCompFile) {
242
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
243
- logger.debug(
244
- `file ${filePath} is inside the component ${updatedComponentId!.toString()} but configured to be ignored`
245
- );
246
- }
247
241
  return isCompFile;
248
242
  });
249
243
  if (!compFiles.length) {
244
+ logger.debug(
245
+ `the following files are part of the component ${componentId.toStringWithoutVersion()} but configured to be ignored:\n${files.join(
246
+ '\n'
247
+ )}'`
248
+ );
250
249
  return [];
251
250
  }
252
251
  const buildResults = await this.executeWatchOperationsOnComponent(updatedComponentId, compFiles, true, initiator);
@@ -305,18 +304,21 @@ export class Watcher {
305
304
  this.pubsub.pub(WorkspaceAspect.id, this.creatOnComponentAddEvent(idStr, 'OnComponentAdd'));
306
305
  }
307
306
 
308
- let buildResults: OnComponentEventResult[];
309
- try {
310
- buildResults = isChange
311
- ? await this.workspace.triggerOnComponentChange(componentId, files, initiator)
312
- : await this.workspace.triggerOnComponentAdd(componentId);
313
- } catch (err: any) {
314
- // do not exit the watch process on errors, just print them
315
- const msg = `found an issue during onComponentChange or onComponentAdd hooks`;
316
- logger.error(msg, err);
317
- logger.console(`\n${msg}: ${err.message || err}`);
318
- return [];
319
- }
307
+ // the try/catch is probably not needed here because this gets called by `handleChange()` which already has a try/catch
308
+ // I left it here commented out for now just in case, but it should be removed as soon as we're more confident
309
+
310
+ // let buildResults: OnComponentEventResult[];
311
+ // try {
312
+ const buildResults = isChange
313
+ ? await this.workspace.triggerOnComponentChange(componentId, files, initiator)
314
+ : await this.workspace.triggerOnComponentAdd(componentId);
315
+ // } catch (err: any) {
316
+ // // do not exit the watch process on errors, just print them
317
+ // const msg = `found an issue during onComponentChange or onComponentAdd hooks for ${idStr}`;
318
+ // logger.error(msg, err);
319
+ // logger.console(`\n${msg}: ${err.message || err}`);
320
+ // return [];
321
+ // }
320
322
  return buildResults;
321
323
  }
322
324