@teambit/aspect-loader 0.0.549 → 0.0.555

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.
@@ -6,12 +6,47 @@ export declare type AspectDefinitionProps = {
6
6
  runtimePath: string | null;
7
7
  };
8
8
  export declare class AspectDefinition {
9
+ /**
10
+ * path the the root directory of the aspect module.
11
+ */
9
12
  readonly aspectPath: string;
13
+ /**
14
+ * path to the runtime entry
15
+ */
10
16
  readonly runtimePath: string | null;
17
+ /**
18
+ * aspect component
19
+ */
11
20
  readonly component?: Component | undefined;
21
+ /**
22
+ * id of the component (used instead of component in the case of core aspect)
23
+ */
12
24
  readonly id?: string | undefined;
25
+ /**
26
+ * aspect defined using 'file://' protocol
27
+ */
13
28
  readonly local?: boolean | undefined;
14
- constructor(aspectPath: string, runtimePath: string | null, component?: Component | undefined, id?: string | undefined, local?: boolean | undefined);
29
+ constructor(
30
+ /**
31
+ * path the the root directory of the aspect module.
32
+ */
33
+ aspectPath: string,
34
+ /**
35
+ * path to the runtime entry
36
+ */
37
+ runtimePath: string | null,
38
+ /**
39
+ * aspect component
40
+ */
41
+ component?: Component | undefined,
42
+ /**
43
+ * id of the component (used instead of component in the case of core aspect)
44
+ */
45
+ id?: string | undefined,
46
+ /**
47
+ * aspect defined using 'file://' protocol
48
+ */
49
+ local?: boolean | undefined);
15
50
  get getId(): string | null;
16
51
  static from({ component, aspectPath, runtimePath, id }: AspectDefinitionProps): AspectDefinition;
17
52
  }
@@ -9,7 +9,13 @@ import { PluginDefinition } from './plugin-definition';
9
9
  import { Plugins } from './plugins';
10
10
  export declare type PluginDefinitionSlot = SlotRegistry<PluginDefinition[]>;
11
11
  export declare type AspectDescriptor = {
12
+ /**
13
+ * name of the extension.
14
+ */
12
15
  id: string;
16
+ /**
17
+ * icon of the extension.
18
+ */
13
19
  icon?: string;
14
20
  };
15
21
  export declare type AspectResolver = (component: Component) => Promise<ResolvedAspect>;
