@teambit/compiler 0.0.555 → 0.0.556

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.
Files changed (39) hide show
  1. package/dist/compiler.main.runtime.d.ts +4 -2
  2. package/dist/compiler.main.runtime.js +23 -2
  3. package/dist/compiler.main.runtime.js.map +1 -1
  4. package/dist/templates/compiler/files/aspect-file.d.ts +2 -0
  5. package/dist/templates/compiler/files/aspect-file.js +20 -0
  6. package/dist/templates/compiler/files/aspect-file.js.map +1 -0
  7. package/dist/templates/compiler/files/compiler-file.d.ts +2 -0
  8. package/dist/templates/compiler/files/compiler-file.js +84 -0
  9. package/dist/templates/compiler/files/compiler-file.js.map +1 -0
  10. package/dist/templates/compiler/files/index-file.d.ts +2 -0
  11. package/dist/templates/compiler/files/index-file.js +20 -0
  12. package/dist/templates/compiler/files/index-file.js.map +1 -0
  13. package/dist/templates/compiler/files/main-runtime-file.d.ts +2 -0
  14. package/dist/templates/compiler/files/main-runtime-file.js +47 -0
  15. package/dist/templates/compiler/files/main-runtime-file.js.map +1 -0
  16. package/dist/templates/compiler/index.d.ts +2 -0
  17. package/dist/templates/compiler/index.js +71 -0
  18. package/dist/templates/compiler/index.js.map +1 -0
  19. package/package.json +24 -17
  20. package/compiler.aspect.ts +0 -5
  21. package/compiler.cmd.ts +0 -115
  22. package/compiler.docs.mdx +0 -8
  23. package/compiler.main.runtime.ts +0 -99
  24. package/compiler.service.tsx +0 -47
  25. package/compiler.task.ts +0 -52
  26. package/dist-artifact.ts +0 -12
  27. package/events/compiler-error.ts +0 -14
  28. package/events/component-compilation-on-done.ts +0 -30
  29. package/events/index.ts +0 -2
  30. package/exceptions/dist-artifact-not-found.ts +0 -8
  31. package/exceptions/index.ts +0 -1
  32. package/index.ts +0 -11
  33. package/output-formatter.ts +0 -19
  34. package/package-tar/teambit-compiler-0.0.555.tgz +0 -0
  35. package/tsconfig.json +0 -34
  36. package/types/asset.d.ts +0 -29
  37. package/types/style.d.ts +0 -42
  38. package/types.ts +0 -137
  39. package/workspace-compiler.ts +0 -306
@@ -5,6 +5,7 @@ import { Component } from '@teambit/component';
5
5
  import { EnvsMain } from '@teambit/envs';
6
6
  import { BitId } from '@teambit/legacy-bit-id';
7
7
  import { LoggerMain } from '@teambit/logger';
8
+ import { GeneratorMain } from '@teambit/generator';
8
9
  import { PubsubMain } from '@teambit/pubsub';
9
10
  import { UiMain } from '@teambit/ui';
10
11
  import { Workspace } from '@teambit/workspace';
