@teambit/compiler 1.0.466 → 1.0.468
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/artifacts/__bit_junit.xml +1 -1
- package/artifacts/preview/teambit_compilation_compiler-preview.js +1 -1
- package/artifacts/schema.json +773 -267
- package/dist/compiler.cmd.js +1 -1
- package/dist/compiler.cmd.js.map +1 -1
- package/dist/compiler.task.d.ts +1 -1
- package/dist/compiler.task.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{preview-1731933800507.js → preview-1732072955804.js} +2 -2
- package/dist/types.d.ts +6 -0
- package/dist/types.js.map +1 -1
- package/dist/workspace-compiler.d.ts +15 -5
- package/dist/workspace-compiler.js +106 -9
- package/dist/workspace-compiler.js.map +1 -1
- package/package.json +20 -19
package/dist/compiler.cmd.js
CHANGED
|
@@ -59,7 +59,7 @@ class CompileCmd {
|
|
|
59
59
|
}]);
|
|
60
60
|
_defineProperty(this, "alias", '');
|
|
61
61
|
_defineProperty(this, "group", 'development');
|
|
62
|
-
_defineProperty(this, "options", [['c', 'changed', 'compile only new and modified components'], ['v', 'verbose', 'show more data, such as, dist paths'], ['j', 'json', 'return the compile results in json format'], ['d', 'delete-dist-dir', 'delete existing dist folder before writing new compiled files']]);
|
|
62
|
+
_defineProperty(this, "options", [['c', 'changed', 'compile only new and modified components'], ['v', 'verbose', 'show more data, such as, dist paths'], ['j', 'json', 'return the compile results in json format'], ['d', 'delete-dist-dir', 'delete existing dist folder before writing new compiled files'], ['', 'generate-types', 'generate d.ts files for typescript components (hurts performance)']]);
|
|
63
63
|
}
|
|
64
64
|
async report([components = []], compilerOptions) {
|
|
65
65
|
const startTimestamp = process.hrtime();
|
package/dist/compiler.cmd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_logger","data","require","_chalk","_interopRequireDefault","_prettyTime","_outputFormatter","_types","e","__esModule","default","ownKeys","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","CompileCmd","constructor","compile","logger","pubsub","name","description","report","components","compilerOptions","startTimestamp","process","hrtime","setStatusLine","outputString","results","compileComponents","initiator","CompilationInitiator","CmdReport","compileTimeLength","chalk","underline","formatCompileResults","verbose","getStatusLine","clearStatusLine","code","getExitCode","json","deleteDistDir","compileResults","CmdJson","failedComponents","componentsStatus","component","errors","getSummaryIcon","Logger","successSymbol","red","yellow","numberOfComponents","numberOfFailingComponents","numberOfSuccessfulComponents","icon","summaryLine","prettyTime","exports"],"sources":["compiler.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport { Logger } from '@teambit/logger';\nimport type { PubsubMain } from '@teambit/pubsub';\nimport chalk from 'chalk';\nimport prettyTime from 'pretty-time';\nimport { formatCompileResults } from './output-formatter';\nimport { WorkspaceCompiler, CompileOptions, BuildResult } from './workspace-compiler';\nimport { CompilationInitiator } from './types';\n\nexport class CompileCmd implements Command {\n name = 'compile [component-names...]';\n description = 'compile components in the workspace';\n helpUrl = 'reference/compiling/compiler-overview';\n arguments = [\n {\n name: 'component-names...',\n description: 'a list of component names or component IDs (defaults to all components)',\n },\n ];\n alias = '';\n group = 'development';\n options = [\n ['c', 'changed', 'compile only new and modified components'],\n ['v', 'verbose', 'show more data, such as, dist paths'],\n ['j', 'json', 'return the compile results in json format'],\n ['d', 'delete-dist-dir', 'delete existing dist folder before writing new compiled files'],\n ] as CommandOptions;\n\n constructor(\n private compile: WorkspaceCompiler,\n private logger: Logger,\n private pubsub: PubsubMain\n ) {}\n\n async report([components = []]: [string[]], compilerOptions: CompileOptions) {\n const startTimestamp = process.hrtime();\n this.logger.setStatusLine('Compiling your components, hold tight.');\n\n let outputString = '';\n const results = await this.compile.compileComponents(components, {\n ...compilerOptions,\n initiator: CompilationInitiator.CmdReport,\n });\n const compileTimeLength = process.hrtime(startTimestamp);\n\n outputString += '\\n';\n outputString += ` ${chalk.underline('STATUS')}\\t${chalk.underline('COMPONENT ID')}\\n`;\n outputString += formatCompileResults(results, !!compilerOptions.verbose);\n outputString += '\\n';\n\n outputString += this.getStatusLine(results, compileTimeLength);\n\n this.logger.clearStatusLine();\n\n return {\n data: outputString,\n code: this.getExitCode(results),\n };\n }\n\n async json([components]: [string[]], compilerOptions: CompileOptions) {\n compilerOptions.deleteDistDir = true;\n // @ts-ignore\n const compileResults = await this.compile.compileComponents(components, {\n ...compilerOptions,\n initiator: CompilationInitiator.CmdJson,\n });\n return {\n data: compileResults,\n // @todo: fix the code once compile is ready.\n code: 0,\n };\n }\n\n private failedComponents(componentsStatus: BuildResult[]): BuildResult[] {\n return componentsStatus.filter((component) => component.errors.length);\n }\n\n private getSummaryIcon(componentsStatus: BuildResult[]) {\n switch (this.failedComponents(componentsStatus).length) {\n case 0:\n return Logger.successSymbol();\n case componentsStatus.length:\n return chalk.red('✗');\n default:\n return chalk.yellow('⍻');\n }\n }\n\n private getExitCode(componentsStatus: BuildResult[]) {\n return this.failedComponents(componentsStatus).length ? 1 : 0;\n }\n\n private getStatusLine(componentsStatus: BuildResult[], compileTimeLength) {\n const numberOfComponents = componentsStatus.length;\n const numberOfFailingComponents = this.failedComponents(componentsStatus).length;\n const numberOfSuccessfulComponents = componentsStatus.filter((component) => !component.errors.length).length;\n\n const icon = this.getSummaryIcon(componentsStatus);\n const summaryLine = numberOfFailingComponents\n ? `${icon} ${numberOfFailingComponents}/${numberOfComponents} components failed to compile.`\n : `${icon} ${numberOfSuccessfulComponents}/${numberOfComponents} components compiled successfully.`;\n\n return `${summaryLine}\\nFinished. (${prettyTime(compileTimeLength)})`;\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,C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I,CAACD,gBAAgB,CAACC,gBAAgB,CAAC,CAACpD,MAAM,GAAG,CAAC,GAAG,CAAC;EAC/D;EAEQ2C,aAAaA,CAACS,gBAA+B,EAAEd,iBAAiB,EAAE;IACxE,MAAMsB,kBAAkB,GAAGR,gBAAgB,CAACpD,MAAM;IAClD,MAAM6D,yBAAyB,GAAG,IAAI,CAACV,gBAAgB,CAACC,gBAAgB,CAAC,CAACpD,MAAM;IAChF,MAAM8D,4BAA4B,GAAGV,gBAAgB,CAAC3D,MAAM,CAAE4D,SAAS,IAAK,CAACA,SAAS,CAACC,MAAM,CAACtD,MAAM,CAAC,CAACA,MAAM;IAE5G,MAAM+D,IAAI,GAAG,IAAI,CAACR,cAAc,CAACH,gBAAgB,CAAC;IAClD,MAAMY,WAAW,GAAGH,yBAAyB,GACzC,GAAGE,IAAI,IAAIF,yBAAyB,IAAID,kBAAkB,gCAAgC,GAC1F,GAAGG,IAAI,IAAID,4BAA4B,IAAIF,kBAAkB,oCAAoC;IAErG,OAAO,GAAGI,WAAW,gBAAgB,IAAAC,qBAAU,EAAC3B,iBAAiB,CAAC,GAAG;EACvE;AACF;AAAC4B,OAAA,CAAAhD,UAAA,GAAAA,UAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_logger","data","require","_chalk","_interopRequireDefault","_prettyTime","_outputFormatter","_types","e","__esModule","default","ownKeys","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","CompileCmd","constructor","compile","logger","pubsub","name","description","report","components","compilerOptions","startTimestamp","process","hrtime","setStatusLine","outputString","results","compileComponents","initiator","CompilationInitiator","CmdReport","compileTimeLength","chalk","underline","formatCompileResults","verbose","getStatusLine","clearStatusLine","code","getExitCode","json","deleteDistDir","compileResults","CmdJson","failedComponents","componentsStatus","component","errors","getSummaryIcon","Logger","successSymbol","red","yellow","numberOfComponents","numberOfFailingComponents","numberOfSuccessfulComponents","icon","summaryLine","prettyTime","exports"],"sources":["compiler.cmd.ts"],"sourcesContent":["import { Command, CommandOptions } from '@teambit/cli';\nimport { Logger } from '@teambit/logger';\nimport type { PubsubMain } from '@teambit/pubsub';\nimport chalk from 'chalk';\nimport prettyTime from 'pretty-time';\nimport { formatCompileResults } from './output-formatter';\nimport { WorkspaceCompiler, CompileOptions, BuildResult } from './workspace-compiler';\nimport { CompilationInitiator } from './types';\n\nexport class CompileCmd implements Command {\n name = 'compile [component-names...]';\n description = 'compile components in the workspace';\n helpUrl = 'reference/compiling/compiler-overview';\n arguments = [\n {\n name: 'component-names...',\n description: 'a list of component names or component IDs (defaults to all components)',\n },\n ];\n alias = '';\n group = 'development';\n options = [\n ['c', 'changed', 'compile only new and modified components'],\n ['v', 'verbose', 'show more data, such as, dist paths'],\n ['j', 'json', 'return the compile results in json format'],\n ['d', 'delete-dist-dir', 'delete existing dist folder before writing new compiled files'],\n ['', 'generate-types', 'generate d.ts files for typescript components (hurts performance)'],\n ] as CommandOptions;\n\n constructor(\n private compile: WorkspaceCompiler,\n private logger: Logger,\n private pubsub: PubsubMain\n ) {}\n\n async report([components = []]: [string[]], compilerOptions: CompileOptions) {\n const startTimestamp = process.hrtime();\n this.logger.setStatusLine('Compiling your components, hold tight.');\n\n let outputString = '';\n const results = await this.compile.compileComponents(components, {\n ...compilerOptions,\n initiator: CompilationInitiator.CmdReport,\n });\n const compileTimeLength = process.hrtime(startTimestamp);\n\n outputString += '\\n';\n outputString += ` ${chalk.underline('STATUS')}\\t${chalk.underline('COMPONENT ID')}\\n`;\n outputString += formatCompileResults(results, !!compilerOptions.verbose);\n outputString += '\\n';\n\n outputString += this.getStatusLine(results, compileTimeLength);\n\n this.logger.clearStatusLine();\n\n return {\n data: outputString,\n code: this.getExitCode(results),\n };\n }\n\n async json([components]: [string[]], compilerOptions: CompileOptions) {\n compilerOptions.deleteDistDir = true;\n // @ts-ignore\n const compileResults = await this.compile.compileComponents(components, {\n ...compilerOptions,\n initiator: CompilationInitiator.CmdJson,\n });\n return {\n data: compileResults,\n // @todo: fix the code once compile is ready.\n code: 0,\n };\n }\n\n private failedComponents(componentsStatus: BuildResult[]): BuildResult[] {\n return componentsStatus.filter((component) => component.errors.length);\n }\n\n private getSummaryIcon(componentsStatus: BuildResult[]) {\n switch (this.failedComponents(componentsStatus).length) {\n case 0:\n return Logger.successSymbol();\n case componentsStatus.length:\n return chalk.red('✗');\n default:\n return chalk.yellow('⍻');\n }\n }\n\n private getExitCode(componentsStatus: BuildResult[]) {\n return this.failedComponents(componentsStatus).length ? 1 : 0;\n }\n\n private getStatusLine(componentsStatus: BuildResult[], compileTimeLength) {\n const numberOfComponents = componentsStatus.length;\n const numberOfFailingComponents = this.failedComponents(componentsStatus).length;\n const numberOfSuccessfulComponents = componentsStatus.filter((component) => !component.errors.length).length;\n\n const icon = this.getSummaryIcon(componentsStatus);\n const summaryLine = numberOfFailingComponents\n ? `${icon} ${numberOfFailingComponents}/${numberOfComponents} components failed to compile.`\n : `${icon} ${numberOfSuccessfulComponents}/${numberOfComponents} components compiled successfully.`;\n\n return `${summaryLine}\\nFinished. (${prettyTime(compileTimeLength)})`;\n }\n}\n"],"mappings":";;;;;;AACA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,OAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,MAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,YAAA;EAAA,MAAAJ,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAG,WAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAA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8D,4BAA4B,GAAGV,gBAAgB,CAAC3D,MAAM,CAAE4D,SAAS,IAAK,CAACA,SAAS,CAACC,MAAM,CAACtD,MAAM,CAAC,CAACA,MAAM;IAE5G,MAAM+D,IAAI,GAAG,IAAI,CAACR,cAAc,CAACH,gBAAgB,CAAC;IAClD,MAAMY,WAAW,GAAGH,yBAAyB,GACzC,GAAGE,IAAI,IAAIF,yBAAyB,IAAID,kBAAkB,gCAAgC,GAC1F,GAAGG,IAAI,IAAID,4BAA4B,IAAIF,kBAAkB,oCAAoC;IAErG,OAAO,GAAGI,WAAW,gBAAgB,IAAAC,qBAAU,EAAC3B,iBAAiB,CAAC,GAAG;EACvE;AACF;AAAC4B,OAAA,CAAAhD,UAAA,GAAAA,UAAA","ignoreList":[]}
|
package/dist/compiler.task.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type CompilerTaskOptions = {
|
|
|
19
19
|
export declare class CompilerTask implements BuildTask {
|
|
20
20
|
readonly aspectId: string;
|
|
21
21
|
readonly name: string;
|
|
22
|
-
|
|
22
|
+
readonly compilerInstance: Compiler;
|
|
23
23
|
private dependencyResolver;
|
|
24
24
|
readonly description = "compile components";
|
|
25
25
|
constructor(aspectId: string, name: string, compilerInstance: Compiler, dependencyResolver: DependencyResolverMain);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_toolboxFs","data","require","_fsExtra","_interopRequireDefault","_path","_compiler","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","CompilerTask","constructor","aspectId","name","compilerInstance","dependencyResolver","artifactName","description","preBuild","context","Promise","all","capsuleNetwork","seedersCapsules","map","capsule","copyNonSupportedFiles","execute","buildResults","build","_hardLinkBuildArtifactsOnCapsules","relCompDir","path","relative","capsulesRootDir","replace","injectedDirs","getInjectedDirs","getPackageName","component","hardLinkDirectory","injectedDir","join","postBuild","tasksResults","compiler","shouldCopyNonSupportedFiles","filesystem","files","file","isFileSupported","content","contents","fs","outputFile","distDir","from","options","CompilerAspect","id","depResolve","getAspect","exports"],"sources":["compiler.task.ts"],"sourcesContent":["import { BuildContext, BuiltTaskResult, BuildTask, TaskResultsList } from '@teambit/builder';\nimport { Capsule } from '@teambit/isolator';\nimport { hardLinkDirectory } from '@teambit/toolbox.fs.hard-link-directory';\nimport { EnvContext, EnvHandler } from '@teambit/envs';\nimport { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport { Compiler } from './types';\nimport { CompilerAspect } from './compiler.aspect';\n\nexport type CompilerTaskOptions = {\n /**\n * instance of compiler to use.\n */\n compiler: EnvHandler<Compiler>;\n\n /**\n * name of compiler task\n */\n name?: string;\n};\n\n/**\n * compiler build task. Allows to compile components during component build.\n */\nexport class CompilerTask implements BuildTask {\n readonly description = 'compile components';\n constructor(\n readonly aspectId: string,\n readonly name: string,\n
|
|
1
|
+
{"version":3,"names":["_toolboxFs","data","require","_fsExtra","_interopRequireDefault","_path","_compiler","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","CompilerTask","constructor","aspectId","name","compilerInstance","dependencyResolver","artifactName","description","preBuild","context","Promise","all","capsuleNetwork","seedersCapsules","map","capsule","copyNonSupportedFiles","execute","buildResults","build","_hardLinkBuildArtifactsOnCapsules","relCompDir","path","relative","capsulesRootDir","replace","injectedDirs","getInjectedDirs","getPackageName","component","hardLinkDirectory","injectedDir","join","postBuild","tasksResults","compiler","shouldCopyNonSupportedFiles","filesystem","files","file","isFileSupported","content","contents","fs","outputFile","distDir","from","options","CompilerAspect","id","depResolve","getAspect","exports"],"sources":["compiler.task.ts"],"sourcesContent":["import { BuildContext, BuiltTaskResult, BuildTask, TaskResultsList } from '@teambit/builder';\nimport { Capsule } from '@teambit/isolator';\nimport { hardLinkDirectory } from '@teambit/toolbox.fs.hard-link-directory';\nimport { EnvContext, EnvHandler } from '@teambit/envs';\nimport { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport { Compiler } from './types';\nimport { CompilerAspect } from './compiler.aspect';\n\nexport type CompilerTaskOptions = {\n /**\n * instance of compiler to use.\n */\n compiler: EnvHandler<Compiler>;\n\n /**\n * name of compiler task\n */\n name?: string;\n};\n\n/**\n * compiler build task. Allows to compile components during component build.\n */\nexport class CompilerTask implements BuildTask {\n readonly description = 'compile components';\n constructor(\n readonly aspectId: string,\n readonly name: string,\n readonly compilerInstance: Compiler,\n private dependencyResolver: DependencyResolverMain\n ) {\n if (compilerInstance.artifactName) {\n this.description += ` for artifact ${compilerInstance.artifactName}`;\n }\n }\n\n async preBuild(context: BuildContext) {\n await Promise.all(\n context.capsuleNetwork.seedersCapsules.map((capsule) =>\n this.copyNonSupportedFiles(capsule, this.compilerInstance)\n )\n );\n if (!this.compilerInstance.preBuild) return;\n await this.compilerInstance.preBuild(context);\n }\n\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n const buildResults = await this.compilerInstance.build(context);\n await this._hardLinkBuildArtifactsOnCapsules(context);\n return buildResults;\n }\n\n /**\n * This function hard links the compiled artifacts to the `node_modules` of other component capsules.\n * For instance, if we have a `button` component that is a dependency of the `card` component,\n * then the `dist` folder of the `button` component will be copied to `<card_capsule>/node_modules/button/dist`.\n */\n private async _hardLinkBuildArtifactsOnCapsules(context: BuildContext): Promise<void> {\n await Promise.all(\n context.capsuleNetwork.seedersCapsules.map(async (capsule) => {\n const relCompDir = path.relative(context.capsuleNetwork.capsulesRootDir, capsule.path).replace(/\\\\/g, '/');\n const injectedDirs = await this.dependencyResolver.getInjectedDirs(\n context.capsuleNetwork.capsulesRootDir,\n relCompDir,\n this.dependencyResolver.getPackageName(capsule.component)\n );\n return hardLinkDirectory(\n capsule.path,\n injectedDirs.map((injectedDir) => path.join(context.capsuleNetwork.capsulesRootDir, injectedDir))\n );\n })\n );\n }\n\n async postBuild?(context: BuildContext, tasksResults: TaskResultsList): Promise<void> {\n if (!this.compilerInstance.postBuild) return;\n await this.compilerInstance.postBuild(context, tasksResults);\n }\n\n async copyNonSupportedFiles(capsule: Capsule, compiler: Compiler) {\n if (!compiler.shouldCopyNonSupportedFiles) {\n return;\n }\n const component = capsule.component;\n await Promise.all(\n component.filesystem.files.map(async (file) => {\n if (compiler.isFileSupported(file.path)) return;\n const content = file.contents;\n await fs.outputFile(path.join(capsule.path, compiler.distDir, file.relative), content);\n })\n );\n }\n\n static from(options: CompilerTaskOptions) {\n return (context: EnvContext) => {\n const aspectId = CompilerAspect.id;\n const name = options.name || 'compiler-task';\n const depResolve = context.getAspect<any>('teambit.dependencies/dependency-resolver');\n return new CompilerTask(aspectId, name, options.compiler(context), depResolve);\n };\n }\n}\n"],"mappings":";;;;;;AAEA,SAAAA,WAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,UAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAE,SAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,QAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,MAAA;EAAA,MAAAJ,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAG,KAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAK,UAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,SAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAmD,SAAAG,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EA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,SAAS,EAAE;IACtC,MAAM,IAAI,CAAC7B,gBAAgB,CAAC6B,SAAS,CAACxB,OAAO,EAAEyB,YAAY,CAAC;EAC9D;EAEA,MAAMlB,qBAAqBA,CAACD,OAAgB,EAAEoB,QAAkB,EAAE;IAChE,IAAI,CAACA,QAAQ,CAACC,2BAA2B,EAAE;MACzC;IACF;IACA,MAAMP,SAAS,GAAGd,OAAO,CAACc,SAAS;IACnC,MAAMnB,OAAO,CAACC,GAAG,CACfkB,SAAS,CAACQ,UAAU,CAACC,KAAK,CAACxB,GAAG,CAAC,MAAOyB,IAAI,IAAK;MAC7C,IAAIJ,QAAQ,CAACK,eAAe,CAACD,IAAI,CAACjB,IAAI,CAAC,EAAE;MACzC,MAAMmB,OAAO,GAAGF,IAAI,CAACG,QAAQ;MAC7B,MAAMC,kBAAE,CAACC,UAAU,CAACtB,eAAI,CAACU,IAAI,CAACjB,OAAO,CAACO,IAAI,EAAEa,QAAQ,CAACU,OAAO,EAAEN,IAAI,CAAChB,QAAQ,CAAC,EAAEkB,OAAO,CAAC;IACxF,CAAC,CACH,CAAC;EACH;EAEA,OAAOK,IAAIA,CAACC,OAA4B,EAAE;IACxC,OAAQtC,OAAmB,IAAK;MAC9B,MAAMP,QAAQ,GAAG8C,0BAAc,CAACC,EAAE;MAClC,MAAM9C,IAAI,GAAG4C,OAAO,CAAC5C,IAAI,IAAI,eAAe;MAC5C,MAAM+C,UAAU,GAAGzC,OAAO,CAAC0C,SAAS,CAAM,0CAA0C,CAAC;MACrF,OAAO,IAAInD,YAAY,CAACE,QAAQ,EAAEC,IAAI,EAAE4C,OAAO,CAACZ,QAAQ,CAAC1B,OAAO,CAAC,EAAEyC,UAAU,CAAC;IAChF,CAAC;EACH;AACF;AAACE,OAAA,CAAApD,YAAA,GAAAA,YAAA","ignoreList":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ export { CompilerTask } from './compiler.task';
|
|
|
4
4
|
export type { CompilerEnv } from './compiler-env-type';
|
|
5
5
|
export { CompilerAspect } from './compiler.aspect';
|
|
6
6
|
export { CompilationInitiator } from './types';
|
|
7
|
-
export type { Compiler, CompilerOptions, TranspileFileOutput, TranspileFileParams, TranspileComponentParams, TranspileFileOutputOneFile, } from './types';
|
|
7
|
+
export type { Compiler, CompilerOptions, TranspileFileOutput, TranspileFileParams, TranspileComponentParams, TranspileFileOutputOneFile, TypeGeneratorCompParams, } from './types';
|
|
8
8
|
export * from './events';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_compiler","data","require","_compiler2","_types","_events","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export type { CompilerMain } from './compiler.main.runtime';\nexport type { CompilerTaskOptions } from './compiler.task';\nexport { CompilerTask } from './compiler.task';\nexport type { CompilerEnv } from './compiler-env-type';\nexport { CompilerAspect } from './compiler.aspect';\nexport { CompilationInitiator } from './types';\nexport type {\n Compiler,\n CompilerOptions,\n TranspileFileOutput,\n TranspileFileParams,\n TranspileComponentParams,\n TranspileFileOutputOneFile,\n} from './types';\nexport * from './events';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,WAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,OAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,MAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;
|
|
1
|
+
{"version":3,"names":["_compiler","data","require","_compiler2","_types","_events","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get"],"sources":["index.ts"],"sourcesContent":["export type { CompilerMain } from './compiler.main.runtime';\nexport type { CompilerTaskOptions } from './compiler.task';\nexport { CompilerTask } from './compiler.task';\nexport type { CompilerEnv } from './compiler-env-type';\nexport { CompilerAspect } from './compiler.aspect';\nexport { CompilationInitiator } from './types';\nexport type {\n Compiler,\n CompilerOptions,\n TranspileFileOutput,\n TranspileFileParams,\n TranspileComponentParams,\n TranspileFileOutputOneFile,\n TypeGeneratorCompParams,\n} from './types';\nexport * from './events';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAAA,UAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,SAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,WAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,OAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,MAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAUA,IAAAI,OAAA,GAAAH,OAAA;AAAAI,MAAA,CAAAC,IAAA,CAAAF,OAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,OAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,OAAA,CAAAI,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
|
|
@@ -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.468/dist/compiler.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.compilation_compiler@1.0.468/dist/compiler.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
package/dist/types.d.ts
CHANGED
|
@@ -22,6 +22,10 @@ export type TranspileComponentParams = {
|
|
|
22
22
|
outputDir: string;
|
|
23
23
|
initiator: CompilationInitiator;
|
|
24
24
|
};
|
|
25
|
+
export type TypeGeneratorCompParams = {
|
|
26
|
+
component: Component;
|
|
27
|
+
packageDir: string;
|
|
28
|
+
};
|
|
25
29
|
export type TranspileFileOutputOneFile = {
|
|
26
30
|
outputText: string;
|
|
27
31
|
outputPath: string;
|
|
@@ -76,6 +80,8 @@ export interface Compiler extends CompilerOptions, ServiceHandler {
|
|
|
76
80
|
* transpile all the files of a component, use this when you can't use `transpileFile`
|
|
77
81
|
*/
|
|
78
82
|
transpileComponent?: (params: TranspileComponentParams) => Promise<void>;
|
|
83
|
+
preGenerateTypesOnWorkspace?: (params: TypeGeneratorCompParams[], envId: string) => Promise<void>;
|
|
84
|
+
generateTypesOnWorkspace?: (rootDir: string, params: TypeGeneratorCompParams[]) => Promise<void>;
|
|
79
85
|
/**
|
|
80
86
|
* compile components inside isolated capsules. this being used during tag for the release.
|
|
81
87
|
* meaning, the final package of the component has the dists generated by this method.
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CompilationInitiator","exports"],"sources":["types.ts"],"sourcesContent":["import { BuildContext, BuildTask, BuiltTaskResult, TaskResultsList } from '@teambit/builder';\nimport type { Component } from '@teambit/component';\nimport { ServiceHandler } from '@teambit/envs';\n\nexport type TranspileFileParams = {\n componentDir: string; // absolute path of the component's root directory\n filePath: string; // relative path of the file inside the component directory\n};\n\nexport enum CompilationInitiator {\n CmdReport,\n CmdJson,\n PreStart,\n PreWatch,\n Start,\n ComponentChanged,\n AspectLoadFail,\n ComponentAdded,\n Install,\n}\n\nexport type TranspileComponentParams = {\n component: Component;\n componentDir: string; // absolute path of the component's root directory\n outputDir: string; // absolute path of the component's output directory\n initiator: CompilationInitiator; // origin of the compilation's request\n};\n\nexport type TranspileFileOutputOneFile = {\n outputText: string;\n outputPath: string;\n};\n\nexport type TranspileFileOutput = TranspileFileOutputOneFile[] | null;\n\nexport interface CompilerOptions {\n /**\n * name of the compiler.\n */\n name?: string;\n\n /**\n * relative path of the dist directory inside the capsule. e.g. \"dist\".\n */\n distDir: string;\n\n /**\n * determines which ones of the generated files will be saved in the bit objects when tagging.\n * e.g. distGlobPatterns = [`${this.distDir}/**`, `!${this.distDir}/tsconfig.tsbuildinfo`];\n * see https://github.com/mrmlnc/fast-glob for the supported glob patters syntax.\n */\n distGlobPatterns?: string[];\n\n /**\n * whether or not unsupported files (such as assets) should be copied into the dist directory\n */\n shouldCopyNonSupportedFiles?: boolean;\n\n /**\n * optional. default to \"dist\".\n * useful when the build pipeline has multiple compiler tasks of the same compiler.\n * e.g. using the same Babel compiler for two different tasks, one for creating \"es5\" files, and\n * the second for creating \"esm\". the artifact names would be \"es5\" and \"esm\" accordingly.\n */\n artifactName?: string;\n}\n\nexport interface Compiler extends CompilerOptions, ServiceHandler {\n /**\n * id of the compiler.\n */\n id: string;\n\n /**\n * Delete dist folder before writing the new compiled files\n */\n deleteDistDir?: boolean;\n\n /**\n * serialized config of the compiler.\n */\n displayConfig?(): string;\n\n /**\n * transpile a single file that gets saved into the workspace, used by `bit compile` and during\n * development\n */\n transpileFile?: (\n fileContent: string,\n params: TranspileFileParams\n ) => TranspileFileOutput | Promise<TranspileFileOutput>;\n\n /**\n * transpile all the files of a component, use this when you can't use `transpileFile`\n */\n transpileComponent?: (params: TranspileComponentParams) => Promise<void>;\n\n /**\n * compile components inside isolated capsules. this being used during tag for the release.\n * meaning, the final package of the component has the dists generated by this method.\n *\n * no need to handle non-supported-files (e.g. assets) in this method because the compiler-aspect already copies them\n * into the compiler.dist in the preBuild stage.\n */\n build(context: BuildContext): Promise<BuiltTaskResult>;\n\n /**\n * return the dist dir of the compiled files (relative path from the component root dir)\n */\n getDistDir?(): string;\n\n /**\n * given a source file, return its parallel in the dists. e.g. \"index.ts\" => \"dist/index.js\"\n * both, the return path and the given path are relative paths.\n */\n getDistPathBySrcPath(srcPath: string): string;\n\n /**\n * given a component, returns the path to the source folder to use for the preview, uses the one\n * in node_modules by default\n */\n getPreviewComponentRootPath?(component: Component): string;\n\n /**\n * only supported files matching get compiled. others, are copied to the dist dir.\n */\n isFileSupported(filePath: string): boolean;\n\n /**\n * sugar to create a Compiler task via the concrete compiler\n */\n createTask?(name?: string): BuildTask;\n\n /**\n * run before the build pipeline has started. this is useful when some preparation are needed to\n * be done on all envs before the build starts.\n */\n preBuild?(context: BuildContext): Promise<void>;\n\n /**\n * run after the build pipeline completed for all envs. useful for some cleanups\n */\n postBuild?(context: BuildContext, tasksResults: TaskResultsList): Promise<void>;\n\n /**\n * returns the version of the current compiler instance (e.g. '4.0.1').\n */\n version(): string;\n\n /**\n * returns the display name of the current compiler instance (e.g. 'TypeScript')\n */\n displayName: string;\n}\n"],"mappings":";;;;;;IASYA,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,0BAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["CompilationInitiator","exports"],"sources":["types.ts"],"sourcesContent":["import { BuildContext, BuildTask, BuiltTaskResult, TaskResultsList } from '@teambit/builder';\nimport type { Component } from '@teambit/component';\nimport { ServiceHandler } from '@teambit/envs';\n\nexport type TranspileFileParams = {\n componentDir: string; // absolute path of the component's root directory\n filePath: string; // relative path of the file inside the component directory\n};\n\nexport enum CompilationInitiator {\n CmdReport,\n CmdJson,\n PreStart,\n PreWatch,\n Start,\n ComponentChanged,\n AspectLoadFail,\n ComponentAdded,\n Install,\n}\n\nexport type TranspileComponentParams = {\n component: Component;\n componentDir: string; // absolute path of the component's root directory\n outputDir: string; // absolute path of the component's output directory\n initiator: CompilationInitiator; // origin of the compilation's request\n};\n\nexport type TypeGeneratorCompParams = { component: Component; packageDir: string };\n\nexport type TranspileFileOutputOneFile = {\n outputText: string;\n outputPath: string;\n};\n\nexport type TranspileFileOutput = TranspileFileOutputOneFile[] | null;\n\nexport interface CompilerOptions {\n /**\n * name of the compiler.\n */\n name?: string;\n\n /**\n * relative path of the dist directory inside the capsule. e.g. \"dist\".\n */\n distDir: string;\n\n /**\n * determines which ones of the generated files will be saved in the bit objects when tagging.\n * e.g. distGlobPatterns = [`${this.distDir}/**`, `!${this.distDir}/tsconfig.tsbuildinfo`];\n * see https://github.com/mrmlnc/fast-glob for the supported glob patters syntax.\n */\n distGlobPatterns?: string[];\n\n /**\n * whether or not unsupported files (such as assets) should be copied into the dist directory\n */\n shouldCopyNonSupportedFiles?: boolean;\n\n /**\n * optional. default to \"dist\".\n * useful when the build pipeline has multiple compiler tasks of the same compiler.\n * e.g. using the same Babel compiler for two different tasks, one for creating \"es5\" files, and\n * the second for creating \"esm\". the artifact names would be \"es5\" and \"esm\" accordingly.\n */\n artifactName?: string;\n}\n\nexport interface Compiler extends CompilerOptions, ServiceHandler {\n /**\n * id of the compiler.\n */\n id: string;\n\n /**\n * Delete dist folder before writing the new compiled files\n */\n deleteDistDir?: boolean;\n\n /**\n * serialized config of the compiler.\n */\n displayConfig?(): string;\n\n /**\n * transpile a single file that gets saved into the workspace, used by `bit compile` and during\n * development\n */\n transpileFile?: (\n fileContent: string,\n params: TranspileFileParams\n ) => TranspileFileOutput | Promise<TranspileFileOutput>;\n\n /**\n * transpile all the files of a component, use this when you can't use `transpileFile`\n */\n transpileComponent?: (params: TranspileComponentParams) => Promise<void>;\n\n preGenerateTypesOnWorkspace?: (params: TypeGeneratorCompParams[], envId: string) => Promise<void>;\n\n generateTypesOnWorkspace?: (rootDir: string, params: TypeGeneratorCompParams[]) => Promise<void>;\n\n /**\n * compile components inside isolated capsules. this being used during tag for the release.\n * meaning, the final package of the component has the dists generated by this method.\n *\n * no need to handle non-supported-files (e.g. assets) in this method because the compiler-aspect already copies them\n * into the compiler.dist in the preBuild stage.\n */\n build(context: BuildContext): Promise<BuiltTaskResult>;\n\n /**\n * return the dist dir of the compiled files (relative path from the component root dir)\n */\n getDistDir?(): string;\n\n /**\n * given a source file, return its parallel in the dists. e.g. \"index.ts\" => \"dist/index.js\"\n * both, the return path and the given path are relative paths.\n */\n getDistPathBySrcPath(srcPath: string): string;\n\n /**\n * given a component, returns the path to the source folder to use for the preview, uses the one\n * in node_modules by default\n */\n getPreviewComponentRootPath?(component: Component): string;\n\n /**\n * only supported files matching get compiled. others, are copied to the dist dir.\n */\n isFileSupported(filePath: string): boolean;\n\n /**\n * sugar to create a Compiler task via the concrete compiler\n */\n createTask?(name?: string): BuildTask;\n\n /**\n * run before the build pipeline has started. this is useful when some preparation are needed to\n * be done on all envs before the build starts.\n */\n preBuild?(context: BuildContext): Promise<void>;\n\n /**\n * run after the build pipeline completed for all envs. useful for some cleanups\n */\n postBuild?(context: BuildContext, tasksResults: TaskResultsList): Promise<void>;\n\n /**\n * returns the version of the current compiler instance (e.g. '4.0.1').\n */\n version(): string;\n\n /**\n * returns the display name of the current compiler instance (e.g. 'TypeScript')\n */\n displayName: string;\n}\n"],"mappings":";;;;;;IASYA,oBAAoB,GAAAC,OAAA,CAAAD,oBAAA,0BAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAApBA,oBAAoB,CAApBA,oBAAoB;EAAA,OAApBA,oBAAoB;AAAA","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component } from '@teambit/component';
|
|
2
|
-
import { EnvsMain } from '@teambit/envs';
|
|
2
|
+
import { EnvDefinition, EnvsMain } from '@teambit/envs';
|
|
3
3
|
import type { PubsubMain } from '@teambit/pubsub';
|
|
4
4
|
import { SerializableResults, Workspace } from '@teambit/workspace';
|
|
5
5
|
import type { WorkspaceComponentLoadOptions } from '@teambit/workspace';
|
|
@@ -28,6 +28,11 @@ export type CompileOptions = {
|
|
|
28
28
|
deleteDistDir?: boolean;
|
|
29
29
|
initiator: CompilationInitiator;
|
|
30
30
|
linkComponents?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* whether to generate types after the compilation, default = false.
|
|
33
|
+
* keep in mind that it's a heavy operation, and hurts the performance.
|
|
34
|
+
*/
|
|
35
|
+
generateTypes?: boolean;
|
|
31
36
|
};
|
|
32
37
|
export type CompileError = {
|
|
33
38
|
path: string;
|
|
@@ -36,19 +41,21 @@ export type CompileError = {
|
|
|
36
41
|
export declare class ComponentCompiler {
|
|
37
42
|
private pubsub;
|
|
38
43
|
private workspace;
|
|
39
|
-
|
|
40
|
-
|
|
44
|
+
readonly component: Component;
|
|
45
|
+
readonly compilerInstance: Compiler;
|
|
41
46
|
private compilerId;
|
|
42
47
|
private logger;
|
|
43
|
-
|
|
48
|
+
readonly env: EnvDefinition;
|
|
44
49
|
private dists;
|
|
45
50
|
private compileErrors;
|
|
46
|
-
constructor(pubsub: PubsubMain, workspace: Workspace, component: Component, compilerInstance: Compiler, compilerId: string, logger: Logger,
|
|
51
|
+
constructor(pubsub: PubsubMain, workspace: Workspace, component: Component, compilerInstance: Compiler, compilerId: string, logger: Logger, env: EnvDefinition, dists?: Dist[], compileErrors?: CompileError[]);
|
|
47
52
|
compile(noThrow: boolean | undefined, options: CompileOptions): Promise<BuildResult>;
|
|
53
|
+
getPackageDir(): string;
|
|
48
54
|
private throwOnCompileErrors;
|
|
49
55
|
private distDirs;
|
|
50
56
|
private getInjectedDirs;
|
|
51
57
|
private get componentDir();
|
|
58
|
+
copyTypesToOtherDists(): Promise<void>;
|
|
52
59
|
private compileOneFile;
|
|
53
60
|
private compileAllFiles;
|
|
54
61
|
}
|
|
@@ -72,6 +79,9 @@ export declare class WorkspaceCompiler {
|
|
|
72
79
|
compileComponents(componentsIds: string[] | ComponentID[] | ComponentID[], // when empty, it compiles new+modified (unless options.all is set),
|
|
73
80
|
options: CompileOptions, noThrow?: boolean, componentLoadOptions?: WorkspaceComponentLoadOptions): Promise<BuildResult[]>;
|
|
74
81
|
private runCompileComponents;
|
|
82
|
+
private getTypesCompilerPerEnv;
|
|
83
|
+
private preGenerateTypesOnWorkspace;
|
|
84
|
+
private generateTypesOnWorkspace;
|
|
75
85
|
/**
|
|
76
86
|
* This function groups the components to compile into groups by their environment and dependencies.
|
|
77
87
|
* The order of the groups is important, the first group should be compiled first.
|
|
@@ -11,6 +11,20 @@ function _pMapSeries() {
|
|
|
11
11
|
};
|
|
12
12
|
return data;
|
|
13
13
|
}
|
|
14
|
+
function _globby() {
|
|
15
|
+
const data = _interopRequireDefault(require("globby"));
|
|
16
|
+
_globby = function () {
|
|
17
|
+
return data;
|
|
18
|
+
};
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
function _fsExtra() {
|
|
22
|
+
const data = _interopRequireDefault(require("fs-extra"));
|
|
23
|
+
_fsExtra = function () {
|
|
24
|
+
return data;
|
|
25
|
+
};
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
14
28
|
function _workspace() {
|
|
15
29
|
const data = require("@teambit/workspace");
|
|
16
30
|
_workspace = function () {
|
|
@@ -120,14 +134,14 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
120
134
|
/* eslint-disable max-classes-per-file */
|
|
121
135
|
|
|
122
136
|
class ComponentCompiler {
|
|
123
|
-
constructor(pubsub, workspace, component, compilerInstance, compilerId, logger,
|
|
137
|
+
constructor(pubsub, workspace, component, compilerInstance, compilerId, logger, env, dists = [], compileErrors = []) {
|
|
124
138
|
this.pubsub = pubsub;
|
|
125
139
|
this.workspace = workspace;
|
|
126
140
|
this.component = component;
|
|
127
141
|
this.compilerInstance = compilerInstance;
|
|
128
142
|
this.compilerId = compilerId;
|
|
129
143
|
this.logger = logger;
|
|
130
|
-
this.
|
|
144
|
+
this.env = env;
|
|
131
145
|
this.dists = dists;
|
|
132
146
|
this.compileErrors = compileErrors;
|
|
133
147
|
}
|
|
@@ -151,7 +165,7 @@ class ComponentCompiler {
|
|
|
151
165
|
await Promise.all(this.component.filesystem.files.map(file => this.compileOneFile(file, options.initiator, distDirs)));
|
|
152
166
|
}
|
|
153
167
|
if (canTranspileComponent) {
|
|
154
|
-
await this.compileAllFiles(
|
|
168
|
+
await this.compileAllFiles(options.initiator, distDirs);
|
|
155
169
|
}
|
|
156
170
|
if (!canTranspileFile && !canTranspileComponent) {
|
|
157
171
|
throw new Error(`compiler ${this.compilerId.toString()} doesn't implement either "transpileFile" or "transpileComponent" methods`);
|
|
@@ -172,6 +186,10 @@ class ComponentCompiler {
|
|
|
172
186
|
errors: this.compileErrors
|
|
173
187
|
};
|
|
174
188
|
}
|
|
189
|
+
getPackageDir() {
|
|
190
|
+
const packageName = (0, _pkgModules().componentIdToPackageName)(this.component.state._consumer);
|
|
191
|
+
return _path().default.join('node_modules', packageName);
|
|
192
|
+
}
|
|
175
193
|
throwOnCompileErrors(noThrow = true) {
|
|
176
194
|
if (this.compileErrors.length) {
|
|
177
195
|
this.compileErrors.forEach(errorItem => {
|
|
@@ -203,6 +221,27 @@ ${this.compileErrors.map(formatError).join('\n')}`);
|
|
|
203
221
|
get componentDir() {
|
|
204
222
|
return this.workspace.componentDir(this.component.id);
|
|
205
223
|
}
|
|
224
|
+
async copyTypesToOtherDists() {
|
|
225
|
+
const distDirs = await this.distDirs();
|
|
226
|
+
if (distDirs.length <= 1) return;
|
|
227
|
+
const packageDistDir = distDirs[0];
|
|
228
|
+
const otherDirs = distDirs.slice(1);
|
|
229
|
+
const packageDistDirAbs = _path().default.join(this.workspace.path, packageDistDir);
|
|
230
|
+
const matches = await (0, _globby().default)(`**/*.d.ts`, {
|
|
231
|
+
cwd: packageDistDirAbs,
|
|
232
|
+
onlyFiles: true,
|
|
233
|
+
ignore: [`${packageDistDir}/node_modules/`]
|
|
234
|
+
});
|
|
235
|
+
if (!matches.length) return;
|
|
236
|
+
await Promise.all(otherDirs.map(async distDir => {
|
|
237
|
+
const distDirAbs = _path().default.join(this.workspace.path, distDir);
|
|
238
|
+
await Promise.all(matches.map(async match => {
|
|
239
|
+
const source = _path().default.join(packageDistDirAbs, match);
|
|
240
|
+
const dest = _path().default.join(distDirAbs, match);
|
|
241
|
+
await _fsExtra().default.copyFile(source, dest);
|
|
242
|
+
}));
|
|
243
|
+
}));
|
|
244
|
+
}
|
|
206
245
|
async compileOneFile(file, initiator, distDirs) {
|
|
207
246
|
const options = {
|
|
208
247
|
componentDir: this.componentDir,
|
|
@@ -239,10 +278,10 @@ ${this.compileErrors.map(formatError).join('\n')}`);
|
|
|
239
278
|
}
|
|
240
279
|
}
|
|
241
280
|
}
|
|
242
|
-
async compileAllFiles(
|
|
281
|
+
async compileAllFiles(initiator, distDirs) {
|
|
243
282
|
const filesToCompile = [];
|
|
244
283
|
for (const base of distDirs) {
|
|
245
|
-
component.filesystem.files.forEach(file => {
|
|
284
|
+
this.component.filesystem.files.forEach(file => {
|
|
246
285
|
const isFileSupported = this.compilerInstance.isFileSupported(file.path);
|
|
247
286
|
if (isFileSupported) {
|
|
248
287
|
filesToCompile.push(file);
|
|
@@ -259,9 +298,9 @@ ${this.compileErrors.map(formatError).join('\n')}`);
|
|
|
259
298
|
if (filesToCompile.length) {
|
|
260
299
|
try {
|
|
261
300
|
await this.compilerInstance.transpileComponent?.({
|
|
262
|
-
component,
|
|
301
|
+
component: this.component,
|
|
263
302
|
componentDir: this.componentDir,
|
|
264
|
-
outputDir: await this.workspace.getComponentPackagePath(component),
|
|
303
|
+
outputDir: await this.workspace.getComponentPackagePath(this.component),
|
|
265
304
|
initiator
|
|
266
305
|
});
|
|
267
306
|
} catch (error) {
|
|
@@ -379,18 +418,76 @@ class WorkspaceCompiler {
|
|
|
379
418
|
async runCompileComponents(components, options, noThrow) {
|
|
380
419
|
const componentsCompilers = [];
|
|
381
420
|
components.forEach(c => {
|
|
382
|
-
const
|
|
421
|
+
const env = this.envs.getEnv(c);
|
|
422
|
+
const environment = env.env;
|
|
383
423
|
const compilerInstance = environment.getCompiler?.();
|
|
384
424
|
if (compilerInstance) {
|
|
385
425
|
const compilerName = compilerInstance.constructor.name || 'compiler';
|
|
386
|
-
componentsCompilers.push(new ComponentCompiler(this.pubsub, this.workspace, c, compilerInstance, compilerName, this.logger,
|
|
426
|
+
componentsCompilers.push(new ComponentCompiler(this.pubsub, this.workspace, c, compilerInstance, compilerName, this.logger, env));
|
|
387
427
|
} else {
|
|
388
428
|
this.logger.warn(`unable to find a compiler instance for ${c.id.toString()}`);
|
|
389
429
|
}
|
|
390
430
|
});
|
|
431
|
+
const typeGeneratorParamsPerEnv = options.generateTypes ? await this.getTypesCompilerPerEnv(componentsCompilers) : undefined;
|
|
432
|
+
if (typeGeneratorParamsPerEnv) {
|
|
433
|
+
await this.preGenerateTypesOnWorkspace(typeGeneratorParamsPerEnv);
|
|
434
|
+
}
|
|
391
435
|
const resultOnWorkspace = await (0, _pMapSeries().default)(componentsCompilers, componentCompiler => componentCompiler.compile(noThrow, options));
|
|
436
|
+
if (typeGeneratorParamsPerEnv) {
|
|
437
|
+
await this.generateTypesOnWorkspace(typeGeneratorParamsPerEnv, componentsCompilers);
|
|
438
|
+
}
|
|
392
439
|
return resultOnWorkspace;
|
|
393
440
|
}
|
|
441
|
+
async getTypesCompilerPerEnv(componentsCompilers) {
|
|
442
|
+
const envsMap = {};
|
|
443
|
+
componentsCompilers.forEach(componentCompiler => {
|
|
444
|
+
const envId = componentCompiler.env.id;
|
|
445
|
+
if (!envsMap[envId]) envsMap[envId] = [];
|
|
446
|
+
envsMap[envId].push(componentCompiler);
|
|
447
|
+
});
|
|
448
|
+
const results = await (0, _pMapSeries().default)(Object.keys(envsMap), async envId => {
|
|
449
|
+
const componentCompilers = envsMap[envId];
|
|
450
|
+
const compParams = await Promise.all(componentCompilers.map(async componentCompiler => {
|
|
451
|
+
return {
|
|
452
|
+
component: componentCompiler.component,
|
|
453
|
+
packageDir: _path().default.join(this.workspace.path, componentCompiler.getPackageDir())
|
|
454
|
+
};
|
|
455
|
+
}));
|
|
456
|
+
let typeCompiler = componentCompilers[0].compilerInstance;
|
|
457
|
+
if (!typeCompiler.preGenerateTypesOnWorkspace) {
|
|
458
|
+
const buildPipe = componentCompilers[0].env.env.getBuildPipe();
|
|
459
|
+
const compilerTasks = buildPipe.filter(task => task.aspectId === _compiler().CompilerAspect.id);
|
|
460
|
+
const tsTask = compilerTasks.find(task => task.compilerInstance && task.compilerInstance.displayName === 'TypeScript');
|
|
461
|
+
if (!tsTask) return;
|
|
462
|
+
typeCompiler = tsTask.compilerInstance;
|
|
463
|
+
if (!typeCompiler.preGenerateTypesOnWorkspace) return;
|
|
464
|
+
}
|
|
465
|
+
return {
|
|
466
|
+
envId,
|
|
467
|
+
compParams,
|
|
468
|
+
typeCompiler
|
|
469
|
+
};
|
|
470
|
+
});
|
|
471
|
+
return (0, _lodash().compact)(results);
|
|
472
|
+
}
|
|
473
|
+
async preGenerateTypesOnWorkspace(typesGeneratorParamsPerEnv) {
|
|
474
|
+
await (0, _pMapSeries().default)(typesGeneratorParamsPerEnv, async ({
|
|
475
|
+
envId,
|
|
476
|
+
compParams,
|
|
477
|
+
typeCompiler
|
|
478
|
+
}) => {
|
|
479
|
+
await typeCompiler.preGenerateTypesOnWorkspace(compParams, envId);
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
async generateTypesOnWorkspace(typesGeneratorParamsPerEnv, componentsCompilers) {
|
|
483
|
+
await (0, _pMapSeries().default)(typesGeneratorParamsPerEnv, async ({
|
|
484
|
+
compParams,
|
|
485
|
+
typeCompiler
|
|
486
|
+
}) => {
|
|
487
|
+
await typeCompiler.generateTypesOnWorkspace(_path().default.join(this.workspace.path, 'node_modules'), compParams);
|
|
488
|
+
});
|
|
489
|
+
await Promise.all(componentsCompilers.map(componentCompiler => componentCompiler.copyTypesToOtherDists()));
|
|
490
|
+
}
|
|
394
491
|
|
|
395
492
|
/**
|
|
396
493
|
* This function groups the components to compile into groups by their environment and dependencies.
|