@teambit/compiler 1.0.1156 → 1.0.1157
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/{preview-1788575535452.js → preview-1788878075084.js} +2 -2
- package/dist/workspace-compiler.js +23 -3
- package/dist/workspace-compiler.js.map +1 -1
- package/dist/workspace-compiler.spec.d.ts +1 -0
- package/dist/workspace-compiler.spec.js +178 -0
- package/dist/workspace-compiler.spec.js.map +1 -0
- package/package.json +23 -22
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.compilation_compiler@1.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.compilation_compiler@1.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.compilation_compiler@1.0.1157/dist/compiler.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.compilation_compiler@1.0.1157/dist/compiler.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
@@ -405,7 +405,11 @@ class WorkspaceCompiler {
|
|
|
405
405
|
}
|
|
406
406
|
}
|
|
407
407
|
async onAspectLoadFail(err, component) {
|
|
408
|
-
if ((err.code && (err.code === 'MODULE_NOT_FOUND' || err.code === 'ERR_MODULE_NOT_FOUND' || err.code === 'ERR_REQUIRE_ESM'
|
|
408
|
+
if ((err.code && (err.code === 'MODULE_NOT_FOUND' || err.code === 'ERR_MODULE_NOT_FOUND' || err.code === 'ERR_REQUIRE_ESM' ||
|
|
409
|
+
// node refuses to load .ts files from node_modules. happens when the loaded instance
|
|
410
|
+
// has only the component sources (e.g. re-created by the package manager mid-install)
|
|
411
|
+
// and compiling the component fixes it, same as a missing-module failure
|
|
412
|
+
err.code === 'ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING') || err.message.includes('import.meta') || err.message.includes('exports is not defined')) && this.workspace) {
|
|
409
413
|
const inInstallContext = this.workspace.inInstallContext;
|
|
410
414
|
const inInstallAfterPmContext = this.workspace.inInstallAfterPmContext;
|
|
411
415
|
// If we are now running install we only want to compile after the package manager is done
|
|
@@ -414,6 +418,20 @@ class WorkspaceCompiler {
|
|
|
414
418
|
const id = component.id;
|
|
415
419
|
const idStr = id.toString();
|
|
416
420
|
|
|
421
|
+
// compiling can only fix a workspace component whose dists are missing or stale. when the
|
|
422
|
+
// failed aspect is not in the workspace (e.g. an env that used to be a core aspect,
|
|
423
|
+
// resolved to its pinned version but not installed yet), the cascade below imports the
|
|
424
|
+
// env's full dependency closure from the remote and recompiles a large part of the
|
|
425
|
+
// workspace into every injected node_modules copy - minutes of work that cannot
|
|
426
|
+
// materialize the missing package. skip it and let the regular missing-aspect handling
|
|
427
|
+
// report it (a NonLoadedEnv issue with a "bit install" remediation).
|
|
428
|
+
if (!this.workspace.hasId(id, {
|
|
429
|
+
ignoreVersion: true
|
|
430
|
+
})) {
|
|
431
|
+
this.logger.debug(`onAspectLoadFail: skipping compilation of ${idStr} - not a workspace component, compiling cannot fix its missing module`);
|
|
432
|
+
return false;
|
|
433
|
+
}
|
|
434
|
+
|
|
417
435
|
// Prevent infinite loop when there's a circular dependency between an env and a component.
|
|
418
436
|
// If we're already processing this component, don't re-enter.
|
|
419
437
|
if (this.componentsBeingProcessedInOnAspectLoadFail.has(idStr)) {
|
|
@@ -665,7 +683,9 @@ class WorkspaceCompiler {
|
|
|
665
683
|
const envsOfEnvsWithoutCoreCompIds = envsOfEnvsCompIds.filter(id => !this.envs.isCoreEnv(id));
|
|
666
684
|
let depsOfEnvsOfEnvsCompIds = [];
|
|
667
685
|
if (graph) {
|
|
668
|
-
|
|
686
|
+
// envs installed as packages (e.g. legacy core envs) are not part of the workspace graph
|
|
687
|
+
const envsOfEnvsOnGraph = envsOfEnvsWithoutCoreCompIds.filter(id => graph.hasNode(id));
|
|
688
|
+
const subGraph = graph.successorsSubgraph(envsOfEnvsOnGraph, {
|
|
669
689
|
nodeFilter: node => this.workspace.hasId(node.attr)
|
|
670
690
|
});
|
|
671
691
|
depsOfEnvsOfEnvsCompIds = subGraph.nodes.map(n => n.id);
|
|
@@ -681,7 +701,7 @@ class WorkspaceCompiler {
|
|
|
681
701
|
if (graph) {
|
|
682
702
|
const otherEnvsIds = (groupedByEnvsOfEnvs.otherEnvs || []).map(c => c.id.toString());
|
|
683
703
|
if (otherEnvsIds.length) {
|
|
684
|
-
const otherEnvsWithoutCoreIds = otherEnvsIds.filter(id => !this.envs.isCoreEnv(id));
|
|
704
|
+
const otherEnvsWithoutCoreIds = otherEnvsIds.filter(id => !this.envs.isCoreEnv(id) && graph.hasNode(id));
|
|
685
705
|
const subGraph = graph.successorsSubgraph(otherEnvsWithoutCoreIds, {
|
|
686
706
|
nodeFilter: node => this.workspace.hasId(node.attr)
|
|
687
707
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_pMapSeries","data","_interopRequireDefault","require","_globby","_fsExtra","_workspace","_path","_chalk","_componentId","_logger","_legacy","_component","_workspaceModules","_dependencyResolver","_pkgModules","_workspace2","_lodash","_compiler","_events","_types","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ComponentCompiler","constructor","pubsub","workspace","component","compilerInstance","compilerId","logger","env","dists","compileErrors","compile","noThrow","options","dataToPersist","deleteDistDir","distDirs","relativeDistDirs","filter","distDir","path","isAbsolute","absoluteDistDirs","length","DataToPersist","removePath","RemovePath","addBasePath","persistAllToFS","Promise","all","map","fs","remove","compilers","canTranspileFile","find","c","transpileFile","canTranspileComponent","transpileComponent","filesystem","files","file","compileOneFile","initiator","compileAllFiles","Error","toString","throwOnCompileErrors","relativeDists","distFile","absoluteDists","addManyFiles","write","buildResults","state","_consumer","compiler","consoleSuccess","id","errors","getPackageDir","packageName","componentIdToPackageName","join","toAbsolutePath","pathToResolve","forEach","errorItem","error","formatError","err","pub","CompilerAspect","CompilerErrorEvent","console","message","packageDir","distDirName","getDistDir","DEFAULT_DIST_DIRNAME","injectedDirs","getInjectedDirs","dist","rootDirs","readRootComponentsDir","rootComponentsPath","rootDir","relative","componentDir","copyTypesToOtherDists","packageDistDir","otherDirs","slice","packageDistDirAbs","matches","globby","cwd","onlyFiles","ignore","distDirAbs","match","source","dest","copyFile","copyCompiledFilesToOtherDists","outputDir","getComponentPackagePath","sourceDistDirAbs","pathExists","dir","resolve","ensureDir","dirname","filePath","isFileSupported","compileResults","contents","push","base","result","Dist","outputPath","Buffer","from","outputText","shouldCopyNonSupportedFiles","filesToCompile","exports","WorkspaceCompiler","envs","aspectLoader","ui","dependencyResolver","watcher","Set","registerOnComponentChange","onComponentChange","bind","registerOnComponentAdd","onComponentAdd","registerOnPreWatch","onPreWatch","registerPreStart","onPreStart","registerOnAspectLoadErrorSlot","onAspectLoadFail","preStartOpts","skipCompilation","compileComponents","changed","verbose","CompilationInitiator","PreStart","watchScopeInternalFiles","code","includes","inInstallContext","inInstallAfterPmContext","shouldCompile","idStr","componentsBeingProcessedInOnAspectLoadFail","has","debug","add","graph","successors","getEnvDepsGraph","depsIds","s","AspectLoadFail","loadExtensions","executeLoadSlot","delete","envComponentId","getGraphIds","nodeFilter","node","hasId","attr","watchOpts","undefined","removedFiles","Boolean","removeLinksFromNodeModules","ComponentChanged","generateTypes","results","formatCompileResults","componentIds","preCompile","start","Date","now","PreWatch","end","componentsIds","componentLoadOptions","OutsideWorkspaceError","getIdsToCompile","loadSeedersAsAspects","components","getMany","loadExternalEnvs","grouped","buildGroupsToCompile","mapSeries","group","runCompileComponents","linkComponents","linkToNodeModulesByComponents","flat","componentsIdsStr","envIdsCompIdsMap","compsWithWrongEnvId","envId","calculateEnvId","envIdByGet","getEnvId","externalEnvsIds","keys","nonLoadedEnvs","isEnvRegistered","loadAspects","idsToClearCache","uniq","reduce","acc","compIds","concat","clearComponentsCache","ComponentID","fromString","componentsCompilers","skipped","getOrCalculateEnv","environment","getCompiler","compilerName","name","warn","reason","typeGeneratorParamsPerEnv","getTypesCompilerPerEnv","preGenerateTypesOnWorkspace","resultOnWorkspace","componentCompiler","generateTypesOnWorkspace","envsMap","componentCompilers","compParams","typeCompiler","buildPipe","getBuildPipe","compilerTasks","task","aspectId","tsTask","displayName","compact","typesGeneratorParamsPerEnv","envCompIds","envsIds","groupedByIsEnv","groupBy","isEnv","envsOfEnvsCompIds","groupedByEnvsOfEnvs","envsOfEnvsWithoutCoreCompIds","isCoreEnv","depsOfEnvsOfEnvsCompIds","subGraph","successorsSubgraph","nodes","n","depsOfEnvsOfEnvsCompLists","envsOfEnvs","envComp","getDependencies","DependencyList","merge","getComponentDependencies","dep","groupedByIsDepsOfEnvsOfEnvs","other","depsOfEnvsOfCompIds","otherEnvsIds","otherEnvs","otherEnvsWithoutCoreIds","depsOfEnvsCompLists","groupedByIsDepsOfEnvs","depsOfEnvsOfEnvs","depsOfEnvs","resolveMultipleComponentIds","filterIds","getNewAndModifiedIds","listIds","buildResult","title","chalk","underline","verboseComponentFilesArrayToString","Logger","successSymbol"],"sources":["workspace-compiler.ts"],"sourcesContent":["/* eslint-disable max-classes-per-file */\nimport mapSeries from 'p-map-series';\nimport globby from 'globby';\nimport fs from 'fs-extra';\nimport type { Component } from '@teambit/component';\nimport type { EnvDefinition, EnvsMain } from '@teambit/envs';\nimport type { PubsubMain } from '@teambit/pubsub';\nimport { OutsideWorkspaceError } from '@teambit/workspace';\nimport type { WorkspaceComponentLoadOptions, SerializableResults, Workspace } from '@teambit/workspace';\nimport type { WatcherMain, WatchOptions } from '@teambit/watcher';\nimport path from 'path';\nimport chalk from 'chalk';\nimport { ComponentID } from '@teambit/component-id';\nimport { Logger } from '@teambit/logger';\nimport { DEFAULT_DIST_DIRNAME } from '@teambit/legacy.constants';\nimport type { AbstractVinyl } from '@teambit/component.sources';\nimport { Dist, DataToPersist, RemovePath } from '@teambit/component.sources';\nimport {\n linkToNodeModulesByComponents,\n removeLinksFromNodeModules,\n} from '@teambit/workspace.modules.node-modules-linker';\nimport type { AspectLoaderMain } from '@teambit/aspect-loader';\nimport type { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { DependencyList } from '@teambit/dependency-resolver';\nimport type { PathOsBasedAbsolute } from '@teambit/toolbox.path.path';\nimport { componentIdToPackageName } from '@teambit/pkg.modules.component-package-name';\nimport type { UiMain, PreStartOpts } from '@teambit/ui';\nimport { readRootComponentsDir } from '@teambit/workspace.root-components';\nimport { compact, groupBy, uniq } from 'lodash';\nimport type { MultiCompiler } from '@teambit/multi-compiler';\nimport type { CompIdGraph } from '@teambit/graph';\nimport { CompilerAspect } from './compiler.aspect';\nimport { CompilerErrorEvent } from './events';\nimport type { Compiler, TypeGeneratorCompParams } from './types';\nimport { CompilationInitiator } from './types';\n\nexport type BuildResult = {\n component: string;\n buildResults: string[];\n errors: CompileError[];\n /**\n * set when nothing was compiled for the component because its env provides no compiler. such a\n * component is neither a success nor a failure, so it is counted and reported on its own.\n */\n skipped?: { reason: string };\n};\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 // should we create links in node_modules for the compiled components (default = true)\n // this will link the source files, and create the package.json\n linkComponents?: boolean;\n /**\n * whether to generate types after the compilation, default = false.\n * keep in mind that it's a heavy operation, and hurts the performance.\n */\n generateTypes?: boolean;\n};\n\nexport type CompileError = { path: string; error: Error };\n\nexport class ComponentCompiler {\n constructor(\n private pubsub: PubsubMain,\n private workspace: Workspace,\n readonly component: Component,\n readonly compilerInstance: Compiler,\n private compilerId: string,\n private logger: Logger,\n readonly env: EnvDefinition,\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 const distDirs = await this.distDirs();\n // delete dist folder before transpilation (because some compilers (like ngPackagr) can generate files there during the compilation process)\n if (deleteDistDir) {\n const relativeDistDirs = distDirs.filter((distDir) => !path.isAbsolute(distDir));\n const absoluteDistDirs = distDirs.filter((distDir) => path.isAbsolute(distDir));\n if (relativeDistDirs.length) {\n dataToPersist = new DataToPersist();\n for (const distDir of relativeDistDirs) {\n dataToPersist.removePath(new RemovePath(distDir));\n }\n dataToPersist.addBasePath(this.workspace.path);\n await dataToPersist.persistAllToFS();\n }\n await Promise.all(absoluteDistDirs.map((distDir) => fs.remove(distDir)));\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) =>\n this.compileOneFile(file, options.initiator, distDirs)\n )\n );\n }\n\n if (canTranspileComponent) {\n await this.compileAllFiles(options.initiator, distDirs);\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 const relativeDists = this.dists.filter((distFile) => !path.isAbsolute(distFile.path));\n const absoluteDists = this.dists.filter((distFile) => path.isAbsolute(distFile.path));\n if (relativeDists.length) {\n dataToPersist = new DataToPersist();\n dataToPersist.addManyFiles(relativeDists);\n dataToPersist.addBasePath(this.workspace.path);\n await dataToPersist.persistAllToFS();\n }\n await Promise.all(absoluteDists.map((distFile) => distFile.write()));\n const buildResults = this.dists.map((distFile) => distFile.path);\n if (this.component.state._consumer.compiler) this.logger.consoleSuccess();\n\n return { component: this.component.id.toString(), buildResults, errors: this.compileErrors };\n }\n\n getPackageDir() {\n const packageName = componentIdToPackageName(this.component.state._consumer);\n return path.join('node_modules', packageName);\n }\n\n private toAbsolutePath(pathToResolve: string): string {\n return path.isAbsolute(pathToResolve) ? pathToResolve : path.join(this.workspace.path, pathToResolve);\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<string[]> {\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 injectedDirs = await this.workspace.getInjectedDirs(this.component);\n if (injectedDirs.length > 0) return injectedDirs;\n\n const rootDirs = await readRootComponentsDir(this.workspace.rootComponentsPath);\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 async copyTypesToOtherDists() {\n const distDirs = await this.distDirs();\n if (distDirs.length <= 1) return;\n const packageDistDir = distDirs[0];\n const otherDirs = distDirs.slice(1);\n const packageDistDirAbs = this.toAbsolutePath(packageDistDir);\n const matches = await globby(`**/*.d.ts`, {\n cwd: packageDistDirAbs,\n onlyFiles: true,\n ignore: [`${packageDistDir}/node_modules/`],\n });\n if (!matches.length) return;\n await Promise.all(\n otherDirs.map(async (distDir) => {\n const distDirAbs = this.toAbsolutePath(distDir);\n await Promise.all(\n matches.map(async (match) => {\n const source = path.join(packageDistDirAbs, match);\n const dest = path.join(distDirAbs, match);\n await fs.copyFile(source, dest);\n })\n );\n })\n );\n }\n\n /**\n * Copy all compiled files from the outputDir (where the compiler wrote) to all other dist directories.\n * This is needed for compilers that use transpileComponent and write directly to the filesystem,\n * as they only receive one outputDir but files need to be available in all dist locations.\n */\n async copyCompiledFilesToOtherDists() {\n const distDirs = await this.distDirs();\n if (distDirs.length <= 1) return;\n\n // The compiler writes to the outputDir from getComponentPackagePath + distDirName\n const outputDir = await this.workspace.getComponentPackagePath(this.component);\n const distDirName = this.compilerInstance.getDistDir?.() || DEFAULT_DIST_DIRNAME;\n const sourceDistDirAbs = path.join(outputDir, distDirName);\n\n // Check if the dist directory exists (compiler may not have written anything)\n if (!(await fs.pathExists(sourceDistDirAbs))) return;\n\n const otherDirs = distDirs.filter(\n (dir) => path.resolve(this.toAbsolutePath(dir)) !== path.resolve(sourceDistDirAbs)\n );\n\n if (!otherDirs.length) return;\n\n const matches = await globby(`**/*`, {\n cwd: sourceDistDirAbs,\n onlyFiles: true,\n ignore: ['node_modules/**'],\n });\n if (!matches.length) return;\n\n await Promise.all(\n otherDirs.map(async (distDir) => {\n const distDirAbs = this.toAbsolutePath(distDir);\n await Promise.all(\n matches.map(async (match) => {\n const source = path.join(sourceDistDirAbs, match);\n const dest = path.join(distDirAbs, match);\n try {\n await fs.ensureDir(path.dirname(dest));\n await fs.copyFile(source, dest);\n } catch (err: any) {\n throw new Error(`failed to copy compiled file from \"${source}\" to \"${dest}\": ${err.message}`);\n }\n })\n );\n })\n );\n }\n\n private async compileOneFile(\n file: AbstractVinyl,\n initiator: CompilationInitiator,\n distDirs: string[]\n ): 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 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(initiator: CompilationInitiator, distDirs: string[]): Promise<void> {\n const filesToCompile: AbstractVinyl[] = [];\n for (const base of distDirs) {\n this.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: this.component,\n componentDir: this.componentDir,\n outputDir: await this.workspace.getComponentPackagePath(this.component),\n initiator,\n });\n // Copy compiled files to all other dist directories (injected dirs)\n await this.copyCompiledFilesToOtherDists();\n } catch (error: any) {\n this.compileErrors.push({ path: this.componentDir, error });\n }\n }\n }\n}\n\ntype TypeGeneratorParamsPerEnv = { envId: string; compParams: TypeGeneratorCompParams[]; typeCompiler: Compiler };\n\nexport class WorkspaceCompiler {\n private componentsBeingProcessedInOnAspectLoadFail = new Set<string>();\n\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.onComponentAdd.bind(this));\n this.watcher.registerOnPreWatch(this.onPreWatch.bind(this));\n }\n this.ui.registerPreStart(this.onPreStart.bind(this));\n if (this.aspectLoader) {\n this.aspectLoader.registerOnAspectLoadErrorSlot(this.onAspectLoadFail.bind(this));\n }\n }\n\n async onPreStart(preStartOpts: PreStartOpts): Promise<void> {\n if (this.workspace) {\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 } else {\n await this.watcher.watchScopeInternalFiles();\n }\n }\n\n async onAspectLoadFail(err: Error & { code?: string }, component: Component): Promise<boolean> {\n if (\n ((err.code &&\n (err.code === 'MODULE_NOT_FOUND' || err.code === 'ERR_MODULE_NOT_FOUND' || err.code === 'ERR_REQUIRE_ESM')) ||\n err.message.includes('import.meta') ||\n err.message.includes('exports is not defined')) &&\n this.workspace\n ) {\n const inInstallContext = this.workspace.inInstallContext;\n const inInstallAfterPmContext = this.workspace.inInstallAfterPmContext;\n // If we are now running install we only want to compile after the package manager is done\n const shouldCompile = (inInstallContext && inInstallAfterPmContext) || !inInstallContext;\n if (shouldCompile) {\n const id = component.id;\n const idStr = id.toString();\n\n // Prevent infinite loop when there's a circular dependency between an env and a component.\n // If we're already processing this component, don't re-enter.\n if (this.componentsBeingProcessedInOnAspectLoadFail.has(idStr)) {\n this.logger.debug(\n `onAspectLoadFail: skipping ${idStr} as it's already being processed (preventing infinite loop)`\n );\n return false;\n }\n\n this.componentsBeingProcessedInOnAspectLoadFail.add(idStr);\n try {\n const { graph, successors } = await this.getEnvDepsGraph(id);\n // const deps = this.dependencyResolver.getDependencies(component);\n // const depsIds = deps.getComponentDependencies().map((dep) => {\n // return dep.id.toString();\n // });\n const depsIds = successors.map((s) => s.id);\n await this.compileComponents(\n [id.toString(), ...depsIds],\n { initiator: CompilationInitiator.AspectLoadFail },\n true,\n { loadExtensions: true, executeLoadSlot: true },\n graph\n );\n return true;\n } finally {\n this.componentsBeingProcessedInOnAspectLoadFail.delete(idStr);\n }\n }\n }\n return false;\n }\n\n async getEnvDepsGraph(envComponentId: ComponentID): Promise<{ graph: CompIdGraph; successors: { id: string }[] }> {\n const graph = await this.workspace.getGraphIds([envComponentId]);\n const successors = graph.successors(envComponentId.toString(), {\n nodeFilter: (node) => this.workspace.hasId(node.attr),\n });\n return { graph, successors };\n }\n\n async onComponentAdd(component: Component, files: string[], watchOpts: WatchOptions) {\n return this.onComponentChange(component, files, undefined, watchOpts);\n }\n\n async onComponentChange(\n component: Component,\n files: string[],\n removedFiles: string[] = [],\n watchOpts: WatchOptions\n ): Promise<SerializableResults | void> {\n if (!watchOpts.compile) return undefined;\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 {\n initiator: watchOpts.initiator || CompilationInitiator.ComponentChanged,\n deleteDistDir,\n generateTypes: watchOpts.generateTypes,\n },\n true\n );\n return {\n results: buildResults,\n toString() {\n return formatCompileResults(buildResults, watchOpts.verbose);\n },\n };\n }\n\n async onPreWatch(componentIds: ComponentID[], watchOpts: WatchOptions) {\n if (watchOpts.preCompile) {\n const start = Date.now();\n this.logger.console(`compiling ${componentIds.length} components`);\n await this.compileComponents(\n componentIds.map((id) => id),\n { initiator: CompilationInitiator.PreWatch, generateTypes: watchOpts.generateTypes }\n );\n const end = Date.now() - start;\n this.logger.consoleSuccess(`compiled ${componentIds.length} components successfully (${end / 1000} sec)`);\n }\n }\n\n async compileComponents(\n componentsIds: string[] | ComponentID[] | ComponentID[], // when empty, it compiles new+modified (unless options.all is set),\n options: CompileOptions,\n noThrow?: boolean,\n componentLoadOptions: WorkspaceComponentLoadOptions = {},\n graph?: CompIdGraph\n ): Promise<BuildResult[]> {\n if (!this.workspace) throw new OutsideWorkspaceError();\n const componentIds = await this.getIdsToCompile(componentsIds, options.changed);\n // In case the aspect failed to load, we want to compile it without try to re-load it again\n if (options.initiator === CompilationInitiator.AspectLoadFail) {\n componentLoadOptions.loadSeedersAsAspects = false;\n }\n let components = await this.workspace.getMany(componentIds, componentLoadOptions);\n await this.loadExternalEnvs(components);\n // reload components as we might cleared the cache as part of the loadExternalEnvs\n components = await this.workspace.getMany(componentIds, componentLoadOptions);\n const grouped = await this.buildGroupsToCompile(components, graph);\n\n const results = await mapSeries(grouped, async (group) => {\n return this.runCompileComponents(group.components, options, noThrow);\n });\n const linkComponents = options.linkComponents ?? true;\n if (linkComponents) {\n await linkToNodeModulesByComponents(components, this.workspace);\n }\n return results.flat();\n }\n\n /**\n * This will ensue that the envs of the components are loaded before the compilation starts.\n * @param components\n */\n private async loadExternalEnvs(components: Component[]) {\n const componentsIdsStr = components.map((c) => c.id.toString());\n const envIdsCompIdsMap = {};\n const compsWithWrongEnvId: string[] = [];\n await Promise.all(\n components.map(async (component) => {\n // It's important to use calculate here to get the real id even if it's not loaded\n const envId = (await this.envs.calculateEnvId(component)).toString();\n // This might be different from the env id above, because the component might be loaded before the env\n // in that case we will need to clear the cache of that component\n const envIdByGet = this.envs.getEnvId(component);\n if (envId !== envIdByGet) {\n compsWithWrongEnvId.push(component.id.toString());\n }\n // If it's part of the components it will be handled later as it's not external\n // and might need to be compiled as well\n if (componentsIdsStr.includes(envId)) return undefined;\n if (!envIdsCompIdsMap[envId]) envIdsCompIdsMap[envId] = [component.id.toString()];\n envIdsCompIdsMap[envId].push(component.id.toString());\n })\n );\n const externalEnvsIds = Object.keys(envIdsCompIdsMap);\n\n if (!externalEnvsIds.length) return;\n const nonLoadedEnvs = externalEnvsIds.filter((envId) => !this.envs.isEnvRegistered(envId));\n await this.workspace.loadAspects(nonLoadedEnvs);\n const idsToClearCache: string[] = uniq(\n nonLoadedEnvs\n .reduce((acc, envId) => {\n const compIds = envIdsCompIdsMap[envId];\n return [...acc, ...compIds];\n }, [] as string[])\n .concat(compsWithWrongEnvId)\n );\n this.workspace.clearComponentsCache(idsToClearCache.map((id) => ComponentID.fromString(id)));\n }\n\n private async runCompileComponents(\n components: Component[],\n options: CompileOptions,\n noThrow?: boolean\n ): Promise<BuildResult[]> {\n const componentsCompilers: ComponentCompiler[] = [];\n const skipped: BuildResult[] = [];\n\n components.forEach((c) => {\n const env = this.envs.getOrCalculateEnv(c);\n const environment = env.env;\n const compilerInstance = environment.getCompiler?.();\n\n if (compilerInstance) {\n const compilerName = compilerInstance.constructor.name || 'compiler';\n componentsCompilers.push(\n new ComponentCompiler(this.pubsub, this.workspace, c, compilerInstance, compilerName, this.logger, env)\n );\n } else {\n this.logger.warn(`unable to find a compiler instance for ${c.id.toString()}`);\n skipped.push({\n component: c.id.toString(),\n buildResults: [],\n errors: [],\n skipped: { reason: `the env \"${env.id}\" provides no compiler` },\n });\n }\n });\n\n const typeGeneratorParamsPerEnv = options.generateTypes\n ? await this.getTypesCompilerPerEnv(componentsCompilers)\n : undefined;\n\n if (typeGeneratorParamsPerEnv) {\n await this.preGenerateTypesOnWorkspace(typeGeneratorParamsPerEnv);\n }\n\n const resultOnWorkspace = await mapSeries(componentsCompilers, (componentCompiler) =>\n componentCompiler.compile(noThrow, options)\n );\n\n if (typeGeneratorParamsPerEnv) {\n await this.generateTypesOnWorkspace(typeGeneratorParamsPerEnv, componentsCompilers);\n }\n\n return [...resultOnWorkspace, ...skipped];\n }\n\n private async getTypesCompilerPerEnv(componentsCompilers: ComponentCompiler[]): Promise<TypeGeneratorParamsPerEnv[]> {\n const envsMap: { [envId: string]: ComponentCompiler[] } = {};\n componentsCompilers.forEach((componentCompiler) => {\n const envId = componentCompiler.env.id;\n if (!envsMap[envId]) envsMap[envId] = [];\n envsMap[envId].push(componentCompiler);\n });\n\n const results = await mapSeries(Object.keys(envsMap), async (envId) => {\n const componentCompilers = envsMap[envId];\n const compParams = await Promise.all(\n componentCompilers.map(async (componentCompiler) => {\n return {\n component: componentCompiler.component,\n packageDir: path.join(this.workspace.path, componentCompiler.getPackageDir()),\n };\n })\n );\n\n let typeCompiler = componentCompilers[0].compilerInstance;\n if (!typeCompiler.preGenerateTypesOnWorkspace) {\n const buildPipe = componentCompilers[0].env.env.getBuildPipe();\n const compilerTasks = buildPipe.filter((task) => task.aspectId === CompilerAspect.id);\n const tsTask = compilerTasks.find(\n (task) => task.compilerInstance && task.compilerInstance.displayName === 'TypeScript'\n );\n if (!tsTask) return;\n typeCompiler = tsTask.compilerInstance;\n if (!typeCompiler.preGenerateTypesOnWorkspace) return;\n }\n return { envId, compParams, typeCompiler };\n });\n return compact(results);\n }\n\n private async preGenerateTypesOnWorkspace(typesGeneratorParamsPerEnv: TypeGeneratorParamsPerEnv[]) {\n await mapSeries(typesGeneratorParamsPerEnv, async ({ envId, compParams, typeCompiler }) => {\n await typeCompiler.preGenerateTypesOnWorkspace!(compParams, envId);\n });\n }\n\n private async generateTypesOnWorkspace(\n typesGeneratorParamsPerEnv: TypeGeneratorParamsPerEnv[],\n componentsCompilers: ComponentCompiler[]\n ) {\n await mapSeries(typesGeneratorParamsPerEnv, async ({ compParams, typeCompiler }) => {\n await typeCompiler.generateTypesOnWorkspace!(path.join(this.workspace.path, 'node_modules'), compParams);\n });\n await Promise.all(componentsCompilers.map((componentCompiler) => componentCompiler.copyTypesToOtherDists()));\n }\n\n /**\n * This function groups the components to compile into groups by their environment and dependencies.\n * The order of the groups is important, the first group should be compiled first.\n * The order inside the group is not important.\n * The groups are:\n * 1. dependencies of envs of envs.\n * 2. envs of envs.\n * 3. dependencies of envs.\n * 4. envs.\n * 5. the rest.\n * @param ids\n */\n async buildGroupsToCompile(\n components: Component[],\n graph?: CompIdGraph\n ): Promise<\n Array<{\n components: Component[];\n envsOfEnvs?: boolean;\n envs?: boolean;\n depsOfEnvsOfEnvs?: boolean;\n depsOfEnvs?: boolean;\n other?: boolean;\n }>\n > {\n const envCompIds = await Promise.all(\n components\n // .map((component) => this.envs.getEnvId(component))\n .map(async (component) => {\n const envId = await this.envs.calculateEnvId(component);\n return envId.toString();\n })\n );\n const envsIds = uniq(envCompIds);\n const groupedByIsEnv = groupBy(components, (component) => {\n if (envsIds.includes(component.id.toString())) return 'envs';\n if (this.envs.isEnv(component)) return 'envs';\n return 'other';\n });\n const envsOfEnvsCompIds = await Promise.all(\n (groupedByIsEnv.envs || [])\n // .map((component) => this.envs.getEnvId(component))\n .map(async (component) => (await this.envs.calculateEnvId(component)).toString())\n );\n const groupedByEnvsOfEnvs = groupBy(groupedByIsEnv.envs, (component) => {\n if (envsOfEnvsCompIds.includes(component.id.toString())) return 'envsOfEnvs';\n return 'otherEnvs';\n });\n const envsOfEnvsWithoutCoreCompIds = envsOfEnvsCompIds.filter((id) => !this.envs.isCoreEnv(id));\n let depsOfEnvsOfEnvsCompIds: string[] = [];\n if (graph) {\n const subGraph = graph.successorsSubgraph(envsOfEnvsWithoutCoreCompIds, {\n nodeFilter: (node) => this.workspace.hasId(node.attr),\n });\n depsOfEnvsOfEnvsCompIds = subGraph.nodes.map((n) => n.id);\n } else {\n const depsOfEnvsOfEnvsCompLists = (groupedByEnvsOfEnvs.envsOfEnvs || []).map((envComp) =>\n this.dependencyResolver.getDependencies(envComp)\n );\n depsOfEnvsOfEnvsCompIds = DependencyList.merge(depsOfEnvsOfEnvsCompLists)\n .getComponentDependencies()\n .map((dep) => dep.id.toString());\n }\n const groupedByIsDepsOfEnvsOfEnvs = groupBy(groupedByIsEnv.other, (component) => {\n if (depsOfEnvsOfEnvsCompIds.includes(component.id.toString())) return 'depsOfEnvsOfEnvs';\n return 'other';\n });\n let depsOfEnvsOfCompIds: string[] = [];\n if (graph) {\n const otherEnvsIds = (groupedByEnvsOfEnvs.otherEnvs || []).map((c) => c.id.toString());\n if (otherEnvsIds.length) {\n const otherEnvsWithoutCoreIds = otherEnvsIds.filter((id) => !this.envs.isCoreEnv(id));\n const subGraph = graph.successorsSubgraph(otherEnvsWithoutCoreIds, {\n nodeFilter: (node) => this.workspace.hasId(node.attr),\n });\n depsOfEnvsOfCompIds = subGraph.nodes.map((n) => n.id);\n }\n } else {\n const depsOfEnvsCompLists = (groupedByEnvsOfEnvs.otherEnvs || []).map((envComp) =>\n this.dependencyResolver.getDependencies(envComp)\n );\n depsOfEnvsOfCompIds = DependencyList.merge(depsOfEnvsCompLists)\n .getComponentDependencies()\n .map((dep) => dep.id.toString());\n }\n const groupedByIsDepsOfEnvs = groupBy(groupedByIsDepsOfEnvsOfEnvs.other, (component) => {\n if (depsOfEnvsOfCompIds.includes(component.id.toString())) return 'depsOfEnvs';\n return 'other';\n });\n return [\n {\n components: groupedByIsDepsOfEnvsOfEnvs.depsOfEnvsOfEnvs || [],\n depsOfEnvsOfEnvs: true,\n },\n {\n components: groupedByEnvsOfEnvs.envsOfEnvs || [],\n envsOfEnvs: true,\n },\n {\n components: groupedByIsDepsOfEnvs.depsOfEnvs || [],\n depsOfEnvs: true,\n },\n {\n components: groupedByEnvsOfEnvs.otherEnvs || [],\n envs: true,\n },\n {\n components: groupedByIsDepsOfEnvs.other || [],\n other: true,\n },\n ];\n }\n\n private async getIdsToCompile(componentsIds: Array<string | ComponentID>, changed = false): 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.listIds();\n }\n}\n\nfunction formatCompileResults(buildResults: BuildResult[], verbose?: boolean) {\n // this gets called when a file is changed, so the buildResults array always has only one item\n const buildResult = buildResults.find((result) => !result.skipped);\n if (!buildResult) return '';\n const title = ` ${chalk.underline('STATUS\\tCOMPONENT ID')}`;\n const verboseComponentFilesArrayToString = () => {\n return buildResult.buildResults.map((filePath) => ` \\t - ${filePath}`).join('\\n');\n };\n\n return `${title}\n ${Logger.successSymbol()}SUCCESS\\t${buildResult.component}\\n\n ${verbose ? `${verboseComponentFilesArrayToString()}\\n` : ''}`;\n}\n"],"mappings":";;;;;;AACA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAIA,SAAAK,WAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,UAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAM,MAAA;EAAA,MAAAN,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAI,KAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,OAAA;EAAA,MAAAP,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAK,MAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,aAAA;EAAA,MAAAR,IAAA,GAAAE,OAAA;EAAAM,YAAA,YAAAA,CAAA;IAAA,OAAAR,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAS,QAAA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oreList":[]}
|
|
1
|
+
{"version":3,"names":["_pMapSeries","data","_interopRequireDefault","require","_globby","_fsExtra","_workspace","_path","_chalk","_componentId","_logger","_legacy","_component","_workspaceModules","_dependencyResolver","_pkgModules","_workspace2","_lodash","_compiler","_events","_types","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ComponentCompiler","constructor","pubsub","workspace","component","compilerInstance","compilerId","logger","env","dists","compileErrors","compile","noThrow","options","dataToPersist","deleteDistDir","distDirs","relativeDistDirs","filter","distDir","path","isAbsolute","absoluteDistDirs","length","DataToPersist","removePath","RemovePath","addBasePath","persistAllToFS","Promise","all","map","fs","remove","compilers","canTranspileFile","find","c","transpileFile","canTranspileComponent","transpileComponent","filesystem","files","file","compileOneFile","initiator","compileAllFiles","Error","toString","throwOnCompileErrors","relativeDists","distFile","absoluteDists","addManyFiles","write","buildResults","state","_consumer","compiler","consoleSuccess","id","errors","getPackageDir","packageName","componentIdToPackageName","join","toAbsolutePath","pathToResolve","forEach","errorItem","error","formatError","err","pub","CompilerAspect","CompilerErrorEvent","console","message","packageDir","distDirName","getDistDir","DEFAULT_DIST_DIRNAME","injectedDirs","getInjectedDirs","dist","rootDirs","readRootComponentsDir","rootComponentsPath","rootDir","relative","componentDir","copyTypesToOtherDists","packageDistDir","otherDirs","slice","packageDistDirAbs","matches","globby","cwd","onlyFiles","ignore","distDirAbs","match","source","dest","copyFile","copyCompiledFilesToOtherDists","outputDir","getComponentPackagePath","sourceDistDirAbs","pathExists","dir","resolve","ensureDir","dirname","filePath","isFileSupported","compileResults","contents","push","base","result","Dist","outputPath","Buffer","from","outputText","shouldCopyNonSupportedFiles","filesToCompile","exports","WorkspaceCompiler","envs","aspectLoader","ui","dependencyResolver","watcher","Set","registerOnComponentChange","onComponentChange","bind","registerOnComponentAdd","onComponentAdd","registerOnPreWatch","onPreWatch","registerPreStart","onPreStart","registerOnAspectLoadErrorSlot","onAspectLoadFail","preStartOpts","skipCompilation","compileComponents","changed","verbose","CompilationInitiator","PreStart","watchScopeInternalFiles","code","includes","inInstallContext","inInstallAfterPmContext","shouldCompile","idStr","hasId","ignoreVersion","debug","componentsBeingProcessedInOnAspectLoadFail","has","add","graph","successors","getEnvDepsGraph","depsIds","s","AspectLoadFail","loadExtensions","executeLoadSlot","delete","envComponentId","getGraphIds","nodeFilter","node","attr","watchOpts","undefined","removedFiles","Boolean","removeLinksFromNodeModules","ComponentChanged","generateTypes","results","formatCompileResults","componentIds","preCompile","start","Date","now","PreWatch","end","componentsIds","componentLoadOptions","OutsideWorkspaceError","getIdsToCompile","loadSeedersAsAspects","components","getMany","loadExternalEnvs","grouped","buildGroupsToCompile","mapSeries","group","runCompileComponents","linkComponents","linkToNodeModulesByComponents","flat","componentsIdsStr","envIdsCompIdsMap","compsWithWrongEnvId","envId","calculateEnvId","envIdByGet","getEnvId","externalEnvsIds","keys","nonLoadedEnvs","isEnvRegistered","loadAspects","idsToClearCache","uniq","reduce","acc","compIds","concat","clearComponentsCache","ComponentID","fromString","componentsCompilers","skipped","getOrCalculateEnv","environment","getCompiler","compilerName","name","warn","reason","typeGeneratorParamsPerEnv","getTypesCompilerPerEnv","preGenerateTypesOnWorkspace","resultOnWorkspace","componentCompiler","generateTypesOnWorkspace","envsMap","componentCompilers","compParams","typeCompiler","buildPipe","getBuildPipe","compilerTasks","task","aspectId","tsTask","displayName","compact","typesGeneratorParamsPerEnv","envCompIds","envsIds","groupedByIsEnv","groupBy","isEnv","envsOfEnvsCompIds","groupedByEnvsOfEnvs","envsOfEnvsWithoutCoreCompIds","isCoreEnv","depsOfEnvsOfEnvsCompIds","envsOfEnvsOnGraph","hasNode","subGraph","successorsSubgraph","nodes","n","depsOfEnvsOfEnvsCompLists","envsOfEnvs","envComp","getDependencies","DependencyList","merge","getComponentDependencies","dep","groupedByIsDepsOfEnvsOfEnvs","other","depsOfEnvsOfCompIds","otherEnvsIds","otherEnvs","otherEnvsWithoutCoreIds","depsOfEnvsCompLists","groupedByIsDepsOfEnvs","depsOfEnvsOfEnvs","depsOfEnvs","resolveMultipleComponentIds","filterIds","getNewAndModifiedIds","listIds","buildResult","title","chalk","underline","verboseComponentFilesArrayToString","Logger","successSymbol"],"sources":["workspace-compiler.ts"],"sourcesContent":["/* eslint-disable max-classes-per-file */\nimport mapSeries from 'p-map-series';\nimport globby from 'globby';\nimport fs from 'fs-extra';\nimport type { Component } from '@teambit/component';\nimport type { EnvDefinition, EnvsMain } from '@teambit/envs';\nimport type { PubsubMain } from '@teambit/pubsub';\nimport { OutsideWorkspaceError } from '@teambit/workspace';\nimport type { WorkspaceComponentLoadOptions, SerializableResults, Workspace } from '@teambit/workspace';\nimport type { WatcherMain, WatchOptions } from '@teambit/watcher';\nimport path from 'path';\nimport chalk from 'chalk';\nimport { ComponentID } from '@teambit/component-id';\nimport { Logger } from '@teambit/logger';\nimport { DEFAULT_DIST_DIRNAME } from '@teambit/legacy.constants';\nimport type { AbstractVinyl } from '@teambit/component.sources';\nimport { Dist, DataToPersist, RemovePath } from '@teambit/component.sources';\nimport {\n linkToNodeModulesByComponents,\n removeLinksFromNodeModules,\n} from '@teambit/workspace.modules.node-modules-linker';\nimport type { AspectLoaderMain } from '@teambit/aspect-loader';\nimport type { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { DependencyList } from '@teambit/dependency-resolver';\nimport type { PathOsBasedAbsolute } from '@teambit/toolbox.path.path';\nimport { componentIdToPackageName } from '@teambit/pkg.modules.component-package-name';\nimport type { UiMain, PreStartOpts } from '@teambit/ui';\nimport { readRootComponentsDir } from '@teambit/workspace.root-components';\nimport { compact, groupBy, uniq } from 'lodash';\nimport type { MultiCompiler } from '@teambit/multi-compiler';\nimport type { CompIdGraph } from '@teambit/graph';\nimport { CompilerAspect } from './compiler.aspect';\nimport { CompilerErrorEvent } from './events';\nimport type { Compiler, TypeGeneratorCompParams } from './types';\nimport { CompilationInitiator } from './types';\n\nexport type BuildResult = {\n component: string;\n buildResults: string[];\n errors: CompileError[];\n /**\n * set when nothing was compiled for the component because its env provides no compiler. such a\n * component is neither a success nor a failure, so it is counted and reported on its own.\n */\n skipped?: { reason: string };\n};\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 // should we create links in node_modules for the compiled components (default = true)\n // this will link the source files, and create the package.json\n linkComponents?: boolean;\n /**\n * whether to generate types after the compilation, default = false.\n * keep in mind that it's a heavy operation, and hurts the performance.\n */\n generateTypes?: boolean;\n};\n\nexport type CompileError = { path: string; error: Error };\n\nexport class ComponentCompiler {\n constructor(\n private pubsub: PubsubMain,\n private workspace: Workspace,\n readonly component: Component,\n readonly compilerInstance: Compiler,\n private compilerId: string,\n private logger: Logger,\n readonly env: EnvDefinition,\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 const distDirs = await this.distDirs();\n // delete dist folder before transpilation (because some compilers (like ngPackagr) can generate files there during the compilation process)\n if (deleteDistDir) {\n const relativeDistDirs = distDirs.filter((distDir) => !path.isAbsolute(distDir));\n const absoluteDistDirs = distDirs.filter((distDir) => path.isAbsolute(distDir));\n if (relativeDistDirs.length) {\n dataToPersist = new DataToPersist();\n for (const distDir of relativeDistDirs) {\n dataToPersist.removePath(new RemovePath(distDir));\n }\n dataToPersist.addBasePath(this.workspace.path);\n await dataToPersist.persistAllToFS();\n }\n await Promise.all(absoluteDistDirs.map((distDir) => fs.remove(distDir)));\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) =>\n this.compileOneFile(file, options.initiator, distDirs)\n )\n );\n }\n\n if (canTranspileComponent) {\n await this.compileAllFiles(options.initiator, distDirs);\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 const relativeDists = this.dists.filter((distFile) => !path.isAbsolute(distFile.path));\n const absoluteDists = this.dists.filter((distFile) => path.isAbsolute(distFile.path));\n if (relativeDists.length) {\n dataToPersist = new DataToPersist();\n dataToPersist.addManyFiles(relativeDists);\n dataToPersist.addBasePath(this.workspace.path);\n await dataToPersist.persistAllToFS();\n }\n await Promise.all(absoluteDists.map((distFile) => distFile.write()));\n const buildResults = this.dists.map((distFile) => distFile.path);\n if (this.component.state._consumer.compiler) this.logger.consoleSuccess();\n\n return { component: this.component.id.toString(), buildResults, errors: this.compileErrors };\n }\n\n getPackageDir() {\n const packageName = componentIdToPackageName(this.component.state._consumer);\n return path.join('node_modules', packageName);\n }\n\n private toAbsolutePath(pathToResolve: string): string {\n return path.isAbsolute(pathToResolve) ? pathToResolve : path.join(this.workspace.path, pathToResolve);\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<string[]> {\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 injectedDirs = await this.workspace.getInjectedDirs(this.component);\n if (injectedDirs.length > 0) return injectedDirs;\n\n const rootDirs = await readRootComponentsDir(this.workspace.rootComponentsPath);\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 async copyTypesToOtherDists() {\n const distDirs = await this.distDirs();\n if (distDirs.length <= 1) return;\n const packageDistDir = distDirs[0];\n const otherDirs = distDirs.slice(1);\n const packageDistDirAbs = this.toAbsolutePath(packageDistDir);\n const matches = await globby(`**/*.d.ts`, {\n cwd: packageDistDirAbs,\n onlyFiles: true,\n ignore: [`${packageDistDir}/node_modules/`],\n });\n if (!matches.length) return;\n await Promise.all(\n otherDirs.map(async (distDir) => {\n const distDirAbs = this.toAbsolutePath(distDir);\n await Promise.all(\n matches.map(async (match) => {\n const source = path.join(packageDistDirAbs, match);\n const dest = path.join(distDirAbs, match);\n await fs.copyFile(source, dest);\n })\n );\n })\n );\n }\n\n /**\n * Copy all compiled files from the outputDir (where the compiler wrote) to all other dist directories.\n * This is needed for compilers that use transpileComponent and write directly to the filesystem,\n * as they only receive one outputDir but files need to be available in all dist locations.\n */\n async copyCompiledFilesToOtherDists() {\n const distDirs = await this.distDirs();\n if (distDirs.length <= 1) return;\n\n // The compiler writes to the outputDir from getComponentPackagePath + distDirName\n const outputDir = await this.workspace.getComponentPackagePath(this.component);\n const distDirName = this.compilerInstance.getDistDir?.() || DEFAULT_DIST_DIRNAME;\n const sourceDistDirAbs = path.join(outputDir, distDirName);\n\n // Check if the dist directory exists (compiler may not have written anything)\n if (!(await fs.pathExists(sourceDistDirAbs))) return;\n\n const otherDirs = distDirs.filter(\n (dir) => path.resolve(this.toAbsolutePath(dir)) !== path.resolve(sourceDistDirAbs)\n );\n\n if (!otherDirs.length) return;\n\n const matches = await globby(`**/*`, {\n cwd: sourceDistDirAbs,\n onlyFiles: true,\n ignore: ['node_modules/**'],\n });\n if (!matches.length) return;\n\n await Promise.all(\n otherDirs.map(async (distDir) => {\n const distDirAbs = this.toAbsolutePath(distDir);\n await Promise.all(\n matches.map(async (match) => {\n const source = path.join(sourceDistDirAbs, match);\n const dest = path.join(distDirAbs, match);\n try {\n await fs.ensureDir(path.dirname(dest));\n await fs.copyFile(source, dest);\n } catch (err: any) {\n throw new Error(`failed to copy compiled file from \"${source}\" to \"${dest}\": ${err.message}`);\n }\n })\n );\n })\n );\n }\n\n private async compileOneFile(\n file: AbstractVinyl,\n initiator: CompilationInitiator,\n distDirs: string[]\n ): 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 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(initiator: CompilationInitiator, distDirs: string[]): Promise<void> {\n const filesToCompile: AbstractVinyl[] = [];\n for (const base of distDirs) {\n this.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: this.component,\n componentDir: this.componentDir,\n outputDir: await this.workspace.getComponentPackagePath(this.component),\n initiator,\n });\n // Copy compiled files to all other dist directories (injected dirs)\n await this.copyCompiledFilesToOtherDists();\n } catch (error: any) {\n this.compileErrors.push({ path: this.componentDir, error });\n }\n }\n }\n}\n\ntype TypeGeneratorParamsPerEnv = { envId: string; compParams: TypeGeneratorCompParams[]; typeCompiler: Compiler };\n\nexport class WorkspaceCompiler {\n private componentsBeingProcessedInOnAspectLoadFail = new Set<string>();\n\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.onComponentAdd.bind(this));\n this.watcher.registerOnPreWatch(this.onPreWatch.bind(this));\n }\n this.ui.registerPreStart(this.onPreStart.bind(this));\n if (this.aspectLoader) {\n this.aspectLoader.registerOnAspectLoadErrorSlot(this.onAspectLoadFail.bind(this));\n }\n }\n\n async onPreStart(preStartOpts: PreStartOpts): Promise<void> {\n if (this.workspace) {\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 } else {\n await this.watcher.watchScopeInternalFiles();\n }\n }\n\n async onAspectLoadFail(err: Error & { code?: string }, component: Component): Promise<boolean> {\n if (\n ((err.code &&\n (err.code === 'MODULE_NOT_FOUND' ||\n err.code === 'ERR_MODULE_NOT_FOUND' ||\n err.code === 'ERR_REQUIRE_ESM' ||\n // node refuses to load .ts files from node_modules. happens when the loaded instance\n // has only the component sources (e.g. re-created by the package manager mid-install)\n // and compiling the component fixes it, same as a missing-module failure\n err.code === 'ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING')) ||\n err.message.includes('import.meta') ||\n err.message.includes('exports is not defined')) &&\n this.workspace\n ) {\n const inInstallContext = this.workspace.inInstallContext;\n const inInstallAfterPmContext = this.workspace.inInstallAfterPmContext;\n // If we are now running install we only want to compile after the package manager is done\n const shouldCompile = (inInstallContext && inInstallAfterPmContext) || !inInstallContext;\n if (shouldCompile) {\n const id = component.id;\n const idStr = id.toString();\n\n // compiling can only fix a workspace component whose dists are missing or stale. when the\n // failed aspect is not in the workspace (e.g. an env that used to be a core aspect,\n // resolved to its pinned version but not installed yet), the cascade below imports the\n // env's full dependency closure from the remote and recompiles a large part of the\n // workspace into every injected node_modules copy - minutes of work that cannot\n // materialize the missing package. skip it and let the regular missing-aspect handling\n // report it (a NonLoadedEnv issue with a \"bit install\" remediation).\n if (!this.workspace.hasId(id, { ignoreVersion: true })) {\n this.logger.debug(\n `onAspectLoadFail: skipping compilation of ${idStr} - not a workspace component, compiling cannot fix its missing module`\n );\n return false;\n }\n\n // Prevent infinite loop when there's a circular dependency between an env and a component.\n // If we're already processing this component, don't re-enter.\n if (this.componentsBeingProcessedInOnAspectLoadFail.has(idStr)) {\n this.logger.debug(\n `onAspectLoadFail: skipping ${idStr} as it's already being processed (preventing infinite loop)`\n );\n return false;\n }\n\n this.componentsBeingProcessedInOnAspectLoadFail.add(idStr);\n try {\n const { graph, successors } = await this.getEnvDepsGraph(id);\n // const deps = this.dependencyResolver.getDependencies(component);\n // const depsIds = deps.getComponentDependencies().map((dep) => {\n // return dep.id.toString();\n // });\n const depsIds = successors.map((s) => s.id);\n await this.compileComponents(\n [id.toString(), ...depsIds],\n { initiator: CompilationInitiator.AspectLoadFail },\n true,\n { loadExtensions: true, executeLoadSlot: true },\n graph\n );\n return true;\n } finally {\n this.componentsBeingProcessedInOnAspectLoadFail.delete(idStr);\n }\n }\n }\n return false;\n }\n\n async getEnvDepsGraph(envComponentId: ComponentID): Promise<{ graph: CompIdGraph; successors: { id: string }[] }> {\n const graph = await this.workspace.getGraphIds([envComponentId]);\n const successors = graph.successors(envComponentId.toString(), {\n nodeFilter: (node) => this.workspace.hasId(node.attr),\n });\n return { graph, successors };\n }\n\n async onComponentAdd(component: Component, files: string[], watchOpts: WatchOptions) {\n return this.onComponentChange(component, files, undefined, watchOpts);\n }\n\n async onComponentChange(\n component: Component,\n files: string[],\n removedFiles: string[] = [],\n watchOpts: WatchOptions\n ): Promise<SerializableResults | void> {\n if (!watchOpts.compile) return undefined;\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 {\n initiator: watchOpts.initiator || CompilationInitiator.ComponentChanged,\n deleteDistDir,\n generateTypes: watchOpts.generateTypes,\n },\n true\n );\n return {\n results: buildResults,\n toString() {\n return formatCompileResults(buildResults, watchOpts.verbose);\n },\n };\n }\n\n async onPreWatch(componentIds: ComponentID[], watchOpts: WatchOptions) {\n if (watchOpts.preCompile) {\n const start = Date.now();\n this.logger.console(`compiling ${componentIds.length} components`);\n await this.compileComponents(\n componentIds.map((id) => id),\n { initiator: CompilationInitiator.PreWatch, generateTypes: watchOpts.generateTypes }\n );\n const end = Date.now() - start;\n this.logger.consoleSuccess(`compiled ${componentIds.length} components successfully (${end / 1000} sec)`);\n }\n }\n\n async compileComponents(\n componentsIds: string[] | ComponentID[] | ComponentID[], // when empty, it compiles new+modified (unless options.all is set),\n options: CompileOptions,\n noThrow?: boolean,\n componentLoadOptions: WorkspaceComponentLoadOptions = {},\n graph?: CompIdGraph\n ): Promise<BuildResult[]> {\n if (!this.workspace) throw new OutsideWorkspaceError();\n const componentIds = await this.getIdsToCompile(componentsIds, options.changed);\n // In case the aspect failed to load, we want to compile it without try to re-load it again\n if (options.initiator === CompilationInitiator.AspectLoadFail) {\n componentLoadOptions.loadSeedersAsAspects = false;\n }\n let components = await this.workspace.getMany(componentIds, componentLoadOptions);\n await this.loadExternalEnvs(components);\n // reload components as we might cleared the cache as part of the loadExternalEnvs\n components = await this.workspace.getMany(componentIds, componentLoadOptions);\n const grouped = await this.buildGroupsToCompile(components, graph);\n\n const results = await mapSeries(grouped, async (group) => {\n return this.runCompileComponents(group.components, options, noThrow);\n });\n const linkComponents = options.linkComponents ?? true;\n if (linkComponents) {\n await linkToNodeModulesByComponents(components, this.workspace);\n }\n return results.flat();\n }\n\n /**\n * This will ensue that the envs of the components are loaded before the compilation starts.\n * @param components\n */\n private async loadExternalEnvs(components: Component[]) {\n const componentsIdsStr = components.map((c) => c.id.toString());\n const envIdsCompIdsMap = {};\n const compsWithWrongEnvId: string[] = [];\n await Promise.all(\n components.map(async (component) => {\n // It's important to use calculate here to get the real id even if it's not loaded\n const envId = (await this.envs.calculateEnvId(component)).toString();\n // This might be different from the env id above, because the component might be loaded before the env\n // in that case we will need to clear the cache of that component\n const envIdByGet = this.envs.getEnvId(component);\n if (envId !== envIdByGet) {\n compsWithWrongEnvId.push(component.id.toString());\n }\n // If it's part of the components it will be handled later as it's not external\n // and might need to be compiled as well\n if (componentsIdsStr.includes(envId)) return undefined;\n if (!envIdsCompIdsMap[envId]) envIdsCompIdsMap[envId] = [component.id.toString()];\n envIdsCompIdsMap[envId].push(component.id.toString());\n })\n );\n const externalEnvsIds = Object.keys(envIdsCompIdsMap);\n\n if (!externalEnvsIds.length) return;\n const nonLoadedEnvs = externalEnvsIds.filter((envId) => !this.envs.isEnvRegistered(envId));\n await this.workspace.loadAspects(nonLoadedEnvs);\n const idsToClearCache: string[] = uniq(\n nonLoadedEnvs\n .reduce((acc, envId) => {\n const compIds = envIdsCompIdsMap[envId];\n return [...acc, ...compIds];\n }, [] as string[])\n .concat(compsWithWrongEnvId)\n );\n this.workspace.clearComponentsCache(idsToClearCache.map((id) => ComponentID.fromString(id)));\n }\n\n private async runCompileComponents(\n components: Component[],\n options: CompileOptions,\n noThrow?: boolean\n ): Promise<BuildResult[]> {\n const componentsCompilers: ComponentCompiler[] = [];\n const skipped: BuildResult[] = [];\n\n components.forEach((c) => {\n const env = this.envs.getOrCalculateEnv(c);\n const environment = env.env;\n const compilerInstance = environment.getCompiler?.();\n\n if (compilerInstance) {\n const compilerName = compilerInstance.constructor.name || 'compiler';\n componentsCompilers.push(\n new ComponentCompiler(this.pubsub, this.workspace, c, compilerInstance, compilerName, this.logger, env)\n );\n } else {\n this.logger.warn(`unable to find a compiler instance for ${c.id.toString()}`);\n skipped.push({\n component: c.id.toString(),\n buildResults: [],\n errors: [],\n skipped: { reason: `the env \"${env.id}\" provides no compiler` },\n });\n }\n });\n\n const typeGeneratorParamsPerEnv = options.generateTypes\n ? await this.getTypesCompilerPerEnv(componentsCompilers)\n : undefined;\n\n if (typeGeneratorParamsPerEnv) {\n await this.preGenerateTypesOnWorkspace(typeGeneratorParamsPerEnv);\n }\n\n const resultOnWorkspace = await mapSeries(componentsCompilers, (componentCompiler) =>\n componentCompiler.compile(noThrow, options)\n );\n\n if (typeGeneratorParamsPerEnv) {\n await this.generateTypesOnWorkspace(typeGeneratorParamsPerEnv, componentsCompilers);\n }\n\n return [...resultOnWorkspace, ...skipped];\n }\n\n private async getTypesCompilerPerEnv(componentsCompilers: ComponentCompiler[]): Promise<TypeGeneratorParamsPerEnv[]> {\n const envsMap: { [envId: string]: ComponentCompiler[] } = {};\n componentsCompilers.forEach((componentCompiler) => {\n const envId = componentCompiler.env.id;\n if (!envsMap[envId]) envsMap[envId] = [];\n envsMap[envId].push(componentCompiler);\n });\n\n const results = await mapSeries(Object.keys(envsMap), async (envId) => {\n const componentCompilers = envsMap[envId];\n const compParams = await Promise.all(\n componentCompilers.map(async (componentCompiler) => {\n return {\n component: componentCompiler.component,\n packageDir: path.join(this.workspace.path, componentCompiler.getPackageDir()),\n };\n })\n );\n\n let typeCompiler = componentCompilers[0].compilerInstance;\n if (!typeCompiler.preGenerateTypesOnWorkspace) {\n const buildPipe = componentCompilers[0].env.env.getBuildPipe();\n const compilerTasks = buildPipe.filter((task) => task.aspectId === CompilerAspect.id);\n const tsTask = compilerTasks.find(\n (task) => task.compilerInstance && task.compilerInstance.displayName === 'TypeScript'\n );\n if (!tsTask) return;\n typeCompiler = tsTask.compilerInstance;\n if (!typeCompiler.preGenerateTypesOnWorkspace) return;\n }\n return { envId, compParams, typeCompiler };\n });\n return compact(results);\n }\n\n private async preGenerateTypesOnWorkspace(typesGeneratorParamsPerEnv: TypeGeneratorParamsPerEnv[]) {\n await mapSeries(typesGeneratorParamsPerEnv, async ({ envId, compParams, typeCompiler }) => {\n await typeCompiler.preGenerateTypesOnWorkspace!(compParams, envId);\n });\n }\n\n private async generateTypesOnWorkspace(\n typesGeneratorParamsPerEnv: TypeGeneratorParamsPerEnv[],\n componentsCompilers: ComponentCompiler[]\n ) {\n await mapSeries(typesGeneratorParamsPerEnv, async ({ compParams, typeCompiler }) => {\n await typeCompiler.generateTypesOnWorkspace!(path.join(this.workspace.path, 'node_modules'), compParams);\n });\n await Promise.all(componentsCompilers.map((componentCompiler) => componentCompiler.copyTypesToOtherDists()));\n }\n\n /**\n * This function groups the components to compile into groups by their environment and dependencies.\n * The order of the groups is important, the first group should be compiled first.\n * The order inside the group is not important.\n * The groups are:\n * 1. dependencies of envs of envs.\n * 2. envs of envs.\n * 3. dependencies of envs.\n * 4. envs.\n * 5. the rest.\n * @param ids\n */\n async buildGroupsToCompile(\n components: Component[],\n graph?: CompIdGraph\n ): Promise<\n Array<{\n components: Component[];\n envsOfEnvs?: boolean;\n envs?: boolean;\n depsOfEnvsOfEnvs?: boolean;\n depsOfEnvs?: boolean;\n other?: boolean;\n }>\n > {\n const envCompIds = await Promise.all(\n components\n // .map((component) => this.envs.getEnvId(component))\n .map(async (component) => {\n const envId = await this.envs.calculateEnvId(component);\n return envId.toString();\n })\n );\n const envsIds = uniq(envCompIds);\n const groupedByIsEnv = groupBy(components, (component) => {\n if (envsIds.includes(component.id.toString())) return 'envs';\n if (this.envs.isEnv(component)) return 'envs';\n return 'other';\n });\n const envsOfEnvsCompIds = await Promise.all(\n (groupedByIsEnv.envs || [])\n // .map((component) => this.envs.getEnvId(component))\n .map(async (component) => (await this.envs.calculateEnvId(component)).toString())\n );\n const groupedByEnvsOfEnvs = groupBy(groupedByIsEnv.envs, (component) => {\n if (envsOfEnvsCompIds.includes(component.id.toString())) return 'envsOfEnvs';\n return 'otherEnvs';\n });\n const envsOfEnvsWithoutCoreCompIds = envsOfEnvsCompIds.filter((id) => !this.envs.isCoreEnv(id));\n let depsOfEnvsOfEnvsCompIds: string[] = [];\n if (graph) {\n // envs installed as packages (e.g. legacy core envs) are not part of the workspace graph\n const envsOfEnvsOnGraph = envsOfEnvsWithoutCoreCompIds.filter((id) => graph.hasNode(id));\n const subGraph = graph.successorsSubgraph(envsOfEnvsOnGraph, {\n nodeFilter: (node) => this.workspace.hasId(node.attr),\n });\n depsOfEnvsOfEnvsCompIds = subGraph.nodes.map((n) => n.id);\n } else {\n const depsOfEnvsOfEnvsCompLists = (groupedByEnvsOfEnvs.envsOfEnvs || []).map((envComp) =>\n this.dependencyResolver.getDependencies(envComp)\n );\n depsOfEnvsOfEnvsCompIds = DependencyList.merge(depsOfEnvsOfEnvsCompLists)\n .getComponentDependencies()\n .map((dep) => dep.id.toString());\n }\n const groupedByIsDepsOfEnvsOfEnvs = groupBy(groupedByIsEnv.other, (component) => {\n if (depsOfEnvsOfEnvsCompIds.includes(component.id.toString())) return 'depsOfEnvsOfEnvs';\n return 'other';\n });\n let depsOfEnvsOfCompIds: string[] = [];\n if (graph) {\n const otherEnvsIds = (groupedByEnvsOfEnvs.otherEnvs || []).map((c) => c.id.toString());\n if (otherEnvsIds.length) {\n const otherEnvsWithoutCoreIds = otherEnvsIds.filter((id) => !this.envs.isCoreEnv(id) && graph.hasNode(id));\n const subGraph = graph.successorsSubgraph(otherEnvsWithoutCoreIds, {\n nodeFilter: (node) => this.workspace.hasId(node.attr),\n });\n depsOfEnvsOfCompIds = subGraph.nodes.map((n) => n.id);\n }\n } else {\n const depsOfEnvsCompLists = (groupedByEnvsOfEnvs.otherEnvs || []).map((envComp) =>\n this.dependencyResolver.getDependencies(envComp)\n );\n depsOfEnvsOfCompIds = DependencyList.merge(depsOfEnvsCompLists)\n .getComponentDependencies()\n .map((dep) => dep.id.toString());\n }\n const groupedByIsDepsOfEnvs = groupBy(groupedByIsDepsOfEnvsOfEnvs.other, (component) => {\n if (depsOfEnvsOfCompIds.includes(component.id.toString())) return 'depsOfEnvs';\n return 'other';\n });\n return [\n {\n components: groupedByIsDepsOfEnvsOfEnvs.depsOfEnvsOfEnvs || [],\n depsOfEnvsOfEnvs: true,\n },\n {\n components: groupedByEnvsOfEnvs.envsOfEnvs || [],\n envsOfEnvs: true,\n },\n {\n components: groupedByIsDepsOfEnvs.depsOfEnvs || [],\n depsOfEnvs: true,\n },\n {\n components: groupedByEnvsOfEnvs.otherEnvs || [],\n envs: true,\n },\n {\n components: groupedByIsDepsOfEnvs.other || [],\n other: true,\n },\n ];\n }\n\n private async getIdsToCompile(componentsIds: Array<string | ComponentID>, changed = false): 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.listIds();\n }\n}\n\nfunction formatCompileResults(buildResults: BuildResult[], verbose?: boolean) {\n // this gets called when a file is changed, so the buildResults array always has only one item\n const buildResult = buildResults.find((result) => !result.skipped);\n if (!buildResult) return '';\n const title = ` ${chalk.underline('STATUS\\tCOMPONENT ID')}`;\n const verboseComponentFilesArrayToString = () => {\n return buildResult.buildResults.map((filePath) => ` \\t - ${filePath}`).join('\\n');\n };\n\n return `${title}\n ${Logger.successSymbol()}SUCCESS\\t${buildResult.component}\\n\n ${verbose ? `${verboseComponentFilesArrayToString()}\\n` : ''}`;\n}\n"],"mappings":";;;;;;AACA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,SAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAIA,SAAAK,WAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,UAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAM,MAAA;EAAA,MAAAN,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAI,KAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAO,OAAA;EAAA,MAAAP,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAK,MAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,aAAA;EAAA,MAAAR,IAAA,GAAAE,OAAA;EAAAM,YAAA,YAAAA,CAAA;IAAA,OAAAR,IAAA;EAAA;EAAA,OAAAA,IAAA;AA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,OAAO,CAAC;EAClE,IAAI,CAACiE,WAAW,EAAE,OAAO,EAAE;EAC3B,MAAMC,KAAK,GAAG,IAAIC,gBAAK,CAACC,SAAS,CAAC,sBAAsB,CAAC,EAAE;EAC3D,MAAMC,kCAAkC,GAAGA,CAAA,KAAM;IAC/C,OAAOJ,WAAW,CAACtP,YAAY,CAACxB,GAAG,CAAEoF,QAAQ,IAAK,SAASA,QAAQ,EAAE,CAAC,CAAClD,IAAI,CAAC,IAAI,CAAC;EACnF,CAAC;EAED,OAAO,GAAG6O,KAAK;AACjB,IAAII,gBAAM,CAACC,aAAa,CAAC,CAAC,YAAYN,WAAW,CAACzS,SAAS;AAC3D,IAAIoJ,OAAO,GAAG,GAAGyJ,kCAAkC,CAAC,CAAC,IAAI,GAAG,EAAE,EAAE;AAChE","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _chai() {
|
|
4
|
+
const data = require("chai");
|
|
5
|
+
_chai = function () {
|
|
6
|
+
return data;
|
|
7
|
+
};
|
|
8
|
+
return data;
|
|
9
|
+
}
|
|
10
|
+
function _componentId() {
|
|
11
|
+
const data = require("@teambit/component-id");
|
|
12
|
+
_componentId = function () {
|
|
13
|
+
return data;
|
|
14
|
+
};
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
function _workspaceCompiler() {
|
|
18
|
+
const data = require("./workspace-compiler");
|
|
19
|
+
_workspaceCompiler = function () {
|
|
20
|
+
return data;
|
|
21
|
+
};
|
|
22
|
+
return data;
|
|
23
|
+
}
|
|
24
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
25
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
26
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
27
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
28
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
29
|
+
/**
|
|
30
|
+
* the only members of the aspects the tested methods touch. the rest of the constructor arguments
|
|
31
|
+
* are there because the constructor registers listeners on them.
|
|
32
|
+
*/
|
|
33
|
+
function createCompiler({
|
|
34
|
+
workspace = {},
|
|
35
|
+
envs = {}
|
|
36
|
+
}) {
|
|
37
|
+
const workspaceStub = _objectSpread({
|
|
38
|
+
registerOnComponentChange: () => {},
|
|
39
|
+
registerOnComponentAdd: () => {},
|
|
40
|
+
inInstallContext: false,
|
|
41
|
+
inInstallAfterPmContext: false,
|
|
42
|
+
hasId: () => true
|
|
43
|
+
}, workspace);
|
|
44
|
+
return new (_workspaceCompiler().WorkspaceCompiler)(workspaceStub, envs, {},
|
|
45
|
+
// pubsub
|
|
46
|
+
undefined,
|
|
47
|
+
// aspectLoader. when absent, the constructor skips its listener registration
|
|
48
|
+
{
|
|
49
|
+
registerPreStart: () => {}
|
|
50
|
+
},
|
|
51
|
+
// ui
|
|
52
|
+
{
|
|
53
|
+
debug: () => {}
|
|
54
|
+
},
|
|
55
|
+
// logger
|
|
56
|
+
{},
|
|
57
|
+
// dependencyResolver
|
|
58
|
+
{
|
|
59
|
+
registerOnPreWatch: () => {}
|
|
60
|
+
} // watcher
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
describe('WorkspaceCompiler.onAspectLoadFail', () => {
|
|
64
|
+
const aspect = {
|
|
65
|
+
id: _componentId().ComponentID.fromString('my-org.my-scope/my-aspect')
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* the compilation itself is replaced by a recorder - it needs a workspace on the filesystem, and
|
|
70
|
+
* what is under test is only whether it is triggered at all.
|
|
71
|
+
*/
|
|
72
|
+
function createCompilerRecordingCompilation(isWorkspaceComponent) {
|
|
73
|
+
const compiler = createCompiler({
|
|
74
|
+
workspace: {
|
|
75
|
+
hasId: () => isWorkspaceComponent
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
const compiled = [];
|
|
79
|
+
compiler.getEnvDepsGraph = async () => ({
|
|
80
|
+
graph: undefined,
|
|
81
|
+
successors: []
|
|
82
|
+
});
|
|
83
|
+
compiler.compileComponents = async ids => {
|
|
84
|
+
compiled.push(ids);
|
|
85
|
+
return [];
|
|
86
|
+
};
|
|
87
|
+
return {
|
|
88
|
+
compiler,
|
|
89
|
+
compiled
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
it('should compile a workspace component that failed to load', async () => {
|
|
93
|
+
const {
|
|
94
|
+
compiler,
|
|
95
|
+
compiled
|
|
96
|
+
} = createCompilerRecordingCompilation(true);
|
|
97
|
+
const err = Object.assign(new Error('Cannot find module'), {
|
|
98
|
+
code: 'MODULE_NOT_FOUND'
|
|
99
|
+
});
|
|
100
|
+
(0, _chai().expect)(await compiler.onAspectLoadFail(err, aspect)).to.be.true;
|
|
101
|
+
(0, _chai().expect)(compiled).to.deep.equal([['my-org.my-scope/my-aspect']]);
|
|
102
|
+
});
|
|
103
|
+
it('should compile when node refuses to strip the types of a ts file under node_modules', async () => {
|
|
104
|
+
const {
|
|
105
|
+
compiler,
|
|
106
|
+
compiled
|
|
107
|
+
} = createCompilerRecordingCompilation(true);
|
|
108
|
+
const err = Object.assign(new Error('Stripping types is currently unsupported for files under node_modules'), {
|
|
109
|
+
code: 'ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING'
|
|
110
|
+
});
|
|
111
|
+
(0, _chai().expect)(await compiler.onAspectLoadFail(err, aspect)).to.be.true;
|
|
112
|
+
(0, _chai().expect)(compiled).to.have.lengthOf(1);
|
|
113
|
+
});
|
|
114
|
+
it('should not compile an aspect that is not a workspace component', async () => {
|
|
115
|
+
const {
|
|
116
|
+
compiler,
|
|
117
|
+
compiled
|
|
118
|
+
} = createCompilerRecordingCompilation(false);
|
|
119
|
+
const err = Object.assign(new Error('Cannot find module'), {
|
|
120
|
+
code: 'MODULE_NOT_FOUND'
|
|
121
|
+
});
|
|
122
|
+
(0, _chai().expect)(await compiler.onAspectLoadFail(err, aspect)).to.be.false;
|
|
123
|
+
(0, _chai().expect)(compiled).to.be.empty;
|
|
124
|
+
});
|
|
125
|
+
it('should not compile on an error that compiling cannot fix', async () => {
|
|
126
|
+
const {
|
|
127
|
+
compiler,
|
|
128
|
+
compiled
|
|
129
|
+
} = createCompilerRecordingCompilation(true);
|
|
130
|
+
const err = Object.assign(new Error('socket hang up'), {
|
|
131
|
+
code: 'ECONNRESET'
|
|
132
|
+
});
|
|
133
|
+
(0, _chai().expect)(await compiler.onAspectLoadFail(err, aspect)).to.be.false;
|
|
134
|
+
(0, _chai().expect)(compiled).to.be.empty;
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
describe('WorkspaceCompiler.buildGroupsToCompile', () => {
|
|
138
|
+
const compId = 'my-org.my-scope/my-comp';
|
|
139
|
+
const envId = 'my-org.my-scope/my-env';
|
|
140
|
+
// the env of the env. installed as a package, hence not a node on the workspace graph
|
|
141
|
+
const envOfEnvId = 'my-org.installed/my-env-of-env';
|
|
142
|
+
const envIdOf = {
|
|
143
|
+
[compId]: envId,
|
|
144
|
+
[envId]: envOfEnvId
|
|
145
|
+
};
|
|
146
|
+
const component = idStr => ({
|
|
147
|
+
id: _componentId().ComponentID.fromString(idStr)
|
|
148
|
+
});
|
|
149
|
+
const envs = {
|
|
150
|
+
calculateEnvId: async comp => _componentId().ComponentID.fromString(envIdOf[comp.id.toString()]),
|
|
151
|
+
isEnv: comp => comp.id.toString() === envId,
|
|
152
|
+
isCoreEnv: () => false
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/** mimics cleargraph, which throws when asked for the successors of a node it does not have */
|
|
156
|
+
const graph = {
|
|
157
|
+
hasNode: id => id === compId || id === envId,
|
|
158
|
+
successorsSubgraph: ids => {
|
|
159
|
+
const missing = ids.find(id => !graph.hasNode(id));
|
|
160
|
+
if (missing) throw new Error(`Node ${missing} does not exist on graph`);
|
|
161
|
+
return {
|
|
162
|
+
nodes: []
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
it('should skip env ids that are not on the given graph', async () => {
|
|
167
|
+
const compiler = createCompiler({
|
|
168
|
+
envs
|
|
169
|
+
});
|
|
170
|
+
const groups = await compiler.buildGroupsToCompile([component(compId), component(envId)], graph);
|
|
171
|
+
const idsOfGroup = key => groups.find(group => group[key]).components.map(comp => comp.id.toString());
|
|
172
|
+
(0, _chai().expect)(idsOfGroup('envs')).to.deep.equal([envId]);
|
|
173
|
+
(0, _chai().expect)(idsOfGroup('other')).to.deep.equal([compId]);
|
|
174
|
+
(0, _chai().expect)(idsOfGroup('depsOfEnvsOfEnvs')).to.be.empty;
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
//# sourceMappingURL=workspace-compiler.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_chai","data","require","_componentId","_workspaceCompiler","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","_toPropertyKey","value","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","createCompiler","workspace","envs","workspaceStub","registerOnComponentChange","registerOnComponentAdd","inInstallContext","inInstallAfterPmContext","hasId","WorkspaceCompiler","undefined","registerPreStart","debug","registerOnPreWatch","describe","aspect","id","ComponentID","fromString","createCompilerRecordingCompilation","isWorkspaceComponent","compiler","compiled","getEnvDepsGraph","graph","successors","compileComponents","ids","it","err","assign","Error","code","expect","onAspectLoadFail","to","be","true","deep","equal","have","lengthOf","false","empty","compId","envId","envOfEnvId","envIdOf","component","idStr","calculateEnvId","comp","toString","isEnv","isCoreEnv","hasNode","successorsSubgraph","missing","find","nodes","groups","buildGroupsToCompile","idsOfGroup","key","group","components","map"],"sources":["workspace-compiler.spec.ts"],"sourcesContent":["import { expect } from 'chai';\nimport { ComponentID } from '@teambit/component-id';\nimport type { Component } from '@teambit/component';\nimport type { CompIdGraph } from '@teambit/graph';\nimport { WorkspaceCompiler } from './workspace-compiler';\n\n/**\n * the only members of the aspects the tested methods touch. the rest of the constructor arguments\n * are there because the constructor registers listeners on them.\n */\nfunction createCompiler({\n workspace = {},\n envs = {},\n}: {\n workspace?: Record<string, any>;\n envs?: Record<string, any>;\n}) {\n const workspaceStub = {\n registerOnComponentChange: () => {},\n registerOnComponentAdd: () => {},\n inInstallContext: false,\n inInstallAfterPmContext: false,\n hasId: () => true,\n ...workspace,\n };\n return new WorkspaceCompiler(\n workspaceStub as any,\n envs as any,\n {} as any, // pubsub\n undefined as any, // aspectLoader. when absent, the constructor skips its listener registration\n { registerPreStart: () => {} } as any, // ui\n { debug: () => {} } as any, // logger\n {} as any, // dependencyResolver\n { registerOnPreWatch: () => {} } as any // watcher\n );\n}\n\ndescribe('WorkspaceCompiler.onAspectLoadFail', () => {\n const aspect = { id: ComponentID.fromString('my-org.my-scope/my-aspect') } as Component;\n\n /**\n * the compilation itself is replaced by a recorder - it needs a workspace on the filesystem, and\n * what is under test is only whether it is triggered at all.\n */\n function createCompilerRecordingCompilation(isWorkspaceComponent: boolean) {\n const compiler = createCompiler({ workspace: { hasId: () => isWorkspaceComponent } });\n const compiled: string[][] = [];\n compiler.getEnvDepsGraph = async () => ({ graph: undefined as unknown as CompIdGraph, successors: [] });\n compiler.compileComponents = async (ids) => {\n compiled.push(ids as string[]);\n return [];\n };\n return { compiler, compiled };\n }\n\n it('should compile a workspace component that failed to load', async () => {\n const { compiler, compiled } = createCompilerRecordingCompilation(true);\n const err = Object.assign(new Error('Cannot find module'), { code: 'MODULE_NOT_FOUND' });\n expect(await compiler.onAspectLoadFail(err, aspect)).to.be.true;\n expect(compiled).to.deep.equal([['my-org.my-scope/my-aspect']]);\n });\n\n it('should compile when node refuses to strip the types of a ts file under node_modules', async () => {\n const { compiler, compiled } = createCompilerRecordingCompilation(true);\n const err = Object.assign(new Error('Stripping types is currently unsupported for files under node_modules'), {\n code: 'ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING',\n });\n expect(await compiler.onAspectLoadFail(err, aspect)).to.be.true;\n expect(compiled).to.have.lengthOf(1);\n });\n\n it('should not compile an aspect that is not a workspace component', async () => {\n const { compiler, compiled } = createCompilerRecordingCompilation(false);\n const err = Object.assign(new Error('Cannot find module'), { code: 'MODULE_NOT_FOUND' });\n expect(await compiler.onAspectLoadFail(err, aspect)).to.be.false;\n expect(compiled).to.be.empty;\n });\n\n it('should not compile on an error that compiling cannot fix', async () => {\n const { compiler, compiled } = createCompilerRecordingCompilation(true);\n const err = Object.assign(new Error('socket hang up'), { code: 'ECONNRESET' });\n expect(await compiler.onAspectLoadFail(err, aspect)).to.be.false;\n expect(compiled).to.be.empty;\n });\n});\n\ndescribe('WorkspaceCompiler.buildGroupsToCompile', () => {\n const compId = 'my-org.my-scope/my-comp';\n const envId = 'my-org.my-scope/my-env';\n // the env of the env. installed as a package, hence not a node on the workspace graph\n const envOfEnvId = 'my-org.installed/my-env-of-env';\n const envIdOf = { [compId]: envId, [envId]: envOfEnvId };\n\n const component = (idStr: string) => ({ id: ComponentID.fromString(idStr) }) as Component;\n\n const envs = {\n calculateEnvId: async (comp: Component) => ComponentID.fromString(envIdOf[comp.id.toString()]),\n isEnv: (comp: Component) => comp.id.toString() === envId,\n isCoreEnv: () => false,\n };\n\n /** mimics cleargraph, which throws when asked for the successors of a node it does not have */\n const graph = {\n hasNode: (id: string) => id === compId || id === envId,\n successorsSubgraph: (ids: string[]) => {\n const missing = ids.find((id) => !graph.hasNode(id));\n if (missing) throw new Error(`Node ${missing} does not exist on graph`);\n return { nodes: [] };\n },\n } as unknown as CompIdGraph;\n\n type Group = Awaited<ReturnType<WorkspaceCompiler['buildGroupsToCompile']>>[number];\n\n it('should skip env ids that are not on the given graph', async () => {\n const compiler = createCompiler({ envs });\n const groups = await compiler.buildGroupsToCompile([component(compId), component(envId)], graph);\n const idsOfGroup = (key: keyof Omit<Group, 'components'>) =>\n groups.find((group) => group[key])!.components.map((comp) => comp.id.toString());\n expect(idsOfGroup('envs')).to.deep.equal([envId]);\n expect(idsOfGroup('other')).to.deep.equal([compId]);\n expect(idsOfGroup('depsOfEnvsOfEnvs')).to.be.empty;\n });\n});\n"],"mappings":";;AAAA,SAAAA,MAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,KAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,aAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,YAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAG,mBAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,kBAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAyD,SAAAI,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CA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;IACzC,MAAM0D,MAAM,GAAG,MAAMvC,QAAQ,CAACwC,oBAAoB,CAAC,CAACb,SAAS,CAACJ,MAAM,CAAC,EAAEI,SAAS,CAACH,KAAK,CAAC,CAAC,EAAErB,KAAK,CAAC;IAChG,MAAMsC,UAAU,GAAIC,GAAoC,IACtDH,MAAM,CAACF,IAAI,CAAEM,KAAK,IAAKA,KAAK,CAACD,GAAG,CAAC,CAAC,CAAEE,UAAU,CAACC,GAAG,CAAEf,IAAI,IAAKA,IAAI,CAACnC,EAAE,CAACoC,QAAQ,CAAC,CAAC,CAAC;IAClF,IAAAnB,cAAM,EAAC6B,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC3B,EAAE,CAACG,IAAI,CAACC,KAAK,CAAC,CAACM,KAAK,CAAC,CAAC;IACjD,IAAAZ,cAAM,EAAC6B,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC3B,EAAE,CAACG,IAAI,CAACC,KAAK,CAAC,CAACK,MAAM,CAAC,CAAC;IACnD,IAAAX,cAAM,EAAC6B,UAAU,CAAC,kBAAkB,CAAC,CAAC,CAAC3B,EAAE,CAACC,EAAE,CAACO,KAAK;EACpD,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/compiler",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1157",
|
|
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": "1.0.
|
|
9
|
+
"version": "1.0.1157"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"pretty-time": "1.1.0",
|
|
@@ -17,33 +17,33 @@
|
|
|
17
17
|
"lodash": "4.17.21",
|
|
18
18
|
"p-map-series": "2.1.0",
|
|
19
19
|
"@teambit/harmony": "0.4.12",
|
|
20
|
-
"@teambit/component-id": "1.2.4",
|
|
21
|
-
"@teambit/workspace.root-components": "1.0.1",
|
|
22
|
-
"@teambit/bit-error": "0.0.404",
|
|
23
|
-
"@teambit/envs": "1.0.1156",
|
|
24
20
|
"@teambit/cli": "0.0.1389",
|
|
25
21
|
"@teambit/logger": "0.0.1482",
|
|
26
|
-
"@teambit/
|
|
27
|
-
"@teambit/aspect-loader": "1.0.1156",
|
|
28
|
-
"@teambit/builder": "1.0.1156",
|
|
29
|
-
"@teambit/bundler": "1.0.1156",
|
|
22
|
+
"@teambit/component-id": "1.2.4",
|
|
30
23
|
"@teambit/component-issues": "0.0.186",
|
|
31
|
-
"@teambit/component": "1.0.1156",
|
|
32
|
-
"@teambit/dependency-resolver": "1.0.1156",
|
|
33
|
-
"@teambit/generator": "1.0.1157",
|
|
34
|
-
"@teambit/issues": "1.0.1156",
|
|
35
24
|
"@teambit/legacy.constants": "0.0.43",
|
|
36
|
-
"@teambit/ui": "1.0.1156",
|
|
37
|
-
"@teambit/watcher": "1.0.1156",
|
|
38
|
-
"@teambit/workspace": "1.0.1156",
|
|
39
|
-
"@teambit/isolator": "1.0.1156",
|
|
40
25
|
"@teambit/toolbox.fs.hard-link-directory": "0.0.40",
|
|
41
26
|
"@teambit/component.sources": "0.0.212",
|
|
42
27
|
"@teambit/toolbox.path.path": "0.0.22",
|
|
43
|
-
"@teambit/graph": "1.0.1156",
|
|
44
|
-
"@teambit/multi-compiler": "1.0.1156",
|
|
45
28
|
"@teambit/pkg.modules.component-package-name": "0.0.167",
|
|
46
|
-
"@teambit/workspace.modules.node-modules-linker": "0.0.392"
|
|
29
|
+
"@teambit/workspace.modules.node-modules-linker": "0.0.392",
|
|
30
|
+
"@teambit/workspace.root-components": "1.0.1",
|
|
31
|
+
"@teambit/bit-error": "0.0.404",
|
|
32
|
+
"@teambit/envs": "1.0.1157",
|
|
33
|
+
"@teambit/pubsub": "1.0.1157",
|
|
34
|
+
"@teambit/aspect-loader": "1.0.1157",
|
|
35
|
+
"@teambit/builder": "1.0.1157",
|
|
36
|
+
"@teambit/bundler": "1.0.1157",
|
|
37
|
+
"@teambit/component": "1.0.1157",
|
|
38
|
+
"@teambit/dependency-resolver": "1.0.1157",
|
|
39
|
+
"@teambit/generator": "1.0.1158",
|
|
40
|
+
"@teambit/issues": "1.0.1157",
|
|
41
|
+
"@teambit/ui": "1.0.1157",
|
|
42
|
+
"@teambit/watcher": "1.0.1157",
|
|
43
|
+
"@teambit/workspace": "1.0.1157",
|
|
44
|
+
"@teambit/isolator": "1.0.1157",
|
|
45
|
+
"@teambit/graph": "1.0.1157",
|
|
46
|
+
"@teambit/multi-compiler": "1.0.1157"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/pretty-time": "^1.1.5",
|
|
@@ -54,7 +54,8 @@
|
|
|
54
54
|
"@teambit/harmony.envs.core-aspect-env": "2.1.0"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"react": "^17.0.0 || ^18.0.0 || ^19.0.0"
|
|
57
|
+
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
58
|
+
"chai": "5.2.1"
|
|
58
59
|
},
|
|
59
60
|
"license": "Apache-2.0",
|
|
60
61
|
"optionalDependencies": {},
|