@teambit/snapping 1.0.170 → 1.0.173

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.
@@ -55,7 +55,7 @@ function _componentSchema() {
55
55
  return data;
56
56
  }
57
57
  function _dependencyResolver() {
58
- const data = _interopRequireDefault(require("@teambit/dependency-resolver"));
58
+ const data = require("@teambit/dependency-resolver");
59
59
  _dependencyResolver = function () {
60
60
  return data;
61
61
  };
@@ -142,25 +142,29 @@ async function addDeps(component, snapData, scope, deps, depsResolver) {
142
142
  return acc;
143
143
  }, {});
144
144
  };
145
+ const getPkgObj = type => {
146
+ return toPackageObj(packageDeps.filter(dep => dep.type === type));
147
+ };
148
+ const consumerComponent = component.state._consumer;
145
149
  const dependenciesData = {
146
150
  allDependencies: {
147
- dependencies: compDeps,
148
- devDependencies: compDevDeps
151
+ dependencies: [...compDeps, ...consumerComponent.dependencies.get()],
152
+ devDependencies: [...compDevDeps, ...consumerComponent.devDependencies.get()]
149
153
  },
150
154
  allPackagesDependencies: {
151
- packageDependencies: toPackageObj(packageDeps.filter(dep => dep.type === 'runtime')),
152
- devPackageDependencies: toPackageObj(packageDeps.filter(dep => dep.type === 'dev')),
153
- peerPackageDependencies: toPackageObj(packageDeps.filter(dep => dep.type === 'peer'))
155
+ packageDependencies: _objectSpread(_objectSpread({}, consumerComponent.packageDependencies), getPkgObj('runtime')),
156
+ devPackageDependencies: _objectSpread(_objectSpread({}, consumerComponent.devPackageDependencies), getPkgObj('dev')),
157
+ peerPackageDependencies: _objectSpread(_objectSpread({}, consumerComponent.peerPackageDependencies), getPkgObj('peer'))
154
158
  }
155
159
  };
156
- const consumerComponent = component.state._consumer;
160
+
157
161
  // add the dependencies to the legacy ConsumerComponent object
158
162
  // it takes care of both: given dependencies (from the cli) and the overrides, which are coming from the env.
159
163
  await deps.loadDependenciesFromScope(consumerComponent, dependenciesData);
160
164
 
161
165
  // add the dependencies data to the dependency-resolver aspect
162
166
  const dependenciesListSerialized = (await depsResolver.extractDepsFromLegacy(component)).serialize();
163
- const extId = _dependencyResolver().default.id;
167
+ const extId = _dependencyResolver().DependencyResolverAspect.id;
164
168
  const data = {
165
169
  dependencies: dependenciesListSerialized
166
170
  };
