@teambit/workspace 1.0.1017 → 1.0.1019
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-loading-redesign.md +279 -0
- package/dist/component-loading-redesign.md +279 -0
- package/dist/debug-load.cmd.d.ts +53 -0
- package/dist/debug-load.cmd.js +177 -0
- package/dist/debug-load.cmd.js.map +1 -0
- package/dist/{preview-1781213779199.js → preview-1781551713034.js} +2 -2
- package/dist/ui/workspace/use-workspace.d.ts +1 -1
- package/dist/workspace-aspects-loader.d.ts +1 -0
- package/dist/workspace-aspects-loader.js +21 -7
- package/dist/workspace-aspects-loader.js.map +1 -1
- package/dist/workspace-component/workspace-component-loader.d.ts +13 -0
- package/dist/workspace-component/workspace-component-loader.js +158 -24
- package/dist/workspace-component/workspace-component-loader.js.map +1 -1
- package/dist/workspace.d.ts +19 -1
- package/dist/workspace.js +32 -1
- package/dist/workspace.js.map +1 -1
- package/dist/workspace.main.runtime.js +8 -1
- package/dist/workspace.main.runtime.js.map +1 -1
- package/package.json +38 -37
- package/workspace-component/workspace-component-loader.ts +181 -41
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DebugLoadCmd = void 0;
|
|
7
|
+
function _chalk() {
|
|
8
|
+
const data = _interopRequireDefault(require("chalk"));
|
|
9
|
+
_chalk = function () {
|
|
10
|
+
return data;
|
|
11
|
+
};
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
function _cli() {
|
|
15
|
+
const data = require("@teambit/cli");
|
|
16
|
+
_cli = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _bitError() {
|
|
22
|
+
const data = require("@teambit/bit-error");
|
|
23
|
+
_bitError = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
function _harmonyModules() {
|
|
29
|
+
const data = require("@teambit/harmony.modules.load-trace");
|
|
30
|
+
_harmonyModules = function () {
|
|
31
|
+
return data;
|
|
32
|
+
};
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
function _envs() {
|
|
36
|
+
const data = require("@teambit/envs");
|
|
37
|
+
_envs = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
return data;
|
|
41
|
+
}
|
|
42
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
43
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
44
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
45
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
46
|
+
/** strip the version suffix from a raw id string (ids here are raw `stringId`s, not ComponentIDs). */
|
|
47
|
+
const noVersion = id => id.split('@')[0];
|
|
48
|
+
class DebugLoadCmd {
|
|
49
|
+
constructor(workspace) {
|
|
50
|
+
this.workspace = workspace;
|
|
51
|
+
_defineProperty(this, "name", 'debug-load <component-id>');
|
|
52
|
+
_defineProperty(this, "group", 'info-analysis');
|
|
53
|
+
_defineProperty(this, "description", 'EXPERIMENTAL. load a component with tracing enabled and explain how it was loaded');
|
|
54
|
+
_defineProperty(this, "extendedDescription", `clears the component's caches and loads it fresh, then prints: the load stages with timings and
|
|
55
|
+
cache hits/misses, the sources that contributed each extension (and which one won the merge),
|
|
56
|
+
the resolved env and which source determined it, and any load issues found.`);
|
|
57
|
+
_defineProperty(this, "arguments", [{
|
|
58
|
+
name: 'component-id',
|
|
59
|
+
description: 'the component id to load'
|
|
60
|
+
}]);
|
|
61
|
+
_defineProperty(this, "alias", '');
|
|
62
|
+
_defineProperty(this, "options", [['j', 'json', 'return the load trace in json format']]);
|
|
63
|
+
_defineProperty(this, "loader", true);
|
|
64
|
+
_defineProperty(this, "private", true);
|
|
65
|
+
}
|
|
66
|
+
async report([idStr]) {
|
|
67
|
+
const data = await this.gatherData(idStr);
|
|
68
|
+
const sections = [this.renderStagesSection(data), this.renderExtensionSourcesSection(data), this.renderEnvSection(data), this.renderIssuesSection(data)];
|
|
69
|
+
return (0, _cli().joinSections)(sections);
|
|
70
|
+
}
|
|
71
|
+
async json([idStr]) {
|
|
72
|
+
return this.gatherData(idStr);
|
|
73
|
+
}
|
|
74
|
+
async gatherData(idStr) {
|
|
75
|
+
const componentId = await this.workspace.resolveComponentId(idStr);
|
|
76
|
+
// ignoreVersion is needed because workspace ids carry versions while the resolved id may not
|
|
77
|
+
if (!this.workspace.hasId(componentId, {
|
|
78
|
+
ignoreVersion: true
|
|
79
|
+
})) {
|
|
80
|
+
throw new (_bitError().BitError)(`unable to find "${idStr}" in the workspace. debug-load works on workspace components only`);
|
|
81
|
+
}
|
|
82
|
+
// a debug command must not report a cache-hit no-op, so load fresh
|
|
83
|
+
await this.workspace.clearComponentCache(componentId);
|
|
84
|
+
let trace;
|
|
85
|
+
const component = await (0, _harmonyModules().startOrJoinLoadTrace)('debug-load', {
|
|
86
|
+
id: componentId.toString()
|
|
87
|
+
}, async () => {
|
|
88
|
+
trace = (0, _harmonyModules().currentLoadTrace)();
|
|
89
|
+
return this.workspace.get(componentId);
|
|
90
|
+
});
|
|
91
|
+
const componentFromScope = await this.workspace.scope.get(componentId);
|
|
92
|
+
const mergeRes = await this.workspace.componentExtensions(componentId, componentFromScope, undefined, {
|
|
93
|
+
loadExtensions: false
|
|
94
|
+
});
|
|
95
|
+
const extensionSources = this.buildExtensionSources(mergeRes.extensions, mergeRes.beforeMerge);
|
|
96
|
+
// the merge returns an envId only when set via the envs aspect config. when the env is set as
|
|
97
|
+
// a direct extension (e.g. via variants) or not set at all, take it from the loaded
|
|
98
|
+
// component's envs data, and attribute it by searching the merge sources for it.
|
|
99
|
+
const envFromLoad = component.state.aspects.get(_envs().EnvsAspect.id)?.data?.id;
|
|
100
|
+
const envId = mergeRes.envId || envFromLoad;
|
|
101
|
+
const envOrigin = this.findEnvOrigin(mergeRes.beforeMerge, envId);
|
|
102
|
+
return {
|
|
103
|
+
id: component.id.toString(),
|
|
104
|
+
trace: trace?.rootSpan.toObject(),
|
|
105
|
+
extensionSources,
|
|
106
|
+
envId,
|
|
107
|
+
envOrigin,
|
|
108
|
+
issues: component.state.issues.toObject()
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* for every extension in the final (merged) list, find which origins contributed it. the merge
|
|
114
|
+
* gives precedence to the origin that appears first (the order of `beforeMerge`).
|
|
115
|
+
*/
|
|
116
|
+
buildExtensionSources(merged, beforeMerge) {
|
|
117
|
+
return merged.map(mergedExt => {
|
|
118
|
+
const extId = mergedExt.stringId;
|
|
119
|
+
const origins = beforeMerge.filter(entry => entry.extensions.some(ext => noVersion(ext.stringId) === noVersion(extId))).map(entry => entry.origin);
|
|
120
|
+
return {
|
|
121
|
+
extensionId: extId,
|
|
122
|
+
winner: origins[0],
|
|
123
|
+
alsoIn: origins.slice(1)
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* the env is taken from the EnvsAspect entry of the merged extensions. the origin that
|
|
130
|
+
* determined it is the first origin (in precedence order) that sets an env.
|
|
131
|
+
*/
|
|
132
|
+
findEnvOrigin(beforeMerge, envId) {
|
|
133
|
+
if (!envId) return undefined;
|
|
134
|
+
const found = beforeMerge.find(entry => {
|
|
135
|
+
const envsAspect = entry.extensions.findCoreExtension(_envs().EnvsAspect.id);
|
|
136
|
+
if (envsAspect?.config.env && noVersion(envsAspect.config.env) === noVersion(envId)) return true;
|
|
137
|
+
// the env may also appear directly as an extension entry of that origin
|
|
138
|
+
return entry.extensions.some(ext => noVersion(ext.stringId) === noVersion(envId));
|
|
139
|
+
});
|
|
140
|
+
return found?.origin;
|
|
141
|
+
}
|
|
142
|
+
renderStagesSection(data) {
|
|
143
|
+
if (!data.trace) return '';
|
|
144
|
+
const lines = [];
|
|
145
|
+
const renderSpan = (span, depth) => {
|
|
146
|
+
const duration = span.durationMs !== undefined ? _chalk().default.cyan(`${span.durationMs}ms`) : (0, _cli().formatHint)('n/a');
|
|
147
|
+
const attrs = span.attributes ? (0, _cli().formatHint)(` ${JSON.stringify(span.attributes)}`) : '';
|
|
148
|
+
lines.push(` ${' '.repeat(depth)}${span.name} ${duration}${attrs}`);
|
|
149
|
+
(span.children || []).forEach(child => renderSpan(child, depth + 1));
|
|
150
|
+
};
|
|
151
|
+
renderSpan(data.trace, 0);
|
|
152
|
+
return [(0, _cli().formatTitle)('load stages (timings and cache hits)'), ...lines].join('\n');
|
|
153
|
+
}
|
|
154
|
+
renderExtensionSourcesSection(data) {
|
|
155
|
+
if (!data.extensionSources.length) return '';
|
|
156
|
+
const items = data.extensionSources.map(row => {
|
|
157
|
+
const alsoIn = row.alsoIn.length ? (0, _cli().formatHint)(` (also in: ${row.alsoIn.join(', ')})`) : '';
|
|
158
|
+
return (0, _cli().formatItem)(`${row.extensionId} ${(0, _cli().formatHint)('from')} ${_chalk().default.green(row.winner)}${alsoIn}`);
|
|
159
|
+
});
|
|
160
|
+
return [(0, _cli().formatTitle)(`extension sources (${items.length})`), ...items].join('\n');
|
|
161
|
+
}
|
|
162
|
+
renderEnvSection(data) {
|
|
163
|
+
const origin = data.envOrigin || 'computed during load (not set in config)';
|
|
164
|
+
const envLine = data.envId ? (0, _cli().formatItem)(`${_chalk().default.cyan(data.envId)} ${(0, _cli().formatHint)('determined by')} ${_chalk().default.green(origin)}`) : (0, _cli().formatItem)((0, _cli().formatHint)('no env configured'));
|
|
165
|
+
return [(0, _cli().formatTitle)('environment'), envLine].join('\n');
|
|
166
|
+
}
|
|
167
|
+
renderIssuesSection(data) {
|
|
168
|
+
if (!data.issues.length) {
|
|
169
|
+
return [(0, _cli().formatTitle)('load issues'), (0, _cli().formatItem)((0, _cli().formatHint)('none'))].join('\n');
|
|
170
|
+
}
|
|
171
|
+
const items = data.issues.map(issue => (0, _cli().formatItem)(`${_chalk().default.yellow(issue.type)}: ${issue.description} ${(0, _cli().formatHint)(JSON.stringify(issue.data))}`));
|
|
172
|
+
return [(0, _cli().formatTitle)(`load issues (${items.length})`), ...items].join('\n');
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
exports.DebugLoadCmd = DebugLoadCmd;
|
|
176
|
+
|
|
177
|
+
//# sourceMappingURL=debug-load.cmd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_chalk","data","_interopRequireDefault","require","_cli","_bitError","_harmonyModules","_envs","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","noVersion","id","split","DebugLoadCmd","constructor","workspace","name","description","report","idStr","gatherData","sections","renderStagesSection","renderExtensionSourcesSection","renderEnvSection","renderIssuesSection","joinSections","json","componentId","resolveComponentId","hasId","ignoreVersion","BitError","clearComponentCache","trace","component","startOrJoinLoadTrace","toString","currentLoadTrace","get","componentFromScope","scope","mergeRes","componentExtensions","undefined","loadExtensions","extensionSources","buildExtensionSources","extensions","beforeMerge","envFromLoad","state","aspects","EnvsAspect","envId","envOrigin","findEnvOrigin","rootSpan","toObject","issues","merged","map","mergedExt","extId","stringId","origins","filter","entry","some","ext","origin","extensionId","winner","alsoIn","slice","found","find","envsAspect","findCoreExtension","config","env","lines","renderSpan","span","depth","duration","durationMs","chalk","cyan","formatHint","attrs","attributes","JSON","stringify","push","repeat","children","forEach","child","formatTitle","join","length","items","row","formatItem","green","envLine","issue","yellow","type","exports"],"sources":["debug-load.cmd.ts"],"sourcesContent":["import chalk from 'chalk';\nimport type { Command, CommandOptions } from '@teambit/cli';\nimport { formatTitle, formatItem, formatHint, joinSections } from '@teambit/cli';\nimport type { Component } from '@teambit/component';\nimport { BitError } from '@teambit/bit-error';\nimport type { LoadTrace } from '@teambit/harmony.modules.load-trace';\nimport { startOrJoinLoadTrace, currentLoadTrace } from '@teambit/harmony.modules.load-trace';\nimport { EnvsAspect } from '@teambit/envs';\nimport type { ExtensionDataList } from '@teambit/legacy.extension-data';\nimport type { ExtensionsOrigin, Workspace } from './workspace';\n\n/** strip the version suffix from a raw id string (ids here are raw `stringId`s, not ComponentIDs). */\nconst noVersion = (id: string) => id.split('@')[0];\n\ntype ExtensionSourceRow = {\n extensionId: string;\n winner: ExtensionsOrigin;\n alsoIn: ExtensionsOrigin[];\n};\n\ntype DebugLoadData = {\n id: string;\n trace?: Record<string, any>;\n extensionSources: ExtensionSourceRow[];\n envId?: string;\n envOrigin?: ExtensionsOrigin;\n issues: Array<{ type: string; description: string; data: any }>;\n};\n\nexport class DebugLoadCmd implements Command {\n name = 'debug-load <component-id>';\n group = 'info-analysis';\n description = 'EXPERIMENTAL. load a component with tracing enabled and explain how it was loaded';\n extendedDescription = `clears the component's caches and loads it fresh, then prints: the load stages with timings and\ncache hits/misses, the sources that contributed each extension (and which one won the merge),\nthe resolved env and which source determined it, and any load issues found.`;\n arguments = [{ name: 'component-id', description: 'the component id to load' }];\n alias = '';\n options = [['j', 'json', 'return the load trace in json format']] as CommandOptions;\n loader = true;\n private = true;\n\n constructor(private workspace: Workspace) {}\n\n async report([idStr]: [string]): Promise<string> {\n const data = await this.gatherData(idStr);\n const sections = [\n this.renderStagesSection(data),\n this.renderExtensionSourcesSection(data),\n this.renderEnvSection(data),\n this.renderIssuesSection(data),\n ];\n return joinSections(sections);\n }\n\n async json([idStr]: [string]): Promise<DebugLoadData> {\n return this.gatherData(idStr);\n }\n\n private async gatherData(idStr: string): Promise<DebugLoadData> {\n const componentId = await this.workspace.resolveComponentId(idStr);\n // ignoreVersion is needed because workspace ids carry versions while the resolved id may not\n if (!this.workspace.hasId(componentId, { ignoreVersion: true })) {\n throw new BitError(`unable to find \"${idStr}\" in the workspace. debug-load works on workspace components only`);\n }\n // a debug command must not report a cache-hit no-op, so load fresh\n await this.workspace.clearComponentCache(componentId);\n\n let trace: LoadTrace | undefined;\n const component: Component = await startOrJoinLoadTrace('debug-load', { id: componentId.toString() }, async () => {\n trace = currentLoadTrace();\n return this.workspace.get(componentId);\n });\n\n const componentFromScope = await this.workspace.scope.get(componentId);\n const mergeRes = await this.workspace.componentExtensions(componentId, componentFromScope, undefined, {\n loadExtensions: false,\n });\n\n const extensionSources = this.buildExtensionSources(mergeRes.extensions, mergeRes.beforeMerge);\n // the merge returns an envId only when set via the envs aspect config. when the env is set as\n // a direct extension (e.g. via variants) or not set at all, take it from the loaded\n // component's envs data, and attribute it by searching the merge sources for it.\n const envFromLoad = component.state.aspects.get(EnvsAspect.id)?.data?.id;\n const envId = mergeRes.envId || envFromLoad;\n const envOrigin = this.findEnvOrigin(mergeRes.beforeMerge, envId);\n\n return {\n id: component.id.toString(),\n trace: trace?.rootSpan.toObject(),\n extensionSources,\n envId,\n envOrigin,\n issues: component.state.issues.toObject(),\n };\n }\n\n /**\n * for every extension in the final (merged) list, find which origins contributed it. the merge\n * gives precedence to the origin that appears first (the order of `beforeMerge`).\n */\n private buildExtensionSources(\n merged: ExtensionDataList,\n beforeMerge: Array<{ extensions: ExtensionDataList; origin: ExtensionsOrigin; extraData: any }>\n ): ExtensionSourceRow[] {\n return merged.map((mergedExt) => {\n const extId = mergedExt.stringId;\n const origins = beforeMerge\n .filter((entry) => entry.extensions.some((ext) => noVersion(ext.stringId) === noVersion(extId)))\n .map((entry) => entry.origin);\n return {\n extensionId: extId,\n winner: origins[0],\n alsoIn: origins.slice(1),\n };\n });\n }\n\n /**\n * the env is taken from the EnvsAspect entry of the merged extensions. the origin that\n * determined it is the first origin (in precedence order) that sets an env.\n */\n private findEnvOrigin(\n beforeMerge: Array<{ extensions: ExtensionDataList; origin: ExtensionsOrigin; extraData: any }>,\n envId?: string\n ): ExtensionsOrigin | undefined {\n if (!envId) return undefined;\n const found = beforeMerge.find((entry) => {\n const envsAspect = entry.extensions.findCoreExtension(EnvsAspect.id);\n if (envsAspect?.config.env && noVersion(envsAspect.config.env) === noVersion(envId)) return true;\n // the env may also appear directly as an extension entry of that origin\n return entry.extensions.some((ext) => noVersion(ext.stringId) === noVersion(envId));\n });\n return found?.origin;\n }\n\n private renderStagesSection(data: DebugLoadData): string {\n if (!data.trace) return '';\n const lines: string[] = [];\n const renderSpan = (span: Record<string, any>, depth: number) => {\n const duration = span.durationMs !== undefined ? chalk.cyan(`${span.durationMs}ms`) : formatHint('n/a');\n const attrs = span.attributes ? formatHint(` ${JSON.stringify(span.attributes)}`) : '';\n lines.push(` ${' '.repeat(depth)}${span.name} ${duration}${attrs}`);\n (span.children || []).forEach((child: Record<string, any>) => renderSpan(child, depth + 1));\n };\n renderSpan(data.trace, 0);\n return [formatTitle('load stages (timings and cache hits)'), ...lines].join('\\n');\n }\n\n private renderExtensionSourcesSection(data: DebugLoadData): string {\n if (!data.extensionSources.length) return '';\n const items = data.extensionSources.map((row) => {\n const alsoIn = row.alsoIn.length ? formatHint(` (also in: ${row.alsoIn.join(', ')})`) : '';\n return formatItem(`${row.extensionId} ${formatHint('from')} ${chalk.green(row.winner)}${alsoIn}`);\n });\n return [formatTitle(`extension sources (${items.length})`), ...items].join('\\n');\n }\n\n private renderEnvSection(data: DebugLoadData): string {\n const origin = data.envOrigin || 'computed during load (not set in config)';\n const envLine = data.envId\n ? formatItem(`${chalk.cyan(data.envId)} ${formatHint('determined by')} ${chalk.green(origin)}`)\n : formatItem(formatHint('no env configured'));\n return [formatTitle('environment'), envLine].join('\\n');\n }\n\n private renderIssuesSection(data: DebugLoadData): string {\n if (!data.issues.length) {\n return [formatTitle('load issues'), formatItem(formatHint('none'))].join('\\n');\n }\n const items = data.issues.map((issue) =>\n formatItem(`${chalk.yellow(issue.type)}: ${issue.description} ${formatHint(JSON.stringify(issue.data))}`)\n );\n return [formatTitle(`load issues (${items.length})`), ...items].join('\\n');\n }\n}\n"],"mappings":";;;;;;AAAA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,KAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,UAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,SAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,gBAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,eAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,MAAA;EAAA,MAAAN,IAAA,GAAAE,OAAA;EAAAI,KAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA2C,SAAAC,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAJ,CAAA,GAAAO,MAAA,CAAAC,cAAA,CAAAR,CAAA,EAAAI,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAZ,CAAA,CAAAI,CAAA,IAAAC,CAAA,E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ci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.1019/dist/workspace.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.workspace_workspace@1.0.1019/dist/workspace.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
@@ -7,8 +7,8 @@ type UseWorkspaceOptions = {
|
|
|
7
7
|
onComponentRemoved?: (compId: ComponentID[]) => void;
|
|
8
8
|
};
|
|
9
9
|
export declare function useWorkspace(options?: UseWorkspaceOptions): {
|
|
10
|
-
errors?: ReadonlyArray<import("graphql").GraphQLFormattedError> | undefined;
|
|
11
10
|
error?: import("@apollo/client").ApolloError | undefined;
|
|
11
|
+
errors?: ReadonlyArray<import("graphql").GraphQLFormattedError> | undefined;
|
|
12
12
|
client: import("@apollo/client").ApolloClient<any>;
|
|
13
13
|
loading: boolean;
|
|
14
14
|
variables: import("@apollo/client").OperationVariables | undefined;
|
|
@@ -44,6 +44,7 @@ export declare class WorkspaceAspectsLoader {
|
|
|
44
44
|
* keep in mind that the graph may have circles.
|
|
45
45
|
*/
|
|
46
46
|
loadAspects(ids?: string[], throwOnError?: boolean, neededFor?: string, opts?: WorkspaceLoadAspectsOptions): Promise<string[]>;
|
|
47
|
+
private loadAspectsWithSpan;
|
|
47
48
|
private loadFromScopeAspectsCapsule;
|
|
48
49
|
throwWsJsoncAspectNotFoundError(err: any): void;
|
|
49
50
|
private loadAspectDefsByOrder;
|
|
@@ -53,6 +53,13 @@ function _harmonyModules() {
|
|
|
53
53
|
};
|
|
54
54
|
return data;
|
|
55
55
|
}
|
|
56
|
+
function _harmonyModules2() {
|
|
57
|
+
const data = require("@teambit/harmony.modules.load-trace");
|
|
58
|
+
_harmonyModules2 = function () {
|
|
59
|
+
return data;
|
|
60
|
+
};
|
|
61
|
+
return data;
|
|
62
|
+
}
|
|
56
63
|
function _workspaceModules() {
|
|
57
64
|
const data = require("@teambit/workspace.modules.node-modules-linker");
|
|
58
65
|
_workspaceModules = function () {
|
|
@@ -128,6 +135,12 @@ class WorkspaceAspectsLoader {
|
|
|
128
135
|
* keep in mind that the graph may have circles.
|
|
129
136
|
*/
|
|
130
137
|
async loadAspects(ids = [], throwOnError, neededFor, opts = {}) {
|
|
138
|
+
return (0, _harmonyModules2().startOrJoinLoadTrace)('workspace.loadAspects', {
|
|
139
|
+
ids: ids.length,
|
|
140
|
+
neededFor
|
|
141
|
+
}, span => this.loadAspectsWithSpan(ids, span, throwOnError, neededFor, opts));
|
|
142
|
+
}
|
|
143
|
+
async loadAspectsWithSpan(ids, span, throwOnError, neededFor, opts = {}) {
|
|
131
144
|
const calculatedThrowOnError = throwOnError ?? false;
|
|
132
145
|
const defaultOpts = {
|
|
133
146
|
useScopeAspectsCapsule: false,
|
|
@@ -141,11 +154,7 @@ class WorkspaceAspectsLoader {
|
|
|
141
154
|
forceLoad: false
|
|
142
155
|
};
|
|
143
156
|
const mergedOpts = _objectSpread(_objectSpread({}, defaultOpts), opts);
|
|
144
|
-
|
|
145
|
-
// generate a random callId to be able to identify the call from the logs
|
|
146
|
-
const callId = Math.floor(Math.random() * 1000);
|
|
147
|
-
const loggerPrefix = `[${callId}] loadAspects,`;
|
|
148
|
-
this.logger.profileTrace(`[${callId}] workspace.loadAspects`);
|
|
157
|
+
const loggerPrefix = `loadAspects,`;
|
|
149
158
|
this.logger.info(`${loggerPrefix} loading ${ids.length} aspects.
|
|
150
159
|
ids: ${ids.join(', ')}
|
|
151
160
|
needed-for: ${neededFor || '<unknown>'}. using opts: ${JSON.stringify(mergedOpts, null, 2)}`);
|
|
@@ -157,7 +166,7 @@ needed-for: ${neededFor || '<unknown>'}. using opts: ${JSON.stringify(mergedOpts
|
|
|
157
166
|
notLoadedIds = nonLocalAspects.filter(id => !this.aspectLoader.isAspectLoaded(id));
|
|
158
167
|
}
|
|
159
168
|
if (!notLoadedIds.length) {
|
|
160
|
-
|
|
169
|
+
span.setAttribute('alreadyLoaded', true);
|
|
161
170
|
return [];
|
|
162
171
|
}
|
|
163
172
|
const coreAspectsStringIds = this.aspectLoader.getCoreAspectIds();
|
|
@@ -206,7 +215,6 @@ needed-for: ${neededFor || '<unknown>'}. using opts: ${JSON.stringify(mergedOpts
|
|
|
206
215
|
});
|
|
207
216
|
const manifestIds = manifests.map(manifest => manifest.id);
|
|
208
217
|
this.logger.debug(`${loggerPrefix} finish loading aspects`);
|
|
209
|
-
this.logger.profileTrace(`[${callId}] workspace.loadAspects`);
|
|
210
218
|
return (0, _lodash().compact)(manifestIds.concat(scopeAspectIds));
|
|
211
219
|
}
|
|
212
220
|
async loadFromScopeAspectsCapsule(ids, throwOnError, neededFor) {
|
|
@@ -590,6 +598,12 @@ your workspace.jsonc has this component-id set. you might want to remove/change
|
|
|
590
598
|
throw error;
|
|
591
599
|
}
|
|
592
600
|
this.logger.consoleWarning(`failed resolving aspect ${aspectStringId} from ${parentPath}, error: ${error.message}`);
|
|
601
|
+
// record the swallowed failure on the active load-trace so it surfaces as a component issue
|
|
602
|
+
(0, _harmonyModules2().reportLoadFailure)({
|
|
603
|
+
failedId: aspectStringId,
|
|
604
|
+
phase: 'resolve-installed-aspect',
|
|
605
|
+
error: error.message
|
|
606
|
+
});
|
|
593
607
|
return undefined;
|
|
594
608
|
}
|
|
595
609
|
}
|