@teambit/aspect-loader 1.0.1219 → 1.0.1221

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.
@@ -46,6 +46,13 @@ function _recordLoadedEsmFile() {
46
46
  };
47
47
  return data;
48
48
  }
49
+ function _replaceNeverLoadedAspects() {
50
+ const data = require("./replace-never-loaded-aspects");
51
+ _replaceNeverLoadedAspects = function () {
52
+ return data;
53
+ };
54
+ return data;
55
+ }
49
56
  function _componentId() {
50
57
  const data = require("@teambit/component-id");
51
58
  _componentId = function () {
@@ -723,6 +730,10 @@ class AspectLoaderMain {
723
730
  return nodesUniq.map(n => n.attr);
724
731
  };
725
732
  const relevantManifests = getOnlyDeclaredDependenciesManifests();
733
+ const replacedIds = (0, _replaceNeverLoadedAspects().replaceNeverLoadedAspects)(this.harmony, relevantManifests);
734
+ if (replacedIds.length) {
735
+ this.logger.debug(`loadExtensionsByManifests, replaced never-loaded aspects: ${replacedIds.join(', ')}`);
736
+ }
726
737
  // @ts-ignore TODO: fix this
727
738
  await this.harmony.load(relevantManifests);
728
739
  } catch (e) {
@@ -1 +1 @@
1
- {"version":3,"names":["_path","data","require","_nodeUtils","_interopRequireDefault","_fsExtra","_graph","_harmonyModules","_recordLoadedEsmFile","_componentId","_legacy","_harmonyModules2","_harmony","_bitError","_logger","_compilationModules","_envs","_graphql","_pMapSeries","_lodash","_aspectDefinition","_aspectLoader","_constants","_isEsmModule","_exceptions","_coreAspects","_plugins","_aspectLoader2","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","AspectLoaderMain","constructor","logger","envs","harmony","onAspectLoadErrorSlot","onLoadRequireableExtensionSlot","pluginSlot","Set","getCoreAspectsPackagesAndIds","allCoreAspectsIds","getCoreAspectIds","coreAspectsPackagesAndIds","id","packageName","getCoreAspectPackageName","getCompiler","component","env","getEnv","registerOnAspectLoadErrorSlot","onAspectLoadError","register","registerOnLoadRequireableExtensionSlot","onLoadRequireableExtension","triggerOnAspectLoadError","err","entries","toArray","isFixed","mapSeries","onAspectFailFunc","result","getRuntimePath","modulePath","runtime","runtimeFile","filesystem","files","find","file","relative","includes","compiler","join","dist","getDistPathBySrcPath","info","distPath","DEFAULT_DIST_DIRNAME","replaceFileExtToJs","getAspectFilePath","aspectFile","isAspectLoaded","failedAspects","get","getDescriptor","instance","iconFn","icon","undefined","addInMemoryConfiguredAspect","aspectId","inMemoryConfiguredAspects","getConfiguredAspects","configuredAspects","Array","from","config","raw","iMemoryConfiguredAspects","concat","getNotLoadedConfiguredExtensions","harmonyExtensions","extensionsIds","loadedExtensions","extId","extensions","loaded","extensionsToLoad","difference","loadDefinition","props","AspectDefinition","coreAspects","isCoreAspect","ids","setCoreAspects","aspects","setNonCoreAspects","_nonCoreAspects","map","aspect","_reserved","getNonCoreAspectIds","getCoreEnvsIds","envsIds","allIds","intersection","isCoreEnv","getUserAspects","coreAspectIds","nonCoreAspectIds","nonUserAspectIds","getCoreAspectDefs","runtimeName","defs","Promise","all","rawDef","getAspectDef","def","runtimePath","resolveAspects","components","resolver","promises","resolvedAspect","aspectPath","aspectFilePath","aspectDefs","compact","mainAspect","_mainAspect","setMainAspect","failedLoadAspect","resetFailedLoadAspects","addFailure","cloneManifest","manifest","cloned","assign","create","getPrototypeOf","provider","addRuntime","getRuntime","doRequire","requireableExtension","runSubscribers","idStr","toString","runOnLoadRequireableExtensionSubscribers","loadRequireableExtensions","requireableExtensions","throwOnError","manifests","getManifestsFromRequireableExtensions","loadExtensionsByManifests","manifestsP","firstErr","warn","errAfterReLoad","error","handleExtensionLoadingError","addFailedToLoadExt","errorMsg","message","split","msg","UNABLE_TO_LOAD_EXTENSION","console","CannotLoadExtension","reportLoadFailure","failedId","phase","printWarningIfFirstTime","isLoaderStarted","envId","showAsFailure","alreadyShownWarning","has","add","consoleFailure","consoleWarning","updatedManifest","onLoadRequireableExtensionFunc","getPluginDefs","flatten","values","getPluginDefsByAspectId","getPlugins","componentPath","getPluginsFromDefs","isEsmModule","path","loadEsm","module","esmLoader","recordLoadedEsmFile","Plugins","bind","pluginFileResolver","getPluginFiles","hasPluginFiles","isEmpty","searchDistFile","rootDir","relativePath","replaceNotFound","defaultDistDir","fileExtension","extname","fileNames","ext","replace","RegExp","defaultDistPath","fileName","found","existsSync","jsFileName","finalPath","endsWith","distFile","isAspect","isValidAspect","isAspectComponent","isUsingAspectEnv","filterAspectDefs","allDefs","componentIds","filterOpts","coreIds","stringIds","toStringWithoutVersion","afterExclusion","excludeCore","isCore","getId","ComponentID","fromString","isTarget","uniqDefs","uniqBy","filterByRuntime","requestedOnly","componentIdsString","getAspectIdFromAspectFile","isObject","prepareManifests","MainRuntime","Error","Aspect","registerPlugins","pluginDefs","extensionsManifests","context","seeders","options","hideMissingModuleError","ignoreErrors","unifyErrorsByExtId","neededFor","defaultLoadExtByManifestOptions","mergedOptions","isValid","preparedManifests","getOnlyDeclaredDependenciesManifests","manifestGraph","generateManifestGraph","nodes","seeder","successors","flat","seederNodes","node","allNodes","nodesUniq","n","attr","relevantManifests","load","needToPrint","some","failedToLoadExt","parsedId","tryFromString","fullName","code","ignoreErrorFunc","warning","UNABLE_TO_LOAD_EXTENSION_FROM_LIST","BitError","graph","Graph","setNode","Node","deps","dependencies","dep","setEdge","Edge","loadAspectFromPath","localAspects","res","dirPaths","parseLocalAspect","dirPath","localAspect","scopeRuntime","findRuntime","mainRuntime","mainRuntimeModule","mainRuntimeManifest","resolve","nonExistsDirPaths","existsDirPaths","readdirSync","resolveLocalAspects","dirs","dir","srcRuntimeManifest","srcAspectFilePath","findAspectFile","runtimeManifest","loggerExt","graphql","createLogger","AspectLoaderAspect","aspectLoader","aspectLoaderSchema","getEnvPlugin","exports","LoggerAspect","EnvsAspect","GraphqlAspect","Slot","withType","_default"],"sources":["aspect-loader.main.runtime.ts"],"sourcesContent":["import { join, resolve, extname } from 'path';\nimport esmLoader from '@teambit/node.utils.esm-loader';\n// import findRoot from 'find-root';\nimport { readdirSync, existsSync } from 'fs-extra';\nimport { Graph, Node, Edge } from '@teambit/graph.cleargraph';\nimport { reportLoadFailure } from '@teambit/harmony.modules.load-trace';\nimport { recordLoadedEsmFile } from './record-loaded-esm-file';\nimport { ComponentID } from '@teambit/component-id';\nimport { DEFAULT_DIST_DIRNAME } from '@teambit/legacy.constants';\nimport { MainRuntime } from '@teambit/harmony.modules.runtimes';\nimport type { ExtensionManifest, Harmony, SlotRegistry } from '@teambit/harmony';\nimport { Aspect, Slot } from '@teambit/harmony';\nimport { BitError } from '@teambit/bit-error';\nimport type { LoggerMain, Logger } from '@teambit/logger';\nimport type { Component, FilterAspectsOptions } from '@teambit/component';\nimport { LoggerAspect } from '@teambit/logger';\nimport type { RequireableComponent } from '@teambit/harmony.modules.requireable-component';\nimport { replaceFileExtToJs } from '@teambit/compilation.modules.babel-compiler';\nimport type { EnvsMain } from '@teambit/envs';\nimport { EnvsAspect } from '@teambit/envs';\nimport type { GraphqlMain } from '@teambit/graphql';\nimport { GraphqlAspect } from '@teambit/graphql';\nimport mapSeries from 'p-map-series';\nimport { difference, compact, flatten, intersection, uniqBy, some, isEmpty, isObject } from 'lodash';\nimport type { AspectDefinitionProps } from './aspect-definition';\nimport { AspectDefinition } from './aspect-definition';\nimport type { PluginDefinition } from './plugin-definition';\nimport { AspectLoaderAspect } from './aspect-loader.aspect';\nimport { UNABLE_TO_LOAD_EXTENSION, UNABLE_TO_LOAD_EXTENSION_FROM_LIST } from './constants';\nimport { isEsmModule } from './is-esm-module';\nimport { CannotLoadExtension } from './exceptions';\nimport { getAspectDef, getCoreAspectPackageName } from './core-aspects';\nimport { Plugins } from './plugins';\nimport { aspectLoaderSchema } from './aspect-loader.graphql';\n\nexport type PluginDefinitionSlot = SlotRegistry<PluginDefinition[]>;\n\nexport type AspectDescriptor = {\n /**\n * name of the extension.\n */\n id: string;\n\n /**\n * icon of the extension.\n */\n icon?: string;\n};\n\nexport type AspectResolver = (component: Component) => Promise<ResolvedAspect | undefined>;\n\nexport type ResolvedAspect = {\n aspectPath: string;\n runtimePath: string | null;\n aspectFilePath: string | null;\n};\n\nexport type LoadExtByManifestContext = {\n seeders?: string[];\n neededFor?: string;\n};\n\nexport type LoadExtByManifestOptions = {\n throwOnError?: boolean;\n hideMissingModuleError?: boolean;\n ignoreErrorFunc?: (err: Error) => boolean;\n ignoreErrors?: boolean;\n /**\n * If this is enabled then we will show loading error only once for a given extension\n * (even if it was actually try to load it few times by different components for example)\n */\n unifyErrorsByExtId?: boolean;\n};\n\ntype OnAspectLoadError = (err: Error, component: Component) => Promise<boolean>;\nexport type OnAspectLoadErrorSlot = SlotRegistry<OnAspectLoadError>;\n\nexport type OnAspectLoadErrorHandler = (err: Error, component: Component) => Promise<boolean>;\n\nexport type OnLoadRequireableExtension = (\n requireableExtension: RequireableComponent,\n manifest: ExtensionManifest | Aspect\n) => Promise<ExtensionManifest | Aspect>;\n/**\n * A slot which run during loading the requirable extension (after first manifest calculation)\n */\nexport type OnLoadRequireableExtensionSlot = SlotRegistry<OnLoadRequireableExtension>;\n\nexport type MainAspect = {\n /**\n * path to the main aspect.\n */\n path: string;\n\n /**\n * version of the aspect.\n */\n version: string | undefined;\n\n /**\n * package name of the aspect\n */\n packageName: string | undefined;\n\n /**\n * reference to aspect manifest.\n */\n aspect: Aspect;\n\n /**\n * The name of the aspect (without the scope prefix)\n */\n name: string;\n\n /**\n * The name of the aspect\n */\n id: string;\n};\n\nexport class AspectLoaderMain {\n private inMemoryConfiguredAspects: string[] = [];\n private failedToLoadExt = new Set<string>();\n private alreadyShownWarning = new Set<string>();\n\n constructor(\n private logger: Logger,\n private envs: EnvsMain,\n private harmony: Harmony,\n private onAspectLoadErrorSlot: OnAspectLoadErrorSlot,\n private onLoadRequireableExtensionSlot: OnLoadRequireableExtensionSlot,\n private pluginSlot: PluginDefinitionSlot\n ) {}\n\n getCoreAspectsPackagesAndIds(): Record<string, string> {\n const allCoreAspectsIds = this.getCoreAspectIds();\n const coreAspectsPackagesAndIds = {};\n\n allCoreAspectsIds.forEach((id) => {\n const packageName = getCoreAspectPackageName(id);\n coreAspectsPackagesAndIds[packageName] = id;\n });\n\n return coreAspectsPackagesAndIds;\n }\n\n private getCompiler(component: Component) {\n const env = this.envs.getEnv(component)?.env;\n return env?.getCompiler();\n }\n\n registerOnAspectLoadErrorSlot(onAspectLoadError: OnAspectLoadError) {\n this.onAspectLoadErrorSlot.register(onAspectLoadError);\n }\n\n registerOnLoadRequireableExtensionSlot(onLoadRequireableExtension: OnLoadRequireableExtension) {\n this.onLoadRequireableExtensionSlot.register(onLoadRequireableExtension);\n }\n\n /**\n * returns whether the aspect-load issue has been fixed.\n */\n async triggerOnAspectLoadError(err: Error, component: Component): Promise<boolean> {\n const entries = this.onAspectLoadErrorSlot.toArray(); // e.g. [ [ 'teambit.bit/compiler', [Function: bound onAspectLoadError] ] ]\n let isFixed = false;\n await mapSeries(entries, async ([, onAspectFailFunc]) => {\n const result = await onAspectFailFunc(err, component);\n if (result) isFixed = true;\n });\n\n return isFixed;\n }\n\n async getRuntimePath(component: Component, modulePath: string, runtime: string): Promise<string | null> {\n const runtimeFile = component.filesystem.files.find((file: any) => {\n return file.relative.includes(`.${runtime}.runtime`);\n });\n\n // @david we should add a compiler api for this.\n if (!runtimeFile) return null;\n try {\n const compiler = this.getCompiler(component);\n\n if (!compiler) {\n return join(modulePath, runtimeFile.relative);\n }\n\n const dist = compiler.getDistPathBySrcPath(runtimeFile.relative);\n return join(modulePath, dist);\n } catch (e) {\n this.logger.info(`got an error during get runtime path, probably the env is not loaded yet ${e}`);\n // TODO: we are manually adding the dist here and replace the file name to handle case when\n // we load aspects from scope, and their env in the same iteration, but we get into the aspect before its\n // env, so it's env doesn't exist yet\n // we should make sure to first load the env correctly before loading the aspect\n const distPath = join(modulePath, DEFAULT_DIST_DIRNAME, replaceFileExtToJs(runtimeFile.relative));\n return distPath;\n }\n }\n\n async getAspectFilePath(component: Component, modulePath: string): Promise<string | null> {\n const aspectFile = component.filesystem.files.find((file: any) => {\n return file.relative.includes(`.aspect.ts`) || file.relative.includes(`.aspect.js`);\n });\n\n // @david we should add a compiler api for this.\n if (!aspectFile) return null;\n try {\n const compiler = this.getCompiler(component);\n\n if (!compiler) {\n return join(modulePath, aspectFile.relative);\n }\n\n const dist = compiler.getDistPathBySrcPath(aspectFile.relative);\n return join(modulePath, dist);\n } catch (e) {\n this.logger.info(`got an error during get runtime path, probably the env is not loaded yet ${e}`);\n // TODO: we are manually adding the dist here and replace the file name to handle case when\n // we load aspects from scope, and their env in the same iteration, but we get into the aspect before its\n // env, so it's env doesn't exist yet\n // we should make sure to first load the env correctly before loading the aspect\n const distPath = join(modulePath, DEFAULT_DIST_DIRNAME, replaceFileExtToJs(aspectFile.relative));\n return distPath;\n }\n }\n\n isAspectLoaded(id: string) {\n if (this.failedAspects.includes(id)) return true;\n try {\n return this.harmony.get(id);\n } catch {\n return false;\n }\n }\n\n getDescriptor(id: string): AspectDescriptor | undefined {\n try {\n const instance = this.harmony.get<any>(id);\n const iconFn = instance.icon;\n\n const icon = iconFn ? iconFn.apply(instance) : undefined;\n\n return {\n id,\n icon,\n };\n } catch {\n return undefined;\n }\n }\n\n /**\n * This is used when adding aspects to workspace.jsonc during the process (like in bit use command)\n * and we want to make sure that follow operation (like bit install) will recognize those aspects\n * but the harmony config is already in memory.\n * Probably a better to do it is to make sure we can re-load the config somehow\n * ideally by adding the config class in harmony a reload API\n * @param aspectId\n */\n addInMemoryConfiguredAspect(aspectId: string): void {\n this.inMemoryConfiguredAspects.push(aspectId);\n }\n\n /**\n * get all the configured aspects in the config file (workspace.jsonc / scope.jsonc)\n */\n getConfiguredAspects(): string[] {\n const configuredAspects = Array.from(this.harmony.config.raw.keys());\n const iMemoryConfiguredAspects = this.inMemoryConfiguredAspects;\n return configuredAspects.concat(iMemoryConfiguredAspects);\n }\n getNotLoadedConfiguredExtensions() {\n const configuredAspects = this.getConfiguredAspects();\n const harmonyExtensions = this.harmony.extensionsIds;\n const loadedExtensions = harmonyExtensions.filter((extId) => {\n return this.harmony.extensions.get(extId)?.loaded;\n });\n const extensionsToLoad = difference(configuredAspects, loadedExtensions);\n return extensionsToLoad;\n }\n\n loadDefinition(props: AspectDefinitionProps): AspectDefinition {\n return AspectDefinition.from(props);\n }\n\n private _coreAspects: Aspect[] = [];\n private _nonCoreAspects: Aspect[] = [];\n\n get coreAspects() {\n return this._coreAspects;\n }\n\n isCoreAspect(id: string) {\n const ids = this.getCoreAspectIds();\n return ids.includes(id);\n }\n\n setCoreAspects(aspects: Aspect[]) {\n this._coreAspects = aspects;\n return this;\n }\n\n setNonCoreAspects(aspects: Aspect[]) {\n this._nonCoreAspects = aspects;\n return this;\n }\n\n getCoreAspectIds(): string[] {\n const ids = this.coreAspects.map((aspect) => aspect.id);\n return ids.concat(this._reserved);\n }\n\n /**\n * bit aspects that are not core aspects\n * normally coming from a composition over teambit.harmony/bit and are passed to loadBit as \"additionalAspects\".\n * these are *not* user aspects. they're not in workspaces created by users. they're part of bit installation.\n */\n getNonCoreAspectIds(): string[] {\n return this._nonCoreAspects.map((aspect) => aspect.id);\n }\n\n /**\n * Get all the core envs ids which is still register in the bit manifest as core aspect\n */\n getCoreEnvsIds(): string[] {\n const envsIds = this.envs.getCoreEnvsIds();\n const allIds = this.getCoreAspectIds();\n return intersection(allIds, envsIds);\n }\n\n isCoreEnv(id: string): boolean {\n const ids = this.getCoreEnvsIds();\n return ids.includes(id);\n }\n\n private _reserved = ['teambit.harmony/bit', 'teambit.harmony/config'];\n\n getUserAspects(): string[] {\n const coreAspectIds = this.getCoreAspectIds();\n const nonCoreAspectIds = this.getNonCoreAspectIds();\n const nonUserAspectIds = [...coreAspectIds, ...nonCoreAspectIds];\n return difference(this.harmony.extensionsIds, nonUserAspectIds);\n }\n\n async getCoreAspectDefs(runtimeName?: string) {\n const defs = await Promise.all(\n this.coreAspects.map(async (aspect) => {\n const id = aspect.id;\n const rawDef = await getAspectDef(id, runtimeName);\n return this.loadDefinition(rawDef);\n })\n );\n\n return defs.filter((def) => def.runtimePath);\n }\n\n async resolveAspects(components: Component[], resolver: AspectResolver): Promise<AspectDefinition[]> {\n const promises = components.map(async (component) => {\n const resolvedAspect = await resolver(component);\n if (!resolvedAspect) return undefined;\n return new AspectDefinition(\n resolvedAspect.aspectPath,\n resolvedAspect.aspectFilePath,\n resolvedAspect.runtimePath,\n component\n );\n });\n\n const aspectDefs = await Promise.all(promises);\n // return aspectDefs.filter((def) => def.runtimePath);\n return compact(aspectDefs);\n }\n\n private _mainAspect: MainAspect;\n\n get mainAspect() {\n return this._mainAspect;\n }\n\n setMainAspect(mainAspect: MainAspect) {\n this._mainAspect = mainAspect;\n return this;\n }\n\n private failedLoadAspect: string[] = [];\n\n get failedAspects() {\n return this.failedLoadAspect;\n }\n\n public resetFailedLoadAspects() {\n this.failedLoadAspect = [];\n }\n\n private addFailure(id: string): void {\n if (this.failedAspects.includes(id)) return;\n this.failedLoadAspect.push(id);\n }\n\n cloneManifest(manifest: any) {\n const cloned = Object.assign(Object.create(Object.getPrototypeOf(manifest)), manifest);\n cloned.provider = manifest.provider;\n cloned.addRuntime = manifest.addRuntime;\n cloned.getRuntime = manifest.getRuntime;\n return cloned;\n }\n\n /**\n * run \"require\" of the component code to get the manifest\n */\n async doRequire(\n requireableExtension: RequireableComponent,\n runSubscribers = true\n ): Promise<ExtensionManifest | Aspect> {\n const idStr = requireableExtension.component.id.toString();\n const aspect = await requireableExtension.require();\n const manifest = aspect.default || aspect;\n manifest.id = idStr;\n // It's important to clone deep the manifest here to prevent mutate dependencies of other manifests as they point to the same location in memory\n const cloned = this.cloneManifest(manifest);\n if (runSubscribers) return this.runOnLoadRequireableExtensionSubscribers(requireableExtension, cloned);\n return cloned;\n }\n\n /**\n * in case the extension failed to load, prefer to throw an error, unless `throwOnError` param\n * passed as `false`.\n * there are cases when throwing an error blocks the user from doing anything else. for example,\n * when a user develops an extension and deletes the node-modules, the extension on the workspace\n * cannot be loaded anymore until \"bit compile\" is running. however, if this function throws an\n * error, it'll throw for \"bit compile\" as well, which blocks the user.\n * for the CI, it is important to throw an error because errors on console can be ignored.\n * for now, when loading the extension from the workspace the throwOnError is passed as false.\n * when loading from the scope (CI) it should be true.\n *\n * the console printing here is done directly by \"console.error\" and not by the logger. the reason\n * is that the logger.console only prints when the loader started (which, btw, happens after\n * entering this function, so it can't work) and here we want it to be printed regardless of the\n * rules of starting the loader. e.g. if by mistake the CI got it as throwOnError=false, it's ok\n * to break the output by the console.error.\n *\n * @todo: this is not the final word however about throwing/non throwing errors here.\n * in some cases, such as \"bit tag\", it's better not to tag if an extension changes the model.\n */\n async loadRequireableExtensions(requireableExtensions: RequireableComponent[], throwOnError = false): Promise<void> {\n const manifests = await this.getManifestsFromRequireableExtensions(requireableExtensions, throwOnError);\n return this.loadExtensionsByManifests(manifests, undefined, { throwOnError });\n }\n\n async getManifestsFromRequireableExtensions(\n requireableExtensions: RequireableComponent[],\n throwOnError = false,\n runSubscribers = true\n ): Promise<Array<ExtensionManifest | Aspect>> {\n const manifestsP = mapSeries(requireableExtensions, async (requireableExtension) => {\n if (!requireableExtensions) return undefined;\n const idStr = requireableExtension.component.id.toString();\n try {\n return await this.doRequire(requireableExtension, runSubscribers);\n } catch (firstErr: any) {\n this.addFailure(idStr);\n this.logger.warn(`failed loading an aspect \"${idStr}\", will try to fix and reload`, firstErr);\n const isFixed = await this.triggerOnAspectLoadError(firstErr, requireableExtension.component);\n let errAfterReLoad;\n if (isFixed) {\n this.logger.info(`the loading issue might be fixed now, re-loading ${idStr}`);\n try {\n return await this.doRequire(requireableExtension);\n } catch (err: any) {\n this.logger.warn(`re-load of the aspect \"${idStr}\" failed as well`, err);\n errAfterReLoad = err;\n }\n }\n const error = errAfterReLoad || firstErr;\n this.handleExtensionLoadingError(error, idStr, throwOnError);\n }\n return undefined;\n });\n const manifests = await manifestsP;\n\n // Remove empty manifests as a result of loading issue\n return compact(manifests);\n }\n\n handleExtensionLoadingError(error: Error, idStr: string, throwOnError: boolean) {\n this.envs.addFailedToLoadExt(idStr);\n const errorMsg = error.message.split('\\n')[0]; // show only the first line if the error is long (e.g. happens with MODULE_NOT_FOUND errors)\n const msg = UNABLE_TO_LOAD_EXTENSION(idStr, errorMsg);\n if (throwOnError) {\n // @ts-ignore\n this.logger.console(error);\n throw new CannotLoadExtension(idStr, error);\n }\n // the failure is swallowed (best-effort loading). record it on the active load-trace so the\n // component loader surfaces it as a component issue, visible in \"bit status\".\n reportLoadFailure({ failedId: idStr, phase: 'require-aspects', error: errorMsg });\n this.logger.error(msg, error);\n this.printWarningIfFirstTime(idStr, msg, this.logger.isLoaderStarted);\n }\n\n private printWarningIfFirstTime(envId: string, msg: string, showAsFailure: boolean) {\n if (!this.alreadyShownWarning.has(envId)) {\n this.alreadyShownWarning.add(envId);\n if (showAsFailure) {\n this.logger.consoleFailure(msg);\n } else {\n this.logger.consoleWarning(msg);\n }\n }\n }\n\n async runOnLoadRequireableExtensionSubscribers(\n requireableExtension: RequireableComponent,\n manifest: ExtensionManifest | Aspect\n ): Promise<ExtensionManifest | Aspect> {\n let updatedManifest = manifest;\n const entries = this.onLoadRequireableExtensionSlot.toArray();\n await mapSeries(entries, async ([, onLoadRequireableExtensionFunc]) => {\n updatedManifest = await onLoadRequireableExtensionFunc(requireableExtension, updatedManifest);\n });\n return updatedManifest;\n }\n\n getPluginDefs() {\n return flatten(this.pluginSlot.values());\n }\n\n /**\n * same as `getPluginDefs`, only that the defs are grouped by the aspect-id (including the version) that registered\n * them. useful when the same plugin-pattern is registered by more than one version of the same aspect, and the\n * consumer needs to know which version registered what.\n */\n getPluginDefsByAspectId(): Array<[string, PluginDefinition[]]> {\n return this.pluginSlot.toArray();\n }\n\n getPlugins(component: Component, componentPath: string): Plugins {\n const defs = this.getPluginDefs();\n return this.getPluginsFromDefs(component, componentPath, defs);\n }\n\n async isEsmModule(path: string) {\n return isEsmModule(path);\n }\n\n async loadEsm(path: string) {\n const module = await esmLoader(path);\n // only a load that succeeded leaves something in memory that needs its files kept around\n recordLoadedEsmFile(path);\n return module;\n }\n\n getPluginsFromDefs(component: Component, componentPath: string, defs: PluginDefinition[]): Plugins {\n return Plugins.from(\n component,\n defs,\n this.triggerOnAspectLoadError.bind(this),\n this.logger,\n this.pluginFileResolver.call(this, component, componentPath)\n );\n }\n\n getPluginFiles(component: Component, componentPath: string): string[] {\n const defs = this.getPluginDefs();\n return Plugins.files(component, defs, this.pluginFileResolver.call(this, component, componentPath));\n }\n\n hasPluginFiles(component: Component): boolean {\n const defs = this.getPluginDefs();\n const files = Plugins.files(component, defs);\n return !isEmpty(files);\n }\n\n private searchDistFile(rootDir: string, relativePath: string, replaceNotFound = false) {\n const defaultDistDir = join(rootDir, 'dist');\n const fileExtension = extname(relativePath);\n const fileNames = ['ts', 'js', 'tsx', 'jsx'].map((ext) =>\n relativePath.replace(new RegExp(`${fileExtension}$`), `.${ext}`)\n );\n const defaultDistPath = fileNames.map((fileName) => join(defaultDistDir, fileName));\n const found = defaultDistPath.find((distPath) => existsSync(distPath));\n if (found) return found;\n if (!replaceNotFound) return null;\n const jsFileName = relativePath.replace(new RegExp(`${fileExtension}$`), `.js`);\n const finalPath = join(defaultDistDir, jsFileName);\n return finalPath;\n }\n\n pluginFileResolver(component: Component, rootDir: string) {\n return (relativePath: string) => {\n const replaceNotFound = relativePath.endsWith('.ts') || relativePath.endsWith('.tsx');\n\n try {\n const compiler = this.getCompiler(component);\n if (!compiler) {\n const distFile = this.searchDistFile(rootDir, relativePath, replaceNotFound);\n return distFile || join(rootDir, relativePath);\n }\n\n const dist = compiler.getDistPathBySrcPath(relativePath);\n return join(rootDir, dist);\n } catch (err) {\n // This might happen for example when loading an env from the global scope, and the env of the env / aspect is not a core one\n this.logger.info(\n `pluginFileResolver: got an error during get compiler for component ${component.id.toString()}, probably the env is not loaded yet ${err}`\n );\n const distFile = this.searchDistFile(rootDir, relativePath, replaceNotFound);\n return distFile || join(rootDir, relativePath);\n }\n };\n }\n\n isAspect(manifest: any) {\n return !!(manifest.addRuntime && manifest.getRuntime);\n }\n\n isValidAspect(manifest: any): boolean {\n return this.isAspect(manifest) || manifest.provider;\n }\n\n isAspectComponent(component: Component): boolean {\n return this.envs.isUsingAspectEnv(component);\n }\n\n filterAspectDefs(\n allDefs: AspectDefinition[],\n componentIds: ComponentID[],\n runtimeName: string | undefined,\n filterOpts: FilterAspectsOptions = {}\n ) {\n const coreIds = this.getCoreAspectIds();\n const stringIds = componentIds.map((id) => id.toStringWithoutVersion());\n const afterExclusion = filterOpts.excludeCore\n ? allDefs.filter((def) => {\n const isCore = coreIds.includes(def.getId || '');\n const id = ComponentID.fromString(def.getId || '');\n const isTarget = stringIds.includes(id.toStringWithoutVersion());\n if (isTarget) return true;\n return !isCore;\n })\n : allDefs;\n\n const uniqDefs = uniqBy(afterExclusion, (def) => `${def.aspectPath}-${def.runtimePath}`);\n let defs = uniqDefs;\n if (runtimeName && filterOpts.filterByRuntime) {\n defs = defs.filter((def) => def.runtimePath);\n }\n\n if (componentIds && componentIds.length && filterOpts.requestedOnly) {\n const componentIdsString = componentIds.map((id) => id.toString());\n defs = defs.filter((def) => {\n return (\n (def.id && componentIdsString.includes(def.id)) ||\n (def.component && componentIdsString.includes(def.component?.id.toString()))\n );\n });\n }\n\n return defs;\n }\n\n getAspectIdFromAspectFile(aspectFilePath: string): string | undefined {\n try {\n // eslint-disable-next-line global-require, import/no-dynamic-require\n const module = aspectFilePath ? require(aspectFilePath) : undefined;\n let manifest = module.default || module;\n if (this.isAspect(manifest)) {\n return manifest.id;\n }\n if (isObject(manifest)) {\n if (isEmpty(manifest)) {\n this.logger.warn(\n `getAspectIdFromAspectFile - aspect at ${aspectFilePath} missing exports. couldn't calculate the manifest`\n );\n return undefined;\n }\n if (Object.keys(manifest).length > 1) {\n this.logger.warn(\n `getAspectIdFromAspectFile - aspect at ${aspectFilePath} exports too many keys. couldn't calculate the manifest`\n );\n return undefined;\n }\n manifest = Object.values(manifest)[0];\n if (this.isAspect(manifest)) {\n return manifest.id;\n }\n }\n this.logger.warn(`getAspectIdFromAspectFile - aspect at ${aspectFilePath} is not a valid aspect`);\n return undefined;\n } catch (err) {\n this.logger.warn(`getAspectIdFromAspectFile - couldn't require the aspect file ${aspectFilePath}. err: ${err}`);\n return undefined;\n }\n }\n\n private prepareManifests(manifests: Array<ExtensionManifest | Aspect>): Aspect[] {\n return manifests.map((manifest: any) => {\n if (this.isAspect(manifest)) return manifest as Aspect;\n manifest.runtime = MainRuntime;\n if (!manifest.id) throw new Error('manifest must have static id');\n const aspect = Aspect.create({\n id: manifest.id,\n });\n aspect.addRuntime(manifest);\n return aspect;\n });\n }\n\n /**\n * register a plugin.\n */\n registerPlugins(pluginDefs: PluginDefinition[]) {\n this.pluginSlot.register(pluginDefs);\n }\n\n async loadExtensionsByManifests(\n extensionsManifests: Array<ExtensionManifest | Aspect>,\n context: LoadExtByManifestContext = {\n seeders: [],\n },\n options: LoadExtByManifestOptions = {\n throwOnError: true,\n hideMissingModuleError: false,\n ignoreErrors: false,\n unifyErrorsByExtId: true,\n }\n ) {\n const neededFor = context.neededFor;\n const seeders = context.seeders || [];\n const defaultLoadExtByManifestOptions = {\n throwOnError: true,\n hideMissingModuleError: false,\n ignoreErrors: false,\n unifyErrorsByExtId: true,\n };\n const mergedOptions = { ...defaultLoadExtByManifestOptions, ...options };\n try {\n const manifests = extensionsManifests.filter((manifest) => {\n const isValid = this.isValidAspect(manifest);\n if (!isValid) this.logger.warn(`${manifest.id} is invalid. please make sure the extension is valid.`);\n return isValid;\n });\n const preparedManifests = this.prepareManifests(manifests);\n // don't let harmony load all aspects. if seeders were sent, find their manifests, check for their static\n // dependencies, and load only them.\n const getOnlyDeclaredDependenciesManifests = () => {\n if (!seeders.length || seeders.length === preparedManifests.length) {\n return preparedManifests;\n }\n const manifestGraph = this.generateManifestGraph(preparedManifests);\n const nodes = seeders.map((seeder) => manifestGraph.successors(seeder)).flat();\n const seederNodes = compact(seeders.map((seeder) => manifestGraph.node(seeder)));\n const allNodes = [...nodes, ...seederNodes];\n const nodesUniq = uniqBy(allNodes, 'id');\n return nodesUniq.map((n) => n.attr);\n };\n const relevantManifests = getOnlyDeclaredDependenciesManifests();\n // @ts-ignore TODO: fix this\n await this.harmony.load(relevantManifests);\n } catch (e: any) {\n const ids = extensionsManifests.map((manifest) => manifest.id || 'unknown');\n if (mergedOptions.unifyErrorsByExtId) {\n const needToPrint = some(ids, (id) => !this.failedToLoadExt.has(id));\n if (!needToPrint) return;\n ids.forEach((id) => {\n this.failedToLoadExt.add(id);\n this.envs.addFailedToLoadExt(id);\n const parsedId = ComponentID.tryFromString(id);\n if (parsedId) {\n this.failedToLoadExt.add(parsedId.fullName);\n this.envs.addFailedToLoadExt(parsedId.fullName);\n }\n });\n }\n if (mergedOptions.ignoreErrors) return;\n if ((e.code === 'MODULE_NOT_FOUND' || e.code === 'ERR_MODULE_NOT_FOUND') && mergedOptions.hideMissingModuleError)\n return;\n\n if (mergedOptions.ignoreErrorFunc && mergedOptions.ignoreErrorFunc(e)) return;\n // TODO: improve texts\n const errorMsg = e.message.split('\\n')[0];\n const warning = UNABLE_TO_LOAD_EXTENSION_FROM_LIST(ids, errorMsg, neededFor);\n this.logger.error(warning, e);\n if (this.logger.isLoaderStarted) {\n if (mergedOptions.throwOnError) throw new BitError(warning);\n this.logger.consoleFailure(warning);\n } else {\n this.logger.consoleWarning(warning);\n this.logger.consoleWarning(e);\n }\n if (mergedOptions.throwOnError) {\n throw e;\n }\n }\n }\n\n private generateManifestGraph(manifests: Aspect[]) {\n const graph = new Graph<Aspect, string>();\n manifests.forEach((manifest) => graph.setNode(new Node(manifest.id, manifest)));\n manifests.forEach((manifest) => {\n const deps = manifest.getRuntime(MainRuntime)?.dependencies?.map((dep) => dep.id);\n deps?.forEach((dep) => {\n if (graph.node(dep)) {\n graph.setEdge(new Edge(manifest.id, dep, 'dep'));\n }\n });\n });\n return graph;\n }\n\n public async loadAspectFromPath(localAspects: string[]): Promise<Record<string, string>> {\n const res = {};\n const dirPaths = this.parseLocalAspect(localAspects);\n const manifests = dirPaths.map(([dirPath, localAspect]) => {\n const scopeRuntime = this.findRuntime(dirPath, 'scope');\n if (scopeRuntime) {\n // eslint-disable-next-line global-require, import/no-dynamic-require\n const module = require(join(dirPath, 'dist', scopeRuntime));\n const manifest = module.default || module;\n res[manifest.id] = localAspect;\n return manifest;\n }\n const module = require(dirPath);\n const manifest = module.default || module;\n const mainRuntime = this.findRuntime(dirPath, 'main');\n if (mainRuntime) {\n // eslint-disable-next-line global-require, import/no-dynamic-require\n const mainRuntimeModule = require(join(dirPath, 'dist', mainRuntime));\n const mainRuntimeManifest = mainRuntimeModule.default || mainRuntimeModule;\n // manifest has the \"id\" prop. the mainRuntimeManifest doesn't have it normally.\n mainRuntimeManifest.id = manifest.id;\n res[mainRuntimeManifest.id] = localAspect;\n return mainRuntimeManifest;\n }\n res[manifest.id] = localAspect;\n return manifest;\n });\n\n await this.loadExtensionsByManifests(manifests, undefined, { throwOnError: true });\n return res;\n }\n\n private parseLocalAspect(localAspects: string[]) {\n const dirPaths = localAspects.map((localAspect) => [resolve(localAspect.replace('file://', '')), localAspect]);\n const nonExistsDirPaths = dirPaths.filter(([path]) => !existsSync(path));\n nonExistsDirPaths.forEach((path) => this.logger.warn(`no such file or directory: ${path}`));\n const existsDirPaths = dirPaths.filter(([path]) => existsSync(path));\n return existsDirPaths;\n }\n\n private findRuntime(dirPath: string, runtime: string) {\n const files = readdirSync(join(dirPath, 'dist'));\n return files.find((path) => path.includes(`${runtime}.runtime.js`));\n }\n\n public async resolveLocalAspects(ids: string[], runtime?: string): Promise<AspectDefinition[]> {\n const dirs = this.parseLocalAspect(ids).map(([dir]) => dir);\n return dirs.map((dir) => {\n const srcRuntimeManifest = runtime ? this.findRuntime(dir, runtime) : undefined;\n const srcAspectFilePath = runtime ? this.findAspectFile(dir) : undefined;\n const aspectFilePath = srcAspectFilePath ? join(dir, 'dist', srcAspectFilePath) : null;\n const runtimeManifest = srcRuntimeManifest ? join(dir, 'dist', srcRuntimeManifest) : null;\n const aspectId = aspectFilePath ? this.getAspectIdFromAspectFile(aspectFilePath) : undefined;\n\n return new AspectDefinition(dir, aspectFilePath, runtimeManifest, undefined, aspectId, true);\n });\n }\n\n private findAspectFile(dirPath: string) {\n const files = readdirSync(join(dirPath, 'dist'));\n return files.find((path) => path.includes(`.aspect.js`));\n }\n\n static runtime = MainRuntime;\n static dependencies = [LoggerAspect, EnvsAspect, GraphqlAspect];\n static slots = [\n Slot.withType<OnAspectLoadError>(),\n Slot.withType<OnLoadRequireableExtension>(),\n Slot.withType<PluginDefinition[]>(),\n ];\n\n static async provider(\n [loggerExt, envs, graphql]: [LoggerMain, EnvsMain, GraphqlMain],\n config,\n [onAspectLoadErrorSlot, onLoadRequireableExtensionSlot, pluginSlot]: [\n OnAspectLoadErrorSlot,\n OnLoadRequireableExtensionSlot,\n PluginDefinitionSlot,\n ],\n harmony: Harmony\n ) {\n const logger = loggerExt.createLogger(AspectLoaderAspect.id);\n const aspectLoader = new AspectLoaderMain(\n logger,\n envs,\n harmony,\n onAspectLoadErrorSlot,\n onLoadRequireableExtensionSlot,\n pluginSlot\n );\n\n graphql.register(() => aspectLoaderSchema(aspectLoader));\n aspectLoader.registerPlugins([envs.getEnvPlugin()]);\n\n return aspectLoader;\n }\n}\n\nAspectLoaderAspect.addRuntime(AspectLoaderMain);\n\nexport default AspectLoaderMain;\n"],"mappings":";;;;;;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,WAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAA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AAI,IAAKA,IAAI,CAAC/I,QAAQ,CAAC,YAAY,CAAC,CAAC;EAC1D;EAUA,aAAa4F,QAAQA,CACnB,CAACsL,SAAS,EAAEzT,IAAI,EAAE0T,OAAO,CAAsC,EAC/DzP,MAAM,EACN,CAAC/D,qBAAqB,EAAEC,8BAA8B,EAAEC,UAAU,CAIjE,EACDH,OAAgB,EAChB;IACA,MAAMF,MAAM,GAAG0T,SAAS,CAACE,YAAY,CAACC,kCAAkB,CAAClT,EAAE,CAAC;IAC5D,MAAMmT,YAAY,GAAG,IAAIhU,gBAAgB,CACvCE,MAAM,EACNC,IAAI,EACJC,OAAO,EACPC,qBAAqB,EACrBC,8BAA8B,EAC9BC,UACF,CAAC;IAEDsT,OAAO,CAACvS,QAAQ,CAAC,MAAM,IAAA2S,mCAAkB,EAACD,YAAY,CAAC,CAAC;IACxDA,YAAY,CAAC5E,eAAe,CAAC,CAACjP,IAAI,CAAC+T,YAAY,CAAC,CAAC,CAAC,CAAC;IAEnD,OAAOF,YAAY;EACrB;AACF;AAACG,OAAA,CAAAnU,gBAAA,GAAAA,gBAAA;AAAAhB,eAAA,CAnxBYgB,gBAAgB,aAkvBViP,8BAAW;AAAAjQ,eAAA,CAlvBjBgB,gBAAgB,kBAmvBL,CAACoU,sBAAY,EAAEC,kBAAU,EAAEC,wBAAa,CAAC;AAAAtV,eAAA,CAnvBpDgB,gBAAgB,WAovBZ,CACbuU,eAAI,CAACC,QAAQ,CAAoB,CAAC,EAClCD,eAAI,CAACC,QAAQ,CAA6B,CAAC,EAC3CD,eAAI,CAACC,QAAQ,CAAqB,CAAC,CACpC;AA6BHT,kCAAkB,CAACxL,UAAU,CAACvI,gBAAgB,CAAC;AAAC,IAAAyU,QAAA,GAAAN,OAAA,CAAApW,OAAA,GAEjCiC,gBAAgB","ignoreList":[]}
1
+ {"version":3,"names":["_path","data","require","_nodeUtils","_interopRequireDefault","_fsExtra","_graph","_harmonyModules","_recordLoadedEsmFile","_replaceNeverLoadedAspects","_componentId","_legacy","_harmonyModules2","_harmony","_bitError","_logger","_compilationModules","_envs","_graphql","_pMapSeries","_lodash","_aspectDefinition","_aspectLoader","_constants","_isEsmModule","_exceptions","_coreAspects","_plugins","_aspectLoader2","e","__esModule","default","ownKeys","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","AspectLoaderMain","constructor","logger","envs","harmony","onAspectLoadErrorSlot","onLoadRequireableExtensionSlot","pluginSlot","Set","getCoreAspectsPackagesAndIds","allCoreAspectsIds","getCoreAspectIds","coreAspectsPackagesAndIds","id","packageName","getCoreAspectPackageName","getCompiler","component","env","getEnv","registerOnAspectLoadErrorSlot","onAspectLoadError","register","registerOnLoadRequireableExtensionSlot","onLoadRequireableExtension","triggerOnAspectLoadError","err","entries","toArray","isFixed","mapSeries","onAspectFailFunc","result","getRuntimePath","modulePath","runtime","runtimeFile","filesystem","files","find","file","relative","includes","compiler","join","dist","getDistPathBySrcPath","info","distPath","DEFAULT_DIST_DIRNAME","replaceFileExtToJs","getAspectFilePath","aspectFile","isAspectLoaded","failedAspects","get","getDescriptor","instance","iconFn","icon","undefined","addInMemoryConfiguredAspect","aspectId","inMemoryConfiguredAspects","getConfiguredAspects","configuredAspects","Array","from","config","raw","iMemoryConfiguredAspects","concat","getNotLoadedConfiguredExtensions","harmonyExtensions","extensionsIds","loadedExtensions","extId","extensions","loaded","extensionsToLoad","difference","loadDefinition","props","AspectDefinition","coreAspects","isCoreAspect","ids","setCoreAspects","aspects","setNonCoreAspects","_nonCoreAspects","map","aspect","_reserved","getNonCoreAspectIds","getCoreEnvsIds","envsIds","allIds","intersection","isCoreEnv","getUserAspects","coreAspectIds","nonCoreAspectIds","nonUserAspectIds","getCoreAspectDefs","runtimeName","defs","Promise","all","rawDef","getAspectDef","def","runtimePath","resolveAspects","components","resolver","promises","resolvedAspect","aspectPath","aspectFilePath","aspectDefs","compact","mainAspect","_mainAspect","setMainAspect","failedLoadAspect","resetFailedLoadAspects","addFailure","cloneManifest","manifest","cloned","assign","create","getPrototypeOf","provider","addRuntime","getRuntime","doRequire","requireableExtension","runSubscribers","idStr","toString","runOnLoadRequireableExtensionSubscribers","loadRequireableExtensions","requireableExtensions","throwOnError","manifests","getManifestsFromRequireableExtensions","loadExtensionsByManifests","manifestsP","firstErr","warn","errAfterReLoad","error","handleExtensionLoadingError","addFailedToLoadExt","errorMsg","message","split","msg","UNABLE_TO_LOAD_EXTENSION","console","CannotLoadExtension","reportLoadFailure","failedId","phase","printWarningIfFirstTime","isLoaderStarted","envId","showAsFailure","alreadyShownWarning","has","add","consoleFailure","consoleWarning","updatedManifest","onLoadRequireableExtensionFunc","getPluginDefs","flatten","values","getPluginDefsByAspectId","getPlugins","componentPath","getPluginsFromDefs","isEsmModule","path","loadEsm","module","esmLoader","recordLoadedEsmFile","Plugins","bind","pluginFileResolver","getPluginFiles","hasPluginFiles","isEmpty","searchDistFile","rootDir","relativePath","replaceNotFound","defaultDistDir","fileExtension","extname","fileNames","ext","replace","RegExp","defaultDistPath","fileName","found","existsSync","jsFileName","finalPath","endsWith","distFile","isAspect","isValidAspect","isAspectComponent","isUsingAspectEnv","filterAspectDefs","allDefs","componentIds","filterOpts","coreIds","stringIds","toStringWithoutVersion","afterExclusion","excludeCore","isCore","getId","ComponentID","fromString","isTarget","uniqDefs","uniqBy","filterByRuntime","requestedOnly","componentIdsString","getAspectIdFromAspectFile","isObject","prepareManifests","MainRuntime","Error","Aspect","registerPlugins","pluginDefs","extensionsManifests","context","seeders","options","hideMissingModuleError","ignoreErrors","unifyErrorsByExtId","neededFor","defaultLoadExtByManifestOptions","mergedOptions","isValid","preparedManifests","getOnlyDeclaredDependenciesManifests","manifestGraph","generateManifestGraph","nodes","seeder","successors","flat","seederNodes","node","allNodes","nodesUniq","n","attr","relevantManifests","replacedIds","replaceNeverLoadedAspects","debug","load","needToPrint","some","failedToLoadExt","parsedId","tryFromString","fullName","code","ignoreErrorFunc","warning","UNABLE_TO_LOAD_EXTENSION_FROM_LIST","BitError","graph","Graph","setNode","Node","deps","dependencies","dep","setEdge","Edge","loadAspectFromPath","localAspects","res","dirPaths","parseLocalAspect","dirPath","localAspect","scopeRuntime","findRuntime","mainRuntime","mainRuntimeModule","mainRuntimeManifest","resolve","nonExistsDirPaths","existsDirPaths","readdirSync","resolveLocalAspects","dirs","dir","srcRuntimeManifest","srcAspectFilePath","findAspectFile","runtimeManifest","loggerExt","graphql","createLogger","AspectLoaderAspect","aspectLoader","aspectLoaderSchema","getEnvPlugin","exports","LoggerAspect","EnvsAspect","GraphqlAspect","Slot","withType","_default"],"sources":["aspect-loader.main.runtime.ts"],"sourcesContent":["import { join, resolve, extname } from 'path';\nimport esmLoader from '@teambit/node.utils.esm-loader';\n// import findRoot from 'find-root';\nimport { readdirSync, existsSync } from 'fs-extra';\nimport { Graph, Node, Edge } from '@teambit/graph.cleargraph';\nimport { reportLoadFailure } from '@teambit/harmony.modules.load-trace';\nimport { recordLoadedEsmFile } from './record-loaded-esm-file';\nimport { replaceNeverLoadedAspects } from './replace-never-loaded-aspects';\nimport { ComponentID } from '@teambit/component-id';\nimport { DEFAULT_DIST_DIRNAME } from '@teambit/legacy.constants';\nimport { MainRuntime } from '@teambit/harmony.modules.runtimes';\nimport type { ExtensionManifest, Harmony, SlotRegistry } from '@teambit/harmony';\nimport { Aspect, Slot } from '@teambit/harmony';\nimport { BitError } from '@teambit/bit-error';\nimport type { LoggerMain, Logger } from '@teambit/logger';\nimport type { Component, FilterAspectsOptions } from '@teambit/component';\nimport { LoggerAspect } from '@teambit/logger';\nimport type { RequireableComponent } from '@teambit/harmony.modules.requireable-component';\nimport { replaceFileExtToJs } from '@teambit/compilation.modules.babel-compiler';\nimport type { EnvsMain } from '@teambit/envs';\nimport { EnvsAspect } from '@teambit/envs';\nimport type { GraphqlMain } from '@teambit/graphql';\nimport { GraphqlAspect } from '@teambit/graphql';\nimport mapSeries from 'p-map-series';\nimport { difference, compact, flatten, intersection, uniqBy, some, isEmpty, isObject } from 'lodash';\nimport type { AspectDefinitionProps } from './aspect-definition';\nimport { AspectDefinition } from './aspect-definition';\nimport type { PluginDefinition } from './plugin-definition';\nimport { AspectLoaderAspect } from './aspect-loader.aspect';\nimport { UNABLE_TO_LOAD_EXTENSION, UNABLE_TO_LOAD_EXTENSION_FROM_LIST } from './constants';\nimport { isEsmModule } from './is-esm-module';\nimport { CannotLoadExtension } from './exceptions';\nimport { getAspectDef, getCoreAspectPackageName } from './core-aspects';\nimport { Plugins } from './plugins';\nimport { aspectLoaderSchema } from './aspect-loader.graphql';\n\nexport type PluginDefinitionSlot = SlotRegistry<PluginDefinition[]>;\n\nexport type AspectDescriptor = {\n /**\n * name of the extension.\n */\n id: string;\n\n /**\n * icon of the extension.\n */\n icon?: string;\n};\n\nexport type AspectResolver = (component: Component) => Promise<ResolvedAspect | undefined>;\n\nexport type ResolvedAspect = {\n aspectPath: string;\n runtimePath: string | null;\n aspectFilePath: string | null;\n};\n\nexport type LoadExtByManifestContext = {\n seeders?: string[];\n neededFor?: string;\n};\n\nexport type LoadExtByManifestOptions = {\n throwOnError?: boolean;\n hideMissingModuleError?: boolean;\n ignoreErrorFunc?: (err: Error) => boolean;\n ignoreErrors?: boolean;\n /**\n * If this is enabled then we will show loading error only once for a given extension\n * (even if it was actually try to load it few times by different components for example)\n */\n unifyErrorsByExtId?: boolean;\n};\n\ntype OnAspectLoadError = (err: Error, component: Component) => Promise<boolean>;\nexport type OnAspectLoadErrorSlot = SlotRegistry<OnAspectLoadError>;\n\nexport type OnAspectLoadErrorHandler = (err: Error, component: Component) => Promise<boolean>;\n\nexport type OnLoadRequireableExtension = (\n requireableExtension: RequireableComponent,\n manifest: ExtensionManifest | Aspect\n) => Promise<ExtensionManifest | Aspect>;\n/**\n * A slot which run during loading the requirable extension (after first manifest calculation)\n */\nexport type OnLoadRequireableExtensionSlot = SlotRegistry<OnLoadRequireableExtension>;\n\nexport type MainAspect = {\n /**\n * path to the main aspect.\n */\n path: string;\n\n /**\n * version of the aspect.\n */\n version: string | undefined;\n\n /**\n * package name of the aspect\n */\n packageName: string | undefined;\n\n /**\n * reference to aspect manifest.\n */\n aspect: Aspect;\n\n /**\n * The name of the aspect (without the scope prefix)\n */\n name: string;\n\n /**\n * The name of the aspect\n */\n id: string;\n};\n\nexport class AspectLoaderMain {\n private inMemoryConfiguredAspects: string[] = [];\n private failedToLoadExt = new Set<string>();\n private alreadyShownWarning = new Set<string>();\n\n constructor(\n private logger: Logger,\n private envs: EnvsMain,\n private harmony: Harmony,\n private onAspectLoadErrorSlot: OnAspectLoadErrorSlot,\n private onLoadRequireableExtensionSlot: OnLoadRequireableExtensionSlot,\n private pluginSlot: PluginDefinitionSlot\n ) {}\n\n getCoreAspectsPackagesAndIds(): Record<string, string> {\n const allCoreAspectsIds = this.getCoreAspectIds();\n const coreAspectsPackagesAndIds = {};\n\n allCoreAspectsIds.forEach((id) => {\n const packageName = getCoreAspectPackageName(id);\n coreAspectsPackagesAndIds[packageName] = id;\n });\n\n return coreAspectsPackagesAndIds;\n }\n\n private getCompiler(component: Component) {\n const env = this.envs.getEnv(component)?.env;\n return env?.getCompiler();\n }\n\n registerOnAspectLoadErrorSlot(onAspectLoadError: OnAspectLoadError) {\n this.onAspectLoadErrorSlot.register(onAspectLoadError);\n }\n\n registerOnLoadRequireableExtensionSlot(onLoadRequireableExtension: OnLoadRequireableExtension) {\n this.onLoadRequireableExtensionSlot.register(onLoadRequireableExtension);\n }\n\n /**\n * returns whether the aspect-load issue has been fixed.\n */\n async triggerOnAspectLoadError(err: Error, component: Component): Promise<boolean> {\n const entries = this.onAspectLoadErrorSlot.toArray(); // e.g. [ [ 'teambit.bit/compiler', [Function: bound onAspectLoadError] ] ]\n let isFixed = false;\n await mapSeries(entries, async ([, onAspectFailFunc]) => {\n const result = await onAspectFailFunc(err, component);\n if (result) isFixed = true;\n });\n\n return isFixed;\n }\n\n async getRuntimePath(component: Component, modulePath: string, runtime: string): Promise<string | null> {\n const runtimeFile = component.filesystem.files.find((file: any) => {\n return file.relative.includes(`.${runtime}.runtime`);\n });\n\n // @david we should add a compiler api for this.\n if (!runtimeFile) return null;\n try {\n const compiler = this.getCompiler(component);\n\n if (!compiler) {\n return join(modulePath, runtimeFile.relative);\n }\n\n const dist = compiler.getDistPathBySrcPath(runtimeFile.relative);\n return join(modulePath, dist);\n } catch (e) {\n this.logger.info(`got an error during get runtime path, probably the env is not loaded yet ${e}`);\n // TODO: we are manually adding the dist here and replace the file name to handle case when\n // we load aspects from scope, and their env in the same iteration, but we get into the aspect before its\n // env, so it's env doesn't exist yet\n // we should make sure to first load the env correctly before loading the aspect\n const distPath = join(modulePath, DEFAULT_DIST_DIRNAME, replaceFileExtToJs(runtimeFile.relative));\n return distPath;\n }\n }\n\n async getAspectFilePath(component: Component, modulePath: string): Promise<string | null> {\n const aspectFile = component.filesystem.files.find((file: any) => {\n return file.relative.includes(`.aspect.ts`) || file.relative.includes(`.aspect.js`);\n });\n\n // @david we should add a compiler api for this.\n if (!aspectFile) return null;\n try {\n const compiler = this.getCompiler(component);\n\n if (!compiler) {\n return join(modulePath, aspectFile.relative);\n }\n\n const dist = compiler.getDistPathBySrcPath(aspectFile.relative);\n return join(modulePath, dist);\n } catch (e) {\n this.logger.info(`got an error during get runtime path, probably the env is not loaded yet ${e}`);\n // TODO: we are manually adding the dist here and replace the file name to handle case when\n // we load aspects from scope, and their env in the same iteration, but we get into the aspect before its\n // env, so it's env doesn't exist yet\n // we should make sure to first load the env correctly before loading the aspect\n const distPath = join(modulePath, DEFAULT_DIST_DIRNAME, replaceFileExtToJs(aspectFile.relative));\n return distPath;\n }\n }\n\n isAspectLoaded(id: string) {\n if (this.failedAspects.includes(id)) return true;\n try {\n return this.harmony.get(id);\n } catch {\n return false;\n }\n }\n\n getDescriptor(id: string): AspectDescriptor | undefined {\n try {\n const instance = this.harmony.get<any>(id);\n const iconFn = instance.icon;\n\n const icon = iconFn ? iconFn.apply(instance) : undefined;\n\n return {\n id,\n icon,\n };\n } catch {\n return undefined;\n }\n }\n\n /**\n * This is used when adding aspects to workspace.jsonc during the process (like in bit use command)\n * and we want to make sure that follow operation (like bit install) will recognize those aspects\n * but the harmony config is already in memory.\n * Probably a better to do it is to make sure we can re-load the config somehow\n * ideally by adding the config class in harmony a reload API\n * @param aspectId\n */\n addInMemoryConfiguredAspect(aspectId: string): void {\n this.inMemoryConfiguredAspects.push(aspectId);\n }\n\n /**\n * get all the configured aspects in the config file (workspace.jsonc / scope.jsonc)\n */\n getConfiguredAspects(): string[] {\n const configuredAspects = Array.from(this.harmony.config.raw.keys());\n const iMemoryConfiguredAspects = this.inMemoryConfiguredAspects;\n return configuredAspects.concat(iMemoryConfiguredAspects);\n }\n getNotLoadedConfiguredExtensions() {\n const configuredAspects = this.getConfiguredAspects();\n const harmonyExtensions = this.harmony.extensionsIds;\n const loadedExtensions = harmonyExtensions.filter((extId) => {\n return this.harmony.extensions.get(extId)?.loaded;\n });\n const extensionsToLoad = difference(configuredAspects, loadedExtensions);\n return extensionsToLoad;\n }\n\n loadDefinition(props: AspectDefinitionProps): AspectDefinition {\n return AspectDefinition.from(props);\n }\n\n private _coreAspects: Aspect[] = [];\n private _nonCoreAspects: Aspect[] = [];\n\n get coreAspects() {\n return this._coreAspects;\n }\n\n isCoreAspect(id: string) {\n const ids = this.getCoreAspectIds();\n return ids.includes(id);\n }\n\n setCoreAspects(aspects: Aspect[]) {\n this._coreAspects = aspects;\n return this;\n }\n\n setNonCoreAspects(aspects: Aspect[]) {\n this._nonCoreAspects = aspects;\n return this;\n }\n\n getCoreAspectIds(): string[] {\n const ids = this.coreAspects.map((aspect) => aspect.id);\n return ids.concat(this._reserved);\n }\n\n /**\n * bit aspects that are not core aspects\n * normally coming from a composition over teambit.harmony/bit and are passed to loadBit as \"additionalAspects\".\n * these are *not* user aspects. they're not in workspaces created by users. they're part of bit installation.\n */\n getNonCoreAspectIds(): string[] {\n return this._nonCoreAspects.map((aspect) => aspect.id);\n }\n\n /**\n * Get all the core envs ids which is still register in the bit manifest as core aspect\n */\n getCoreEnvsIds(): string[] {\n const envsIds = this.envs.getCoreEnvsIds();\n const allIds = this.getCoreAspectIds();\n return intersection(allIds, envsIds);\n }\n\n isCoreEnv(id: string): boolean {\n const ids = this.getCoreEnvsIds();\n return ids.includes(id);\n }\n\n private _reserved = ['teambit.harmony/bit', 'teambit.harmony/config'];\n\n getUserAspects(): string[] {\n const coreAspectIds = this.getCoreAspectIds();\n const nonCoreAspectIds = this.getNonCoreAspectIds();\n const nonUserAspectIds = [...coreAspectIds, ...nonCoreAspectIds];\n return difference(this.harmony.extensionsIds, nonUserAspectIds);\n }\n\n async getCoreAspectDefs(runtimeName?: string) {\n const defs = await Promise.all(\n this.coreAspects.map(async (aspect) => {\n const id = aspect.id;\n const rawDef = await getAspectDef(id, runtimeName);\n return this.loadDefinition(rawDef);\n })\n );\n\n return defs.filter((def) => def.runtimePath);\n }\n\n async resolveAspects(components: Component[], resolver: AspectResolver): Promise<AspectDefinition[]> {\n const promises = components.map(async (component) => {\n const resolvedAspect = await resolver(component);\n if (!resolvedAspect) return undefined;\n return new AspectDefinition(\n resolvedAspect.aspectPath,\n resolvedAspect.aspectFilePath,\n resolvedAspect.runtimePath,\n component\n );\n });\n\n const aspectDefs = await Promise.all(promises);\n // return aspectDefs.filter((def) => def.runtimePath);\n return compact(aspectDefs);\n }\n\n private _mainAspect: MainAspect;\n\n get mainAspect() {\n return this._mainAspect;\n }\n\n setMainAspect(mainAspect: MainAspect) {\n this._mainAspect = mainAspect;\n return this;\n }\n\n private failedLoadAspect: string[] = [];\n\n get failedAspects() {\n return this.failedLoadAspect;\n }\n\n public resetFailedLoadAspects() {\n this.failedLoadAspect = [];\n }\n\n private addFailure(id: string): void {\n if (this.failedAspects.includes(id)) return;\n this.failedLoadAspect.push(id);\n }\n\n cloneManifest(manifest: any) {\n const cloned = Object.assign(Object.create(Object.getPrototypeOf(manifest)), manifest);\n cloned.provider = manifest.provider;\n cloned.addRuntime = manifest.addRuntime;\n cloned.getRuntime = manifest.getRuntime;\n return cloned;\n }\n\n /**\n * run \"require\" of the component code to get the manifest\n */\n async doRequire(\n requireableExtension: RequireableComponent,\n runSubscribers = true\n ): Promise<ExtensionManifest | Aspect> {\n const idStr = requireableExtension.component.id.toString();\n const aspect = await requireableExtension.require();\n const manifest = aspect.default || aspect;\n manifest.id = idStr;\n // It's important to clone deep the manifest here to prevent mutate dependencies of other manifests as they point to the same location in memory\n const cloned = this.cloneManifest(manifest);\n if (runSubscribers) return this.runOnLoadRequireableExtensionSubscribers(requireableExtension, cloned);\n return cloned;\n }\n\n /**\n * in case the extension failed to load, prefer to throw an error, unless `throwOnError` param\n * passed as `false`.\n * there are cases when throwing an error blocks the user from doing anything else. for example,\n * when a user develops an extension and deletes the node-modules, the extension on the workspace\n * cannot be loaded anymore until \"bit compile\" is running. however, if this function throws an\n * error, it'll throw for \"bit compile\" as well, which blocks the user.\n * for the CI, it is important to throw an error because errors on console can be ignored.\n * for now, when loading the extension from the workspace the throwOnError is passed as false.\n * when loading from the scope (CI) it should be true.\n *\n * the console printing here is done directly by \"console.error\" and not by the logger. the reason\n * is that the logger.console only prints when the loader started (which, btw, happens after\n * entering this function, so it can't work) and here we want it to be printed regardless of the\n * rules of starting the loader. e.g. if by mistake the CI got it as throwOnError=false, it's ok\n * to break the output by the console.error.\n *\n * @todo: this is not the final word however about throwing/non throwing errors here.\n * in some cases, such as \"bit tag\", it's better not to tag if an extension changes the model.\n */\n async loadRequireableExtensions(requireableExtensions: RequireableComponent[], throwOnError = false): Promise<void> {\n const manifests = await this.getManifestsFromRequireableExtensions(requireableExtensions, throwOnError);\n return this.loadExtensionsByManifests(manifests, undefined, { throwOnError });\n }\n\n async getManifestsFromRequireableExtensions(\n requireableExtensions: RequireableComponent[],\n throwOnError = false,\n runSubscribers = true\n ): Promise<Array<ExtensionManifest | Aspect>> {\n const manifestsP = mapSeries(requireableExtensions, async (requireableExtension) => {\n if (!requireableExtensions) return undefined;\n const idStr = requireableExtension.component.id.toString();\n try {\n return await this.doRequire(requireableExtension, runSubscribers);\n } catch (firstErr: any) {\n this.addFailure(idStr);\n this.logger.warn(`failed loading an aspect \"${idStr}\", will try to fix and reload`, firstErr);\n const isFixed = await this.triggerOnAspectLoadError(firstErr, requireableExtension.component);\n let errAfterReLoad;\n if (isFixed) {\n this.logger.info(`the loading issue might be fixed now, re-loading ${idStr}`);\n try {\n return await this.doRequire(requireableExtension);\n } catch (err: any) {\n this.logger.warn(`re-load of the aspect \"${idStr}\" failed as well`, err);\n errAfterReLoad = err;\n }\n }\n const error = errAfterReLoad || firstErr;\n this.handleExtensionLoadingError(error, idStr, throwOnError);\n }\n return undefined;\n });\n const manifests = await manifestsP;\n\n // Remove empty manifests as a result of loading issue\n return compact(manifests);\n }\n\n handleExtensionLoadingError(error: Error, idStr: string, throwOnError: boolean) {\n this.envs.addFailedToLoadExt(idStr);\n const errorMsg = error.message.split('\\n')[0]; // show only the first line if the error is long (e.g. happens with MODULE_NOT_FOUND errors)\n const msg = UNABLE_TO_LOAD_EXTENSION(idStr, errorMsg);\n if (throwOnError) {\n // @ts-ignore\n this.logger.console(error);\n throw new CannotLoadExtension(idStr, error);\n }\n // the failure is swallowed (best-effort loading). record it on the active load-trace so the\n // component loader surfaces it as a component issue, visible in \"bit status\".\n reportLoadFailure({ failedId: idStr, phase: 'require-aspects', error: errorMsg });\n this.logger.error(msg, error);\n this.printWarningIfFirstTime(idStr, msg, this.logger.isLoaderStarted);\n }\n\n private printWarningIfFirstTime(envId: string, msg: string, showAsFailure: boolean) {\n if (!this.alreadyShownWarning.has(envId)) {\n this.alreadyShownWarning.add(envId);\n if (showAsFailure) {\n this.logger.consoleFailure(msg);\n } else {\n this.logger.consoleWarning(msg);\n }\n }\n }\n\n async runOnLoadRequireableExtensionSubscribers(\n requireableExtension: RequireableComponent,\n manifest: ExtensionManifest | Aspect\n ): Promise<ExtensionManifest | Aspect> {\n let updatedManifest = manifest;\n const entries = this.onLoadRequireableExtensionSlot.toArray();\n await mapSeries(entries, async ([, onLoadRequireableExtensionFunc]) => {\n updatedManifest = await onLoadRequireableExtensionFunc(requireableExtension, updatedManifest);\n });\n return updatedManifest;\n }\n\n getPluginDefs() {\n return flatten(this.pluginSlot.values());\n }\n\n /**\n * same as `getPluginDefs`, only that the defs are grouped by the aspect-id (including the version) that registered\n * them. useful when the same plugin-pattern is registered by more than one version of the same aspect, and the\n * consumer needs to know which version registered what.\n */\n getPluginDefsByAspectId(): Array<[string, PluginDefinition[]]> {\n return this.pluginSlot.toArray();\n }\n\n getPlugins(component: Component, componentPath: string): Plugins {\n const defs = this.getPluginDefs();\n return this.getPluginsFromDefs(component, componentPath, defs);\n }\n\n async isEsmModule(path: string) {\n return isEsmModule(path);\n }\n\n async loadEsm(path: string) {\n const module = await esmLoader(path);\n // only a load that succeeded leaves something in memory that needs its files kept around\n recordLoadedEsmFile(path);\n return module;\n }\n\n getPluginsFromDefs(component: Component, componentPath: string, defs: PluginDefinition[]): Plugins {\n return Plugins.from(\n component,\n defs,\n this.triggerOnAspectLoadError.bind(this),\n this.logger,\n this.pluginFileResolver.call(this, component, componentPath)\n );\n }\n\n getPluginFiles(component: Component, componentPath: string): string[] {\n const defs = this.getPluginDefs();\n return Plugins.files(component, defs, this.pluginFileResolver.call(this, component, componentPath));\n }\n\n hasPluginFiles(component: Component): boolean {\n const defs = this.getPluginDefs();\n const files = Plugins.files(component, defs);\n return !isEmpty(files);\n }\n\n private searchDistFile(rootDir: string, relativePath: string, replaceNotFound = false) {\n const defaultDistDir = join(rootDir, 'dist');\n const fileExtension = extname(relativePath);\n const fileNames = ['ts', 'js', 'tsx', 'jsx'].map((ext) =>\n relativePath.replace(new RegExp(`${fileExtension}$`), `.${ext}`)\n );\n const defaultDistPath = fileNames.map((fileName) => join(defaultDistDir, fileName));\n const found = defaultDistPath.find((distPath) => existsSync(distPath));\n if (found) return found;\n if (!replaceNotFound) return null;\n const jsFileName = relativePath.replace(new RegExp(`${fileExtension}$`), `.js`);\n const finalPath = join(defaultDistDir, jsFileName);\n return finalPath;\n }\n\n pluginFileResolver(component: Component, rootDir: string) {\n return (relativePath: string) => {\n const replaceNotFound = relativePath.endsWith('.ts') || relativePath.endsWith('.tsx');\n\n try {\n const compiler = this.getCompiler(component);\n if (!compiler) {\n const distFile = this.searchDistFile(rootDir, relativePath, replaceNotFound);\n return distFile || join(rootDir, relativePath);\n }\n\n const dist = compiler.getDistPathBySrcPath(relativePath);\n return join(rootDir, dist);\n } catch (err) {\n // This might happen for example when loading an env from the global scope, and the env of the env / aspect is not a core one\n this.logger.info(\n `pluginFileResolver: got an error during get compiler for component ${component.id.toString()}, probably the env is not loaded yet ${err}`\n );\n const distFile = this.searchDistFile(rootDir, relativePath, replaceNotFound);\n return distFile || join(rootDir, relativePath);\n }\n };\n }\n\n isAspect(manifest: any) {\n return !!(manifest.addRuntime && manifest.getRuntime);\n }\n\n isValidAspect(manifest: any): boolean {\n return this.isAspect(manifest) || manifest.provider;\n }\n\n isAspectComponent(component: Component): boolean {\n return this.envs.isUsingAspectEnv(component);\n }\n\n filterAspectDefs(\n allDefs: AspectDefinition[],\n componentIds: ComponentID[],\n runtimeName: string | undefined,\n filterOpts: FilterAspectsOptions = {}\n ) {\n const coreIds = this.getCoreAspectIds();\n const stringIds = componentIds.map((id) => id.toStringWithoutVersion());\n const afterExclusion = filterOpts.excludeCore\n ? allDefs.filter((def) => {\n const isCore = coreIds.includes(def.getId || '');\n const id = ComponentID.fromString(def.getId || '');\n const isTarget = stringIds.includes(id.toStringWithoutVersion());\n if (isTarget) return true;\n return !isCore;\n })\n : allDefs;\n\n const uniqDefs = uniqBy(afterExclusion, (def) => `${def.aspectPath}-${def.runtimePath}`);\n let defs = uniqDefs;\n if (runtimeName && filterOpts.filterByRuntime) {\n defs = defs.filter((def) => def.runtimePath);\n }\n\n if (componentIds && componentIds.length && filterOpts.requestedOnly) {\n const componentIdsString = componentIds.map((id) => id.toString());\n defs = defs.filter((def) => {\n return (\n (def.id && componentIdsString.includes(def.id)) ||\n (def.component && componentIdsString.includes(def.component?.id.toString()))\n );\n });\n }\n\n return defs;\n }\n\n getAspectIdFromAspectFile(aspectFilePath: string): string | undefined {\n try {\n // eslint-disable-next-line global-require, import/no-dynamic-require\n const module = aspectFilePath ? require(aspectFilePath) : undefined;\n let manifest = module.default || module;\n if (this.isAspect(manifest)) {\n return manifest.id;\n }\n if (isObject(manifest)) {\n if (isEmpty(manifest)) {\n this.logger.warn(\n `getAspectIdFromAspectFile - aspect at ${aspectFilePath} missing exports. couldn't calculate the manifest`\n );\n return undefined;\n }\n if (Object.keys(manifest).length > 1) {\n this.logger.warn(\n `getAspectIdFromAspectFile - aspect at ${aspectFilePath} exports too many keys. couldn't calculate the manifest`\n );\n return undefined;\n }\n manifest = Object.values(manifest)[0];\n if (this.isAspect(manifest)) {\n return manifest.id;\n }\n }\n this.logger.warn(`getAspectIdFromAspectFile - aspect at ${aspectFilePath} is not a valid aspect`);\n return undefined;\n } catch (err) {\n this.logger.warn(`getAspectIdFromAspectFile - couldn't require the aspect file ${aspectFilePath}. err: ${err}`);\n return undefined;\n }\n }\n\n private prepareManifests(manifests: Array<ExtensionManifest | Aspect>): Aspect[] {\n return manifests.map((manifest: any) => {\n if (this.isAspect(manifest)) return manifest as Aspect;\n manifest.runtime = MainRuntime;\n if (!manifest.id) throw new Error('manifest must have static id');\n const aspect = Aspect.create({\n id: manifest.id,\n });\n aspect.addRuntime(manifest);\n return aspect;\n });\n }\n\n /**\n * register a plugin.\n */\n registerPlugins(pluginDefs: PluginDefinition[]) {\n this.pluginSlot.register(pluginDefs);\n }\n\n async loadExtensionsByManifests(\n extensionsManifests: Array<ExtensionManifest | Aspect>,\n context: LoadExtByManifestContext = {\n seeders: [],\n },\n options: LoadExtByManifestOptions = {\n throwOnError: true,\n hideMissingModuleError: false,\n ignoreErrors: false,\n unifyErrorsByExtId: true,\n }\n ) {\n const neededFor = context.neededFor;\n const seeders = context.seeders || [];\n const defaultLoadExtByManifestOptions = {\n throwOnError: true,\n hideMissingModuleError: false,\n ignoreErrors: false,\n unifyErrorsByExtId: true,\n };\n const mergedOptions = { ...defaultLoadExtByManifestOptions, ...options };\n try {\n const manifests = extensionsManifests.filter((manifest) => {\n const isValid = this.isValidAspect(manifest);\n if (!isValid) this.logger.warn(`${manifest.id} is invalid. please make sure the extension is valid.`);\n return isValid;\n });\n const preparedManifests = this.prepareManifests(manifests);\n // don't let harmony load all aspects. if seeders were sent, find their manifests, check for their static\n // dependencies, and load only them.\n const getOnlyDeclaredDependenciesManifests = () => {\n if (!seeders.length || seeders.length === preparedManifests.length) {\n return preparedManifests;\n }\n const manifestGraph = this.generateManifestGraph(preparedManifests);\n const nodes = seeders.map((seeder) => manifestGraph.successors(seeder)).flat();\n const seederNodes = compact(seeders.map((seeder) => manifestGraph.node(seeder)));\n const allNodes = [...nodes, ...seederNodes];\n const nodesUniq = uniqBy(allNodes, 'id');\n return nodesUniq.map((n) => n.attr);\n };\n const relevantManifests = getOnlyDeclaredDependenciesManifests();\n const replacedIds = replaceNeverLoadedAspects(this.harmony, relevantManifests);\n if (replacedIds.length) {\n this.logger.debug(`loadExtensionsByManifests, replaced never-loaded aspects: ${replacedIds.join(', ')}`);\n }\n // @ts-ignore TODO: fix this\n await this.harmony.load(relevantManifests);\n } catch (e: any) {\n const ids = extensionsManifests.map((manifest) => manifest.id || 'unknown');\n if (mergedOptions.unifyErrorsByExtId) {\n const needToPrint = some(ids, (id) => !this.failedToLoadExt.has(id));\n if (!needToPrint) return;\n ids.forEach((id) => {\n this.failedToLoadExt.add(id);\n this.envs.addFailedToLoadExt(id);\n const parsedId = ComponentID.tryFromString(id);\n if (parsedId) {\n this.failedToLoadExt.add(parsedId.fullName);\n this.envs.addFailedToLoadExt(parsedId.fullName);\n }\n });\n }\n if (mergedOptions.ignoreErrors) return;\n if ((e.code === 'MODULE_NOT_FOUND' || e.code === 'ERR_MODULE_NOT_FOUND') && mergedOptions.hideMissingModuleError)\n return;\n\n if (mergedOptions.ignoreErrorFunc && mergedOptions.ignoreErrorFunc(e)) return;\n // TODO: improve texts\n const errorMsg = e.message.split('\\n')[0];\n const warning = UNABLE_TO_LOAD_EXTENSION_FROM_LIST(ids, errorMsg, neededFor);\n this.logger.error(warning, e);\n if (this.logger.isLoaderStarted) {\n if (mergedOptions.throwOnError) throw new BitError(warning);\n this.logger.consoleFailure(warning);\n } else {\n this.logger.consoleWarning(warning);\n this.logger.consoleWarning(e);\n }\n if (mergedOptions.throwOnError) {\n throw e;\n }\n }\n }\n\n private generateManifestGraph(manifests: Aspect[]) {\n const graph = new Graph<Aspect, string>();\n manifests.forEach((manifest) => graph.setNode(new Node(manifest.id, manifest)));\n manifests.forEach((manifest) => {\n const deps = manifest.getRuntime(MainRuntime)?.dependencies?.map((dep) => dep.id);\n deps?.forEach((dep) => {\n if (graph.node(dep)) {\n graph.setEdge(new Edge(manifest.id, dep, 'dep'));\n }\n });\n });\n return graph;\n }\n\n public async loadAspectFromPath(localAspects: string[]): Promise<Record<string, string>> {\n const res = {};\n const dirPaths = this.parseLocalAspect(localAspects);\n const manifests = dirPaths.map(([dirPath, localAspect]) => {\n const scopeRuntime = this.findRuntime(dirPath, 'scope');\n if (scopeRuntime) {\n // eslint-disable-next-line global-require, import/no-dynamic-require\n const module = require(join(dirPath, 'dist', scopeRuntime));\n const manifest = module.default || module;\n res[manifest.id] = localAspect;\n return manifest;\n }\n const module = require(dirPath);\n const manifest = module.default || module;\n const mainRuntime = this.findRuntime(dirPath, 'main');\n if (mainRuntime) {\n // eslint-disable-next-line global-require, import/no-dynamic-require\n const mainRuntimeModule = require(join(dirPath, 'dist', mainRuntime));\n const mainRuntimeManifest = mainRuntimeModule.default || mainRuntimeModule;\n // manifest has the \"id\" prop. the mainRuntimeManifest doesn't have it normally.\n mainRuntimeManifest.id = manifest.id;\n res[mainRuntimeManifest.id] = localAspect;\n return mainRuntimeManifest;\n }\n res[manifest.id] = localAspect;\n return manifest;\n });\n\n await this.loadExtensionsByManifests(manifests, undefined, { throwOnError: true });\n return res;\n }\n\n private parseLocalAspect(localAspects: string[]) {\n const dirPaths = localAspects.map((localAspect) => [resolve(localAspect.replace('file://', '')), localAspect]);\n const nonExistsDirPaths = dirPaths.filter(([path]) => !existsSync(path));\n nonExistsDirPaths.forEach((path) => this.logger.warn(`no such file or directory: ${path}`));\n const existsDirPaths = dirPaths.filter(([path]) => existsSync(path));\n return existsDirPaths;\n }\n\n private findRuntime(dirPath: string, runtime: string) {\n const files = readdirSync(join(dirPath, 'dist'));\n return files.find((path) => path.includes(`${runtime}.runtime.js`));\n }\n\n public async resolveLocalAspects(ids: string[], runtime?: string): Promise<AspectDefinition[]> {\n const dirs = this.parseLocalAspect(ids).map(([dir]) => dir);\n return dirs.map((dir) => {\n const srcRuntimeManifest = runtime ? this.findRuntime(dir, runtime) : undefined;\n const srcAspectFilePath = runtime ? this.findAspectFile(dir) : undefined;\n const aspectFilePath = srcAspectFilePath ? join(dir, 'dist', srcAspectFilePath) : null;\n const runtimeManifest = srcRuntimeManifest ? join(dir, 'dist', srcRuntimeManifest) : null;\n const aspectId = aspectFilePath ? this.getAspectIdFromAspectFile(aspectFilePath) : undefined;\n\n return new AspectDefinition(dir, aspectFilePath, runtimeManifest, undefined, aspectId, true);\n });\n }\n\n private findAspectFile(dirPath: string) {\n const files = readdirSync(join(dirPath, 'dist'));\n return files.find((path) => path.includes(`.aspect.js`));\n }\n\n static runtime = MainRuntime;\n static dependencies = [LoggerAspect, EnvsAspect, GraphqlAspect];\n static slots = [\n Slot.withType<OnAspectLoadError>(),\n Slot.withType<OnLoadRequireableExtension>(),\n Slot.withType<PluginDefinition[]>(),\n ];\n\n static async provider(\n [loggerExt, envs, graphql]: [LoggerMain, EnvsMain, GraphqlMain],\n config,\n [onAspectLoadErrorSlot, onLoadRequireableExtensionSlot, pluginSlot]: [\n OnAspectLoadErrorSlot,\n OnLoadRequireableExtensionSlot,\n PluginDefinitionSlot,\n ],\n harmony: Harmony\n ) {\n const logger = loggerExt.createLogger(AspectLoaderAspect.id);\n const aspectLoader = new AspectLoaderMain(\n logger,\n envs,\n harmony,\n onAspectLoadErrorSlot,\n onLoadRequireableExtensionSlot,\n pluginSlot\n );\n\n graphql.register(() => aspectLoaderSchema(aspectLoader));\n aspectLoader.registerPlugins([envs.getEnvPlugin()]);\n\n return aspectLoader;\n }\n}\n\nAspectLoaderAspect.addRuntime(AspectLoaderMain);\n\nexport default AspectLoaderMain;\n"],"mappings":";;;;;;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,WAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,QAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,OAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,MAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,gBAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,eAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,qBAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EAAAM,oBAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,2BAAA;EAAA,MAAAR,IAAA,GAA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ACDH,OAAgB,EAChB;IACA,MAAMF,MAAM,GAAG6T,SAAS,CAACE,YAAY,CAACC,kCAAkB,CAACrT,EAAE,CAAC;IAC5D,MAAMsT,YAAY,GAAG,IAAInU,gBAAgB,CACvCE,MAAM,EACNC,IAAI,EACJC,OAAO,EACPC,qBAAqB,EACrBC,8BAA8B,EAC9BC,UACF,CAAC;IAEDyT,OAAO,CAAC1S,QAAQ,CAAC,MAAM,IAAA8S,mCAAkB,EAACD,YAAY,CAAC,CAAC;IACxDA,YAAY,CAAC/E,eAAe,CAAC,CAACjP,IAAI,CAACkU,YAAY,CAAC,CAAC,CAAC,CAAC;IAEnD,OAAOF,YAAY;EACrB;AACF;AAACG,OAAA,CAAAtU,gBAAA,GAAAA,gBAAA;AAAAhB,eAAA,CAvxBYgB,gBAAgB,aAsvBViP,8BAAW;AAAAjQ,eAAA,CAtvBjBgB,gBAAgB,kBAuvBL,CAACuU,sBAAY,EAAEC,kBAAU,EAAEC,wBAAa,CAAC;AAAAzV,eAAA,CAvvBpDgB,gBAAgB,WAwvBZ,CACb0U,eAAI,CAACC,QAAQ,CAAoB,CAAC,EAClCD,eAAI,CAACC,QAAQ,CAA6B,CAAC,EAC3CD,eAAI,CAACC,QAAQ,CAAqB,CAAC,CACpC;AA6BHT,kCAAkB,CAAC3L,UAAU,CAACvI,gBAAgB,CAAC;AAAC,IAAA4U,QAAA,GAAAN,OAAA,CAAAvW,OAAA,GAEjCiC,gBAAgB","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_aspect-loader@1.0.1219/dist/aspect-loader.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_aspect-loader@1.0.1219/dist/aspect-loader.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_aspect-loader@1.0.1221/dist/aspect-loader.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.harmony_aspect-loader@1.0.1221/dist/aspect-loader.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -0,0 +1,10 @@
1
+ import type { Aspect, Harmony } from '@teambit/harmony';
2
+ /**
3
+ * harmony keeps the first manifest it got for an aspect-id and ignores later ones, also when the first one never
4
+ * loaded. a manifest holds the paths the aspect was resolved from at that time. e.g. before the first install, a
5
+ * workspace env with root-components is resolved from its link in node_modules (".bit_roots" doesn't exist yet), and
6
+ * fails to load. after the install, its new manifest points to ".bit_roots", but harmony runs the old one, so the env
7
+ * gets the dependencies of the root node_modules instead of its own. replace such an aspect with the new manifest.
8
+ * returns the ids of the replaced aspects.
9
+ */
10
+ export declare function replaceNeverLoadedAspects(harmony: Harmony, aspects: Aspect[]): string[];
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.replaceNeverLoadedAspects = replaceNeverLoadedAspects;
7
+ function _harmony() {
8
+ const data = require("@teambit/harmony");
9
+ _harmony = function () {
10
+ return data;
11
+ };
12
+ return data;
13
+ }
14
+ /**
15
+ * harmony keeps the first manifest it got for an aspect-id and ignores later ones, also when the first one never
16
+ * loaded. a manifest holds the paths the aspect was resolved from at that time. e.g. before the first install, a
17
+ * workspace env with root-components is resolved from its link in node_modules (".bit_roots" doesn't exist yet), and
18
+ * fails to load. after the install, its new manifest points to ".bit_roots", but harmony runs the old one, so the env
19
+ * gets the dependencies of the root node_modules instead of its own. replace such an aspect with the new manifest.
20
+ * returns the ids of the replaced aspects.
21
+ */
22
+ function replaceNeverLoadedAspects(harmony, aspects) {
23
+ const graph = harmony.graph;
24
+ const replaced = [];
25
+ aspects.forEach(aspect => {
26
+ // harmony.load gets these same aspects as manifests
27
+ const manifest = aspect;
28
+ const existing = graph.get(aspect.id);
29
+ if (!existing || existing.loaded || existing.manifest === manifest) return;
30
+ graph.setNode(aspect.id, new (_harmony().Extension)(manifest)); // keeps the edges of the node
31
+ // @ts-ignore the graph caches the extension per id, so the cached one must go as well
32
+ graph.cache.delete(aspect.id);
33
+ replaced.push(aspect.id);
34
+ });
35
+ return replaced;
36
+ }
37
+
38
+ //# sourceMappingURL=replace-never-loaded-aspects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_harmony","data","require","replaceNeverLoadedAspects","harmony","aspects","graph","replaced","forEach","aspect","manifest","existing","get","id","loaded","setNode","Extension","cache","delete","push"],"sources":["replace-never-loaded-aspects.ts"],"sourcesContent":["import type { Aspect, ExtensionManifest, Harmony } from '@teambit/harmony';\nimport { Extension } from '@teambit/harmony';\n\n/**\n * harmony keeps the first manifest it got for an aspect-id and ignores later ones, also when the first one never\n * loaded. a manifest holds the paths the aspect was resolved from at that time. e.g. before the first install, a\n * workspace env with root-components is resolved from its link in node_modules (\".bit_roots\" doesn't exist yet), and\n * fails to load. after the install, its new manifest points to \".bit_roots\", but harmony runs the old one, so the env\n * gets the dependencies of the root node_modules instead of its own. replace such an aspect with the new manifest.\n * returns the ids of the replaced aspects.\n */\nexport function replaceNeverLoadedAspects(harmony: Harmony, aspects: Aspect[]): string[] {\n const graph = harmony.graph;\n const replaced: string[] = [];\n aspects.forEach((aspect) => {\n // harmony.load gets these same aspects as manifests\n const manifest = aspect as unknown as ExtensionManifest;\n const existing: Extension | undefined = graph.get(aspect.id);\n if (!existing || existing.loaded || existing.manifest === manifest) return;\n graph.setNode(aspect.id, new Extension(manifest)); // keeps the edges of the node\n // @ts-ignore the graph caches the extension per id, so the cached one must go as well\n graph.cache.delete(aspect.id);\n replaced.push(aspect.id);\n });\n return replaced;\n}\n"],"mappings":";;;;;;AACA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,yBAAyBA,CAACC,OAAgB,EAAEC,OAAiB,EAAY;EACvF,MAAMC,KAAK,GAAGF,OAAO,CAACE,KAAK;EAC3B,MAAMC,QAAkB,GAAG,EAAE;EAC7BF,OAAO,CAACG,OAAO,CAAEC,MAAM,IAAK;IAC1B;IACA,MAAMC,QAAQ,GAAGD,MAAsC;IACvD,MAAME,QAA+B,GAAGL,KAAK,CAACM,GAAG,CAACH,MAAM,CAACI,EAAE,CAAC;IAC5D,IAAI,CAACF,QAAQ,IAAIA,QAAQ,CAACG,MAAM,IAAIH,QAAQ,CAACD,QAAQ,KAAKA,QAAQ,EAAE;IACpEJ,KAAK,CAACS,OAAO,CAACN,MAAM,CAACI,EAAE,EAAE,KAAIG,oBAAS,EAACN,QAAQ,CAAC,CAAC,CAAC,CAAC;IACnD;IACAJ,KAAK,CAACW,KAAK,CAACC,MAAM,CAACT,MAAM,CAACI,EAAE,CAAC;IAC7BN,QAAQ,CAACY,IAAI,CAACV,MAAM,CAACI,EAAE,CAAC;EAC1B,CAAC,CAAC;EACF,OAAON,QAAQ;AACjB","ignoreList":[]}
@@ -0,0 +1 @@
1
+ import 'reflect-metadata';
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+
3
+ require("reflect-metadata");
4
+ function _chai() {
5
+ const data = require("chai");
6
+ _chai = function () {
7
+ return data;
8
+ };
9
+ return data;
10
+ }
11
+ function _harmony() {
12
+ const data = require("@teambit/harmony");
13
+ _harmony = function () {
14
+ return data;
15
+ };
16
+ return data;
17
+ }
18
+ function _harmonyModules() {
19
+ const data = require("@teambit/harmony.modules.runtimes");
20
+ _harmonyModules = function () {
21
+ return data;
22
+ };
23
+ return data;
24
+ }
25
+ function _replaceNeverLoadedAspects() {
26
+ const data = require("./replace-never-loaded-aspects");
27
+ _replaceNeverLoadedAspects = function () {
28
+ return data;
29
+ };
30
+ return data;
31
+ }
32
+ const ENV_ID = 'test/env';
33
+ function createEnvAspect(name, shouldFail = false) {
34
+ const aspect = _harmony().Aspect.create({
35
+ id: ENV_ID
36
+ });
37
+ aspect.addRuntime({
38
+ runtime: _harmonyModules().MainRuntime,
39
+ dependencies: [],
40
+ provider: async () => {
41
+ if (shouldFail) throw new Error(`failed loading ${name}`);
42
+ return {
43
+ name
44
+ };
45
+ }
46
+ });
47
+ return aspect;
48
+ }
49
+
50
+ // aspect-loader passes aspects to harmony.load the same way
51
+ function loadAspects(harmony, aspects) {
52
+ return harmony.load(aspects);
53
+ }
54
+ async function loadHarmonyWithFailedAspect() {
55
+ const runtimeAspect = _harmony().Aspect.create({
56
+ id: 'test/runtime',
57
+ declareRuntime: _harmonyModules().MainRuntime
58
+ });
59
+ const harmony = await _harmony().Harmony.load([runtimeAspect], _harmonyModules().MainRuntime.name, {});
60
+ await harmony.run();
61
+ await loadAspects(harmony, [createEnvAspect('stale', true)]).catch(() => {});
62
+ return harmony;
63
+ }
64
+ describe('replaceNeverLoadedAspects()', () => {
65
+ it('without it, harmony runs the first manifest of an aspect that never loaded', async () => {
66
+ const harmony = await loadHarmonyWithFailedAspect();
67
+ let error;
68
+ await loadAspects(harmony, [createEnvAspect('fresh')]).catch(err => {
69
+ error = err;
70
+ });
71
+ (0, _chai().expect)(error?.message).to.include('failed loading stale');
72
+ });
73
+ it('makes harmony run the new manifest of an aspect that never loaded', async () => {
74
+ const harmony = await loadHarmonyWithFailedAspect();
75
+ const freshAspect = createEnvAspect('fresh');
76
+ (0, _chai().expect)((0, _replaceNeverLoadedAspects().replaceNeverLoadedAspects)(harmony, [freshAspect])).to.deep.equal([ENV_ID]);
77
+ await loadAspects(harmony, [freshAspect]);
78
+ (0, _chai().expect)(harmony.get(ENV_ID).name).to.equal('fresh');
79
+ });
80
+ it('does not replace an aspect that loaded already', async () => {
81
+ const harmony = await loadHarmonyWithFailedAspect();
82
+ const freshAspect = createEnvAspect('fresh');
83
+ (0, _replaceNeverLoadedAspects().replaceNeverLoadedAspects)(harmony, [freshAspect]);
84
+ await loadAspects(harmony, [freshAspect]);
85
+ (0, _chai().expect)((0, _replaceNeverLoadedAspects().replaceNeverLoadedAspects)(harmony, [createEnvAspect('another')])).to.deep.equal([]);
86
+ (0, _chai().expect)(harmony.get(ENV_ID).name).to.equal('fresh');
87
+ });
88
+ });
89
+
90
+ //# sourceMappingURL=replace-never-loaded-aspects.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["require","_chai","data","_harmony","_harmonyModules","_replaceNeverLoadedAspects","ENV_ID","createEnvAspect","name","shouldFail","aspect","Aspect","create","id","addRuntime","runtime","MainRuntime","dependencies","provider","Error","loadAspects","harmony","aspects","load","loadHarmonyWithFailedAspect","runtimeAspect","declareRuntime","Harmony","run","catch","describe","it","error","err","expect","message","to","include","freshAspect","replaceNeverLoadedAspects","deep","equal","get"],"sources":["replace-never-loaded-aspects.spec.ts"],"sourcesContent":["import 'reflect-metadata';\nimport { expect } from 'chai';\nimport type { ExtensionManifest } from '@teambit/harmony';\nimport { Aspect, Harmony } from '@teambit/harmony';\nimport { MainRuntime } from '@teambit/harmony.modules.runtimes';\nimport { replaceNeverLoadedAspects } from './replace-never-loaded-aspects';\n\nconst ENV_ID = 'test/env';\n\nfunction createEnvAspect(name: string, shouldFail = false): Aspect {\n const aspect = Aspect.create({ id: ENV_ID });\n aspect.addRuntime({\n runtime: MainRuntime,\n dependencies: [],\n provider: async () => {\n if (shouldFail) throw new Error(`failed loading ${name}`);\n return { name };\n },\n });\n return aspect;\n}\n\n// aspect-loader passes aspects to harmony.load the same way\nfunction loadAspects(harmony: Harmony, aspects: Aspect[]) {\n return harmony.load(aspects as unknown as ExtensionManifest[]);\n}\n\nasync function loadHarmonyWithFailedAspect(): Promise<Harmony> {\n const runtimeAspect = Aspect.create({ id: 'test/runtime', declareRuntime: MainRuntime });\n const harmony = await Harmony.load([runtimeAspect], MainRuntime.name, {});\n await harmony.run();\n await loadAspects(harmony, [createEnvAspect('stale', true)]).catch(() => {});\n return harmony;\n}\n\ndescribe('replaceNeverLoadedAspects()', () => {\n it('without it, harmony runs the first manifest of an aspect that never loaded', async () => {\n const harmony = await loadHarmonyWithFailedAspect();\n let error: Error | undefined;\n await loadAspects(harmony, [createEnvAspect('fresh')]).catch((err) => {\n error = err;\n });\n expect(error?.message).to.include('failed loading stale');\n });\n it('makes harmony run the new manifest of an aspect that never loaded', async () => {\n const harmony = await loadHarmonyWithFailedAspect();\n const freshAspect = createEnvAspect('fresh');\n expect(replaceNeverLoadedAspects(harmony, [freshAspect])).to.deep.equal([ENV_ID]);\n await loadAspects(harmony, [freshAspect]);\n expect(harmony.get<{ name: string }>(ENV_ID).name).to.equal('fresh');\n });\n it('does not replace an aspect that loaded already', async () => {\n const harmony = await loadHarmonyWithFailedAspect();\n const freshAspect = createEnvAspect('fresh');\n replaceNeverLoadedAspects(harmony, [freshAspect]);\n await loadAspects(harmony, [freshAspect]);\n expect(replaceNeverLoadedAspects(harmony, [createEnvAspect('another')])).to.deep.equal([]);\n expect(harmony.get<{ name: string }>(ENV_ID).name).to.equal('fresh');\n });\n});\n"],"mappings":";;AAAAA,OAAA;AACA,SAAAC,MAAA;EAAA,MAAAC,IAAA,GAAAF,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAC,SAAA;EAAA,MAAAD,IAAA,GAAAF,OAAA;EAAAG,QAAA,YAAAA,CAAA;IAAA,OAAAD,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,gBAAA;EAAA,MAAAF,IAAA,GAAAF,OAAA;EAAAI,eAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,2BAAA;EAAA,MAAAH,IAAA,GAAAF,OAAA;EAAAK,0BAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,MAAMI,MAAM,GAAG,UAAU;AAEzB,SAASC,e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,CAAC,CAACE,IAAI,CAAC,CAAC4B,EAAE,CAACK,KAAK,CAAC,OAAO,CAAC;EACtE,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/aspect-loader",
3
- "version": "1.0.1219",
3
+ "version": "1.0.1221",
4
4
  "homepage": "https://bit.cloud/teambit/harmony/aspect-loader",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.harmony",
8
8
  "name": "aspect-loader",
9
- "version": "1.0.1219"
9
+ "version": "1.0.1221"
10
10
  },
11
11
  "dependencies": {
12
12
  "graphql-tag": "2.12.1",
@@ -29,14 +29,15 @@
29
29
  "@teambit/node.utils.esm-loader": "0.0.7",
30
30
  "@teambit/bvm.config": "1.0.2",
31
31
  "@teambit/bvm.path": "1.0.0",
32
- "@teambit/cli": "0.0.1412",
33
- "@teambit/component": "1.0.1219",
34
- "@teambit/envs": "1.0.1219"
32
+ "@teambit/cli": "0.0.1413",
33
+ "@teambit/component": "1.0.1221",
34
+ "@teambit/envs": "1.0.1221"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/fs-extra": "9.0.7",
38
38
  "@types/lodash": "4.14.165",
39
39
  "@types/find-root": "1.1.2",
40
+ "reflect-metadata": "0.1.13",
40
41
  "@types/mocha": "9.1.0",
41
42
  "@teambit/harmony.envs.core-aspect-env": "2.1.2"
42
43
  },