diff --git a/scopes/component/new-component-helper/index.ts b/scopes/component/new-component-helper/index.ts index eea49d03d039..775bd626a7a7 100644 --- a/scopes/component/new-component-helper/index.ts +++ b/scopes/component/new-component-helper/index.ts @@ -1,5 +1,5 @@ import { NewComponentHelperAspect } from './new-component-helper.aspect'; -export type { NewComponentHelperMain, CloneConfig } from './new-component-helper.main.runtime'; +export type { NewComponentHelperMain } from './new-component-helper.main.runtime'; export default NewComponentHelperAspect; export { NewComponentHelperAspect }; diff --git a/scopes/component/new-component-helper/new-component-helper.main.runtime.ts b/scopes/component/new-component-helper/new-component-helper.main.runtime.ts index 58cce424aedd..e3a137e8f257 100644 --- a/scopes/component/new-component-helper/new-component-helper.main.runtime.ts +++ b/scopes/component/new-component-helper/new-component-helper.main.runtime.ts @@ -10,6 +10,7 @@ import { ComponentID } from '@teambit/component-id'; import { Harmony } from '@teambit/harmony'; import { PathLinuxRelative } from '@teambit/legacy/dist/utils/path'; import WorkspaceAspect, { Workspace } from '@teambit/workspace'; +import { PkgAspect } from '@teambit/pkg'; import { NewComponentHelperAspect } from './new-component-helper.aspect'; export class NewComponentHelperMain { @@ -86,20 +87,13 @@ export class NewComponentHelperMain { } async getConfigFromExistingToNewComponent(comp: Component) { - const aspectIds = comp.state.aspects.entries.map((e) => e.id.toString()); - // the reason to load aspects is to be able to check later for the `shouldPreserveConfigForClonedComponent` prop. - // it's not saved in the model, it's available only on the aspect instance. - await this.workspace.loadAspects(aspectIds, undefined, 'new-component-helper.getConfigFromExistingToNewComponent'); const fromExisting = {}; comp.state.aspects.entries.forEach((entry) => { if (!entry.config) return; const aspectId = entry.id.toString(); - const aspect = this.harmony.get(aspectId); - if (!aspect) throw new Error(`error: unable to get "${aspectId}" aspect from Harmony`); - if ( - 'shouldPreserveConfigForClonedComponent' in aspect && - aspect.shouldPreserveConfigForClonedComponent === false - ) { + // don't copy the pkg aspect, it's not relevant for the new component + // (it might contains values that are bounded to the other component name / id) + if (aspectId === PkgAspect.id) { return; } fromExisting[aspectId] = entry.config; @@ -116,7 +110,3 @@ export class NewComponentHelperMain { } NewComponentHelperAspect.addRuntime(NewComponentHelperMain); - -export interface CloneConfig { - readonly shouldPreserveConfigForClonedComponent?: boolean; // default true -} diff --git a/scopes/pkg/pkg/pkg.main.runtime.ts b/scopes/pkg/pkg/pkg.main.runtime.ts index 4feb28982e54..62c3545230e7 100644 --- a/scopes/pkg/pkg/pkg.main.runtime.ts +++ b/scopes/pkg/pkg/pkg.main.runtime.ts @@ -11,7 +11,6 @@ import { ScopeAspect, ScopeMain } from '@teambit/scope'; import { Workspace, WorkspaceAspect } from '@teambit/workspace'; import { PackageJsonTransformer } from '@teambit/workspace.modules.node-modules-linker'; import { BuilderMain, BuilderAspect } from '@teambit/builder'; -import { CloneConfig } from '@teambit/new-component-helper'; import { BitError } from '@teambit/bit-error'; import { snapToSemver } from '@teambit/component-package-version'; import { IssuesClasses } from '@teambit/component-issues'; @@ -96,7 +95,7 @@ export type VersionPackageManifest = { }; }; -export class PkgMain implements CloneConfig { +export class PkgMain { static runtime = MainRuntime; static dependencies = [ CLIAspect, @@ -183,8 +182,6 @@ export class PkgMain implements CloneConfig { return pkg; } - readonly shouldPreserveConfigForClonedComponent = false; - /** * get the package name of a component. */