@@ -35,7 +36,7 @@ export declare class CompilerMain {
35
36
  getDistsFiles(component: Component): Promise<DistArtifact>;
36
37
  static runtime: import("@teambit/harmony").RuntimeDefinition;
37
38
  static dependencies: import("@teambit/harmony").Aspect[];
38
- static provider([cli, workspace, envs, loggerMain, pubsub, aspectLoader, builder, ui]: [
39
+ static provider([cli, workspace, envs, loggerMain, pubsub, aspectLoader, builder, ui, generator]: [
39
40
  CLIMain,
40
41
  Workspace,
41
42
  EnvsMain,
@@ -43,6 +44,7 @@ export declare class CompilerMain {
43
44
  PubsubMain,
44
45
  AspectLoaderMain,
45
46
  BuilderMain,
46
- UiMain
47
+ UiMain,
48
+ GeneratorMain
47
49
  ]): Promise<CompilerMain>;
48
50
  }
@@ -81,6 +81,16 @@ function _logger() {
81
81
  return data;
82
82
  }
83
83
 
84
+ function _generator() {
85
+ const data = require("@teambit/generator");
86
+
87
+ _generator = function () {
88
+ return data;
89
+ };
90
+
91
+ return data;
92
+ }
93
+
84
94
  function _pubsub() {
85
95
  const data = require("@teambit/pubsub");
86
96
 
@@ -191,6 +201,16 @@ function _workspaceCompiler() {
191
201
  return data;
192
202
  }
193
203
 
204
+ function _compiler5() {
205
+ const data = require("./templates/compiler");
206
+
207
+ _compiler5 = function () {
208
+ return data;
209
+ };
210
+
211
+ return data;
212
+ }
213
+
194
214
  class CompilerMain {
195
215
  constructor(pubsub, workspaceCompiler, envs, builder) {
196
216
  this.pubsub = pubsub;
@@ -238,12 +258,13 @@ class CompilerMain {
238
258
  return new (_distArtifact().DistArtifact)(artifacts);
239
259
  }
240
260
 
241
- static async provider([cli, workspace, envs, loggerMain, pubsub, aspectLoader, builder, ui]) {
261
+ static async provider([cli, workspace, envs, loggerMain, pubsub, aspectLoader, builder, ui, generator]) {
242
262
  const logger = loggerMain.createLogger(_compiler().CompilerAspect.id);
243
263
  const workspaceCompiler = new (_workspaceCompiler().WorkspaceCompiler)(workspace, envs, pubsub, aspectLoader, ui, logger);
244
264
  envs.registerService(new (_compiler3().CompilerService)());
245
265
  const compilerMain = new CompilerMain(pubsub, workspaceCompiler, envs, builder);
246
266
  cli.register(new (_compiler2().CompileCmd)(workspaceCompiler, logger, pubsub));
267
+ generator.registerComponentTemplate([_compiler5().compilerTemplate]);
247
268
  _manyComponentsWriter().default.externalCompiler = compilerMain.compileOnWorkspace.bind(compilerMain);
248
269
  return compilerMain;
249
270
  }
@@ -252,7 +273,7 @@ class CompilerMain {
252
273
 
253
274
  exports.CompilerMain = CompilerMain;
254
275
  (0, _defineProperty2().default)(CompilerMain, "runtime", _cli().MainRuntime);
255
- (0, _defineProperty2().default)(CompilerMain, "dependencies", [_cli().CLIAspect, _workspace().WorkspaceAspect, _envs().EnvsAspect, _logger().LoggerAspect, _pubsub().PubsubAspect, _aspectLoader().default, _builder().BuilderAspect, _ui().default]);
276
+ (0, _defineProperty2().default)(CompilerMain, "dependencies", [_cli().CLIAspect, _workspace().WorkspaceAspect, _envs().EnvsAspect, _logger().LoggerAspect, _pubsub().PubsubAspect, _aspectLoader().default, _builder().BuilderAspect, _ui().default, _generator().GeneratorAspect]);
256
277
 
257
278
  _compiler().CompilerAspect.addRuntime(CompilerMain);
258
279
 
@@ -1 +1 @@
1
- {"version":3,"sources":["compiler.main.runtime.ts"],"names":["CompilerMain","constructor","pubsub","workspaceCompiler","envs","builder","compileOnWorkspace","componentsIds","options","initiator","CompilationInitiator","ComponentAdded","compileComponents","createTask","name","compiler","CompilerTask","CompilerAspect","id","getDistPathBySrcPath","component","srcPath","environment","getEnv","env","compilerInstance","getCompiler","getDistsFiles","artifacts","getArtifactsVinylByExtension","length","DistArtifactNotFound","DistArtifact","provider","cli","workspace","loggerMain","aspectLoader","ui","logger","createLogger","WorkspaceCompiler","registerService","CompilerService","compilerMain","register","CompileCmd","ManyComponentsWriter","externalCompiler","bind","MainRuntime","CLIAspect","WorkspaceAspect","EnvsAspect","LoggerAspect","PubsubAspect","AspectLoaderAspect","BuilderAspect","UIAspect","addRuntime"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,YAAN,CAAmB;AACxBC,EAAAA,WAAW,CACDC,MADC,EAEDC,iBAFC,EAGDC,IAHC,EAIDC,OAJC,EAKT;AAAA,SAJQH,MAIR,GAJQA,MAIR;AAAA,SAHQ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vB,EAAmClC,MAAnC,EAA2CmC,YAA3C,EAAyDhC,OAAzD,EAAkEiC,EAAlE,CAAD,EASlB;AACD,UAAMC,MAAM,GAAGH,UAAU,CAACI,YAAX,CAAwBvB,2BAAeC,EAAvC,CAAf;AACA,UAAMf,iBAAiB,GAAG,KAAIsC,sCAAJ,EAAsBN,SAAtB,EAAiC/B,IAAjC,EAAuCF,MAAvC,EAA+CmC,YAA/C,EAA6DC,EAA7D,EAAiEC,MAAjE,CAA1B;AACAnC,IAAAA,IAAI,CAACsC,eAAL,CAAqB,KAAIC,4BAAJ,GAArB;AACA,UAAMC,YAAY,GAAG,IAAI5C,YAAJ,CAAiBE,MAAjB,EAAyBC,iBAAzB,EAA4CC,IAA5C,EAAkDC,OAAlD,CAArB;AACA6B,IAAAA,GAAG,CAACW,QAAJ,CAAa,KAAIC,uBAAJ,EAAe3C,iBAAf,EAAkCoC,MAAlC,EAA0CrC,MAA1C,CAAb;AAEA6C,oCAAqBC,gBAArB,GAAwCJ,YAAY,CAACtC,kBAAb,CAAgC2C,IAAhC,CAAqCL,YAArC,CAAxC;AAEA,WAAOA,YAAP;AACD;;AA1EuB;;;gCAAb5C,Y,aA0CMkD,kB;gCA1CNlD,Y,kBA4CW,CACpBmD,gBADoB,EAEpBC,4BAFoB,EAGpBC,kBAHoB,EAIpBC,sBAJoB,EAKpBC,sBALoB,EAMpBC,uBANoB,EAOpBC,wBAPoB,EAQpBC,aARoB,C;;AAiCxBzC,2BAAe0C,UAAf,CAA0B3D,YAA1B","sourcesContent":["import AspectLoaderAspect, { AspectLoaderMain } from '@teambit/aspect-loader';\nimport { BuilderAspect, BuilderMain } from '@teambit/builder';\nimport { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { Component } from '@teambit/component';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { BitId } from '@teambit/legacy-bit-id';\n\nimport ManyComponentsWriter from '@teambit/legacy/dist/consumer/component-ops/many-components-writer';\nimport { LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { PubsubAspect, PubsubMain } from '@teambit/pubsub';\nimport UIAspect, { UiMain } from '@teambit/ui';\nimport { Workspace, WorkspaceAspect } from '@teambit/workspace';\nimport { CompilerAspect } from './compiler.aspect';\nimport { CompileCmd } from './compiler.cmd';\nimport { CompilerService } from './compiler.service';\nimport { CompilerTask } from './compiler.task';\nimport { DistArtifact } from './dist-artifact';\nimport { DistArtifactNotFound } from './exceptions';\nimport { CompilationInitiator, Compiler } from './types';\nimport { CompileOptions, WorkspaceCompiler } from './workspace-compiler';\n\nexport class CompilerMain {\n constructor(\n private pubsub: PubsubMain,\n private workspaceCompiler: WorkspaceCompiler,\n private envs: EnvsMain,\n private builder: BuilderMain\n ) {}\n\n /**\n * Run compilation on `bit new` and when new components are imported\n */\n compileOnWorkspace(\n componentsIds: string[] | BitId[] = [], // when empty, it compiles all\n options: CompileOptions = { initiator: CompilationInitiator.ComponentAdded }\n ) {\n return this.workspaceCompiler.compileComponents(componentsIds, options);\n }\n /**\n * API to create a new compiler task, it facilitates the usage of multiple compilers.\n * with this method you can create any number of compilers and add them to the buildPipeline.\n */\n createTask(name: string, compiler: Compiler): CompilerTask {\n return new CompilerTask(CompilerAspect.id, name, compiler);\n }\n\n /**\n * find the compiler configured on the workspace and ask for the dist path.\n */\n getDistPathBySrcPath(component: Component, srcPath: string): string | null {\n const environment = this.envs.getEnv(component).env;\n const compilerInstance = environment.getCompiler?.();\n if (!compilerInstance) return null;\n return compilerInstance.getDistPathBySrcPath(srcPath);\n }\n\n async getDistsFiles(component: Component): Promise<DistArtifact> {\n const artifacts = await this.builder.getArtifactsVinylByExtension(component, CompilerAspect.id);\n if (!artifacts.length) throw new DistArtifactNotFound(component.id);\n\n return new DistArtifact(artifacts);\n }\n\n static runtime = MainRuntime;\n\n static dependencies = [\n CLIAspect,\n WorkspaceAspect,\n EnvsAspect,\n LoggerAspect,\n PubsubAspect,\n AspectLoaderAspect,\n BuilderAspect,\n UIAspect,\n ];\n\n static async provider([cli, workspace, envs, loggerMain, pubsub, aspectLoader, builder, ui]: [\n CLIMain,\n Workspace,\n EnvsMain,\n LoggerMain,\n PubsubMain,\n AspectLoaderMain,\n BuilderMain,\n UiMain\n ]) {\n const logger = loggerMain.createLogger(CompilerAspect.id);\n const workspaceCompiler = new WorkspaceCompiler(workspace, envs, pubsub, aspectLoader, ui, logger);\n envs.registerService(new CompilerService());\n const compilerMain = new CompilerMain(pubsub, workspaceCompiler, envs, builder);\n cli.register(new CompileCmd(workspaceCompiler, logger, pubsub));\n\n ManyComponentsWriter.externalCompiler = compilerMain.compileOnWorkspace.bind(compilerMain);\n\n return compilerMain;\n }\n}\n\nCompilerAspect.addRuntime(CompilerMain);\n"]}
1
+ {"version":3,"sources":["compiler.main.runtime.ts"],"names":["CompilerMain","constructor","pubsub","workspaceCompiler","envs","builder","compileOnWorkspace","componentsIds","options","initiator","CompilationInitiator","ComponentAdded","compileComponents","createTask","name","compiler","CompilerTask","CompilerAspect","id","getDistPathBySrcPath","component","srcPath","environment","getEnv","env","compilerInstance","getCompiler","getDistsFiles","artifacts","getArtifactsVinylByExtension","length","DistArtifactNotFound","DistArtifact","provider","cli","workspace","loggerMain","aspectLoader","ui","generator","logger","createLogger","WorkspaceCompiler","registerService","CompilerService","compilerMain","register","CompileCmd","registerComponentTemplate","compilerTemplate","ManyComponentsWriter","externalCompiler","bind","MainRuntime","CLIAspect","WorkspaceAspect","EnvsAspect","LoggerAspect","PubsubAspect","AspectLoaderAspect","BuilderAspect","UIAspect","GeneratorAspect","addRuntime"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;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EAAkDC,OAAlD,CAArB;AACA6B,IAAAA,GAAG,CAACY,QAAJ,CAAa,KAAIC,uBAAJ,EAAe5C,iBAAf,EAAkCqC,MAAlC,EAA0CtC,MAA1C,CAAb;AACAqC,IAAAA,SAAS,CAACS,yBAAV,CAAoC,CAACC,6BAAD,CAApC;AACAC,oCAAqBC,gBAArB,GAAwCN,YAAY,CAACvC,kBAAb,CAAgC8C,IAAhC,CAAqCP,YAArC,CAAxC;AAEA,WAAOA,YAAP;AACD;;AA5EuB;;;gCAAb7C,Y,aA0CMqD,kB;gCA1CNrD,Y,kBA4CW,CACpBsD,gBADoB,EAEpBC,4BAFoB,EAGpBC,kBAHoB,EAIpBC,sBAJoB,EAKpBC,sBALoB,EAMpBC,uBANoB,EAOpBC,wBAPoB,EAQpBC,aARoB,EASpBC,4BAToB,C;;AAmCxB7C,2BAAe8C,UAAf,CAA0B/D,YAA1B","sourcesContent":["import AspectLoaderAspect, { AspectLoaderMain } from '@teambit/aspect-loader';\nimport { BuilderAspect, BuilderMain } from '@teambit/builder';\nimport { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { Component } from '@teambit/component';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { BitId } from '@teambit/legacy-bit-id';\n\nimport ManyComponentsWriter from '@teambit/legacy/dist/consumer/component-ops/many-components-writer';\nimport { LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { GeneratorAspect, GeneratorMain } from '@teambit/generator';\nimport { PubsubAspect, PubsubMain } from '@teambit/pubsub';\nimport UIAspect, { UiMain } from '@teambit/ui';\nimport { Workspace, WorkspaceAspect } from '@teambit/workspace';\nimport { CompilerAspect } from './compiler.aspect';\nimport { CompileCmd } from './compiler.cmd';\nimport { CompilerService } from './compiler.service';\nimport { CompilerTask } from './compiler.task';\nimport { DistArtifact } from './dist-artifact';\nimport { DistArtifactNotFound } from './exceptions';\nimport { CompilationInitiator, Compiler } from './types';\nimport { CompileOptions, WorkspaceCompiler } from './workspace-compiler';\nimport { compilerTemplate } from './templates/compiler';\n\nexport class CompilerMain {\n constructor(\n private pubsub: PubsubMain,\n private workspaceCompiler: WorkspaceCompiler,\n private envs: EnvsMain,\n private builder: BuilderMain\n ) {}\n\n /**\n * Run compilation on `bit new` and when new components are imported\n */\n compileOnWorkspace(\n componentsIds: string[] | BitId[] = [], // when empty, it compiles all\n options: CompileOptions = { initiator: CompilationInitiator.ComponentAdded }\n ) {\n return this.workspaceCompiler.compileComponents(componentsIds, options);\n }\n /**\n * API to create a new compiler task, it facilitates the usage of multiple compilers.\n * with this method you can create any number of compilers and add them to the buildPipeline.\n */\n createTask(name: string, compiler: Compiler): CompilerTask {\n return new CompilerTask(CompilerAspect.id, name, compiler);\n }\n\n /**\n * find the compiler configured on the workspace and ask for the dist path.\n */\n getDistPathBySrcPath(component: Component, srcPath: string): string | null {\n const environment = this.envs.getEnv(component).env;\n const compilerInstance = environment.getCompiler?.();\n if (!compilerInstance) return null;\n return compilerInstance.getDistPathBySrcPath(srcPath);\n }\n\n async getDistsFiles(component: Component): Promise<DistArtifact> {\n const artifacts = await this.builder.getArtifactsVinylByExtension(component, CompilerAspect.id);\n if (!artifacts.length) throw new DistArtifactNotFound(component.id);\n\n return new DistArtifact(artifacts);\n }\n\n static runtime = MainRuntime;\n\n static dependencies = [\n CLIAspect,\n WorkspaceAspect,\n EnvsAspect,\n LoggerAspect,\n PubsubAspect,\n AspectLoaderAspect,\n BuilderAspect,\n UIAspect,\n GeneratorAspect\n ];\n\n static async provider([cli, workspace, envs, loggerMain, pubsub, aspectLoader, builder, ui, generator]: [\n CLIMain,\n Workspace,\n EnvsMain,\n LoggerMain,\n PubsubMain,\n AspectLoaderMain,\n BuilderMain,\n UiMain,\n GeneratorMain\n ]) {\n const logger = loggerMain.createLogger(CompilerAspect.id);\n const workspaceCompiler = new WorkspaceCompiler(workspace, envs, pubsub, aspectLoader, ui, logger);\n envs.registerService(new CompilerService());\n const compilerMain = new CompilerMain(pubsub, workspaceCompiler, envs, builder);\n cli.register(new CompileCmd(workspaceCompiler, logger, pubsub));\n generator.registerComponentTemplate([compilerTemplate]);\n ManyComponentsWriter.externalCompiler = compilerMain.compileOnWorkspace.bind(compilerMain);\n\n return compilerMain;\n }\n}\n\nCompilerAspect.addRuntime(CompilerMain);\n"]}
@@ -0,0 +1,2 @@
1
+ import { ComponentContext } from '@teambit/generator';
2
+ export declare function aspectFile({ namePascalCase, componentId }: ComponentContext): string;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.aspectFile = aspectFile;
7
+
8
+ function aspectFile({
9
+ namePascalCase,
10
+ componentId
11
+ }) {
12
+ return `import { Aspect } from '@teambit/harmony';
13
+
14
+ export const ${namePascalCase}Aspect = Aspect.create({
15
+ id: '${componentId}',
16
+ });
17
+ `;
18
+ }
19
+
20
+ //# sourceMappingURL=aspect-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["aspect-file.ts"],"names":["aspectFile","namePascalCase","componentId"],"mappings":";;;;;;;AAEO,SAASA,UAAT,CAAoB;AAAEC,EAAAA,cAAF;AAAkBC,EAAAA;AAAlB,CAApB,EAAuE;AAC5E,SAAQ;AACV;AACA,eAAeD,cAAe;AAC9B,SAASC,WAAY;AACrB;AACA,GALE;AAMD","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport function aspectFile({ namePascalCase, componentId }: ComponentContext) {\n return `import { Aspect } from '@teambit/harmony';\n\nexport const ${namePascalCase}Aspect = Aspect.create({\n id: '${componentId}',\n});\n `;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { ComponentContext } from '@teambit/generator';
2
+ export declare function compilerFile({ namePascalCase }: ComponentContext): string;
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.compilerFile = compilerFile;
7
+
8
+ function compilerFile({
9
+ namePascalCase
10
+ }) {
11
+ return `import {
12
+ BuildContext,
13
+ BuiltTaskResult,
14
+ ComponentResult,
15
+ } from '@teambit/builder';
16
+ import {
17
+ Compiler,
18
+ CompilerMain,
19
+ TranspileFileParams,
20
+ TranspileFileOutput,
21
+ } from '@teambit/compiler';
22
+
23
+ export class ${namePascalCase} implements Compiler {
24
+
25
+ constructor(readonly id: string, readonly distDir, private compiler: CompilerMain) {}
26
+
27
+ /**
28
+ * Detemines whether unsupported files (such as assets)
29
+ * should be copied by Compiler aspect into the 'dist' directory
30
+ */
31
+ shouldCopyNonSupportedFiles = true;
32
+
33
+ /* The name of the compiler being used. For example, TypeScript, Babel, etc. */
34
+ displayName = '';
35
+
36
+ /* The version of the compiler being used. For example '1.0.0' */
37
+ version(): string {};
38
+
39
+ /**
40
+ * Use this for compilation in the workspace.
41
+ * This will compile one file content at a time (alternatively, use 'transpileComponent') */
42
+ transpileFile( fileContent: string, transpileFileParams: TranspileFileParams): TranspileFileOutput {}
43
+
44
+
45
+ async build(context: BuildContext): Promise<BuiltTaskResult> {
46
+ let componentsResults: ComponentResult[] = [];
47
+ return {
48
+ /* Sets the files to persist as the Component's artifacts,
49
+ and describes them. */
50
+ artifacts: [
51
+ {
52
+ generatedBy: this.id,
53
+ name: 'compilation output',
54
+ globPatterns: [\`\${this.distDir}/**\`],
55
+ },
56
+ ],
57
+ componentsResults,
58
+ };
59
+ }
60
+
61
+ /* This is optional but recommended.
62
+ Not using it will require consumers of your compiler to use two APIs and have two depndencies
63
+ to their Envs - your compiler
64
+ */
65
+ createTask() {
66
+ return this.compiler.createTask('${namePascalCase}', this);
67
+ }
68
+
69
+ /**
70
+ * Given a source file, return its parallel in the dists. e.g. index.ts => dist/index.js.
71
+ * Needed by aspects such as Pkg to determine the main prop.
72
+ */
73
+ getDistPathBySrcPath(srcPath: string): string {}
74
+
75
+ /**
76
+ * Returns a boolean indicating whether a file is supported by the compiler or not.
77
+ * For example, this API is used by Compiler aspect to copy unsupported files to the dist directory.
78
+ */
79
+ isFileSupported(filePath: string): boolean {}
80
+ }
81
+ `;
82
+ }
83
+
84
+ //# sourceMappingURL=compiler-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["compiler-file.ts"],"names":["compilerFile","namePascalCase"],"mappings":";;;;;;;AAEO,SAASA,YAAT,CAAsB;AAAEC,EAAAA;AAAF,CAAtB,EAA4D;AACjE,SAAQ;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAeA,cAAe;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2CAA2CA,cAAe;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAtEE;AAuED","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport function compilerFile({ namePascalCase }: ComponentContext) {\n return `import {\n BuildContext,\n BuiltTaskResult,\n ComponentResult,\n} from '@teambit/builder';\nimport {\n Compiler,\n CompilerMain,\n TranspileFileParams,\n TranspileFileOutput,\n} from '@teambit/compiler';\n\nexport class ${namePascalCase} implements Compiler {\n\n constructor(readonly id: string, readonly distDir, private compiler: CompilerMain) {}\n\n /**\n * Detemines whether unsupported files (such as assets)\n * should be copied by Compiler aspect into the 'dist' directory\n */\n shouldCopyNonSupportedFiles = true;\n\n /* The name of the compiler being used. For example, TypeScript, Babel, etc. */\n displayName = '';\n\n /* The version of the compiler being used. For example '1.0.0' */\n version(): string {};\n\n /**\n * Use this for compilation in the workspace.\n * This will compile one file content at a time (alternatively, use 'transpileComponent') */\n transpileFile( fileContent: string, transpileFileParams: TranspileFileParams): TranspileFileOutput {}\n\n\n async build(context: BuildContext): Promise<BuiltTaskResult> {\n let componentsResults: ComponentResult[] = [];\n return {\n /* Sets the files to persist as the Component's artifacts,\n and describes them. */\n artifacts: [\n {\n generatedBy: this.id,\n name: 'compilation output',\n globPatterns: [\\`\\${this.distDir}/**\\`],\n },\n ],\n componentsResults,\n };\n }\n\n /* This is optional but recommended.\n Not using it will require consumers of your compiler to use two APIs and have two depndencies\n to their Envs - your compiler\n */\n createTask() {\n return this.compiler.createTask('${namePascalCase}', this);\n }\n\n /**\n * Given a source file, return its parallel in the dists. e.g. index.ts => dist/index.js.\n * Needed by aspects such as Pkg to determine the main prop.\n */\n getDistPathBySrcPath(srcPath: string): string {}\n\n /**\n * Returns a boolean indicating whether a file is supported by the compiler or not.\n * For example, this API is used by Compiler aspect to copy unsupported files to the dist directory.\n */\n isFileSupported(filePath: string): boolean {}\n}\n `;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { ComponentContext } from '@teambit/generator';
2
+ export declare function indexFile({ namePascalCase, name }: ComponentContext): string;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.indexFile = indexFile;
7
+
8
+ function indexFile({
9
+ namePascalCase,
10
+ name
11
+ }) {
12
+ return `import { ${namePascalCase}Aspect } from './${name}.aspect';
13
+
14
+ export type { ${namePascalCase}Main } from './${name}.main.runtime';
15
+ export default ${namePascalCase}Aspect;
16
+ export { ${namePascalCase}Aspect };
17
+ `;
18
+ }
19
+
20
+ //# sourceMappingURL=index-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index-file.ts"],"names":["indexFile","namePascalCase","name"],"mappings":";;;;;;;AAEO,SAASA,SAAT,CAAmB;AAAEC,EAAAA,cAAF;AAAkBC,EAAAA;AAAlB,CAAnB,EAA+D;AACpE,SAAQ,YAAWD,cAAe,oBAAmBC,IAAK;AAC5D;AACA,gBAAgBD,cAAe,kBAAiBC,IAAK;AACrD,iBAAiBD,cAAe;AAChC,WAAWA,cAAe;AAC1B,CALE;AAMD","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport function indexFile({ namePascalCase, name }: ComponentContext) {\n return `import { ${namePascalCase}Aspect } from './${name}.aspect';\n\nexport type { ${namePascalCase}Main } from './${name}.main.runtime';\nexport default ${namePascalCase}Aspect;\nexport { ${namePascalCase}Aspect };\n`;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { ComponentContext } from '@teambit/generator';
2
+ export declare function mainRuntimeFile({ name, namePascalCase }: ComponentContext): string;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.mainRuntimeFile = mainRuntimeFile;
7
+
8
+ function mainRuntimeFile({
9
+ name,
10
+ namePascalCase
11
+ }) {
12
+ return `import { MainRuntime } from '@teambit/cli';
13
+ import { CompilerAspect, CompilerMain } from '@teambit/compiler';
14
+ import { ${namePascalCase} } from './${name}.compiler';
15
+ import { ${namePascalCase}Aspect } from './${name}.aspect';
16
+
17
+ export class ${namePascalCase}Main {
18
+ constructor(private compiler: CompilerMain) {}
19
+
20
+ static slots = [];
21
+ static dependencies = [CompilerAspect];
22
+ static runtime = MainRuntime;
23
+
24
+ distDir = 'dist';
25
+
26
+ /* Set the main property of the component's package with
27
+ the relative output path for the main file */
28
+ getPackageJsonProps() {
29
+ return {
30
+ main: '\${this.distDir}/{main}.js',
31
+ };
32
+ }
33
+
34
+ createCompiler(): ${namePascalCase} {
35
+ return new ${namePascalCase}(${namePascalCase}Aspect.id, this.distDir, this.compiler);
36
+ }
37
+
38
+ static async provider([compiler]: [CompilerMain]) {
39
+ return new ${namePascalCase}Main(compiler);
40
+ }
41
+ }
42
+
43
+ ${namePascalCase}Aspect.addRuntime(${namePascalCase}Main);
44
+ `;
45
+ }
46
+
47
+ //# sourceMappingURL=main-runtime-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["main-runtime-file.ts"],"names":["mainRuntimeFile","name","namePascalCase"],"mappings":";;;;;;;AAEO,SAASA,eAAT,CAAyB;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,CAAzB,EAAqE;AAC1E,SAAQ;AACV;AACA,WAAWA,cAAe,cAAaD,IAAK;AAC5C,WAAWC,cAAe,oBAAmBD,IAAK;AAClD;AACA,eAAeC,cAAe;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsBA,cAAe;AACrC,iBAAiBA,cAAe,IAAGA,cAAe;AAClD;AACA;AACA;AACA,iBAAiBA,cAAe;AAChC;AACA;AACA;AACA,EAAEA,cAAe,qBAAoBA,cAAe;AACpD,CAhCE;AAiCD","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport function mainRuntimeFile({ name, namePascalCase }: ComponentContext) {\n return `import { MainRuntime } from '@teambit/cli';\nimport { CompilerAspect, CompilerMain } from '@teambit/compiler';\nimport { ${namePascalCase} } from './${name}.compiler';\nimport { ${namePascalCase}Aspect } from './${name}.aspect';\n\nexport class ${namePascalCase}Main {\n constructor(private compiler: CompilerMain) {}\n\n static slots = [];\n static dependencies = [CompilerAspect];\n static runtime = MainRuntime;\n\n distDir = 'dist';\n\n /* Set the main property of the component's package with\n the relative output path for the main file */\n getPackageJsonProps() {\n return {\n main: '\\${this.distDir}/{main}.js',\n };\n }\n\n createCompiler(): ${namePascalCase} {\n return new ${namePascalCase}(${namePascalCase}Aspect.id, this.distDir, this.compiler);\n }\n\n static async provider([compiler]: [CompilerMain]) {\n return new ${namePascalCase}Main(compiler);\n }\n}\n\n${namePascalCase}Aspect.addRuntime(${namePascalCase}Main);\n`;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { ComponentTemplate } from '@teambit/generator';
2
+ export declare const compilerTemplate: ComponentTemplate;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.compilerTemplate = void 0;
7
+
8
+ function _indexFile() {
9
+ const data = require("./files/index-file");
10
+
11
+ _indexFile = function () {
12
+ return data;
13
+ };
14
+
15
+ return data;
16
+ }
17
+
18
+ function _aspectFile() {
19
+ const data = require("./files/aspect-file");
20
+
21
+ _aspectFile = function () {
22
+ return data;
23
+ };
24
+
25
+ return data;
26
+ }
27
+
28
+ function _mainRuntimeFile() {
29
+ const data = require("./files/main-runtime-file");
30
+
31
+ _mainRuntimeFile = function () {
32
+ return data;
33
+ };
34
+
35
+ return data;
36
+ }
37
+
38
+ function _compilerFile() {
39
+ const data = require("./files/compiler-file");
40
+
41
+ _compilerFile = function () {
42
+ return data;
43
+ };
44
+
45
+ return data;
46
+ }
47
+
48
+ const compilerTemplate = {
49
+ name: 'compiler',
50
+ description: 'A compiler implementation',
51
+ hidden: true,
52
+ generateFiles: context => {
53
+ return [{
54
+ relativePath: 'index.ts',
55
+ content: (0, _indexFile().indexFile)(context),
56
+ isMain: true
57
+ }, {
58
+ relativePath: `${context.name}.aspect.ts`,
59
+ content: (0, _aspectFile().aspectFile)(context)
60
+ }, {
61
+ relativePath: `${context.name}.compiler.ts`,
62
+ content: (0, _compilerFile().compilerFile)(context)
63
+ }, {
64
+ relativePath: `${context.name}.main.runtime.ts`,
65
+ content: (0, _mainRuntimeFile().mainRuntimeFile)(context)
66
+ }];
67
+ }
68
+ };
69
+ exports.compilerTemplate = compilerTemplate;
70
+
71
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":["compilerTemplate","name","description","hidden","generateFiles","context","relativePath","content","isMain"],"mappings":";;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,gBAAmC,GAAG;AACjDC,EAAAA,IAAI,EAAE,UAD2C;AAEjDC,EAAAA,WAAW,EAAE,2BAFoC;AAGjDC,EAAAA,MAAM,EAAE,IAHyC;AAIjDC,EAAAA,aAAa,EAAGC,OAAD,IAA+B;AAC5C,WAAO,CACL;AACEC,MAAAA,YAAY,EAAE,UADhB;AAEEC,MAAAA,OAAO,EAAE,4BAAUF,OAAV,CAFX;AAGEG,MAAAA,MAAM,EAAE;AAHV,KADK,EAML;AACEF,MAAAA,YAAY,EAAG,GAAED,OAAO,CAACJ,IAAK,YADhC;AAEEM,MAAAA,OAAO,EAAE,8BAAWF,OAAX;AAFX,KANK,EAUL;AACEC,MAAAA,YAAY,EAAG,GAAED,OAAO,CAACJ,IAAK,cADhC;AAEEM,MAAAA,OAAO,EAAE,kCAAaF,OAAb;AAFX,KAVK,EAcL;AACEC,MAAAA,YAAY,EAAG,GAAED,OAAO,CAACJ,IAAK,kBADhC;AAEEM,MAAAA,OAAO,EAAE,wCAAgBF,OAAhB;AAFX,KAdK,CAAP;AAmBD;AAxBgD,CAA5C","sourcesContent":["import { ComponentContext, ComponentTemplate } from '@teambit/generator';\nimport { indexFile } from './files/index-file';\nimport { aspectFile } from './files/aspect-file';\nimport { mainRuntimeFile } from './files/main-runtime-file';\nimport { compilerFile } from './files/compiler-file';\n\nexport const compilerTemplate: ComponentTemplate = {\n name: 'compiler',\n description: 'A compiler implementation',\n hidden: true,\n generateFiles: (context: ComponentContext) => {\n return [\n {\n relativePath: 'index.ts',\n content: indexFile(context),\n isMain: true,\n },\n {\n relativePath: `${context.name}.aspect.ts`,\n content: aspectFile(context),\n },\n {\n relativePath: `${context.name}.compiler.ts`,\n content: compilerFile(context),\n },\n {\n relativePath: `${context.name}.main.runtime.ts`,\n content: mainRuntimeFile(context),\n },\n ];\n },\n};\n"]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/compiler",
3
- "version": "0.0.555",
3
+ "version": "0.0.556",
4
4
  "homepage": "https://bit.dev/teambit/compilation/compiler",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.compilation",
8
8
  "name": "compiler",
9
- "version": "0.0.555"
9
+ "version": "0.0.556"
10
10
  },
11
11
  "dependencies": {
12
12
  "@teambit/harmony": "0.2.11",
@@ -18,18 +18,19 @@
18
18
  "p-map-series": "2.1.0",
19
19
  "@babel/runtime": "7.12.18",
20
20
  "core-js": "^3.0.0",
21
- "@teambit/cli": "0.0.386",
22
- "@teambit/logger": "0.0.471",
23
- "@teambit/pubsub": "0.0.555",
24
- "@teambit/aspect-loader": "0.0.555",
25
- "@teambit/builder": "0.0.555",
26
- "@teambit/component": "0.0.555",
27
- "@teambit/envs": "0.0.555",
28
- "@teambit/legacy-bit-id": "0.0.375",
29
- "@teambit/ui": "0.0.555",
30
- "@teambit/workspace": "0.0.555",
31
- "@teambit/isolator": "0.0.555",
32
- "@teambit/bit-error": "0.0.372"
21
+ "@teambit/cli": "0.0.387",
22
+ "@teambit/logger": "0.0.472",
23
+ "@teambit/pubsub": "0.0.556",
24
+ "@teambit/aspect-loader": "0.0.556",
25
+ "@teambit/builder": "0.0.556",
26
+ "@teambit/component": "0.0.556",
27
+ "@teambit/envs": "0.0.556",
28
+ "@teambit/generator": "0.0.556",
29
+ "@teambit/legacy-bit-id": "0.0.376",
30
+ "@teambit/ui": "0.0.556",
31
+ "@teambit/workspace": "0.0.556",
32
+ "@teambit/isolator": "0.0.556",
33
+ "@teambit/bit-error": "0.0.373"
33
34
  },
34
35
  "devDependencies": {
35
36
  "@types/react": "^17.0.8",
@@ -39,10 +40,10 @@
39
40
  "@types/jest": "^26.0.0",
40
41
  "@types/react-dom": "^17.0.5",
41
42
  "@types/node": "12.20.4",
42
- "@teambit/compilation.aspect-docs.compiler": "0.0.105"
43
+ "@teambit/compilation.aspect-docs.compiler": "0.0.106"
43
44
  },
44
45
  "peerDependencies": {
45
- "@teambit/legacy": "1.0.172",
46
+ "@teambit/legacy": "1.0.173",
46
47
  "react-dom": "^16.8.0 || ^17.0.0",
47
48
  "react": "^16.8.0 || ^17.0.0"
48
49
  },
@@ -70,12 +71,18 @@
70
71
  "react": "-"
71
72
  },
72
73
  "peerDependencies": {
73
- "@teambit/legacy": "1.0.172",
74
+ "@teambit/legacy": "1.0.173",
74
75
  "react-dom": "^16.8.0 || ^17.0.0",
75
76
  "react": "^16.8.0 || ^17.0.0"
76
77
  }
77
78
  }
78
79
  },
80
+ "files": [
81
+ "dist",
82
+ "!dist/tsconfig.tsbuildinfo",
83
+ "README.md",
84
+ "README.mdx"
85
+ ],
79
86
  "private": false,
80
87
  "engines": {
81
88
  "node": ">=12.22.0"
@@ -1,5 +0,0 @@
1
- import { Aspect } from '@teambit/harmony';
2
-
3
- export const CompilerAspect = Aspect.create({
4
- id: 'teambit.compilation/compiler',
5
- });
package/compiler.cmd.ts DELETED
@@ -1,115 +0,0 @@
1
- import { Command, CommandOptions } from '@teambit/cli';
2
- import { Logger } from '@teambit/logger';
3
- import type { PubsubMain, BitBaseEvent } from '@teambit/pubsub';
4
- import chalk from 'chalk';
5
- import prettyTime from 'pretty-time';
6
- import type ConsumerComponent from '@teambit/legacy/dist/consumer/component';
7
- import { formatCompileResults } from './output-formatter';
8
- import { CompileError, WorkspaceCompiler, CompileOptions } from './workspace-compiler';
9
- import { CompilationInitiator } from './types';
10
-
11
- // IDs & events
12
- import { CompilerAspect } from './compiler.aspect';
13
- import { ComponentCompilationOnDoneEvent } from './events';
14
-
15
- type ComponentsStatus = {
16
- buildResults: string[];
17
- component: Array<ConsumerComponent>;
18
- errors: Array<CompileError>;
19
- };
20
-
21
- export class CompileCmd implements Command {
22
- componentsStatus: Array<ComponentsStatus> = [];
23
- name = 'compile [component...]';
24
- description = 'compile components in the development workspace';
25
- alias = '';
26
- group = 'development';
27
- options = [
28
- ['c', 'changed', 'compile only new and modified components'],
29
- ['v', 'verbose', 'show more data, such as, dist paths'],
30
- ['j', 'json', 'return the compile results in json format'],
31
- ] as CommandOptions;
32
-
33
- constructor(private compile: WorkspaceCompiler, private logger: Logger, private pubsub: PubsubMain) {}
34
-
35
- async report([components = []]: [string[]], compilerOptions: CompileOptions) {
36
- const startTimestamp = process.hrtime();
37
- this.logger.setStatusLine('Compiling your components, hold tight.');
38
- this.pubsub.sub(CompilerAspect.id, this.onComponentCompilationDone.bind(this));
39
-
40
- let outputString = '';
41
- await this.compile.compileComponents(components, {
42
- ...compilerOptions,
43
- initiator: CompilationInitiator.CmdReport,
44
- deleteDistDir: true,
45
- });
46
- const compileTimeLength = process.hrtime(startTimestamp);
47
-
48
- outputString += '\n';
49
- outputString += ` ${chalk.underline('STATUS')}\t${chalk.underline('COMPONENT ID')}\n`;
50
- outputString += formatCompileResults(this.componentsStatus, compilerOptions.verbose);
51
- outputString += '\n';
52
-
53
- outputString += this.getStatusLine(this.componentsStatus, compileTimeLength);
54
-
55
- this.logger.clearStatusLine();
56
-
57
- return {
58
- data: outputString,
59
- code: this.getExitCode(this.componentsStatus),
60
- };
61
- }
62
-
63
- async json([components]: [string[]], compilerOptions: CompileOptions) {
64
- compilerOptions.deleteDistDir = true;
65
- // @ts-ignore
66
- const compileResults = await this.compile.compileComponents(components, {
67
- ...compilerOptions,
68
- initiator: CompilationInitiator.CmdJson,
69
- deleteDistDir: true,
70
- });
71
- return {
72
- data: compileResults,
73
- // @todo: fix the code once compile is ready.
74
- code: 0,
75
- };
76
- }
77
-
78
- private failedComponents(componentsStatus: ComponentsStatus[]): ComponentsStatus[] {
79
- return componentsStatus.filter((component) => component.errors.length);
80
- }
81
-
82
- private getSummaryIcon(componentsStatus: ComponentsStatus[]) {
83
- switch (this.failedComponents(componentsStatus).length) {
84
- case 0:
85
- return chalk.green('✔');
86
- case componentsStatus.length:
87
- return chalk.red('✗');
88
- default:
89
- return chalk.yellow('⍻');
90
- }
91
- }
92
-
93
- private getExitCode(componentsStatus: ComponentsStatus[]) {
94
- return this.failedComponents(componentsStatus).length ? 1 : 0;
95
- }
96
-
97
- private getStatusLine(componentsStatus: ComponentsStatus[], compileTimeLength) {
98
- const numberOfComponents = componentsStatus.length;
99
- const numberOfFailingComponents = this.failedComponents(componentsStatus).length;
100
- const numberOfSuccessfulComponents = componentsStatus.filter((component) => !component.errors.length).length;
101
-
102
- const icon = this.getSummaryIcon(componentsStatus);
103
- const summaryLine = numberOfFailingComponents
104
- ? `${icon} ${numberOfFailingComponents}/${numberOfComponents} components failed to compile.`
105
- : `${icon} ${numberOfSuccessfulComponents}/${numberOfComponents} components compiled successfully.`;
106
-
107
- return `${summaryLine}\nFinished. (${prettyTime(compileTimeLength)})`;
108
- }
109
-
110
- private onComponentCompilationDone(event: BitBaseEvent<any>) {
111
- if (event.type === ComponentCompilationOnDoneEvent.TYPE) {
112
- this.componentsStatus.push(event.data);
113
- }
114
- }
115
- }
package/compiler.docs.mdx DELETED
@@ -1,8 +0,0 @@
1
- ---
2
- description: Compiler compilation for Bit components
3
- labels: ['compiler', 'bit', 'extension', 'aspect']
4
- ---
5
-
6
- import { Compiler } from '@teambit/compilation.aspect-docs.compiler';
7
-
8
- <Compiler />