@@ -1 +1 @@
1
- {"version":3,"names":["_componentId","data","require","_component","_interopRequireDefault","_dependencies","_sources","_componentOverrides","_config","_componentSchema","_dependencyResolver","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","i","_toPrimitive","String","Symbol","toPrimitive","call","TypeError","Number","generateCompFromScope","scope","compData","snapping","files","Error","map","file","SourceFile","base","path","contents","Buffer","from","content","test","id","componentId","extensions","ExtensionDataList","fromConfigObject","aspects","consumerComponent","ConsumerComponent","mainFile","name","fullName","schema","CURRENT_SCHEMA","overrides","ComponentOverrides","loadNewFromScope","defaultScope","log","message","date","Date","now","toString","username","email","_addFlattenedDependenciesToComponents","version","filesBitObject","legacyScope","sources","consumerComponentToVersion","modelComponent","findOrAddComponent","hash","objects","writeObjectsToTheFS","f","component","getManyByLegacy","addDeps","snapData","deps","depsResolver","newDeps","newDependencies","compIdsData","dep","isComponent","compIdsDataParsed","ComponentID","fromString","compIds","changeVersion","comps","getMany","toDependency","depId","comp","find","c","isEqualWithoutVersion","pkgName","getPackageName","Dependency","compDeps","type","compDevDeps","packageDeps","toPackageObj","pkgs","reduce","acc","curr","dependenciesData","allDependencies","dependencies","devDependencies","allPackagesDependencies","packageDependencies","devPackageDependencies","peerPackageDependencies","state","_consumer","loadDependenciesFromScope","dependenciesListSerialized","extractDepsFromLegacy","serialize","extId","DependencyResolverAspect","existingExtension","config","findExtension","assign"],"sources":["generate-comp-from-scope.ts"],"sourcesContent":["import { ComponentID } from '@teambit/component-id';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport { Dependency } from '@teambit/legacy/dist/consumer/component/dependencies';\nimport { SourceFile } from '@teambit/legacy/dist/consumer/component/sources';\nimport { ScopeMain } from '@teambit/scope';\nimport ComponentOverrides from '@teambit/legacy/dist/consumer/config/component-overrides';\nimport { ExtensionDataList } from '@teambit/legacy/dist/consumer/config';\nimport { Component } from '@teambit/component';\nimport { CURRENT_SCHEMA } from '@teambit/legacy/dist/consumer/component/component-schema';\nimport { DependenciesMain } from '@teambit/dependencies';\nimport DependencyResolverAspect, { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { FileData } from './snap-from-scope.cmd';\nimport type { SnappingMain, SnapDataParsed } from './snapping.main.runtime';\n\nexport type CompData = {\n componentId: ComponentID;\n dependencies: ComponentID[];\n aspects: Record<string, any> | undefined;\n message: string | undefined;\n files: FileData[] | undefined;\n mainFile?: string;\n};\n\n/**\n * normally new components are created from a workspace. the files are in the filesystem and the ConsumerComponent\n * object is created from the files.\n * here, we need to create the ConsumerComponent object \"on the fly\". we don't have workspace, only scope. the files\n * are in-memory (we got them from snap-from-scope command).\n * the way how it is done is by creating a minimal ConsumerComponent object, then convert `Version` object from it,\n * write the version and files into the scope as objects, so then it's possible to load Component object using the\n * ConsumerComponent.\n */\nexport async function generateCompFromScope(\n scope: ScopeMain,\n compData: CompData,\n snapping: SnappingMain\n): Promise<Component> {\n if (!compData.files) throw new Error('generateComp: files are missing');\n const files = compData.files.map((file) => {\n return new SourceFile({ base: '.', path: file.path, contents: Buffer.from(file.content), test: false });\n });\n const id = compData.componentId;\n const extensions = ExtensionDataList.fromConfigObject(compData.aspects || {});\n\n const consumerComponent = new ConsumerComponent({\n mainFile: compData.mainFile || 'index.ts',\n name: compData.componentId.fullName,\n scope: compData.componentId.scope,\n files,\n schema: CURRENT_SCHEMA,\n overrides: await ComponentOverrides.loadNewFromScope(id, files, extensions),\n defaultScope: compData.componentId.scope,\n extensions,\n // the dummy data here are not important. this Version object will be discarded later.\n log: {\n message: compData.message || '',\n date: Date.now().toString(),\n username: '',\n email: '',\n },\n });\n // this is needed, otherwise in case of updating envs/aspects, the version-validator throws\n // an error saying \"the extension ${extensionId.toString()} is missing from the flattenedDependencies\"\n await snapping._addFlattenedDependenciesToComponents([consumerComponent]);\n\n const { version, files: filesBitObject } = await scope.legacyScope.sources.consumerComponentToVersion(\n consumerComponent\n );\n const modelComponent = scope.legacyScope.sources.findOrAddComponent(consumerComponent);\n consumerComponent.version = version.hash().toString();\n await scope.legacyScope.objects.writeObjectsToTheFS([version, modelComponent, ...filesBitObject.map((f) => f.file)]);\n const component = await scope.getManyByLegacy([consumerComponent]);\n\n return component[0];\n}\n\nexport async function addDeps(\n component: Component,\n snapData: SnapDataParsed,\n scope: ScopeMain,\n deps: DependenciesMain,\n depsResolver: DependencyResolverMain\n) {\n const newDeps = snapData.newDependencies || [];\n const compIdsData = newDeps.filter((dep) => dep.isComponent);\n const compIdsDataParsed = compIdsData.map((data) => ({\n ...data,\n id: ComponentID.fromString(data.id),\n }));\n const compIds = compIdsDataParsed.map((dep) => (dep.version ? dep.id.changeVersion(dep.version) : dep.id));\n const comps = await scope.getMany(compIds);\n const toDependency = (depId: ComponentID) => {\n const comp = comps.find((c) => c.id.isEqualWithoutVersion(depId));\n if (!comp) throw new Error(`unable to find the specified dependency ${depId.toString()} in the scope`);\n const pkgName = depsResolver.getPackageName(comp);\n return new Dependency(comp.id, [], pkgName);\n };\n const compDeps = compIdsDataParsed.filter((c) => c.type === 'runtime').map((dep) => toDependency(dep.id));\n const compDevDeps = compIdsDataParsed.filter((c) => c.type === 'dev').map((dep) => toDependency(dep.id));\n const packageDeps = newDeps.filter((dep) => !dep.isComponent);\n const toPackageObj = (pkgs: Array<{ id: string; version?: string }>) => {\n return pkgs.reduce((acc, curr) => {\n if (!curr.version) throw new Error(`please specify a version for the package dependency: \"${curr.id}\"`);\n acc[curr.id] = curr.version;\n return acc;\n }, {});\n };\n const dependenciesData = {\n allDependencies: {\n dependencies: compDeps,\n devDependencies: compDevDeps,\n },\n allPackagesDependencies: {\n packageDependencies: toPackageObj(packageDeps.filter((dep) => dep.type === 'runtime')),\n devPackageDependencies: toPackageObj(packageDeps.filter((dep) => dep.type === 'dev')),\n peerPackageDependencies: toPackageObj(packageDeps.filter((dep) => dep.type === 'peer')),\n },\n };\n\n const consumerComponent = component.state._consumer as ConsumerComponent;\n // add the dependencies to the legacy ConsumerComponent object\n // it takes care of both: given dependencies (from the cli) and the overrides, which are coming from the env.\n await deps.loadDependenciesFromScope(consumerComponent, dependenciesData);\n\n // add the dependencies data to the dependency-resolver aspect\n const dependenciesListSerialized = (await depsResolver.extractDepsFromLegacy(component)).serialize();\n const extId = DependencyResolverAspect.id;\n const data = { dependencies: dependenciesListSerialized };\n const existingExtension = component.config.extensions.findExtension(extId);\n if (!existingExtension) throw new Error('unable to find DependencyResolver extension');\n Object.assign(existingExtension.data, data);\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,aAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,YAAA,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;AACA,SAAAI,cAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,aAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,SAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,QAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,oBAAA;EAAA,MAAAN,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAK,mBAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAA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,IAAI,EAAEA,IAAI,CAAC;AAC7C"}
1
+ {"version":3,"names":["_componentId","data","require","_component","_interopRequireDefault","_dependencies","_sources","_componentOverrides","_config","_componentSchema","_dependencyResolver","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","i","_toPrimitive","String","Symbol","toPrimitive","call","TypeError","Number","generateCompFromScope","scope","compData","snapping","files","Error","map","file","SourceFile","base","path","contents","Buffer","from","content","test","id","componentId","extensions","ExtensionDataList","fromConfigObject","aspects","consumerComponent","ConsumerComponent","mainFile","name","fullName","schema","CURRENT_SCHEMA","overrides","ComponentOverrides","loadNewFromScope","defaultScope","log","message","date","Date","now","toString","username","email","_addFlattenedDependenciesToComponents","version","filesBitObject","legacyScope","sources","consumerComponentToVersion","modelComponent","findOrAddComponent","hash","objects","writeObjectsToTheFS","f","component","getManyByLegacy","addDeps","snapData","deps","depsResolver","newDeps","newDependencies","compIdsData","dep","isComponent","compIdsDataParsed","ComponentID","fromString","compIds","changeVersion","comps","getMany","toDependency","depId","comp","find","c","isEqualWithoutVersion","pkgName","getPackageName","Dependency","compDeps","type","compDevDeps","packageDeps","toPackageObj","pkgs","reduce","acc","curr","getPkgObj","state","_consumer","dependenciesData","allDependencies","dependencies","get","devDependencies","allPackagesDependencies","packageDependencies","devPackageDependencies","peerPackageDependencies","loadDependenciesFromScope","dependenciesListSerialized","extractDepsFromLegacy","serialize","extId","DependencyResolverAspect","existingExtension","config","findExtension","assign"],"sources":["generate-comp-from-scope.ts"],"sourcesContent":["import { ComponentID } from '@teambit/component-id';\nimport ConsumerComponent from '@teambit/legacy/dist/consumer/component';\nimport { Dependency } from '@teambit/legacy/dist/consumer/component/dependencies';\nimport { SourceFile } from '@teambit/legacy/dist/consumer/component/sources';\nimport { ScopeMain } from '@teambit/scope';\nimport ComponentOverrides from '@teambit/legacy/dist/consumer/config/component-overrides';\nimport { ExtensionDataList } from '@teambit/legacy/dist/consumer/config';\nimport { Component } from '@teambit/component';\nimport { CURRENT_SCHEMA } from '@teambit/legacy/dist/consumer/component/component-schema';\nimport { DependenciesMain } from '@teambit/dependencies';\nimport { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { FileData } from './snap-from-scope.cmd';\nimport type { SnappingMain, SnapDataParsed } from './snapping.main.runtime';\n\nexport type CompData = {\n componentId: ComponentID;\n dependencies: ComponentID[];\n aspects: Record<string, any> | undefined;\n message: string | undefined;\n files: FileData[] | undefined;\n mainFile?: string;\n};\n\n/**\n * normally new components are created from a workspace. the files are in the filesystem and the ConsumerComponent\n * object is created from the files.\n * here, we need to create the ConsumerComponent object \"on the fly\". we don't have workspace, only scope. the files\n * are in-memory (we got them from snap-from-scope command).\n * the way how it is done is by creating a minimal ConsumerComponent object, then convert `Version` object from it,\n * write the version and files into the scope as objects, so then it's possible to load Component object using the\n * ConsumerComponent.\n */\nexport async function generateCompFromScope(\n scope: ScopeMain,\n compData: CompData,\n snapping: SnappingMain\n): Promise<Component> {\n if (!compData.files) throw new Error('generateComp: files are missing');\n const files = compData.files.map((file) => {\n return new SourceFile({ base: '.', path: file.path, contents: Buffer.from(file.content), test: false });\n });\n const id = compData.componentId;\n const extensions = ExtensionDataList.fromConfigObject(compData.aspects || {});\n\n const consumerComponent = new ConsumerComponent({\n mainFile: compData.mainFile || 'index.ts',\n name: compData.componentId.fullName,\n scope: compData.componentId.scope,\n files,\n schema: CURRENT_SCHEMA,\n overrides: await ComponentOverrides.loadNewFromScope(id, files, extensions),\n defaultScope: compData.componentId.scope,\n extensions,\n // the dummy data here are not important. this Version object will be discarded later.\n log: {\n message: compData.message || '',\n date: Date.now().toString(),\n username: '',\n email: '',\n },\n });\n // this is needed, otherwise in case of updating envs/aspects, the version-validator throws\n // an error saying \"the extension ${extensionId.toString()} is missing from the flattenedDependencies\"\n await snapping._addFlattenedDependenciesToComponents([consumerComponent]);\n\n const { version, files: filesBitObject } = await scope.legacyScope.sources.consumerComponentToVersion(\n consumerComponent\n );\n const modelComponent = scope.legacyScope.sources.findOrAddComponent(consumerComponent);\n consumerComponent.version = version.hash().toString();\n await scope.legacyScope.objects.writeObjectsToTheFS([version, modelComponent, ...filesBitObject.map((f) => f.file)]);\n const component = await scope.getManyByLegacy([consumerComponent]);\n\n return component[0];\n}\n\nexport async function addDeps(\n component: Component,\n snapData: SnapDataParsed,\n scope: ScopeMain,\n deps: DependenciesMain,\n depsResolver: DependencyResolverMain\n) {\n const newDeps = snapData.newDependencies || [];\n const compIdsData = newDeps.filter((dep) => dep.isComponent);\n const compIdsDataParsed = compIdsData.map((data) => ({\n ...data,\n id: ComponentID.fromString(data.id),\n }));\n const compIds = compIdsDataParsed.map((dep) => (dep.version ? dep.id.changeVersion(dep.version) : dep.id));\n const comps = await scope.getMany(compIds);\n const toDependency = (depId: ComponentID) => {\n const comp = comps.find((c) => c.id.isEqualWithoutVersion(depId));\n if (!comp) throw new Error(`unable to find the specified dependency ${depId.toString()} in the scope`);\n const pkgName = depsResolver.getPackageName(comp);\n return new Dependency(comp.id, [], pkgName);\n };\n const compDeps = compIdsDataParsed.filter((c) => c.type === 'runtime').map((dep) => toDependency(dep.id));\n const compDevDeps = compIdsDataParsed.filter((c) => c.type === 'dev').map((dep) => toDependency(dep.id));\n const packageDeps = newDeps.filter((dep) => !dep.isComponent);\n const toPackageObj = (pkgs: Array<{ id: string; version?: string }>) => {\n return pkgs.reduce((acc, curr) => {\n if (!curr.version) throw new Error(`please specify a version for the package dependency: \"${curr.id}\"`);\n acc[curr.id] = curr.version;\n return acc;\n }, {});\n };\n const getPkgObj = (type: 'runtime' | 'dev' | 'peer') => {\n return toPackageObj(packageDeps.filter((dep) => dep.type === type));\n };\n\n const consumerComponent = component.state._consumer as ConsumerComponent;\n\n const dependenciesData = {\n allDependencies: {\n dependencies: [...compDeps, ...consumerComponent.dependencies.get()],\n devDependencies: [...compDevDeps, ...consumerComponent.devDependencies.get()],\n },\n allPackagesDependencies: {\n packageDependencies: { ...consumerComponent.packageDependencies, ...getPkgObj('runtime') },\n devPackageDependencies: { ...consumerComponent.devPackageDependencies, ...getPkgObj('dev') },\n peerPackageDependencies: { ...consumerComponent.peerPackageDependencies, ...getPkgObj('peer') },\n },\n };\n\n // add the dependencies to the legacy ConsumerComponent object\n // it takes care of both: given dependencies (from the cli) and the overrides, which are coming from the env.\n await deps.loadDependenciesFromScope(consumerComponent, dependenciesData);\n\n // add the dependencies data to the dependency-resolver aspect\n const dependenciesListSerialized = (await depsResolver.extractDepsFromLegacy(component)).serialize();\n const extId = DependencyResolverAspect.id;\n const data = { dependencies: dependenciesListSerialized };\n const existingExtension = component.config.extensions.findExtension(extId);\n if (!existingExtension) throw new Error('unable to find DependencyResolver extension');\n Object.assign(existingExtension.data, data);\n}\n"],"mappings":";;;;;;;AAAA,SAAAA,aAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,YAAA,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;AACA,SAAAI,cAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,aAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,SAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,QAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAM,oBAAA;EAAA,MAAAN,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAK,mBAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EA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K,GAAGC,8CAAwB,CAAC1F,EAAE;EACzC,MAAM/D,IAAI,GAAG;IAAE6I,YAAY,EAAEQ;EAA2B,CAAC;EACzD,MAAMK,iBAAiB,GAAGtD,SAAS,CAACuD,MAAM,CAAC1F,UAAU,CAAC2F,aAAa,CAACJ,KAAK,CAAC;EAC1E,IAAI,CAACE,iBAAiB,EAAE,MAAM,IAAItG,KAAK,CAAC,6CAA6C,CAAC;EACtFnC,MAAM,CAAC4I,MAAM,CAACH,iBAAiB,CAAC1J,IAAI,EAAEA,IAAI,CAAC;AAC7C"}
@@ -26,7 +26,7 @@ function _getFlattenedDependencies() {
26
26
  return data;
27
27
  }
28
28
  function _workspace() {
29
- const data = _interopRequireWildcard(require("@teambit/workspace"));
29
+ const data = require("@teambit/workspace");
30
30
  _workspace = function () {
31
31
  return data;
32
32
  };
@@ -145,7 +145,7 @@ function _scope() {
145
145
  return data;
146
146
  }
147
147
  function _issues() {
148
- const data = _interopRequireDefault(require("@teambit/issues"));
148
+ const data = require("@teambit/issues");
149
149
  _issues = function () {
150
150
  return data;
151
151
  };
@@ -180,7 +180,7 @@ function _laneId() {
180
180
  return data;
181
181
  }
182
182
  function _importer() {
183
- const data = _interopRequireDefault(require("@teambit/importer"));
183
+ const data = require("@teambit/importer");
184
184
  _importer = function () {
185
185
  return data;
186
186
  };
@@ -215,7 +215,7 @@ function _objects() {
215
215
  return data;
216
216
  }
217
217
  function _globalConfig() {
218
- const data = _interopRequireDefault(require("@teambit/global-config"));
218
+ const data = require("@teambit/global-config");
219
219
  _globalConfig = function () {
220
220
  return data;
221
221
  };
@@ -236,7 +236,7 @@ function _exceptions() {
236
236
  return data;
237
237
  }
238
238
  function _dependencies() {
239
- const data = _interopRequireDefault(require("@teambit/dependencies"));
239
+ const data = require("@teambit/dependencies");
240
240
  _dependencies = function () {
241
241
  return data;
242
242
  };
@@ -334,8 +334,6 @@ function _resetComponent() {
334
334
  return data;
335
335
  }
336
336
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
337
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
338
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
339
337
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
340
338
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
341
339
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -632,12 +630,16 @@ if you're willing to lose the history from the head to the specified version, us
632
630
  await this.updateSourceFiles(comp, snapData.files);
633
631
  }
634
632
  }));
635
- await (0, _pMapSeries().default)(components, async comp => this.scope.executeOnCompAspectReCalcSlot(comp));
636
633
 
637
- // run this for new components only.
638
- // otherwise, running this for existing components, will override the existing dependencies unexpectedly.
639
- // if this is needed for existing components, see how to merge the model data.
640
- await (0, _pMapSeries().default)(newComponents, async component => {
634
+ // load the aspects user configured to set on the components. it creates capsules if needed.
635
+ // otherwise, when a user set a custom-env, it won't be loaded and the Version object will leave the
636
+ // teambit.envs/envs in a weird state. the config will be set correctly but the data will be set to the default
637
+ // node env.
638
+ await this.scope.loadManyCompsAspects(components);
639
+
640
+ // this is similar to what happens in the workspace. the "onLoad" is running and populating the "data" of the aspects.
641
+ await (0, _pMapSeries().default)(components, async comp => this.scope.executeOnCompAspectReCalcSlot(comp));
642
+ await (0, _pMapSeries().default)(components, async component => {
641
643
  const snapData = getSnapData(component.id);
642
644
  // adds explicitly defined dependencies and dependencies from envs/aspects (overrides)
643
645
  await (0, _generateCompFromScope().addDeps)(component, snapData, this.scope, this.deps, this.dependencyResolver);
@@ -1341,7 +1343,7 @@ another option, in case this dependency is not in main yet is to remove all refe
1341
1343
  }
1342
1344
  exports.SnappingMain = SnappingMain;
1343
1345
  _defineProperty(SnappingMain, "slots", []);
1344
- _defineProperty(SnappingMain, "dependencies", [_workspace().default, _cli().CLIAspect, _logger().LoggerAspect, _issues().default, _insights().InsightsAspect, _dependencyResolver().DependencyResolverAspect, _scope().ScopeAspect, _export().ExportAspect, _builder().BuilderAspect, _importer().default, _globalConfig().default, _dependencies().default]);
1346
+ _defineProperty(SnappingMain, "dependencies", [_workspace().WorkspaceAspect, _cli().CLIAspect, _logger().LoggerAspect, _issues().IssuesAspect, _insights().InsightsAspect, _dependencyResolver().DependencyResolverAspect, _scope().ScopeAspect, _export().ExportAspect, _builder().BuilderAspect, _importer().ImporterAspect, _globalConfig().GlobalConfigAspect, _dependencies().DependenciesAspect]);
1345
1347
  _defineProperty(SnappingMain, "runtime", _cli().MainRuntime);
1346
1348
  _snapping().SnappingAspect.addRuntime(SnappingMain);
1347
1349
  var _default = exports.default = SnappingMain;