@teambit/compiler 0.0.1094 → 0.0.1096

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/index.d.ts CHANGED
@@ -2,5 +2,5 @@ export type { CompilerMain } from './compiler.main.runtime';
2
2
  export { CompilerTask, CompilerTaskOptions } from './compiler.task';
3
3
  export type { CompilerEnv } from './compiler-env-type';
4
4
  export { CompilerAspect } from './compiler.aspect';
5
- export { Compiler, CompilerOptions, CompilationInitiator, TranspileFileOutput, TranspileFileParams, TranspileComponentParams, } from './types';
5
+ export { Compiler, CompilerOptions, CompilationInitiator, TranspileFileOutput, TranspileFileParams, TranspileComponentParams, TranspileFileOutputOneFile, } from './types';
6
6
  export * from './events';
package/dist/index.js CHANGED
@@ -12,7 +12,8 @@ var _exportNames = {
12
12
  CompilationInitiator: true,
13
13
  TranspileFileOutput: true,
14
14
  TranspileFileParams: true,
15
- TranspileComponentParams: true
15
+ TranspileComponentParams: true,
16
+ TranspileFileOutputOneFile: true
16
17
  };
17
18
  Object.defineProperty(exports, "CompilationInitiator", {
18
19
  enumerable: true,
@@ -62,6 +63,12 @@ Object.defineProperty(exports, "TranspileFileOutput", {
62
63
  return _types().TranspileFileOutput;
63
64
  }
64
65
  });
66
+ Object.defineProperty(exports, "TranspileFileOutputOneFile", {
67
+ enumerable: true,
68
+ get: function () {
69
+ return _types().TranspileFileOutputOneFile;
70
+ }
71
+ });
65
72
  Object.defineProperty(exports, "TranspileFileParams", {
66
73
  enumerable: true,
67
74
  get: function () {
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export type { CompilerMain } from './compiler.main.runtime';\nexport { CompilerTask, CompilerTaskOptions } from './compiler.task';\nexport type { CompilerEnv } from './compiler-env-type';\nexport { CompilerAspect } from './compiler.aspect';\nexport {\n Compiler,\n CompilerOptions,\n CompilationInitiator,\n TranspileFileOutput,\n TranspileFileParams,\n TranspileComponentParams,\n} from './types';\nexport * from './events';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAQA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export type { CompilerMain } from './compiler.main.runtime';\nexport { CompilerTask, CompilerTaskOptions } from './compiler.task';\nexport type { CompilerEnv } from './compiler-env-type';\nexport { CompilerAspect } from './compiler.aspect';\nexport {\n Compiler,\n CompilerOptions,\n CompilationInitiator,\n TranspileFileOutput,\n TranspileFileParams,\n TranspileComponentParams,\n TranspileFileOutputOneFile,\n} from './types';\nexport * from './events';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AASA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compilation_compiler@0.0.1094/dist/compiler.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compilation_compiler@0.0.1094/dist/compiler.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compilation_compiler@0.0.1096/dist/compiler.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compilation_compiler@0.0.1096/dist/compiler.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
package/dist/types.d.ts CHANGED
@@ -22,10 +22,11 @@ export declare type TranspileComponentParams = {
22
22
  outputDir: string;
23
23
  initiator: CompilationInitiator;
24
24
  };
25
- export declare type TranspileFileOutput = {
25
+ export declare type TranspileFileOutputOneFile = {
26
26
  outputText: string;
27
27
  outputPath: string;
28
- }[] | null;
28
+ };
29
+ export declare type TranspileFileOutput = TranspileFileOutputOneFile[] | null;
29
30
  export interface CompilerOptions {
30
31
  /**
31
32
  * name of the compiler.
@@ -70,7 +71,7 @@ export interface Compiler extends CompilerOptions, ServiceHandler {
70
71
  * transpile a single file that gets saved into the workspace, used by `bit compile` and during
71
72
  * development
72
73
  */
73
- transpileFile?: (fileContent: string, params: TranspileFileParams) => TranspileFileOutput;
74
+ transpileFile?: (fileContent: string, params: TranspileFileParams) => TranspileFileOutput | Promise<TranspileFileOutput>;
74
75
  /**
75
76
  * transpile all the files of a component, use this when you can't use `transpileFile`
76
77
  */
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["CompilationInitiator"],"sources":["types.ts"],"sourcesContent":["import { BuildContext, BuildTask, BuiltTaskResult, TaskResultsList } from '@teambit/builder';\nimport type { Component } from '@teambit/component';\nimport { ServiceHandler } from '@teambit/envs';\n\nexport type TranspileFileParams = {\n componentDir: string; // absolute path of the component's root directory\n filePath: string; // relative path of the file inside the component directory\n};\n\nexport enum CompilationInitiator {\n CmdReport,\n CmdJson,\n PreStart,\n PreWatch,\n Start,\n ComponentChanged,\n AspectLoadFail,\n ComponentAdded,\n Install,\n}\n\nexport type TranspileComponentParams = {\n component: Component;\n componentDir: string; // absolute path of the component's root directory\n outputDir: string; // absolute path of the component's output directory\n initiator: CompilationInitiator; // origin of the compilation's request\n};\n\nexport type TranspileFileOutput =\n | {\n outputText: string;\n outputPath: string;\n }[]\n | null;\n\nexport interface CompilerOptions {\n /**\n * name of the compiler.\n */\n name?: string;\n\n /**\n * relative path of the dist directory inside the capsule. e.g. \"dist\".\n */\n distDir: string;\n\n /**\n * determines which ones of the generated files will be saved in the bit objects when tagging.\n * e.g. distGlobPatterns = [`${this.distDir}/**`, `!${this.distDir}/tsconfig.tsbuildinfo`];\n * see https://github.com/mrmlnc/fast-glob for the supported glob patters syntax.\n */\n distGlobPatterns?: string[];\n\n /**\n * whether or not unsupported files (such as assets) should be copied into the dist directory\n */\n shouldCopyNonSupportedFiles?: boolean;\n\n /**\n * optional. default to \"dist\".\n * useful when the build pipeline has multiple compiler tasks of the same compiler.\n * e.g. using the same Babel compiler for two different tasks, one for creating \"es5\" files, and\n * the second for creating \"esm\". the artifact names would be \"es5\" and \"esm\" accordingly.\n */\n artifactName?: string;\n}\n\nexport interface Compiler extends CompilerOptions, ServiceHandler {\n /**\n * id of the compiler.\n */\n id: string;\n\n /**\n * Delete dist folder before writing the new compiled files\n */\n deleteDistDir?: boolean;\n\n /**\n * serialized config of the compiler.\n */\n displayConfig?(): string;\n\n /**\n * transpile a single file that gets saved into the workspace, used by `bit compile` and during\n * development\n */\n transpileFile?: (fileContent: string, params: TranspileFileParams) => TranspileFileOutput;\n\n /**\n * transpile all the files of a component, use this when you can't use `transpileFile`\n */\n transpileComponent?: (params: TranspileComponentParams) => Promise<void>;\n\n /**\n * compile components inside isolated capsules. this being used during tag for the release.\n * meaning, the final package of the component has the dists generated by this method.\n */\n build(context: BuildContext): Promise<BuiltTaskResult>;\n\n /**\n * return the dist dir of the compiled files (relative path from the component root dir)\n */\n getDistDir?(): string;\n\n /**\n * given a source file, return its parallel in the dists. e.g. \"index.ts\" => \"dist/index.js\"\n * both, the return path and the given path are relative paths.\n */\n getDistPathBySrcPath(srcPath: string): string;\n\n /**\n * given a component, returns the path to the source folder to use for the preview, uses the one\n * in node_modules by default\n */\n getPreviewComponentRootPath?(component: Component): string;\n\n /**\n * only supported files matching get compiled. others, are copied to the dist dir.\n */\n isFileSupported(filePath: string): boolean;\n\n /**\n * sugar to create a Compiler task via the concrete compiler\n */\n createTask?(name?: string): BuildTask;\n\n /**\n * run before the build pipeline has started. this is useful when some preparation are needed to\n * be done on all envs before the build starts.\n */\n preBuild?(context: BuildContext): Promise<void>;\n\n /**\n * run after the build pipeline completed for all envs. useful for some cleanups\n */\n postBuild?(context: BuildContext, tasksResults: TaskResultsList): Promise<void>;\n\n /**\n * returns the version of the current compiler instance (e.g. '4.0.1').\n */\n version(): string;\n\n /**\n * returns the display name of the current compiler instance (e.g. 'TypeScript')\n */\n displayName: string;\n}\n"],"mappings":";;;;;;IASYA,oBAAoB;AAAA;AAAA,WAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;AAAA,GAApBA,oBAAoB,oCAApBA,oBAAoB"}
1
+ {"version":3,"names":["CompilationInitiator"],"sources":["types.ts"],"sourcesContent":["import { BuildContext, BuildTask, BuiltTaskResult, TaskResultsList } from '@teambit/builder';\nimport type { Component } from '@teambit/component';\nimport { ServiceHandler } from '@teambit/envs';\n\nexport type TranspileFileParams = {\n componentDir: string; // absolute path of the component's root directory\n filePath: string; // relative path of the file inside the component directory\n};\n\nexport enum CompilationInitiator {\n CmdReport,\n CmdJson,\n PreStart,\n PreWatch,\n Start,\n ComponentChanged,\n AspectLoadFail,\n ComponentAdded,\n Install,\n}\n\nexport type TranspileComponentParams = {\n component: Component;\n componentDir: string; // absolute path of the component's root directory\n outputDir: string; // absolute path of the component's output directory\n initiator: CompilationInitiator; // origin of the compilation's request\n};\n\nexport type TranspileFileOutputOneFile = {\n outputText: string;\n outputPath: string;\n};\n\nexport type TranspileFileOutput = TranspileFileOutputOneFile[] | null;\n\nexport interface CompilerOptions {\n /**\n * name of the compiler.\n */\n name?: string;\n\n /**\n * relative path of the dist directory inside the capsule. e.g. \"dist\".\n */\n distDir: string;\n\n /**\n * determines which ones of the generated files will be saved in the bit objects when tagging.\n * e.g. distGlobPatterns = [`${this.distDir}/**`, `!${this.distDir}/tsconfig.tsbuildinfo`];\n * see https://github.com/mrmlnc/fast-glob for the supported glob patters syntax.\n */\n distGlobPatterns?: string[];\n\n /**\n * whether or not unsupported files (such as assets) should be copied into the dist directory\n */\n shouldCopyNonSupportedFiles?: boolean;\n\n /**\n * optional. default to \"dist\".\n * useful when the build pipeline has multiple compiler tasks of the same compiler.\n * e.g. using the same Babel compiler for two different tasks, one for creating \"es5\" files, and\n * the second for creating \"esm\". the artifact names would be \"es5\" and \"esm\" accordingly.\n */\n artifactName?: string;\n}\n\nexport interface Compiler extends CompilerOptions, ServiceHandler {\n /**\n * id of the compiler.\n */\n id: string;\n\n /**\n * Delete dist folder before writing the new compiled files\n */\n deleteDistDir?: boolean;\n\n /**\n * serialized config of the compiler.\n */\n displayConfig?(): string;\n\n /**\n * transpile a single file that gets saved into the workspace, used by `bit compile` and during\n * development\n */\n transpileFile?: (\n fileContent: string,\n params: TranspileFileParams\n ) => TranspileFileOutput | Promise<TranspileFileOutput>;\n\n /**\n * transpile all the files of a component, use this when you can't use `transpileFile`\n */\n transpileComponent?: (params: TranspileComponentParams) => Promise<void>;\n\n /**\n * compile components inside isolated capsules. this being used during tag for the release.\n * meaning, the final package of the component has the dists generated by this method.\n */\n build(context: BuildContext): Promise<BuiltTaskResult>;\n\n /**\n * return the dist dir of the compiled files (relative path from the component root dir)\n */\n getDistDir?(): string;\n\n /**\n * given a source file, return its parallel in the dists. e.g. \"index.ts\" => \"dist/index.js\"\n * both, the return path and the given path are relative paths.\n */\n getDistPathBySrcPath(srcPath: string): string;\n\n /**\n * given a component, returns the path to the source folder to use for the preview, uses the one\n * in node_modules by default\n */\n getPreviewComponentRootPath?(component: Component): string;\n\n /**\n * only supported files matching get compiled. others, are copied to the dist dir.\n */\n isFileSupported(filePath: string): boolean;\n\n /**\n * sugar to create a Compiler task via the concrete compiler\n */\n createTask?(name?: string): BuildTask;\n\n /**\n * run before the build pipeline has started. this is useful when some preparation are needed to\n * be done on all envs before the build starts.\n */\n preBuild?(context: BuildContext): Promise<void>;\n\n /**\n * run after the build pipeline completed for all envs. useful for some cleanups\n */\n postBuild?(context: BuildContext, tasksResults: TaskResultsList): Promise<void>;\n\n /**\n * returns the version of the current compiler instance (e.g. '4.0.1').\n */\n version(): string;\n\n /**\n * returns the display name of the current compiler instance (e.g. 'TypeScript')\n */\n displayName: string;\n}\n"],"mappings":";;;;;;IASYA,oBAAoB;AAAA;AAAA,WAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;AAAA,GAApBA,oBAAoB,oCAApBA,oBAAoB"}
@@ -213,7 +213,7 @@ ${this.compileErrors.map(formatError).join('\n')}`);
213
213
  if (isFileSupported) {
214
214
  try {
215
215
  var _this$compilerInstanc3, _this$compilerInstanc4;
216
- compileResults = (_this$compilerInstanc3 = (_this$compilerInstanc4 = this.compilerInstance).transpileFile) === null || _this$compilerInstanc3 === void 0 ? void 0 : _this$compilerInstanc3.call(_this$compilerInstanc4, file.contents.toString(), options);
216
+ compileResults = await ((_this$compilerInstanc3 = (_this$compilerInstanc4 = this.compilerInstance).transpileFile) === null || _this$compilerInstanc3 === void 0 ? void 0 : _this$compilerInstanc3.call(_this$compilerInstanc4, file.contents.toString(), options));
217
217
  } catch (error) {
218
218
  this.compileErrors.push({
219
219
  path: file.path,
@@ -1 +1 @@
1
- {"version":3,"names":["ComponentCompiler","constructor","pubsub","workspace","component","compilerInstance","compilerId","logger","dependencyResolver","dists","compileErrors","compile","noThrow","options","dataToPersist","deleteDistDir","DataToPersist","distDir","distDirs","removePath","RemovePath","addBasePath","path","persistAllToFS","compilers","canTranspileFile","find","c","transpileFile","canTranspileComponent","transpileComponent","Promise","all","filesystem","files","map","file","compileOneFile","initiator","compileAllFiles","Error","toString","throwOnCompileErrors","addManyFiles","buildResults","distFile","state","_consumer","compiler","loader","succeed","pub","CompilerAspect","id","ComponentCompilationOnDoneEvent","length","forEach","errorItem","error","formatError","err","join","CompilerErrorEvent","console","message","packageName","componentIdToPackageName","packageDir","distDirName","getDistDir","DEFAULT_DIST_DIRNAME","injectedDirs","getInjectedDirs","dist","relativeCompDir","componentDir","undefined","relative","rootDirs","readBitRootsDir","rootDir","filePath","isFileSupported","compileResults","contents","push","base","result","Dist","outputPath","Buffer","from","outputText","shouldCopyNonSupportedFiles","filesToCompile","outputDir","getComponentPackagePath","WorkspaceCompiler","envs","aspectLoader","ui","watcher","registerOnComponentChange","onComponentChange","bind","registerOnComponentAdd","registerOnPreWatch","onPreWatch","registerPreStart","onPreStart","registerOnAspectLoadErrorSlot","onAspectLoadFail","preStartOpts","skipCompilation","compileComponents","changed","verbose","CompilationInitiator","PreStart","code","AspectLoadFail","removedFiles","Boolean","removeLinksFromNodeModules","ComponentChanged","linkToNodeModulesByComponents","results","components","watchOpts","preCompile","start","Date","now","_legacy","PreWatch","end","consoleSuccess","componentsIds","OutsideWorkspaceError","componentIds","getIdsToCompile","getMany","grouped","groupByIsEnv","envsResults","runCompileComponents","otherResults","other","componentsCompilers","environment","getEnv","env","getCompiler","compilerName","name","warn","resultOnWorkspace","mapSeries","componentCompiler","envsIds","uniq","getEnvId","filter","envId","isCoreEnv","groupBy","includes","resolveMultipleComponentIds","filterIds","getNewAndModifiedIds","getAllComponentIds"],"sources":["workspace-compiler.ts"],"sourcesContent":["/* eslint-disable max-classes-per-file */\nimport mapSeries from 'p-map-series';\nimport { Component, ComponentID } from '@teambit/component';\nimport { EnvsMain } from '@teambit/envs';\nimport type { PubsubMain } from '@teambit/pubsub';\nimport { SerializableResults, Workspace, OutsideWorkspaceError } from '@teambit/workspace';\nimport { WatcherMain, WatchOptions } from '@teambit/watcher';\nimport path from 'path';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { Logger } from '@teambit/logger';\nimport loader from '@teambit/legacy/dist/cli/loader';\nimport { DEFAULT_DIST_DIRNAME } from '@teambit/legacy/dist/constants';\nimport { AbstractVinyl, Dist } from '@teambit/legacy/dist/consumer/component/sources';\nimport DataToPersist from '@teambit/legacy/dist/consumer/component/sources/data-to-persist';\nimport {\n linkToNodeModulesByComponents,\n removeLinksFromNodeModules,\n} from '@teambit/workspace.modules.node-modules-linker';\nimport { AspectLoaderMain } from '@teambit/aspect-loader';\nimport { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport componentIdToPackageName from '@teambit/legacy/dist/utils/bit/component-id-to-package-name';\nimport RemovePath from '@teambit/legacy/dist/consumer/component/sources/remove-path';\nimport { UiMain } from '@teambit/ui';\nimport { readBitRootsDir } from '@teambit/bit-roots';\nimport { groupBy, uniq } from 'lodash';\nimport type { PreStartOpts } from '@teambit/ui';\nimport { PathOsBasedAbsolute, PathOsBasedRelative } from '@teambit/legacy/dist/utils/path';\nimport { MultiCompiler } from '@teambit/multi-compiler';\nimport { CompilerAspect } from './compiler.aspect';\nimport { CompilerErrorEvent, ComponentCompilationOnDoneEvent } from './events';\nimport { Compiler, CompilationInitiator } from './types';\n\nexport type BuildResult = { component: string; buildResults: string[] | null | undefined };\n\nexport type CompileOptions = {\n changed?: boolean; // compile only new and modified components\n verbose?: boolean; // show more data, such as, dist paths\n /**\n * whether the dist root dir should be deleted before writing new dists.\n * defaults to true for `bit compile` and false everywhere else, such as `bit watch` and `bit\n * start` to avoid webpack \"EINTR\" error.\n */\n deleteDistDir?: boolean;\n initiator: CompilationInitiator; // describes where the compilation is coming from\n};\n\nexport type CompileError = { path: string; error: Error };\n\nexport class ComponentCompiler {\n constructor(\n private pubsub: PubsubMain,\n private workspace: Workspace,\n private component: Component,\n private compilerInstance: Compiler,\n private compilerId: string,\n private logger: Logger,\n private dependencyResolver: DependencyResolverMain,\n private dists: Dist[] = [],\n private compileErrors: CompileError[] = []\n ) {}\n\n async compile(noThrow = true, options: CompileOptions): Promise<BuildResult> {\n let dataToPersist;\n const deleteDistDir = options.deleteDistDir ?? this.compilerInstance.deleteDistDir;\n // delete dist folder before transpilation (because some compilers (like ngPackagr) can generate files there during the compilation process)\n if (deleteDistDir) {\n dataToPersist = new DataToPersist();\n for (const distDir of await this.distDirs()) {\n dataToPersist.removePath(new RemovePath(distDir));\n }\n dataToPersist.addBasePath(this.workspace.path);\n await dataToPersist.persistAllToFS();\n }\n\n const compilers: Compiler[] = (this.compilerInstance as MultiCompiler).compilers\n ? (this.compilerInstance as MultiCompiler).compilers\n : [this.compilerInstance];\n const canTranspileFile = compilers.find((c) => c.transpileFile);\n const canTranspileComponent = compilers.find((c) => c.transpileComponent);\n\n if (canTranspileFile) {\n await Promise.all(\n this.component.filesystem.files.map((file: AbstractVinyl) => this.compileOneFile(file, options.initiator))\n );\n }\n\n if (canTranspileComponent) {\n await this.compileAllFiles(this.component, options.initiator);\n }\n\n if (!canTranspileFile && !canTranspileComponent) {\n throw new Error(\n `compiler ${this.compilerId.toString()} doesn't implement either \"transpileFile\" or \"transpileComponent\" methods`\n );\n }\n this.throwOnCompileErrors(noThrow);\n\n // writing the dists with `component.setDists(dists); component.dists.writeDists` is tricky\n // as it uses other base-paths and doesn't respect the new node-modules base path.\n dataToPersist = new DataToPersist();\n dataToPersist.addManyFiles(this.dists);\n dataToPersist.addBasePath(this.workspace.path);\n await dataToPersist.persistAllToFS();\n const buildResults = this.dists.map((distFile) => distFile.path);\n if (this.component.state._consumer.compiler) loader.succeed();\n this.pubsub.pub(\n CompilerAspect.id,\n new ComponentCompilationOnDoneEvent(this.compileErrors, this.component, buildResults)\n );\n return { component: this.component.id.toString(), buildResults };\n }\n\n private throwOnCompileErrors(noThrow = true) {\n if (this.compileErrors.length) {\n this.compileErrors.forEach((errorItem) => {\n this.logger.error(`compilation error at ${errorItem.path}`, errorItem.error);\n });\n const formatError = (errorItem) => `${errorItem.path}\\n${errorItem.error}`;\n const err = new Error(`compilation failed. see the following errors from the compiler\n${this.compileErrors.map(formatError).join('\\n')}`);\n\n this.pubsub.pub(CompilerAspect.id, new CompilerErrorEvent(err));\n\n if (!noThrow) {\n throw err;\n }\n\n this.logger.console(err.message);\n }\n }\n\n private async distDirs(): Promise<PathOsBasedRelative[]> {\n const packageName = componentIdToPackageName(this.component.state._consumer);\n const packageDir = path.join('node_modules', packageName);\n const distDirName = this.compilerInstance.getDistDir?.() || DEFAULT_DIST_DIRNAME;\n const injectedDirs = await this.getInjectedDirs(packageName);\n return [packageDir, ...injectedDirs].map((dist) => path.join(dist, distDirName));\n }\n\n private async getInjectedDirs(packageName: string): Promise<string[]> {\n const relativeCompDir = this.workspace.componentDir(this.component.id, undefined, {\n relative: true,\n });\n const injectedDirs = await this.dependencyResolver.getInjectedDirs(\n this.workspace.path,\n relativeCompDir,\n packageName\n );\n if (injectedDirs.length > 0) return injectedDirs;\n\n const rootDirs = await readBitRootsDir(this.workspace.path);\n return rootDirs.map((rootDir) => path.relative(this.workspace.path, path.join(rootDir, packageName)));\n }\n\n private get componentDir(): PathOsBasedAbsolute {\n return this.workspace.componentDir(this.component.id);\n }\n\n private async compileOneFile(file: AbstractVinyl, initiator: CompilationInitiator): Promise<void> {\n const options = { componentDir: this.componentDir, filePath: file.relative, initiator };\n const isFileSupported = this.compilerInstance.isFileSupported(file.path);\n let compileResults;\n if (isFileSupported) {\n try {\n compileResults = this.compilerInstance.transpileFile?.(file.contents.toString(), options);\n } catch (error: any) {\n this.compileErrors.push({ path: file.path, error });\n return;\n }\n }\n for (const base of await this.distDirs()) {\n if (isFileSupported && compileResults) {\n this.dists.push(\n ...compileResults.map(\n (result) =>\n new Dist({\n base,\n path: path.join(base, result.outputPath),\n contents: Buffer.from(result.outputText),\n })\n )\n );\n } else if (this.compilerInstance.shouldCopyNonSupportedFiles) {\n // compiler doesn't support this file type. copy the file as is to the dist dir.\n this.dists.push(new Dist({ base, path: path.join(base, file.relative), contents: file.contents }));\n }\n }\n }\n\n private async compileAllFiles(component: Component, initiator: CompilationInitiator): Promise<void> {\n const filesToCompile: AbstractVinyl[] = [];\n for (const base of await this.distDirs()) {\n component.filesystem.files.forEach((file: AbstractVinyl) => {\n const isFileSupported = this.compilerInstance.isFileSupported(file.path);\n if (isFileSupported) {\n filesToCompile.push(file);\n } else if (this.compilerInstance.shouldCopyNonSupportedFiles) {\n // compiler doesn't support this file type. copy the file as is to the dist dir.\n this.dists.push(\n new Dist({\n base,\n path: path.join(base, file.relative),\n contents: file.contents,\n })\n );\n }\n });\n }\n\n if (filesToCompile.length) {\n try {\n await this.compilerInstance.transpileComponent?.({\n component,\n componentDir: this.componentDir,\n outputDir: this.workspace.getComponentPackagePath(component),\n initiator,\n });\n } catch (error: any) {\n this.compileErrors.push({ path: this.componentDir, error });\n }\n }\n }\n}\n\nexport class WorkspaceCompiler {\n constructor(\n private workspace: Workspace,\n private envs: EnvsMain,\n private pubsub: PubsubMain,\n private aspectLoader: AspectLoaderMain,\n private ui: UiMain,\n private logger: Logger,\n private dependencyResolver: DependencyResolverMain,\n private watcher: WatcherMain\n ) {\n if (this.workspace) {\n this.workspace.registerOnComponentChange(this.onComponentChange.bind(this));\n this.workspace.registerOnComponentAdd(this.onComponentChange.bind(this));\n this.watcher.registerOnPreWatch(this.onPreWatch.bind(this));\n this.ui.registerPreStart(this.onPreStart.bind(this));\n }\n if (this.aspectLoader) {\n this.aspectLoader.registerOnAspectLoadErrorSlot(this.onAspectLoadFail.bind(this));\n }\n }\n\n async onPreStart(preStartOpts: PreStartOpts): Promise<void> {\n if (preStartOpts.skipCompilation) {\n return;\n }\n await this.compileComponents([], {\n changed: true,\n verbose: false,\n deleteDistDir: false,\n initiator: CompilationInitiator.PreStart,\n });\n }\n\n async onAspectLoadFail(err: Error & { code?: string }, id: ComponentID): Promise<boolean> {\n if (err.code && err.code === 'MODULE_NOT_FOUND' && this.workspace) {\n await this.compileComponents([id.toString()], { initiator: CompilationInitiator.AspectLoadFail }, true);\n return true;\n }\n return false;\n }\n\n async onComponentChange(\n component: Component,\n files: string[],\n removedFiles?: string[],\n initiator?: CompilationInitiator\n ): Promise<SerializableResults> {\n // when files are removed, we need to remove the dist directories and the old symlinks, otherwise, it has\n // symlinks to non-exist files and the dist has stale files\n const deleteDistDir = Boolean(removedFiles?.length);\n if (removedFiles?.length) {\n await removeLinksFromNodeModules(component, this.workspace, removedFiles);\n }\n const buildResults = await this.compileComponents(\n [component.id.toString()],\n { initiator: initiator || CompilationInitiator.ComponentChanged, deleteDistDir },\n true\n );\n await linkToNodeModulesByComponents([component], this.workspace);\n return {\n results: buildResults,\n toString() {\n return `${buildResults[0]?.buildResults?.join('\\n\\t')}`;\n },\n };\n }\n\n async onPreWatch(components: Component[], watchOpts: WatchOptions) {\n if (watchOpts.preCompile) {\n const start = Date.now();\n this.logger.console(`compiling ${components.length} components`);\n await this.compileComponents(\n components.map((c) => c.id._legacy),\n { initiator: CompilationInitiator.PreWatch }\n );\n const end = Date.now() - start;\n this.logger.consoleSuccess(`compiled ${components.length} components successfully (${end / 1000} sec)`);\n }\n }\n\n async compileComponents(\n componentsIds: string[] | BitId[] | ComponentID[], // when empty, it compiles new+modified (unless options.all is set),\n options: CompileOptions,\n noThrow?: boolean\n ): Promise<BuildResult[]> {\n if (!this.workspace) throw new OutsideWorkspaceError();\n const componentIds = await this.getIdsToCompile(componentsIds, options.changed);\n const components = await this.workspace.getMany(componentIds);\n\n const grouped = this.groupByIsEnv(components);\n const envsResults = grouped.envs ? await this.runCompileComponents(grouped.envs, options, noThrow) : [];\n const otherResults = grouped.other ? await this.runCompileComponents(grouped.other, options, noThrow) : [];\n return [...envsResults, ...otherResults];\n }\n\n private async runCompileComponents(\n components: Component[],\n options: CompileOptions,\n noThrow?: boolean\n ): Promise<BuildResult[]> {\n const componentsCompilers: ComponentCompiler[] = [];\n\n components.forEach((c) => {\n const environment = this.envs.getEnv(c).env;\n const compilerInstance = environment.getCompiler?.();\n\n if (compilerInstance) {\n const compilerName = compilerInstance.constructor.name || 'compiler';\n componentsCompilers.push(\n new ComponentCompiler(\n this.pubsub,\n this.workspace,\n c,\n compilerInstance,\n compilerName,\n this.logger,\n this.dependencyResolver\n )\n );\n } else {\n this.logger.warn(`unable to find a compiler instance for ${c.id.toString()}`);\n }\n });\n const resultOnWorkspace = await mapSeries(componentsCompilers, (componentCompiler) =>\n componentCompiler.compile(noThrow, options)\n );\n\n return resultOnWorkspace;\n }\n\n /**\n * This function get's a list of aspect ids and return them grouped by whether any of them is the env of other from the list\n * @param ids\n */\n groupByIsEnv(components: Component[]): { envs?: Component[]; other?: Component[] } {\n const envsIds = uniq(\n components\n .map((component) => this.envs.getEnvId(component))\n .filter((envId) => !this.aspectLoader.isCoreEnv(envId))\n );\n const grouped = groupBy(components, (component) => {\n if (envsIds.includes(component.id.toString())) return 'envs';\n return 'other';\n });\n return grouped as { envs: Component[]; other: Component[] };\n }\n\n private async getIdsToCompile(\n componentsIds: Array<string | ComponentID | BitId>,\n changed = false\n ): Promise<ComponentID[]> {\n if (componentsIds.length) {\n const componentIds = await this.workspace.resolveMultipleComponentIds(componentsIds);\n return this.workspace.filterIds(componentIds);\n }\n if (changed) {\n return this.workspace.getNewAndModifiedIds();\n }\n return this.workspace.getAllComponentIds();\n }\n}\n"],"mappings":";;;;;;;;;AACA;EAAA;EAAA;IAAA;EA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OAAO,IAAI,CAACtI,SAAS,CAACqK,SAAS,CAAC7B,YAAY,CAAC;IAC/C;IACA,IAAIxB,OAAO,EAAE;MACX,OAAO,IAAI,CAAChH,SAAS,CAACsK,oBAAoB,EAAE;IAC9C;IACA,OAAO,IAAI,CAACtK,SAAS,CAACuK,kBAAkB,EAAE;EAC5C;AACF;AAAC"}
1
+ {"version":3,"names":["ComponentCompiler","constructor","pubsub","workspace","component","compilerInstance","compilerId","logger","dependencyResolver","dists","compileErrors","compile","noThrow","options","dataToPersist","deleteDistDir","DataToPersist","distDir","distDirs","removePath","RemovePath","addBasePath","path","persistAllToFS","compilers","canTranspileFile","find","c","transpileFile","canTranspileComponent","transpileComponent","Promise","all","filesystem","files","map","file","compileOneFile","initiator","compileAllFiles","Error","toString","throwOnCompileErrors","addManyFiles","buildResults","distFile","state","_consumer","compiler","loader","succeed","pub","CompilerAspect","id","ComponentCompilationOnDoneEvent","length","forEach","errorItem","error","formatError","err","join","CompilerErrorEvent","console","message","packageName","componentIdToPackageName","packageDir","distDirName","getDistDir","DEFAULT_DIST_DIRNAME","injectedDirs","getInjectedDirs","dist","relativeCompDir","componentDir","undefined","relative","rootDirs","readBitRootsDir","rootDir","filePath","isFileSupported","compileResults","contents","push","base","result","Dist","outputPath","Buffer","from","outputText","shouldCopyNonSupportedFiles","filesToCompile","outputDir","getComponentPackagePath","WorkspaceCompiler","envs","aspectLoader","ui","watcher","registerOnComponentChange","onComponentChange","bind","registerOnComponentAdd","registerOnPreWatch","onPreWatch","registerPreStart","onPreStart","registerOnAspectLoadErrorSlot","onAspectLoadFail","preStartOpts","skipCompilation","compileComponents","changed","verbose","CompilationInitiator","PreStart","code","AspectLoadFail","removedFiles","Boolean","removeLinksFromNodeModules","ComponentChanged","linkToNodeModulesByComponents","results","components","watchOpts","preCompile","start","Date","now","_legacy","PreWatch","end","consoleSuccess","componentsIds","OutsideWorkspaceError","componentIds","getIdsToCompile","getMany","grouped","groupByIsEnv","envsResults","runCompileComponents","otherResults","other","componentsCompilers","environment","getEnv","env","getCompiler","compilerName","name","warn","resultOnWorkspace","mapSeries","componentCompiler","envsIds","uniq","getEnvId","filter","envId","isCoreEnv","groupBy","includes","resolveMultipleComponentIds","filterIds","getNewAndModifiedIds","getAllComponentIds"],"sources":["workspace-compiler.ts"],"sourcesContent":["/* eslint-disable max-classes-per-file */\nimport mapSeries from 'p-map-series';\nimport { Component, ComponentID } from '@teambit/component';\nimport { EnvsMain } from '@teambit/envs';\nimport type { PubsubMain } from '@teambit/pubsub';\nimport { SerializableResults, Workspace, OutsideWorkspaceError } from '@teambit/workspace';\nimport { WatcherMain, WatchOptions } from '@teambit/watcher';\nimport path from 'path';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { Logger } from '@teambit/logger';\nimport loader from '@teambit/legacy/dist/cli/loader';\nimport { DEFAULT_DIST_DIRNAME } from '@teambit/legacy/dist/constants';\nimport { AbstractVinyl, Dist } from '@teambit/legacy/dist/consumer/component/sources';\nimport DataToPersist from '@teambit/legacy/dist/consumer/component/sources/data-to-persist';\nimport {\n linkToNodeModulesByComponents,\n removeLinksFromNodeModules,\n} from '@teambit/workspace.modules.node-modules-linker';\nimport { AspectLoaderMain } from '@teambit/aspect-loader';\nimport { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport componentIdToPackageName from '@teambit/legacy/dist/utils/bit/component-id-to-package-name';\nimport RemovePath from '@teambit/legacy/dist/consumer/component/sources/remove-path';\nimport { UiMain } from '@teambit/ui';\nimport { readBitRootsDir } from '@teambit/bit-roots';\nimport { groupBy, uniq } from 'lodash';\nimport type { PreStartOpts } from '@teambit/ui';\nimport { PathOsBasedAbsolute, PathOsBasedRelative } from '@teambit/legacy/dist/utils/path';\nimport { MultiCompiler } from '@teambit/multi-compiler';\nimport { CompilerAspect } from './compiler.aspect';\nimport { CompilerErrorEvent, ComponentCompilationOnDoneEvent } from './events';\nimport { Compiler, CompilationInitiator } from './types';\n\nexport type BuildResult = { component: string; buildResults: string[] | null | undefined };\n\nexport type CompileOptions = {\n changed?: boolean; // compile only new and modified components\n verbose?: boolean; // show more data, such as, dist paths\n /**\n * whether the dist root dir should be deleted before writing new dists.\n * defaults to true for `bit compile` and false everywhere else, such as `bit watch` and `bit\n * start` to avoid webpack \"EINTR\" error.\n */\n deleteDistDir?: boolean;\n initiator: CompilationInitiator; // describes where the compilation is coming from\n};\n\nexport type CompileError = { path: string; error: Error };\n\nexport class ComponentCompiler {\n constructor(\n private pubsub: PubsubMain,\n private workspace: Workspace,\n private component: Component,\n private compilerInstance: Compiler,\n private compilerId: string,\n private logger: Logger,\n private dependencyResolver: DependencyResolverMain,\n private dists: Dist[] = [],\n private compileErrors: CompileError[] = []\n ) {}\n\n async compile(noThrow = true, options: CompileOptions): Promise<BuildResult> {\n let dataToPersist;\n const deleteDistDir = options.deleteDistDir ?? this.compilerInstance.deleteDistDir;\n // delete dist folder before transpilation (because some compilers (like ngPackagr) can generate files there during the compilation process)\n if (deleteDistDir) {\n dataToPersist = new DataToPersist();\n for (const distDir of await this.distDirs()) {\n dataToPersist.removePath(new RemovePath(distDir));\n }\n dataToPersist.addBasePath(this.workspace.path);\n await dataToPersist.persistAllToFS();\n }\n\n const compilers: Compiler[] = (this.compilerInstance as MultiCompiler).compilers\n ? (this.compilerInstance as MultiCompiler).compilers\n : [this.compilerInstance];\n const canTranspileFile = compilers.find((c) => c.transpileFile);\n const canTranspileComponent = compilers.find((c) => c.transpileComponent);\n\n if (canTranspileFile) {\n await Promise.all(\n this.component.filesystem.files.map((file: AbstractVinyl) => this.compileOneFile(file, options.initiator))\n );\n }\n\n if (canTranspileComponent) {\n await this.compileAllFiles(this.component, options.initiator);\n }\n\n if (!canTranspileFile && !canTranspileComponent) {\n throw new Error(\n `compiler ${this.compilerId.toString()} doesn't implement either \"transpileFile\" or \"transpileComponent\" methods`\n );\n }\n this.throwOnCompileErrors(noThrow);\n\n // writing the dists with `component.setDists(dists); component.dists.writeDists` is tricky\n // as it uses other base-paths and doesn't respect the new node-modules base path.\n dataToPersist = new DataToPersist();\n dataToPersist.addManyFiles(this.dists);\n dataToPersist.addBasePath(this.workspace.path);\n await dataToPersist.persistAllToFS();\n const buildResults = this.dists.map((distFile) => distFile.path);\n if (this.component.state._consumer.compiler) loader.succeed();\n this.pubsub.pub(\n CompilerAspect.id,\n new ComponentCompilationOnDoneEvent(this.compileErrors, this.component, buildResults)\n );\n return { component: this.component.id.toString(), buildResults };\n }\n\n private throwOnCompileErrors(noThrow = true) {\n if (this.compileErrors.length) {\n this.compileErrors.forEach((errorItem) => {\n this.logger.error(`compilation error at ${errorItem.path}`, errorItem.error);\n });\n const formatError = (errorItem) => `${errorItem.path}\\n${errorItem.error}`;\n const err = new Error(`compilation failed. see the following errors from the compiler\n${this.compileErrors.map(formatError).join('\\n')}`);\n\n this.pubsub.pub(CompilerAspect.id, new CompilerErrorEvent(err));\n\n if (!noThrow) {\n throw err;\n }\n\n this.logger.console(err.message);\n }\n }\n\n private async distDirs(): Promise<PathOsBasedRelative[]> {\n const packageName = componentIdToPackageName(this.component.state._consumer);\n const packageDir = path.join('node_modules', packageName);\n const distDirName = this.compilerInstance.getDistDir?.() || DEFAULT_DIST_DIRNAME;\n const injectedDirs = await this.getInjectedDirs(packageName);\n return [packageDir, ...injectedDirs].map((dist) => path.join(dist, distDirName));\n }\n\n private async getInjectedDirs(packageName: string): Promise<string[]> {\n const relativeCompDir = this.workspace.componentDir(this.component.id, undefined, {\n relative: true,\n });\n const injectedDirs = await this.dependencyResolver.getInjectedDirs(\n this.workspace.path,\n relativeCompDir,\n packageName\n );\n if (injectedDirs.length > 0) return injectedDirs;\n\n const rootDirs = await readBitRootsDir(this.workspace.path);\n return rootDirs.map((rootDir) => path.relative(this.workspace.path, path.join(rootDir, packageName)));\n }\n\n private get componentDir(): PathOsBasedAbsolute {\n return this.workspace.componentDir(this.component.id);\n }\n\n private async compileOneFile(file: AbstractVinyl, initiator: CompilationInitiator): Promise<void> {\n const options = { componentDir: this.componentDir, filePath: file.relative, initiator };\n const isFileSupported = this.compilerInstance.isFileSupported(file.path);\n let compileResults;\n if (isFileSupported) {\n try {\n compileResults = await this.compilerInstance.transpileFile?.(file.contents.toString(), options);\n } catch (error: any) {\n this.compileErrors.push({ path: file.path, error });\n return;\n }\n }\n for (const base of await this.distDirs()) {\n if (isFileSupported && compileResults) {\n this.dists.push(\n ...compileResults.map(\n (result) =>\n new Dist({\n base,\n path: path.join(base, result.outputPath),\n contents: Buffer.from(result.outputText),\n })\n )\n );\n } else if (this.compilerInstance.shouldCopyNonSupportedFiles) {\n // compiler doesn't support this file type. copy the file as is to the dist dir.\n this.dists.push(new Dist({ base, path: path.join(base, file.relative), contents: file.contents }));\n }\n }\n }\n\n private async compileAllFiles(component: Component, initiator: CompilationInitiator): Promise<void> {\n const filesToCompile: AbstractVinyl[] = [];\n for (const base of await this.distDirs()) {\n component.filesystem.files.forEach((file: AbstractVinyl) => {\n const isFileSupported = this.compilerInstance.isFileSupported(file.path);\n if (isFileSupported) {\n filesToCompile.push(file);\n } else if (this.compilerInstance.shouldCopyNonSupportedFiles) {\n // compiler doesn't support this file type. copy the file as is to the dist dir.\n this.dists.push(\n new Dist({\n base,\n path: path.join(base, file.relative),\n contents: file.contents,\n })\n );\n }\n });\n }\n\n if (filesToCompile.length) {\n try {\n await this.compilerInstance.transpileComponent?.({\n component,\n componentDir: this.componentDir,\n outputDir: this.workspace.getComponentPackagePath(component),\n initiator,\n });\n } catch (error: any) {\n this.compileErrors.push({ path: this.componentDir, error });\n }\n }\n }\n}\n\nexport class WorkspaceCompiler {\n constructor(\n private workspace: Workspace,\n private envs: EnvsMain,\n private pubsub: PubsubMain,\n private aspectLoader: AspectLoaderMain,\n private ui: UiMain,\n private logger: Logger,\n private dependencyResolver: DependencyResolverMain,\n private watcher: WatcherMain\n ) {\n if (this.workspace) {\n this.workspace.registerOnComponentChange(this.onComponentChange.bind(this));\n this.workspace.registerOnComponentAdd(this.onComponentChange.bind(this));\n this.watcher.registerOnPreWatch(this.onPreWatch.bind(this));\n this.ui.registerPreStart(this.onPreStart.bind(this));\n }\n if (this.aspectLoader) {\n this.aspectLoader.registerOnAspectLoadErrorSlot(this.onAspectLoadFail.bind(this));\n }\n }\n\n async onPreStart(preStartOpts: PreStartOpts): Promise<void> {\n if (preStartOpts.skipCompilation) {\n return;\n }\n await this.compileComponents([], {\n changed: true,\n verbose: false,\n deleteDistDir: false,\n initiator: CompilationInitiator.PreStart,\n });\n }\n\n async onAspectLoadFail(err: Error & { code?: string }, id: ComponentID): Promise<boolean> {\n if (err.code && err.code === 'MODULE_NOT_FOUND' && this.workspace) {\n await this.compileComponents([id.toString()], { initiator: CompilationInitiator.AspectLoadFail }, true);\n return true;\n }\n return false;\n }\n\n async onComponentChange(\n component: Component,\n files: string[],\n removedFiles?: string[],\n initiator?: CompilationInitiator\n ): Promise<SerializableResults> {\n // when files are removed, we need to remove the dist directories and the old symlinks, otherwise, it has\n // symlinks to non-exist files and the dist has stale files\n const deleteDistDir = Boolean(removedFiles?.length);\n if (removedFiles?.length) {\n await removeLinksFromNodeModules(component, this.workspace, removedFiles);\n }\n const buildResults = await this.compileComponents(\n [component.id.toString()],\n { initiator: initiator || CompilationInitiator.ComponentChanged, deleteDistDir },\n true\n );\n await linkToNodeModulesByComponents([component], this.workspace);\n return {\n results: buildResults,\n toString() {\n return `${buildResults[0]?.buildResults?.join('\\n\\t')}`;\n },\n };\n }\n\n async onPreWatch(components: Component[], watchOpts: WatchOptions) {\n if (watchOpts.preCompile) {\n const start = Date.now();\n this.logger.console(`compiling ${components.length} components`);\n await this.compileComponents(\n components.map((c) => c.id._legacy),\n { initiator: CompilationInitiator.PreWatch }\n );\n const end = Date.now() - start;\n this.logger.consoleSuccess(`compiled ${components.length} components successfully (${end / 1000} sec)`);\n }\n }\n\n async compileComponents(\n componentsIds: string[] | BitId[] | ComponentID[], // when empty, it compiles new+modified (unless options.all is set),\n options: CompileOptions,\n noThrow?: boolean\n ): Promise<BuildResult[]> {\n if (!this.workspace) throw new OutsideWorkspaceError();\n const componentIds = await this.getIdsToCompile(componentsIds, options.changed);\n const components = await this.workspace.getMany(componentIds);\n\n const grouped = this.groupByIsEnv(components);\n const envsResults = grouped.envs ? await this.runCompileComponents(grouped.envs, options, noThrow) : [];\n const otherResults = grouped.other ? await this.runCompileComponents(grouped.other, options, noThrow) : [];\n return [...envsResults, ...otherResults];\n }\n\n private async runCompileComponents(\n components: Component[],\n options: CompileOptions,\n noThrow?: boolean\n ): Promise<BuildResult[]> {\n const componentsCompilers: ComponentCompiler[] = [];\n\n components.forEach((c) => {\n const environment = this.envs.getEnv(c).env;\n const compilerInstance = environment.getCompiler?.();\n\n if (compilerInstance) {\n const compilerName = compilerInstance.constructor.name || 'compiler';\n componentsCompilers.push(\n new ComponentCompiler(\n this.pubsub,\n this.workspace,\n c,\n compilerInstance,\n compilerName,\n this.logger,\n this.dependencyResolver\n )\n );\n } else {\n this.logger.warn(`unable to find a compiler instance for ${c.id.toString()}`);\n }\n });\n const resultOnWorkspace = await mapSeries(componentsCompilers, (componentCompiler) =>\n componentCompiler.compile(noThrow, options)\n );\n\n return resultOnWorkspace;\n }\n\n /**\n * This function get's a list of aspect ids and return them grouped by whether any of them is the env of other from the list\n * @param ids\n */\n groupByIsEnv(components: Component[]): { envs?: Component[]; other?: Component[] } {\n const envsIds = uniq(\n components\n .map((component) => this.envs.getEnvId(component))\n .filter((envId) => !this.aspectLoader.isCoreEnv(envId))\n );\n const grouped = groupBy(components, (component) => {\n if (envsIds.includes(component.id.toString())) return 'envs';\n return 'other';\n });\n return grouped as { envs: Component[]; other: Component[] };\n }\n\n private async getIdsToCompile(\n componentsIds: Array<string | ComponentID | BitId>,\n changed = false\n ): Promise<ComponentID[]> {\n if (componentsIds.length) {\n const componentIds = await this.workspace.resolveMultipleComponentIds(componentsIds);\n return this.workspace.filterIds(componentIds);\n }\n if (changed) {\n return this.workspace.getNewAndModifiedIds();\n }\n return this.workspace.getAllComponentIds();\n }\n}\n"],"mappings":";;;;;;;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AA2B,CAAC9B,aAAa,CAAC;MACpF,OAAO,IAAI,CAACtI,SAAS,CAACqK,SAAS,CAAC7B,YAAY,CAAC;IAC/C;IACA,IAAIxB,OAAO,EAAE;MACX,OAAO,IAAI,CAAChH,SAAS,CAACsK,oBAAoB,EAAE;IAC9C;IACA,OAAO,IAAI,CAACtK,SAAS,CAACuK,kBAAkB,EAAE;EAC5C;AACF;AAAC"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/compiler",
3
- "version": "0.0.1094",
3
+ "version": "0.0.1096",
4
4
  "homepage": "https://bit.cloud/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.1094"
9
+ "version": "0.0.1096"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "2.4.2",
@@ -20,24 +20,24 @@
20
20
  "@babel/runtime": "7.20.0",
21
21
  "@teambit/harmony": "0.4.6",
22
22
  "@teambit/legacy-bit-id": "0.0.423",
23
- "@teambit/envs": "0.0.1094",
24
- "@teambit/cli": "0.0.735",
25
- "@teambit/component": "0.0.1094",
26
- "@teambit/logger": "0.0.828",
27
- "@teambit/pubsub": "0.0.1094",
28
- "@teambit/aspect-loader": "0.0.1094",
29
- "@teambit/builder": "0.0.1094",
23
+ "@teambit/envs": "0.0.1096",
24
+ "@teambit/cli": "0.0.736",
25
+ "@teambit/component": "0.0.1096",
26
+ "@teambit/logger": "0.0.829",
27
+ "@teambit/pubsub": "0.0.1096",
28
+ "@teambit/aspect-loader": "0.0.1096",
29
+ "@teambit/builder": "0.0.1096",
30
30
  "@teambit/component-issues": "0.0.92",
31
- "@teambit/dependency-resolver": "0.0.1094",
32
- "@teambit/generator": "0.0.1094",
33
- "@teambit/ui": "0.0.1094",
34
- "@teambit/watcher": "0.0.106",
35
- "@teambit/workspace": "0.0.1094",
36
- "@teambit/isolator": "0.0.1094",
31
+ "@teambit/dependency-resolver": "0.0.1096",
32
+ "@teambit/generator": "0.0.1096",
33
+ "@teambit/ui": "0.0.1096",
34
+ "@teambit/watcher": "0.0.108",
35
+ "@teambit/workspace": "0.0.1096",
36
+ "@teambit/isolator": "0.0.1096",
37
37
  "@teambit/toolbox.fs.hard-link-directory": "0.0.14",
38
- "@teambit/bit-roots": "0.0.72",
39
- "@teambit/multi-compiler": "0.0.1094",
40
- "@teambit/workspace.modules.node-modules-linker": "0.0.79",
38
+ "@teambit/bit-roots": "0.0.73",
39
+ "@teambit/multi-compiler": "0.0.1096",
40
+ "@teambit/workspace.modules.node-modules-linker": "0.0.80",
41
41
  "@teambit/bit-error": "0.0.402"
42
42
  },
43
43
  "devDependencies": {
@@ -52,7 +52,7 @@
52
52
  "@teambit/compilation.content.compiler-overview": "1.95.0"
53
53
  },
54
54
  "peerDependencies": {
55
- "@teambit/legacy": "1.0.516",
55
+ "@teambit/legacy": "1.0.517",
56
56
  "react": "^16.8.0 || ^17.0.0",
57
57
  "react-dom": "^16.8.0 || ^17.0.0"
58
58
  },