@@ -20,13 +26,34 @@ export declare type ResolvedAspect = {
20
26
  declare type OnAspectLoadError = (err: Error, id: ComponentID) => Promise<boolean>;
21
27
  export declare type OnAspectLoadErrorSlot = SlotRegistry<OnAspectLoadError>;
22
28
  export declare type OnLoadRequireableExtension = (requireableExtension: RequireableComponent, manifest: ExtensionManifest | Aspect) => Promise<ExtensionManifest | Aspect>;
29
+ /**
30
+ * A slot which run during loading the requirable extension (after first manifest calculation)
31
+ */
23
32
  export declare type OnLoadRequireableExtensionSlot = SlotRegistry<OnLoadRequireableExtension>;
24
33
  export declare type MainAspect = {
34
+ /**
35
+ * path to the main aspect.
36
+ */
25
37
  path: string;
38
+ /**
39
+ * version of the aspect.
40
+ */
26
41
  version: string | undefined;
42
+ /**
43
+ * package name of the aspect
44
+ */
27
45
  packageName: string | undefined;
46
+ /**
47
+ * reference to aspect manifest.
48
+ */
28
49
  aspect: Aspect;
50
+ /**
51
+ * The name of the aspect (without the scope prefix)
52
+ */
29
53
  name: string;
54
+ /**
55
+ * The name of the aspect
56
+ */
30
57
  id: string;
31
58
  };
32
59
  export declare class AspectLoaderMain {
@@ -40,6 +67,9 @@ export declare class AspectLoaderMain {
40
67
  private getCompiler;
41
68
  registerOnAspectLoadErrorSlot(onAspectLoadError: OnAspectLoadError): void;
42
69
  registerOnLoadRequireableExtensionSlot(onLoadRequireableExtension: OnLoadRequireableExtension): void;
70
+ /**
71
+ * returns whether the aspect-load issue has been fixed.
72
+ */
43
73
  triggerOnAspectLoadError(err: Error, component: Component): Promise<boolean>;
44
74
  getRuntimePath(component: Component, modulePath: string, runtime: string): Promise<string | null>;
45
75
  isAspectLoaded(id: string): unknown;
@@ -61,7 +91,30 @@ export declare class AspectLoaderMain {
61
91
  private failedLoadAspect;
62
92
  get failedAspects(): string[];
63
93
  private addFailure;
94
+ /**
95
+ * run "require" of the component code to get the manifest
96
+ */
64
97
  doRequire(requireableExtension: RequireableComponent): Promise<ExtensionManifest | Aspect>;
98
+ /**
99
+ * in case the extension failed to load, prefer to throw an error, unless `throwOnError` param
100
+ * passed as `false`.
101
+ * there are cases when throwing an error blocks the user from doing anything else. for example,
102
+ * when a user develops an extension and deletes the node-modules, the extension on the workspace
103
+ * cannot be loaded anymore until "bit compile" is running. however, if this function throws an
104
+ * error, it'll throw for "bit compile" as well, which blocks the user.
105
+ * for the CI, it is important to throw an error because errors on console can be ignored.
106
+ * for now, when loading the extension from the workspace the throwOnError is passed as false.
107
+ * when loading from the scope (CI) it should be true.
108
+ *
109
+ * the console printing here is done directly by "console.error" and not by the logger. the reason
110
+ * is that the logger.console only prints when the loader started (which, btw, happens after
111
+ * entering this function, so it can't work) and here we want it to be printed regardless of the
112
+ * rules of starting the loader. e.g. if by mistake the CI got it as throwOnError=false, it's ok
113
+ * to break the output by the console.error.
114
+ *
115
+ * @todo: this is not the final word however about throwing/non throwing errors here.
116
+ * in some cases, such as "bit tag", it's better not to tag if an extension changes the model.
117
+ */
65
118
  loadRequireableExtensions(requireableExtensions: RequireableComponent[], throwOnError?: boolean): Promise<void>;
66
119
  getManifestsFromRequireableExtensions(requireableExtensions: RequireableComponent[], throwOnError?: boolean): Promise<Array<ExtensionManifest | Aspect>>;
67
120
  handleExtensionLoadingError(error: Error, idStr: string, throwOnError: boolean): void;
@@ -70,8 +123,15 @@ export declare class AspectLoaderMain {
70
123
  getPlugins(component: Component, componentPath: string): Plugins;
71
124
  isAspect(manifest: any): boolean;
72
125
  isAspectComponent(component: Component): boolean;
126
+ /**
127
+ * get or create a global scope, import the non-core aspects, load bit from that scope, create
128
+ * capsules for the aspects and load them from the capsules.
129
+ */
73
130
  loadAspectsFromGlobalScope(aspectIds: string[]): Promise<Component[]>;
74
131
  private prepareManifests;
132
+ /**
133
+ * register a plugin.
134
+ */
75
135
  registerPlugins(pluginDefs: PluginDefinition[]): this;
76
136
  loadExtensionsByManifests(extensionsManifests: Array<ExtensionManifest | Aspect>, throwOnError?: boolean): Promise<void>;
77
137
  static runtime: import("@teambit/harmony").RuntimeDefinition;
@@ -1,5 +1,14 @@
1
1
  export interface PluginDefinition {
2
+ /**
3
+ * regex pattern for detecting the definition file within a component.
4
+ */
2
5
  pattern: string | RegExp;
6
+ /**
7
+ * runtimes for the plugin to apply.
8
+ */
3
9
  runtimes: string[];
10
+ /**
11
+ * register the plugin to its slot registry.
12
+ */
4
13
  register<T>(object: T): void;
5
14
  }
package/dist/plugin.d.ts CHANGED
@@ -4,6 +4,9 @@ export declare class Plugin {
4
4
  readonly path: string;
5
5
  constructor(def: PluginDefinition, path: string);
6
6
  private _instance;
7
+ /**
8
+ * determines whether the plugin supports a certain runtime.
9
+ */
7
10
  supportsRuntime(runtime: string): boolean;
8
11
  register(): void;
9
12
  require(): unknown;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/aspect-loader",
3
- "version": "0.0.549",
3
+ "version": "0.0.555",
4
4
  "homepage": "https://bit.dev/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": "0.0.549"
9
+ "version": "0.0.555"
10
10
  },
11
11
  "dependencies": {
12
12
  "@teambit/harmony": "0.2.11",
@@ -15,15 +15,15 @@
15
15
  "fs-extra": "10.0.0",
16
16
  "@babel/runtime": "7.12.18",
17
17
  "core-js": "^3.0.0",
18
- "@teambit/component": "0.0.549",
19
- "@teambit/bit": "0.0.551",
20
- "@teambit/cli": "0.0.380",
21
- "@teambit/envs": "0.0.549",
22
- "@teambit/harmony.modules.requireable-component": "0.0.457",
23
- "@teambit/legacy-bit-id": "0.0.369",
24
- "@teambit/logger": "0.0.465",
25
- "@teambit/scope": "0.0.549",
26
- "@teambit/bit-error": "0.0.366"
18
+ "@teambit/component": "0.0.555",
19
+ "@teambit/bit": "0.0.557",
20
+ "@teambit/cli": "0.0.386",
21
+ "@teambit/envs": "0.0.555",
22
+ "@teambit/harmony.modules.requireable-component": "0.0.461",
23
+ "@teambit/legacy-bit-id": "0.0.375",
24
+ "@teambit/logger": "0.0.471",
25
+ "@teambit/scope": "0.0.555",
26
+ "@teambit/bit-error": "0.0.372"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/lodash": "4.14.165",
@@ -36,7 +36,7 @@
36
36
  "@types/node": "12.20.4"
37
37
  },
38
38
  "peerDependencies": {
39
- "@teambit/legacy": "1.0.76",
39
+ "@teambit/legacy": "1.0.172",
40
40
  "react-dom": "^16.8.0 || ^17.0.0",
41
41
  "react": "^16.8.0 || ^17.0.0"
42
42
  },
@@ -64,7 +64,7 @@
64
64
  "react": "-"
65
65
  },
66
66
  "peerDependencies": {
67
- "@teambit/legacy": "1.0.76",
67
+ "@teambit/legacy": "1.0.172",
68
68
  "react-dom": "^16.8.0 || ^17.0.0",
69
69
  "react": "^16.8.0 || ^17.0.0"
70
70
  }
package/tsconfig.json CHANGED
@@ -25,7 +25,6 @@
25
25
  "strict": true,
26
26
  "noImplicitAny": false,
27
27
  "rootDir": ".",
28
- "removeComments": true,
29
28
  "preserveConstEnums": true,
30
29
  "resolveJsonModule": true
31
30
  },