@teambit/aspect-loader 0.0.996 → 0.0.999
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/plugins.js
CHANGED
|
@@ -52,6 +52,9 @@ class Plugins {
|
|
|
52
52
|
await Promise.all(plugins.map(async plugin => {
|
|
53
53
|
return this.registerPluginWithTryCatch(plugin, aspect);
|
|
54
54
|
}));
|
|
55
|
+
// Return an empty object so haromny will have something in the extension instance
|
|
56
|
+
// otherwise it will throw an error when trying to access the extension instance (harmony.get)
|
|
57
|
+
return {};
|
|
55
58
|
},
|
|
56
59
|
runtime,
|
|
57
60
|
// dependencies: this.computeDependencies(runtime)
|
package/dist/plugins.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Plugins","constructor","component","plugins","triggerOnAspectLoadError","logger","getByRuntime","runtime","filter","plugin","supportsRuntime","load","aspect","Aspect","create","id","toString","addRuntime","provider","Promise","all","map","registerPluginWithTryCatch","dependencies","register","firstErr","warn","def","pattern","isFixed","errAfterReLoad","info","err","error","has","Boolean","length","from","defs","resolvePath","flatMap","pluginDef","files","filesystem","byGlob","byRegex","file","Plugin","relative","path"],"sources":["plugins.ts"],"sourcesContent":["import { Component } from '@teambit/component';\nimport { Logger } from '@teambit/logger';\nimport { Aspect } from '@teambit/harmony';\nimport { PluginDefinition } from './plugin-definition';\nimport { Plugin } from './plugin';\nimport { OnAspectLoadErrorHandler } from './aspect-loader.main.runtime';\n\nexport type PluginMap = { [filePath: string]: PluginDefinition };\n\nexport class Plugins {\n constructor(\n readonly component: Component,\n readonly plugins: Plugin[],\n private triggerOnAspectLoadError: OnAspectLoadErrorHandler,\n private logger: Logger\n ) {}\n\n // computeDependencies(runtime: string): Aspect[] {\n // const inRuntime = this.getByRuntime(runtime);\n // return inRuntime.flatMap((plugin) => {\n // return plugin.def.dependencies;\n // });\n // }\n\n getByRuntime(runtime: string) {\n return this.plugins.filter((plugin) => {\n return plugin.supportsRuntime(runtime);\n });\n }\n\n async load(runtime: string) {\n const plugins = this.getByRuntime(runtime);\n const aspect = Aspect.create({\n id: this.component.id.toString(),\n });\n\n aspect.addRuntime({\n provider: async () => {\n await Promise.all(\n plugins.map(async (plugin) => {\n return this.registerPluginWithTryCatch(plugin, aspect);\n })\n );\n },\n runtime,\n // dependencies: this.computeDependencies(runtime)\n dependencies: [],\n });\n\n return aspect;\n }\n\n async registerPluginWithTryCatch(plugin: Plugin, aspect: Aspect) {\n try {\n return plugin.register(aspect);\n } catch (firstErr: any) {\n this.logger.warn(\n `failed loading plugin with pattern \"${\n plugin.def.pattern\n }\", in component ${this.component.id.toString()}, will try to fix and reload`,\n firstErr\n );\n const isFixed = await this.triggerOnAspectLoadError(firstErr, this.component);\n let errAfterReLoad;\n if (isFixed) {\n this.logger.info(\n `the loading issue might be fixed now, re-loading plugin with pattern \"${\n plugin.def.pattern\n }\", in component ${this.component.id.toString()}`\n );\n try {\n return plugin.register(aspect);\n } catch (err: any) {\n this.logger.warn(\n `re-load of the plugin with pattern \"${\n plugin.def.pattern\n }\", in component ${this.component.id.toString()} failed as well`,\n err\n );\n errAfterReLoad = err;\n }\n }\n const error = errAfterReLoad || firstErr;\n throw error;\n }\n }\n\n has() {\n return Boolean(this.plugins.length);\n }\n\n static from(\n component: Component,\n defs: PluginDefinition[],\n triggerOnAspectLoadError: OnAspectLoadErrorHandler,\n logger: Logger,\n resolvePath?: (path: string) => string\n ) {\n const plugins = defs.flatMap((pluginDef) => {\n const files =\n typeof pluginDef.pattern === 'string'\n ? component.filesystem.byGlob([pluginDef.pattern])\n : component.filesystem.byRegex(pluginDef.pattern);\n\n return files.map((file) => {\n return new Plugin(pluginDef, resolvePath ? resolvePath(file.relative) : file.path);\n });\n });\n\n return new Plugins(component, plugins, triggerOnAspectLoadError, logger);\n }\n}\n"],"mappings":";;;;;;;;;;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKO,MAAMA,OAAO,CAAC;EACnBC,WAAW,CACAC,SAAoB,EACpBC,OAAiB,EAClBC,wBAAkD,EAClDC,MAAc,EACtB;IAAA,KAJSH,SAAoB,GAApBA,SAAoB;IAAA,KACpBC,OAAiB,GAAjBA,OAAiB;IAAA,KAClBC,wBAAkD,GAAlDA,wBAAkD;IAAA,KAClDC,MAAc,GAAdA,MAAc;EACrB;;EAEH;EACA;EACA;EACA;EACA;EACA;;EAEAC,YAAY,CAACC,OAAe,EAAE;IAC5B,OAAO,IAAI,CAACJ,OAAO,CAACK,MAAM,CAAEC,MAAM,IAAK;MACrC,OAAOA,MAAM,CAACC,eAAe,CAACH,OAAO,CAAC;IACxC,CAAC,CAAC;EACJ;EAEA,MAAMI,IAAI,CAACJ,OAAe,EAAE;IAC1B,MAAMJ,OAAO,GAAG,IAAI,CAACG,YAAY,CAACC,OAAO,CAAC;IAC1C,MAAMK,MAAM,GAAGC,iBAAM,CAACC,MAAM,CAAC;MAC3BC,EAAE,EAAE,IAAI,CAACb,SAAS,CAACa,EAAE,CAACC,QAAQ;IAChC,CAAC,CAAC;IAEFJ,MAAM,CAACK,UAAU,CAAC;MAChBC,QAAQ,EAAE,YAAY;QACpB,MAAMC,OAAO,CAACC,GAAG,CACfjB,OAAO,CAACkB,GAAG,CAAC,MAAOZ,MAAM,IAAK;UAC5B,OAAO,IAAI,CAACa,0BAA0B,CAACb,MAAM,EAAEG,MAAM,CAAC;QACxD,CAAC,CAAC,CACH;
|
|
1
|
+
{"version":3,"names":["Plugins","constructor","component","plugins","triggerOnAspectLoadError","logger","getByRuntime","runtime","filter","plugin","supportsRuntime","load","aspect","Aspect","create","id","toString","addRuntime","provider","Promise","all","map","registerPluginWithTryCatch","dependencies","register","firstErr","warn","def","pattern","isFixed","errAfterReLoad","info","err","error","has","Boolean","length","from","defs","resolvePath","flatMap","pluginDef","files","filesystem","byGlob","byRegex","file","Plugin","relative","path"],"sources":["plugins.ts"],"sourcesContent":["import { Component } from '@teambit/component';\nimport { Logger } from '@teambit/logger';\nimport { Aspect } from '@teambit/harmony';\nimport { PluginDefinition } from './plugin-definition';\nimport { Plugin } from './plugin';\nimport { OnAspectLoadErrorHandler } from './aspect-loader.main.runtime';\n\nexport type PluginMap = { [filePath: string]: PluginDefinition };\n\nexport class Plugins {\n constructor(\n readonly component: Component,\n readonly plugins: Plugin[],\n private triggerOnAspectLoadError: OnAspectLoadErrorHandler,\n private logger: Logger\n ) {}\n\n // computeDependencies(runtime: string): Aspect[] {\n // const inRuntime = this.getByRuntime(runtime);\n // return inRuntime.flatMap((plugin) => {\n // return plugin.def.dependencies;\n // });\n // }\n\n getByRuntime(runtime: string) {\n return this.plugins.filter((plugin) => {\n return plugin.supportsRuntime(runtime);\n });\n }\n\n async load(runtime: string) {\n const plugins = this.getByRuntime(runtime);\n const aspect = Aspect.create({\n id: this.component.id.toString(),\n });\n\n aspect.addRuntime({\n provider: async () => {\n await Promise.all(\n plugins.map(async (plugin) => {\n return this.registerPluginWithTryCatch(plugin, aspect);\n })\n );\n // Return an empty object so haromny will have something in the extension instance\n // otherwise it will throw an error when trying to access the extension instance (harmony.get)\n return {};\n },\n runtime,\n // dependencies: this.computeDependencies(runtime)\n dependencies: [],\n });\n\n return aspect;\n }\n\n async registerPluginWithTryCatch(plugin: Plugin, aspect: Aspect) {\n try {\n return plugin.register(aspect);\n } catch (firstErr: any) {\n this.logger.warn(\n `failed loading plugin with pattern \"${\n plugin.def.pattern\n }\", in component ${this.component.id.toString()}, will try to fix and reload`,\n firstErr\n );\n const isFixed = await this.triggerOnAspectLoadError(firstErr, this.component);\n let errAfterReLoad;\n if (isFixed) {\n this.logger.info(\n `the loading issue might be fixed now, re-loading plugin with pattern \"${\n plugin.def.pattern\n }\", in component ${this.component.id.toString()}`\n );\n try {\n return plugin.register(aspect);\n } catch (err: any) {\n this.logger.warn(\n `re-load of the plugin with pattern \"${\n plugin.def.pattern\n }\", in component ${this.component.id.toString()} failed as well`,\n err\n );\n errAfterReLoad = err;\n }\n }\n const error = errAfterReLoad || firstErr;\n throw error;\n }\n }\n\n has() {\n return Boolean(this.plugins.length);\n }\n\n static from(\n component: Component,\n defs: PluginDefinition[],\n triggerOnAspectLoadError: OnAspectLoadErrorHandler,\n logger: Logger,\n resolvePath?: (path: string) => string\n ) {\n const plugins = defs.flatMap((pluginDef) => {\n const files =\n typeof pluginDef.pattern === 'string'\n ? component.filesystem.byGlob([pluginDef.pattern])\n : component.filesystem.byRegex(pluginDef.pattern);\n\n return files.map((file) => {\n return new Plugin(pluginDef, resolvePath ? resolvePath(file.relative) : file.path);\n });\n });\n\n return new Plugins(component, plugins, triggerOnAspectLoadError, logger);\n }\n}\n"],"mappings":";;;;;;;;;;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAKO,MAAMA,OAAO,CAAC;EACnBC,WAAW,CACAC,SAAoB,EACpBC,OAAiB,EAClBC,wBAAkD,EAClDC,MAAc,EACtB;IAAA,KAJSH,SAAoB,GAApBA,SAAoB;IAAA,KACpBC,OAAiB,GAAjBA,OAAiB;IAAA,KAClBC,wBAAkD,GAAlDA,wBAAkD;IAAA,KAClDC,MAAc,GAAdA,MAAc;EACrB;;EAEH;EACA;EACA;EACA;EACA;EACA;;EAEAC,YAAY,CAACC,OAAe,EAAE;IAC5B,OAAO,IAAI,CAACJ,OAAO,CAACK,MAAM,CAAEC,MAAM,IAAK;MACrC,OAAOA,MAAM,CAACC,eAAe,CAACH,OAAO,CAAC;IACxC,CAAC,CAAC;EACJ;EAEA,MAAMI,IAAI,CAACJ,OAAe,EAAE;IAC1B,MAAMJ,OAAO,GAAG,IAAI,CAACG,YAAY,CAACC,OAAO,CAAC;IAC1C,MAAMK,MAAM,GAAGC,iBAAM,CAACC,MAAM,CAAC;MAC3BC,EAAE,EAAE,IAAI,CAACb,SAAS,CAACa,EAAE,CAACC,QAAQ;IAChC,CAAC,CAAC;IAEFJ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,GAAG,CACJ;UACDF,cAAc,GAAGE,GAAG;QACtB;MACF;MACA,MAAMC,KAAK,GAAGH,cAAc,IAAIL,QAAQ;MACxC,MAAMQ,KAAK;IACb;EACF;EAEAC,GAAG,GAAG;IACJ,OAAOC,OAAO,CAAC,IAAI,CAAChC,OAAO,CAACiC,MAAM,CAAC;EACrC;EAEA,OAAOC,IAAI,CACTnC,SAAoB,EACpBoC,IAAwB,EACxBlC,wBAAkD,EAClDC,MAAc,EACdkC,WAAsC,EACtC;IACA,MAAMpC,OAAO,GAAGmC,IAAI,CAACE,OAAO,CAAEC,SAAS,IAAK;MAC1C,MAAMC,KAAK,GACT,OAAOD,SAAS,CAACb,OAAO,KAAK,QAAQ,GACjC1B,SAAS,CAACyC,UAAU,CAACC,MAAM,CAAC,CAACH,SAAS,CAACb,OAAO,CAAC,CAAC,GAChD1B,SAAS,CAACyC,UAAU,CAACE,OAAO,CAACJ,SAAS,CAACb,OAAO,CAAC;MAErD,OAAOc,KAAK,CAACrB,GAAG,CAAEyB,IAAI,IAAK;QACzB,OAAO,KAAIC,gBAAM,EAACN,SAAS,EAAEF,WAAW,GAAGA,WAAW,CAACO,IAAI,CAACE,QAAQ,CAAC,GAAGF,IAAI,CAACG,IAAI,CAAC;MACpF,CAAC,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,IAAIjD,OAAO,CAACE,SAAS,EAAEC,OAAO,EAAEC,wBAAwB,EAAEC,MAAM,CAAC;EAC1E;AACF;AAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_aspect-loader@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_aspect-loader@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_aspect-loader@0.0.999/dist/aspect-loader.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_aspect-loader@0.0.999/dist/aspect-loader.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/aspect-loader",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.999",
|
|
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.
|
|
9
|
+
"version": "0.0.999"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"lodash": "4.17.21",
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
"@teambit/harmony": "0.4.6",
|
|
18
18
|
"@teambit/graph.cleargraph": "0.0.1",
|
|
19
19
|
"@teambit/bvm.config": "0.2.2",
|
|
20
|
-
"@teambit/component": "0.0.
|
|
21
|
-
"@teambit/bit": "0.0.
|
|
22
|
-
"@teambit/cli": "0.0.
|
|
20
|
+
"@teambit/component": "0.0.999",
|
|
21
|
+
"@teambit/bit": "0.0.1001",
|
|
22
|
+
"@teambit/cli": "0.0.670",
|
|
23
23
|
"@teambit/compilation.modules.babel-compiler": "0.0.133",
|
|
24
|
-
"@teambit/envs": "0.0.
|
|
24
|
+
"@teambit/envs": "0.0.999",
|
|
25
25
|
"@teambit/harmony.modules.requireable-component": "0.0.491",
|
|
26
26
|
"@teambit/legacy-bit-id": "0.0.423",
|
|
27
|
-
"@teambit/logger": "0.0.
|
|
28
|
-
"@teambit/scope": "0.0.
|
|
27
|
+
"@teambit/logger": "0.0.763",
|
|
28
|
+
"@teambit/scope": "0.0.999",
|
|
29
29
|
"@teambit/bit-error": "0.0.402"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@types/testing-library__jest-dom": "5.9.5"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@teambit/legacy": "1.0.
|
|
42
|
+
"@teambit/legacy": "1.0.452",
|
|
43
43
|
"react": "^16.8.0 || ^17.0.0",
|
|
44
44
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
45
45
|
},
|
|
Binary file
|