@teambit/typescript 0.0.1075 → 0.0.1076

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.
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.1075/dist/typescript.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.1075/dist/typescript.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.1076/dist/typescript.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.1076/dist/typescript.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -0,0 +1,8 @@
1
+ import { BuildContext, BuildTask, BuiltTaskResult } from '@teambit/builder';
2
+ export declare class RemoveTypesTask implements BuildTask {
3
+ readonly aspectId: string;
4
+ readonly name = "RemoveTypesProp";
5
+ readonly description = "remove the types prop from package.json";
6
+ execute(context: BuildContext): Promise<BuiltTaskResult>;
7
+ private removeTypesFromPkgJson;
8
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ require("core-js/modules/es.array.iterator.js");
5
+ require("core-js/modules/es.promise.js");
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.RemoveTypesTask = void 0;
10
+ function _defineProperty2() {
11
+ const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
+ _defineProperty2 = function () {
13
+ return data;
14
+ };
15
+ return data;
16
+ }
17
+ function _packageJsonFile() {
18
+ const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/component/package-json-file"));
19
+ _packageJsonFile = function () {
20
+ return data;
21
+ };
22
+ return data;
23
+ }
24
+ function _typescript() {
25
+ const data = require("./typescript.aspect");
26
+ _typescript = function () {
27
+ return data;
28
+ };
29
+ return data;
30
+ }
31
+ class RemoveTypesTask {
32
+ constructor() {
33
+ (0, _defineProperty2().default)(this, "aspectId", _typescript().TypescriptAspect.id);
34
+ (0, _defineProperty2().default)(this, "name", 'RemoveTypesProp');
35
+ (0, _defineProperty2().default)(this, "description", 'remove the types prop from package.json');
36
+ }
37
+ async execute(context) {
38
+ await this.removeTypesFromPkgJson(context.capsuleNetwork);
39
+ const result = {
40
+ componentsResults: []
41
+ };
42
+ return result;
43
+ }
44
+ async removeTypesFromPkgJson(capsuleNetwork) {
45
+ await Promise.all(capsuleNetwork.seedersCapsules.map(async capsule => {
46
+ const packageJson = _packageJsonFile().default.loadFromCapsuleSync(capsule.path);
47
+ // the types['index.ts'] is needed only during the build to avoid errors when tsc finds the
48
+ // same type once in the d.ts and once in the ts file.
49
+ // the reason for `packageJson.packageJsonObject.main` is that .d.ts components don't have a main file and they do need the types prop
50
+ if (packageJson.packageJsonObject.types && packageJson.packageJsonObject.main) {
51
+ delete packageJson.packageJsonObject.types;
52
+ await packageJson.write();
53
+ }
54
+ }));
55
+ }
56
+ }
57
+ exports.RemoveTypesTask = RemoveTypesTask;
58
+
59
+ //# sourceMappingURL=remove-types-task.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["RemoveTypesTask","TypescriptAspect","id","execute","context","removeTypesFromPkgJson","capsuleNetwork","result","componentsResults","Promise","all","seedersCapsules","map","capsule","packageJson","PackageJsonFile","loadFromCapsuleSync","path","packageJsonObject","types","main","write"],"sources":["remove-types-task.ts"],"sourcesContent":["import PackageJsonFile from '@teambit/legacy/dist/consumer/component/package-json-file';\nimport { Network } from '@teambit/isolator';\nimport { BuildContext, BuildTask, BuiltTaskResult } from '@teambit/builder';\nimport { TypescriptAspect } from './typescript.aspect';\n\nexport class RemoveTypesTask implements BuildTask {\n readonly aspectId = TypescriptAspect.id;\n readonly name = 'RemoveTypesProp';\n readonly description = 'remove the types prop from package.json';\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n await this.removeTypesFromPkgJson(context.capsuleNetwork);\n\n const result = {\n componentsResults: [],\n };\n\n return result;\n }\n private async removeTypesFromPkgJson(capsuleNetwork: Network) {\n await Promise.all(\n capsuleNetwork.seedersCapsules.map(async (capsule) => {\n const packageJson = PackageJsonFile.loadFromCapsuleSync(capsule.path);\n // the types['index.ts'] is needed only during the build to avoid errors when tsc finds the\n // same type once in the d.ts and once in the ts file.\n // the reason for `packageJson.packageJsonObject.main` is that .d.ts components don't have a main file and they do need the types prop\n if (packageJson.packageJsonObject.types && packageJson.packageJsonObject.main) {\n delete packageJson.packageJsonObject.types;\n await packageJson.write();\n }\n })\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAGA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,eAAe,CAAsB;EAAA;IAAA,kDAC5BC,8BAAgB,CAACC,EAAE;IAAA,8CACvB,iBAAiB;IAAA,qDACV,yCAAyC;EAAA;EAChE,MAAMC,OAAO,CAACC,OAAqB,EAA4B;IAC7D,MAAM,IAAI,CAACC,sBAAsB,CAACD,OAAO,CAACE,cAAc,CAAC;IAEzD,MAAMC,MAAM,GAAG;MACbC,iBAAiB,EAAE;IACrB,CAAC;IAED,OAAOD,MAAM;EACf;EACA,MAAcF,sBAAsB,CAACC,cAAuB,EAAE;IAC5D,MAAMG,OAAO,CAACC,GAAG,CACfJ,cAAc,CAACK,eAAe,CAACC,GAAG,CAAC,MAAOC,OAAO,IAAK;MACpD,MAAMC,WAAW,GAAGC,0BAAe,CAACC,mBAAmB,CAACH,OAAO,CAACI,IAAI,CAAC;MACrE;MACA;MACA;MACA,IAAIH,WAAW,CAACI,iBAAiB,CAACC,KAAK,IAAIL,WAAW,CAACI,iBAAiB,CAACE,IAAI,EAAE;QAC7E,OAAON,WAAW,CAACI,iBAAiB,CAACC,KAAK;QAC1C,MAAML,WAAW,CAACO,KAAK,EAAE;MAC3B;IACF,CAAC,CAAC,CACH;EACH;AACF;AAAC"}
@@ -31,7 +31,6 @@ export declare class TypescriptCompiler implements Compiler, TypescriptCompilerI
31
31
  * compile multiple components on the capsules
32
32
  */
33
33
  build(context: BuildContext): Promise<BuiltTaskResult>;
34
- postBuild(context: BuildContext): Promise<void>;
35
34
  getArtifactDefinition(): {
36
35
  generatedBy: string;
37
36
  name: string;
@@ -38,13 +38,6 @@ function _bitError() {
38
38
  };
39
39
  return data;
40
40
  }
41
- function _packageJsonFile() {
42
- const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/component/package-json-file"));
43
- _packageJsonFile = function () {
44
- return data;
45
- };
46
- return data;
47
- }
48
41
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
49
42
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
50
43
  class TypescriptCompiler {
@@ -142,18 +135,6 @@ class TypescriptCompiler {
142
135
  componentsResults
143
136
  };
144
137
  }
145
- async postBuild(context) {
146
- await Promise.all(context.capsuleNetwork.seedersCapsules.map(async capsule => {
147
- const packageJson = _packageJsonFile().default.loadFromCapsuleSync(capsule.path);
148
- // the types['index.ts'] is needed only during the build to avoid errors when tsc finds the
149
- // same type once in the d.ts and once in the ts file.
150
- // the reason for `packageJson.packageJsonObject.main` is that .d.ts components don't have a main file and they do need the types prop
151
- if (packageJson.packageJsonObject.types && packageJson.packageJsonObject.main) {
152
- delete packageJson.packageJsonObject.types;
153
- await packageJson.write();
154
- }
155
- }));
156
- }
157
138
  getArtifactDefinition() {
158
139
  return [{
159
140
  generatedBy: this.id,
@@ -1 +1 @@
1
- {"version":3,"names":["TypescriptCompiler","constructor","id","logger","options","tsModule","distDir","distGlobPatterns","shouldCopyNonSupportedFiles","artifactName","tsconfig","compilerOptions","outDir","generateIdeConfig","globalTypesPaths","types","displayConfig","stringifyTsconfig","getDistDir","transpileFile","fileContent","isFileSupported","filePath","compilerOptionsFromTsconfig","convertCompilerOptionsFromJson","errors","length","formattedErrors","formatDiagnosticsWithColorAndContext","getFormatDiagnosticsHost","Error","sourceRoot","componentDir","rootDir","result","transpileModule","fileName","reportDiagnostics","diagnostics","formatHost","error","outputPath","replaceFileExtToJs","outputFiles","outputText","sourceMapText","push","preBuild","context","capsules","capsuleNetwork","seedersCapsules","capsuleDirs","map","capsule","path","writeTsConfig","writeTypes","writeNpmIgnore","build","componentsResults","runTscBuild","artifacts","getArtifactDefinition","postBuild","Promise","all","packageJson","PackageJsonFile","loadFromCapsuleSync","packageJsonObject","main","write","generatedBy","name","globPatterns","getDistPathBySrcPath","srcPath","fileWithJSExtIfNeeded","join","isJsAndCompile","compileJs","endsWith","isJsxAndCompile","compileJsx","network","capsulesRootDir","getCapsulesToCompile","getAllCapsuleDirs","getCanonicalFileName","p","getCurrentDirectory","getNewLine","sys","newLine","currentComponentResult","reportDiagnostic","diagnostic","errorStr","process","stdout","isTTY","formatDiagnostic","file","BitError","consoleFailure","component","reportSolutionBuilderStatus","diag","msg","messageText","debug","errorCounter","errorCount","info","host","createSolutionBuilderHost","undefined","writeProjectReferencesTsConfig","solutionBuilder","createSolutionBuilder","verbose","nextProject","longProcessLogger","createLongProcessLogger","getNextInvalidatedProject","capsulePath","project","replace","currentComponentId","getIdByPathInCapsule","logProgress","toString","getCapsule","startTime","Date","now","done","endTime","end","dirs","typePath","contents","fs","readFile","filename","basename","dir","pathExists","outputFile","NPM_IGNORE_FILE","npmIgnorePath","npmIgnoreEntriesStr","appendFile","projects","files","references","tsconfigStr","writeFile","JSON","stringify","fileExtension","extname","RegExp","version"],"sources":["typescript.compiler.ts"],"sourcesContent":["import { BuildContext, BuiltTaskResult, ComponentResult } from '@teambit/builder';\nimport { Compiler, TranspileFileParams, TranspileFileOutput } from '@teambit/compiler';\nimport { Network } from '@teambit/isolator';\nimport { Logger } from '@teambit/logger';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport ts from 'typescript';\nimport { BitError } from '@teambit/bit-error';\nimport PackageJsonFile from '@teambit/legacy/dist/consumer/component/package-json-file';\nimport { TypeScriptCompilerOptions } from './compiler-options';\nimport { TypescriptCompilerInterface } from './typescript-compiler-interface';\n\nexport class TypescriptCompiler implements Compiler, TypescriptCompilerInterface {\n distDir: string;\n distGlobPatterns: string[];\n shouldCopyNonSupportedFiles: boolean;\n artifactName: string;\n constructor(\n readonly id: string,\n private logger: Logger,\n private options: TypeScriptCompilerOptions,\n private tsModule: typeof ts\n ) {\n this.distDir = options.distDir || 'dist';\n this.distGlobPatterns = options.distGlobPatterns || [`${this.distDir}/**`, `!${this.distDir}/tsconfig.tsbuildinfo`];\n this.shouldCopyNonSupportedFiles =\n typeof options.shouldCopyNonSupportedFiles === 'boolean' ? options.shouldCopyNonSupportedFiles : true;\n this.artifactName = options.artifactName || 'dist';\n this.options.tsconfig ||= {};\n this.options.tsconfig.compilerOptions ||= {};\n // mutate the outDir, otherwise, on capsules, the dists might be written to a different directory and make confusion\n this.options.tsconfig.compilerOptions.outDir = this.distDir;\n }\n\n displayName = 'TypeScript';\n deleteDistDir = false;\n\n generateIdeConfig() {\n return {\n tsconfig: this.options.tsconfig,\n globalTypesPaths: this.options.types,\n };\n }\n\n displayConfig() {\n return this.stringifyTsconfig(this.options.tsconfig);\n }\n\n getDistDir() {\n return this.distDir;\n }\n\n /**\n * compile one file on the workspace\n */\n transpileFile(fileContent: string, options: TranspileFileParams): TranspileFileOutput {\n if (!this.isFileSupported(options.filePath)) {\n return null; // file is not supported\n }\n const compilerOptionsFromTsconfig = this.tsModule.convertCompilerOptionsFromJson(\n this.options.tsconfig.compilerOptions,\n '.'\n );\n if (compilerOptionsFromTsconfig.errors.length) {\n // :TODO @david replace to a more concrete error type and put in 'exceptions' directory here.\n const formattedErrors = this.tsModule.formatDiagnosticsWithColorAndContext(\n compilerOptionsFromTsconfig.errors,\n this.getFormatDiagnosticsHost()\n );\n throw new Error(`failed parsing the tsconfig.json.\\n${formattedErrors}`);\n }\n\n const compilerOptions = compilerOptionsFromTsconfig.options;\n compilerOptions.sourceRoot = options.componentDir;\n compilerOptions.rootDir = '.';\n const result = this.tsModule.transpileModule(fileContent, {\n compilerOptions,\n fileName: options.filePath,\n reportDiagnostics: true,\n });\n\n if (result.diagnostics && result.diagnostics.length) {\n const formatHost = this.getFormatDiagnosticsHost();\n const error = this.tsModule.formatDiagnosticsWithColorAndContext(result.diagnostics, formatHost);\n\n // :TODO @david please replace to a more concrete error type and put in 'exceptions' directory here.\n throw new Error(error);\n }\n\n const outputPath = this.replaceFileExtToJs(options.filePath);\n const outputFiles = [{ outputText: result.outputText, outputPath }];\n if (result.sourceMapText) {\n outputFiles.push({\n outputText: result.sourceMapText,\n outputPath: `${outputPath}.map`,\n });\n }\n return outputFiles;\n }\n\n async preBuild(context: BuildContext) {\n const capsules = context.capsuleNetwork.seedersCapsules;\n const capsuleDirs = capsules.map((capsule) => capsule.path);\n await this.writeTsConfig(capsuleDirs);\n await this.writeTypes(capsuleDirs);\n await this.writeNpmIgnore(capsuleDirs);\n }\n\n /**\n * compile multiple components on the capsules\n */\n async build(context: BuildContext): Promise<BuiltTaskResult> {\n const componentsResults = await this.runTscBuild(context.capsuleNetwork);\n\n return {\n artifacts: this.getArtifactDefinition(),\n componentsResults,\n };\n }\n\n async postBuild(context: BuildContext) {\n await Promise.all(\n context.capsuleNetwork.seedersCapsules.map(async (capsule) => {\n const packageJson = PackageJsonFile.loadFromCapsuleSync(capsule.path);\n // the types['index.ts'] is needed only during the build to avoid errors when tsc finds the\n // same type once in the d.ts and once in the ts file.\n // the reason for `packageJson.packageJsonObject.main` is that .d.ts components don't have a main file and they do need the types prop\n if (packageJson.packageJsonObject.types && packageJson.packageJsonObject.main) {\n delete packageJson.packageJsonObject.types;\n await packageJson.write();\n }\n })\n );\n }\n\n getArtifactDefinition() {\n return [\n {\n generatedBy: this.id,\n name: this.artifactName,\n globPatterns: this.distGlobPatterns,\n },\n ];\n }\n\n /**\n * given a source file, return its parallel in the dists. e.g. index.ts => dist/index.js\n */\n getDistPathBySrcPath(srcPath: string) {\n const fileWithJSExtIfNeeded = this.replaceFileExtToJs(srcPath);\n return path.join(this.distDir, fileWithJSExtIfNeeded);\n }\n\n /**\n * whether typescript is able to compile the given path\n */\n isFileSupported(filePath: string): boolean {\n const isJsAndCompile = !!this.options.compileJs && filePath.endsWith('.js');\n const isJsxAndCompile = !!this.options.compileJsx && filePath.endsWith('.jsx');\n return (\n (filePath.endsWith('.ts') || filePath.endsWith('.tsx') || isJsAndCompile || isJsxAndCompile) &&\n !filePath.endsWith('.d.ts')\n );\n }\n\n /**\n * we have two options here:\n * 1. pass all capsules-dir at the second parameter of createSolutionBuilder and then no\n * need to write the main tsconfig.json with all the references.\n * 2. write main tsconfig.json and pass the capsules root-dir.\n * we went with option #2 because it'll be easier for users to go to the capsule-root and run\n * `tsc --build` to debug issues.\n */\n private async runTscBuild(network: Network): Promise<ComponentResult[]> {\n const rootDir = network.capsulesRootDir;\n const capsules = await network.getCapsulesToCompile();\n if (!capsules.length) {\n return [];\n }\n const capsuleDirs = capsules.getAllCapsuleDirs();\n const formatHost = {\n getCanonicalFileName: (p) => p,\n getCurrentDirectory: () => '', // it helps to get the files with absolute paths\n getNewLine: () => this.tsModule.sys.newLine,\n };\n const componentsResults: ComponentResult[] = [];\n let currentComponentResult: Partial<ComponentResult> = { errors: [] };\n const reportDiagnostic = (diagnostic: ts.Diagnostic) => {\n const errorStr = process.stdout.isTTY\n ? this.tsModule.formatDiagnosticsWithColorAndContext([diagnostic], formatHost)\n : this.tsModule.formatDiagnostic(diagnostic, formatHost);\n if (!diagnostic.file) {\n // the error is general and not related to a specific file. e.g. tsconfig is missing.\n throw new BitError(errorStr);\n }\n this.logger.consoleFailure(errorStr);\n if (!currentComponentResult.component || !currentComponentResult.errors) {\n throw new Error(`currentComponentResult is not defined yet for ${diagnostic.file}`);\n }\n currentComponentResult.errors.push(errorStr);\n };\n // this only works when `verbose` is `true` in the `ts.createSolutionBuilder` function.\n const reportSolutionBuilderStatus = (diag: ts.Diagnostic) => {\n const msg = diag.messageText as string;\n this.logger.debug(msg);\n };\n const errorCounter = (errorCount: number) => {\n this.logger.info(`total error found: ${errorCount}`);\n };\n const host = this.tsModule.createSolutionBuilderHost(\n undefined,\n undefined,\n reportDiagnostic,\n reportSolutionBuilderStatus,\n errorCounter\n );\n await this.writeProjectReferencesTsConfig(rootDir, capsuleDirs);\n const solutionBuilder = this.tsModule.createSolutionBuilder(host, [rootDir], { verbose: true });\n let nextProject;\n const longProcessLogger = this.logger.createLongProcessLogger('compile typescript components', capsules.length);\n // eslint-disable-next-line no-cond-assign\n while ((nextProject = solutionBuilder.getNextInvalidatedProject())) {\n // regex to make sure it will work correctly for both linux and windows\n // it replaces both /tsconfig.json and \\tsocnfig.json\n const capsulePath = nextProject.project.replace(/[/\\\\]tsconfig.json/, '');\n const currentComponentId = capsules.getIdByPathInCapsule(capsulePath);\n if (!currentComponentId) throw new Error(`unable to find component for ${capsulePath}`);\n longProcessLogger.logProgress(currentComponentId.toString());\n const capsule = capsules.getCapsule(currentComponentId);\n if (!capsule) throw new Error(`unable to find capsule for ${currentComponentId.toString()}`);\n currentComponentResult.component = capsule.component;\n currentComponentResult.startTime = Date.now();\n nextProject.done();\n currentComponentResult.endTime = Date.now();\n componentsResults.push({ ...currentComponentResult } as ComponentResult);\n currentComponentResult = { errors: [] };\n }\n longProcessLogger.end();\n\n return componentsResults;\n }\n\n private getFormatDiagnosticsHost(): ts.FormatDiagnosticsHost {\n return {\n getCanonicalFileName: (p) => p,\n getCurrentDirectory: this.tsModule.sys.getCurrentDirectory,\n getNewLine: () => this.tsModule.sys.newLine,\n };\n }\n\n private async writeTypes(dirs: string[]) {\n await Promise.all(\n this.options.types.map(async (typePath) => {\n const contents = await fs.readFile(typePath, 'utf8');\n const filename = path.basename(typePath);\n\n await Promise.all(\n dirs.map(async (dir) => {\n const filePath = path.join(dir, 'types', filename);\n if (!(await fs.pathExists(filePath))) {\n await fs.outputFile(filePath, contents);\n }\n })\n );\n })\n );\n }\n\n /**\n * when using project-references, typescript adds a file \"tsconfig.tsbuildinfo\" which is not\n * needed for the package.\n */\n private async writeNpmIgnore(dirs: string[]) {\n const NPM_IGNORE_FILE = '.npmignore';\n await Promise.all(\n dirs.map(async (dir) => {\n const npmIgnorePath = path.join(dir, NPM_IGNORE_FILE);\n const npmIgnoreEntriesStr = `\\n${this.distDir}/tsconfig.tsbuildinfo\\n`;\n await fs.appendFile(npmIgnorePath, npmIgnoreEntriesStr);\n })\n );\n }\n\n private async writeProjectReferencesTsConfig(rootDir: string, projects: string[]) {\n const files = [];\n const references = projects.map((project) => ({ path: project }));\n const tsconfig = { files, references };\n const tsconfigStr = this.stringifyTsconfig(tsconfig);\n await fs.writeFile(path.join(rootDir, 'tsconfig.json'), tsconfigStr);\n }\n\n private async writeTsConfig(dirs: string[]) {\n const tsconfigStr = this.stringifyTsconfig(this.options.tsconfig);\n await Promise.all(dirs.map((dir) => fs.writeFile(path.join(dir, 'tsconfig.json'), tsconfigStr)));\n }\n\n private stringifyTsconfig(tsconfig) {\n return JSON.stringify(tsconfig, undefined, 2);\n }\n\n private replaceFileExtToJs(filePath: string): string {\n if (!this.isFileSupported(filePath)) return filePath;\n const fileExtension = path.extname(filePath);\n return filePath.replace(new RegExp(`${fileExtension}$`), '.js'); // makes sure it's the last occurrence\n }\n\n version() {\n return this.tsModule.version;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAwF;AAAA;AAIjF,MAAMA,kBAAkB,CAAkD;EAK/EC,WAAW,CACAC,EAAU,EACXC,MAAc,EACdC,OAAkC,EAClCC,QAAmB,EAC3B;IAAA;IAAA,KAJSH,EAAU,GAAVA,EAAU;IAAA,KACXC,MAAc,GAAdA,MAAc;IAAA,KACdC,OAAkC,GAAlCA,OAAkC;IAAA,KAClCC,QAAmB,GAAnBA,QAAmB;IAAA;IAAA;IAAA;IAAA;IAAA,qDAaf,YAAY;IAAA,uDACV,KAAK;IAZnB,IAAI,CAACC,OAAO,GAAGF,OAAO,CAACE,OAAO,IAAI,MAAM;IACxC,IAAI,CAACC,gBAAgB,GAAGH,OAAO,CAACG,gBAAgB,IAAI,CAAE,GAAE,IAAI,CAACD,OAAQ,KAAI,EAAG,IAAG,IAAI,CAACA,OAAQ,uBAAsB,CAAC;IACnH,IAAI,CAACE,2BAA2B,GAC9B,OAAOJ,OAAO,CAACI,2BAA2B,KAAK,SAAS,GAAGJ,OAAO,CAACI,2BAA2B,GAAG,IAAI;IACvG,IAAI,CAACC,YAAY,GAAGL,OAAO,CAACK,YAAY,IAAI,MAAM;IAClD,qBAAI,CAACL,OAAO,EAACM,QAAQ,KAArB,cAAaA,QAAQ,GAAK,CAAC,CAAC;IAC5B,6BAAI,CAACN,OAAO,CAACM,QAAQ,EAACC,eAAe,KAArC,sBAAsBA,eAAe,GAAK,CAAC,CAAC;IAC5C;IACA,IAAI,CAAC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IAAc,EAAE;IAC1C,MAAMiB,WAAW,GAAG,IAAI,CAAC5I,iBAAiB,CAAC,IAAI,CAACb,OAAO,CAACM,QAAQ,CAAC;IACjE,MAAMuD,OAAO,CAACC,GAAG,CAAC0E,IAAI,CAACvF,GAAG,CAAE8F,GAAG,IAAKJ,kBAAE,CAACe,SAAS,CAACvG,eAAI,CAACwB,IAAI,CAACoE,GAAG,EAAE,eAAe,CAAC,EAAEU,WAAW,CAAC,CAAC,CAAC;EAClG;EAEQ5I,iBAAiB,CAACP,QAAQ,EAAE;IAClC,OAAOqJ,IAAI,CAACC,SAAS,CAACtJ,QAAQ,EAAE2G,SAAS,EAAE,CAAC,CAAC;EAC/C;EAEQ3E,kBAAkB,CAACpB,QAAgB,EAAU;IACnD,IAAI,CAAC,IAAI,CAACD,eAAe,CAACC,QAAQ,CAAC,EAAE,OAAOA,QAAQ;IACpD,MAAM2I,aAAa,GAAG1G,eAAI,CAAC2G,OAAO,CAAC5I,QAAQ,CAAC;IAC5C,OAAOA,QAAQ,CAAC0G,OAAO,CAAC,IAAImC,MAAM,CAAE,GAAEF,aAAc,GAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;EACnE;;EAEAG,OAAO,GAAG;IACR,OAAO,IAAI,CAAC/J,QAAQ,CAAC+J,OAAO;EAC9B;AACF;AAAC"}
1
+ {"version":3,"names":["TypescriptCompiler","constructor","id","logger","options","tsModule","distDir","distGlobPatterns","shouldCopyNonSupportedFiles","artifactName","tsconfig","compilerOptions","outDir","generateIdeConfig","globalTypesPaths","types","displayConfig","stringifyTsconfig","getDistDir","transpileFile","fileContent","isFileSupported","filePath","compilerOptionsFromTsconfig","convertCompilerOptionsFromJson","errors","length","formattedErrors","formatDiagnosticsWithColorAndContext","getFormatDiagnosticsHost","Error","sourceRoot","componentDir","rootDir","result","transpileModule","fileName","reportDiagnostics","diagnostics","formatHost","error","outputPath","replaceFileExtToJs","outputFiles","outputText","sourceMapText","push","preBuild","context","capsules","capsuleNetwork","seedersCapsules","capsuleDirs","map","capsule","path","writeTsConfig","writeTypes","writeNpmIgnore","build","componentsResults","runTscBuild","artifacts","getArtifactDefinition","generatedBy","name","globPatterns","getDistPathBySrcPath","srcPath","fileWithJSExtIfNeeded","join","isJsAndCompile","compileJs","endsWith","isJsxAndCompile","compileJsx","network","capsulesRootDir","getCapsulesToCompile","getAllCapsuleDirs","getCanonicalFileName","p","getCurrentDirectory","getNewLine","sys","newLine","currentComponentResult","reportDiagnostic","diagnostic","errorStr","process","stdout","isTTY","formatDiagnostic","file","BitError","consoleFailure","component","reportSolutionBuilderStatus","diag","msg","messageText","debug","errorCounter","errorCount","info","host","createSolutionBuilderHost","undefined","writeProjectReferencesTsConfig","solutionBuilder","createSolutionBuilder","verbose","nextProject","longProcessLogger","createLongProcessLogger","getNextInvalidatedProject","capsulePath","project","replace","currentComponentId","getIdByPathInCapsule","logProgress","toString","getCapsule","startTime","Date","now","done","endTime","end","dirs","Promise","all","typePath","contents","fs","readFile","filename","basename","dir","pathExists","outputFile","NPM_IGNORE_FILE","npmIgnorePath","npmIgnoreEntriesStr","appendFile","projects","files","references","tsconfigStr","writeFile","JSON","stringify","fileExtension","extname","RegExp","version"],"sources":["typescript.compiler.ts"],"sourcesContent":["import { BuildContext, BuiltTaskResult, ComponentResult } from '@teambit/builder';\nimport { Compiler, TranspileFileParams, TranspileFileOutput } from '@teambit/compiler';\nimport { Network } from '@teambit/isolator';\nimport { Logger } from '@teambit/logger';\nimport fs from 'fs-extra';\nimport path from 'path';\nimport ts from 'typescript';\nimport { BitError } from '@teambit/bit-error';\nimport { TypeScriptCompilerOptions } from './compiler-options';\nimport { TypescriptCompilerInterface } from './typescript-compiler-interface';\n\nexport class TypescriptCompiler implements Compiler, TypescriptCompilerInterface {\n distDir: string;\n distGlobPatterns: string[];\n shouldCopyNonSupportedFiles: boolean;\n artifactName: string;\n constructor(\n readonly id: string,\n private logger: Logger,\n private options: TypeScriptCompilerOptions,\n private tsModule: typeof ts\n ) {\n this.distDir = options.distDir || 'dist';\n this.distGlobPatterns = options.distGlobPatterns || [`${this.distDir}/**`, `!${this.distDir}/tsconfig.tsbuildinfo`];\n this.shouldCopyNonSupportedFiles =\n typeof options.shouldCopyNonSupportedFiles === 'boolean' ? options.shouldCopyNonSupportedFiles : true;\n this.artifactName = options.artifactName || 'dist';\n this.options.tsconfig ||= {};\n this.options.tsconfig.compilerOptions ||= {};\n // mutate the outDir, otherwise, on capsules, the dists might be written to a different directory and make confusion\n this.options.tsconfig.compilerOptions.outDir = this.distDir;\n }\n\n displayName = 'TypeScript';\n deleteDistDir = false;\n\n generateIdeConfig() {\n return {\n tsconfig: this.options.tsconfig,\n globalTypesPaths: this.options.types,\n };\n }\n\n displayConfig() {\n return this.stringifyTsconfig(this.options.tsconfig);\n }\n\n getDistDir() {\n return this.distDir;\n }\n\n /**\n * compile one file on the workspace\n */\n transpileFile(fileContent: string, options: TranspileFileParams): TranspileFileOutput {\n if (!this.isFileSupported(options.filePath)) {\n return null; // file is not supported\n }\n const compilerOptionsFromTsconfig = this.tsModule.convertCompilerOptionsFromJson(\n this.options.tsconfig.compilerOptions,\n '.'\n );\n if (compilerOptionsFromTsconfig.errors.length) {\n // :TODO @david replace to a more concrete error type and put in 'exceptions' directory here.\n const formattedErrors = this.tsModule.formatDiagnosticsWithColorAndContext(\n compilerOptionsFromTsconfig.errors,\n this.getFormatDiagnosticsHost()\n );\n throw new Error(`failed parsing the tsconfig.json.\\n${formattedErrors}`);\n }\n\n const compilerOptions = compilerOptionsFromTsconfig.options;\n compilerOptions.sourceRoot = options.componentDir;\n compilerOptions.rootDir = '.';\n const result = this.tsModule.transpileModule(fileContent, {\n compilerOptions,\n fileName: options.filePath,\n reportDiagnostics: true,\n });\n\n if (result.diagnostics && result.diagnostics.length) {\n const formatHost = this.getFormatDiagnosticsHost();\n const error = this.tsModule.formatDiagnosticsWithColorAndContext(result.diagnostics, formatHost);\n\n // :TODO @david please replace to a more concrete error type and put in 'exceptions' directory here.\n throw new Error(error);\n }\n\n const outputPath = this.replaceFileExtToJs(options.filePath);\n const outputFiles = [{ outputText: result.outputText, outputPath }];\n if (result.sourceMapText) {\n outputFiles.push({\n outputText: result.sourceMapText,\n outputPath: `${outputPath}.map`,\n });\n }\n return outputFiles;\n }\n\n async preBuild(context: BuildContext) {\n const capsules = context.capsuleNetwork.seedersCapsules;\n const capsuleDirs = capsules.map((capsule) => capsule.path);\n await this.writeTsConfig(capsuleDirs);\n await this.writeTypes(capsuleDirs);\n await this.writeNpmIgnore(capsuleDirs);\n }\n\n /**\n * compile multiple components on the capsules\n */\n async build(context: BuildContext): Promise<BuiltTaskResult> {\n const componentsResults = await this.runTscBuild(context.capsuleNetwork);\n\n return {\n artifacts: this.getArtifactDefinition(),\n componentsResults,\n };\n }\n\n getArtifactDefinition() {\n return [\n {\n generatedBy: this.id,\n name: this.artifactName,\n globPatterns: this.distGlobPatterns,\n },\n ];\n }\n\n /**\n * given a source file, return its parallel in the dists. e.g. index.ts => dist/index.js\n */\n getDistPathBySrcPath(srcPath: string) {\n const fileWithJSExtIfNeeded = this.replaceFileExtToJs(srcPath);\n return path.join(this.distDir, fileWithJSExtIfNeeded);\n }\n\n /**\n * whether typescript is able to compile the given path\n */\n isFileSupported(filePath: string): boolean {\n const isJsAndCompile = !!this.options.compileJs && filePath.endsWith('.js');\n const isJsxAndCompile = !!this.options.compileJsx && filePath.endsWith('.jsx');\n return (\n (filePath.endsWith('.ts') || filePath.endsWith('.tsx') || isJsAndCompile || isJsxAndCompile) &&\n !filePath.endsWith('.d.ts')\n );\n }\n\n /**\n * we have two options here:\n * 1. pass all capsules-dir at the second parameter of createSolutionBuilder and then no\n * need to write the main tsconfig.json with all the references.\n * 2. write main tsconfig.json and pass the capsules root-dir.\n * we went with option #2 because it'll be easier for users to go to the capsule-root and run\n * `tsc --build` to debug issues.\n */\n private async runTscBuild(network: Network): Promise<ComponentResult[]> {\n const rootDir = network.capsulesRootDir;\n const capsules = await network.getCapsulesToCompile();\n if (!capsules.length) {\n return [];\n }\n const capsuleDirs = capsules.getAllCapsuleDirs();\n const formatHost = {\n getCanonicalFileName: (p) => p,\n getCurrentDirectory: () => '', // it helps to get the files with absolute paths\n getNewLine: () => this.tsModule.sys.newLine,\n };\n const componentsResults: ComponentResult[] = [];\n let currentComponentResult: Partial<ComponentResult> = { errors: [] };\n const reportDiagnostic = (diagnostic: ts.Diagnostic) => {\n const errorStr = process.stdout.isTTY\n ? this.tsModule.formatDiagnosticsWithColorAndContext([diagnostic], formatHost)\n : this.tsModule.formatDiagnostic(diagnostic, formatHost);\n if (!diagnostic.file) {\n // the error is general and not related to a specific file. e.g. tsconfig is missing.\n throw new BitError(errorStr);\n }\n this.logger.consoleFailure(errorStr);\n if (!currentComponentResult.component || !currentComponentResult.errors) {\n throw new Error(`currentComponentResult is not defined yet for ${diagnostic.file}`);\n }\n currentComponentResult.errors.push(errorStr);\n };\n // this only works when `verbose` is `true` in the `ts.createSolutionBuilder` function.\n const reportSolutionBuilderStatus = (diag: ts.Diagnostic) => {\n const msg = diag.messageText as string;\n this.logger.debug(msg);\n };\n const errorCounter = (errorCount: number) => {\n this.logger.info(`total error found: ${errorCount}`);\n };\n const host = this.tsModule.createSolutionBuilderHost(\n undefined,\n undefined,\n reportDiagnostic,\n reportSolutionBuilderStatus,\n errorCounter\n );\n await this.writeProjectReferencesTsConfig(rootDir, capsuleDirs);\n const solutionBuilder = this.tsModule.createSolutionBuilder(host, [rootDir], { verbose: true });\n let nextProject;\n const longProcessLogger = this.logger.createLongProcessLogger('compile typescript components', capsules.length);\n // eslint-disable-next-line no-cond-assign\n while ((nextProject = solutionBuilder.getNextInvalidatedProject())) {\n // regex to make sure it will work correctly for both linux and windows\n // it replaces both /tsconfig.json and \\tsocnfig.json\n const capsulePath = nextProject.project.replace(/[/\\\\]tsconfig.json/, '');\n const currentComponentId = capsules.getIdByPathInCapsule(capsulePath);\n if (!currentComponentId) throw new Error(`unable to find component for ${capsulePath}`);\n longProcessLogger.logProgress(currentComponentId.toString());\n const capsule = capsules.getCapsule(currentComponentId);\n if (!capsule) throw new Error(`unable to find capsule for ${currentComponentId.toString()}`);\n currentComponentResult.component = capsule.component;\n currentComponentResult.startTime = Date.now();\n nextProject.done();\n currentComponentResult.endTime = Date.now();\n componentsResults.push({ ...currentComponentResult } as ComponentResult);\n currentComponentResult = { errors: [] };\n }\n longProcessLogger.end();\n\n return componentsResults;\n }\n\n private getFormatDiagnosticsHost(): ts.FormatDiagnosticsHost {\n return {\n getCanonicalFileName: (p) => p,\n getCurrentDirectory: this.tsModule.sys.getCurrentDirectory,\n getNewLine: () => this.tsModule.sys.newLine,\n };\n }\n\n private async writeTypes(dirs: string[]) {\n await Promise.all(\n this.options.types.map(async (typePath) => {\n const contents = await fs.readFile(typePath, 'utf8');\n const filename = path.basename(typePath);\n\n await Promise.all(\n dirs.map(async (dir) => {\n const filePath = path.join(dir, 'types', filename);\n if (!(await fs.pathExists(filePath))) {\n await fs.outputFile(filePath, contents);\n }\n })\n );\n })\n );\n }\n\n /**\n * when using project-references, typescript adds a file \"tsconfig.tsbuildinfo\" which is not\n * needed for the package.\n */\n private async writeNpmIgnore(dirs: string[]) {\n const NPM_IGNORE_FILE = '.npmignore';\n await Promise.all(\n dirs.map(async (dir) => {\n const npmIgnorePath = path.join(dir, NPM_IGNORE_FILE);\n const npmIgnoreEntriesStr = `\\n${this.distDir}/tsconfig.tsbuildinfo\\n`;\n await fs.appendFile(npmIgnorePath, npmIgnoreEntriesStr);\n })\n );\n }\n\n private async writeProjectReferencesTsConfig(rootDir: string, projects: string[]) {\n const files = [];\n const references = projects.map((project) => ({ path: project }));\n const tsconfig = { files, references };\n const tsconfigStr = this.stringifyTsconfig(tsconfig);\n await fs.writeFile(path.join(rootDir, 'tsconfig.json'), tsconfigStr);\n }\n\n private async writeTsConfig(dirs: string[]) {\n const tsconfigStr = this.stringifyTsconfig(this.options.tsconfig);\n await Promise.all(dirs.map((dir) => fs.writeFile(path.join(dir, 'tsconfig.json'), tsconfigStr)));\n }\n\n private stringifyTsconfig(tsconfig) {\n return JSON.stringify(tsconfig, undefined, 2);\n }\n\n private replaceFileExtToJs(filePath: string): string {\n if (!this.isFileSupported(filePath)) return filePath;\n const fileExtension = path.extname(filePath);\n return filePath.replace(new RegExp(`${fileExtension}$`), '.js'); // makes sure it's the last occurrence\n }\n\n version() {\n return this.tsModule.version;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAIA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAA8C;AAAA;AAIvC,MAAMA,kBAAkB,CAAkD;EAK/EC,WAAW,CACAC,EAAU,EACXC,MAAc,EACdC,OAAkC,EAClCC,QAAmB,EAC3B;IAAA;IAAA,KAJSH,EAAU,GAAVA,EAAU;IAAA,KACXC,MAAc,GAAdA,MAAc;IAAA,KACdC,OAAkC,GAAlCA,OAAkC;IAAA,KAClCC,QAAmB,GAAnBA,QAAmB;IAAA;IAAA;IAAA;IAAA;IAAA,qDAaf,YAAY;IAAA,uDACV,KAAK;IAZnB,IAAI,CAACC,OAAO,GAAGF,OAAO,CAACE,OAAO,IAAI,MAAM;IACxC,IAAI,CAACC,gBAAgB,GAAGH,OAAO,CAACG,gBAAgB,IAAI,CAAE,GAAE,IAAI,CAACD,OAAQ,KAAI,EAAG,IAAG,IAAI,CAACA,OAAQ,uBAAsB,CAAC;IACnH,IAAI,CAACE,2BAA2B,GAC9B,OAAOJ,OAAO,CAACI,2BAA2B,KAAK,SAAS,GAAGJ,OAAO,CAACI,2BAA2B,GAAG,IAAI;IACvG,IAAI,CAACC,YAAY,GAAGL,OAAO,CAACK,YAAY,IAAI,MAAM;IAClD,qBAAI,CAACL,OAAO,EAACM,QAAQ,KAArB,cAAaA,QAAQ,GAAK,CAAC,CAAC;IAC5B,6BAAI,CAACN,OAAO,CAACM,QAAQ,EAACC,eAAe,KAAr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,CAAC;EAC/C;EAEQlE,kBAAkB,CAACpB,QAAgB,EAAU;IACnD,IAAI,CAAC,IAAI,CAACD,eAAe,CAACC,QAAQ,CAAC,EAAE,OAAOA,QAAQ;IACpD,MAAMoI,aAAa,GAAGnG,eAAI,CAACoG,OAAO,CAACrI,QAAQ,CAAC;IAC5C,OAAOA,QAAQ,CAACiG,OAAO,CAAC,IAAIqC,MAAM,CAAE,GAAEF,aAAc,GAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;EACnE;;EAEAG,OAAO,GAAG;IACR,OAAO,IAAI,CAACxJ,QAAQ,CAACwJ,OAAO;EAC9B;AACF;AAAC"}
@@ -13,6 +13,7 @@ import { AspectLoaderMain } from '@teambit/aspect-loader';
13
13
  import { WorkspaceConfigFilesMain } from '@teambit/workspace-config-files';
14
14
  import { WatcherMain } from '@teambit/watcher';
15
15
  import type { Component } from '@teambit/component';
16
+ import { BuilderMain } from '@teambit/builder';
16
17
  import { EnvsMain } from '@teambit/envs';
17
18
  import { ScopeMain } from '@teambit/scope';
18
19
  import { TypeScriptCompilerOptions } from './compiler-options';
@@ -114,7 +115,7 @@ export declare class TypescriptMain {
114
115
  static runtime: import("@teambit/harmony").RuntimeDefinition;
115
116
  static dependencies: import("@teambit/harmony").Aspect[];
116
117
  static slots: ((registerFn: () => string) => SlotRegistry<SchemaTransformer[]>)[];
117
- static provider([schema, loggerExt, aspectLoader, workspace, cli, depResolver, envs, watcher, workspaceConfigFiles, compiler, scope,]: [
118
+ static provider([schema, loggerExt, aspectLoader, workspace, cli, depResolver, envs, watcher, workspaceConfigFiles, compiler, scope, builder,]: [
118
119
  SchemaMain,
119
120
  LoggerMain,
120
121
  AspectLoaderMain,
@@ -125,7 +126,8 @@ export declare class TypescriptMain {
125
126
  WatcherMain,
126
127
  WorkspaceConfigFilesMain,
127
128
  CompilerMain,
128
- ScopeMain
129
+ ScopeMain,
130
+ BuilderMain
129
131
  ], config: any, [schemaTransformerSlot]: [SchemaTransformerSlot]): Promise<TypescriptMain>;
130
132
  }
131
133
  export declare function runTransformersWithContext(config: TypescriptConfigMutator, transformers: TsConfigTransformer[] | undefined, context: TsConfigTransformContext): TypescriptConfigMutator;
@@ -115,6 +115,13 @@ function _watcher() {
115
115
  };
116
116
  return data;
117
117
  }
118
+ function _builder() {
119
+ const data = require("@teambit/builder");
120
+ _builder = function () {
121
+ return data;
122
+ };
123
+ return data;
124
+ }
118
125
  function _envs() {
119
126
  const data = _interopRequireDefault(require("@teambit/envs"));
120
127
  _envs = function () {
@@ -199,6 +206,13 @@ function _tsConfigWriter() {
199
206
  };
200
207
  return data;
201
208
  }
209
+ function _removeTypesTask() {
210
+ const data = require("./remove-types-task");
211
+ _removeTypesTask = function () {
212
+ return data;
213
+ };
214
+ return data;
215
+ }
202
216
  class TypescriptMain {
203
217
  constructor(logger, schemaTransformerSlot, workspace, scope, depResolver, envs, tsConfigWriter, aspectLoader) {
204
218
  this.logger = logger;
@@ -386,7 +400,7 @@ class TypescriptMain {
386
400
  results: 'succeed'
387
401
  };
388
402
  }
389
- static async provider([schema, loggerExt, aspectLoader, workspace, cli, depResolver, envs, watcher, workspaceConfigFiles, compiler, scope], config, [schemaTransformerSlot]) {
403
+ static async provider([schema, loggerExt, aspectLoader, workspace, cli, depResolver, envs, watcher, workspaceConfigFiles, compiler, scope, builder], config, [schemaTransformerSlot]) {
390
404
  schema.registerParser(new (_typescript5().TypeScriptParser)());
391
405
  const logger = loggerExt.createLogger(_typescript3().TypescriptAspect.id);
392
406
  workspaceConfigFiles.registerConfigWriter(new (_tsConfigWriter().TypescriptConfigWriter)(compiler, logger));
@@ -399,6 +413,9 @@ class TypescriptMain {
399
413
  workspace.registerOnComponentChange(tsMain.onComponentChange.bind(tsMain));
400
414
  workspace.registerOnComponentAdd(tsMain.onComponentChange.bind(tsMain));
401
415
  }
416
+ const removeTypesTask = new (_removeTypesTask().RemoveTypesTask)();
417
+ builder.registerSnapTasks([removeTypesTask]);
418
+ builder.registerTagTasks([removeTypesTask]);
402
419
  const checkTypesCmd = new (_checkTypes().CheckTypesCmd)(tsMain, workspace, logger);
403
420
  const writeTsconfigCmd = new (_writeTsconfig().default)(tsMain);
404
421
  cli.register(checkTypesCmd, writeTsconfigCmd);
@@ -407,7 +424,7 @@ class TypescriptMain {
407
424
  }
408
425
  exports.TypescriptMain = TypescriptMain;
409
426
  (0, _defineProperty2().default)(TypescriptMain, "runtime", _cli().MainRuntime);
410
- (0, _defineProperty2().default)(TypescriptMain, "dependencies", [_schema().SchemaAspect, _logger().LoggerAspect, _aspectLoader().default, _workspace().WorkspaceAspect, _cli().CLIAspect, _dependencyResolver().DependencyResolverAspect, _envs().default, _watcher().default, _workspaceConfigFiles().default, _compiler().CompilerAspect, _scope().ScopeAspect]);
427
+ (0, _defineProperty2().default)(TypescriptMain, "dependencies", [_schema().SchemaAspect, _logger().LoggerAspect, _aspectLoader().default, _workspace().WorkspaceAspect, _cli().CLIAspect, _dependencyResolver().DependencyResolverAspect, _envs().default, _watcher().default, _workspaceConfigFiles().default, _compiler().CompilerAspect, _scope().ScopeAspect, _builder().BuilderAspect]);
411
428
  (0, _defineProperty2().default)(TypescriptMain, "slots", [_harmony().Slot.withType()]);
412
429
  _typescript3().TypescriptAspect.addRuntime(TypescriptMain);
413
430
  function runTransformersWithContext(config, transformers = [], context) {
@@ -1 +1 @@
1
- {"version":3,"names":["TypescriptMain","constructor","logger","schemaTransformerSlot","workspace","scope","depResolver","envs","tsConfigWriter","aspectLoader","createCompiler","options","transformers","tsModule","ts","configMutator","TypescriptConfigMutator","transformerContext","afterMutation","runTransformersWithContext","clone","TypescriptCompiler","TypescriptAspect","id","raw","getTsserverClient","tsServer","initTsserverClient","projectPath","files","TsserverClient","init","initTsserverClientFromWorkspace","Error","path","createCjsCompiler","getCjsTransformer","createEsmCompiler","getEsmTransformer","cjsTransformer","config","setModule","esmTransformer","setTarget","tsconfig","compilerOptions","module","lib","createSchemaExtractor","TypeScriptExtractor","getCjsPackageJsonProps","main","types","getEsmPackageJsonProps","type","getSupportedFilesForTsserver","components","map","c","filesystem","flat","f","filter","endsWith","cleanTsconfigJson","list","runtime","createEnvironment","execContext","getEnvExecutionContext","results","TsconfigWriter","clean","writeTsconfigJson","cleanResults","writeResults","write","onPreWatch","watchOpts","spawnTSServer","verbose","checkTypes","printTypeErrors","Boolean","onComponentChange","component","pMapSeries","file","onFileChange","provider","schema","loggerExt","cli","watcher","workspaceConfigFiles","compiler","registerParser","TypeScriptParser","createLogger","registerConfigWriter","TypescriptConfigWriter","registerPlugins","SchemaTransformerPlugin","tsconfigWriter","tsMain","register","ExportDeclarationTransformer","ExportAssignmentTransformer","FunctionLikeTransformer","ParameterTransformer","SetAccessorTransformer","GetAccessorTransformer","IndexSignatureTransformer","PropertyDeclarationTransformer","VariableStatementTransformer","VariableDeclaration","SourceFileTransformer","TypeAliasTransformer","ClassDeclarationTransformer","InterfaceDeclarationTransformer","EnumDeclarationTransformer","BindingElementTransformer","IntersectionTypeTransformer","UnionTypeTransformer","TypeReferenceTransformer","TypeLiteralTransformer","LiteralTypeTransformer","TypeQueryTransformer","ArrayTypeTransformer","TypeOperatorTransformer","KeywordTypeTransformer","TupleTypeTransformer","ParenthesizedTypeTransformer","TypePredicateTransformer","IndexedAccessTypeTransformer","TemplateLiteralTypeSpanTransformer","TemplateLiteralTypeTransformer","ThisTypeTransformer","ConditionalTypeTransformer","NamedTupleTransformer","ConstructorTransformer","ImportDeclarationTransformer","registerOnPreWatch","bind","registerOnComponentChange","registerOnComponentAdd","checkTypesCmd","CheckTypesCmd","writeTsconfigCmd","WriteTsconfigCmd","MainRuntime","SchemaAspect","LoggerAspect","AspectLoaderAspect","WorkspaceAspect","CLIAspect","DependencyResolverAspect","EnvsAspect","WatcherAspect","WorkspaceConfigFilesAspect","CompilerAspect","ScopeAspect","Slot","withType","addRuntime","context","Array","isArray","newConfig","reduce","acc","transformer"],"sources":["typescript.main.runtime.ts"],"sourcesContent":["import ts from 'typescript';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { Compiler, CompilerAspect, CompilerMain } from '@teambit/compiler';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { SchemaAspect, SchemaExtractor, SchemaMain } from '@teambit/schema';\nimport { PackageJsonProps } from '@teambit/pkg';\nimport { TypescriptConfigMutator } from '@teambit/typescript.modules.ts-config-mutator';\nimport { WorkspaceAspect } from '@teambit/workspace';\nimport type { Workspace } from '@teambit/workspace';\nimport { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport pMapSeries from 'p-map-series';\nimport { TsserverClient, TsserverClientOpts } from '@teambit/ts-server';\nimport AspectLoaderAspect, { AspectLoaderMain } from '@teambit/aspect-loader';\nimport WorkspaceConfigFilesAspect, { WorkspaceConfigFilesMain } from '@teambit/workspace-config-files';\nimport WatcherAspect, { WatcherMain, WatchOptions } from '@teambit/watcher';\nimport type { Component } from '@teambit/component';\nimport EnvsAspect, { EnvsMain } from '@teambit/envs';\nimport { ScopeMain, ScopeAspect } from '@teambit/scope';\nimport { TypeScriptExtractor } from './typescript.extractor';\nimport { TypeScriptCompilerOptions } from './compiler-options';\nimport { TypescriptAspect } from './typescript.aspect';\nimport { TypescriptCompiler } from './typescript.compiler';\nimport { TypeScriptParser } from './typescript.parser';\nimport { SchemaTransformer } from './schema-transformer';\nimport { SchemaTransformerPlugin } from './schema-transformer.plugin';\nimport {\n ExportDeclarationTransformer,\n TypeAliasTransformer,\n FunctionLikeTransformer,\n SetAccessorTransformer,\n GetAccessorTransformer,\n IndexSignatureTransformer,\n PropertyDeclarationTransformer,\n ParameterTransformer,\n VariableStatementTransformer,\n VariableDeclaration,\n SourceFileTransformer,\n ClassDeclarationTransformer,\n InterfaceDeclarationTransformer,\n EnumDeclarationTransformer,\n BindingElementTransformer,\n ExportAssignmentTransformer,\n ImportDeclarationTransformer,\n IntersectionTypeTransformer,\n UnionTypeTransformer,\n TypeReferenceTransformer,\n TypeLiteralTransformer,\n LiteralTypeTransformer,\n TypeQueryTransformer,\n ArrayTypeTransformer,\n TypeOperatorTransformer,\n KeywordTypeTransformer,\n TupleTypeTransformer,\n ParenthesizedTypeTransformer,\n TypePredicateTransformer,\n IndexedAccessTypeTransformer,\n TemplateLiteralTypeSpanTransformer,\n TemplateLiteralTypeTransformer,\n ThisTypeTransformer,\n ConditionalTypeTransformer,\n NamedTupleTransformer,\n ConstructorTransformer,\n} from './transformers';\nimport { CheckTypesCmd } from './cmds/check-types.cmd';\nimport { TsconfigPathsPerEnv, TsconfigWriter } from './tsconfig-writer';\nimport WriteTsconfigCmd from './cmds/write-tsconfig.cmd';\nimport { TypescriptConfigWriter } from './ts-config-writer';\n\nexport type TsMode = 'build' | 'dev';\n\nexport type SchemaTransformerSlot = SlotRegistry<SchemaTransformer[]>;\n\nexport type TsConfigTransformContext = {\n // mode: TsMode;\n};\n\nexport type TsconfigWriterOptions = {\n clean?: boolean;\n silent?: boolean; // no prompt\n dedupe?: boolean;\n dryRun?: boolean;\n dryRunWithTsconfig?: boolean;\n};\n\nexport type TsConfigTransformer = (\n config: TypescriptConfigMutator,\n context: TsConfigTransformContext\n) => TypescriptConfigMutator;\n\nexport class TypescriptMain {\n constructor(\n private logger: Logger,\n readonly schemaTransformerSlot: SchemaTransformerSlot,\n readonly workspace: Workspace,\n readonly scope: ScopeMain,\n readonly depResolver: DependencyResolverMain,\n private envs: EnvsMain,\n private tsConfigWriter: TsconfigWriter,\n private aspectLoader: AspectLoaderMain\n ) {}\n\n private tsServer: TsserverClient;\n /**\n * create a new compiler.\n */\n createCompiler(\n options: TypeScriptCompilerOptions,\n transformers: TsConfigTransformer[] = [],\n tsModule = ts\n ): Compiler {\n const configMutator = new TypescriptConfigMutator(options);\n const transformerContext: TsConfigTransformContext = {};\n const afterMutation = runTransformersWithContext(configMutator.clone(), transformers, transformerContext);\n return new TypescriptCompiler(TypescriptAspect.id, this.logger, afterMutation.raw, tsModule);\n }\n\n /**\n * get TsserverClient instance if initiated already, otherwise, return undefined.\n */\n getTsserverClient(): TsserverClient | undefined {\n return this.tsServer;\n }\n\n /**\n * starts a tsserver process to communicate with its API.\n * @param projectPath absolute path of the project root directory\n * @param options TsserverClientOpts\n * @param files optionally, if check-types is enabled, provide files to open and type check.\n * @returns TsserverClient\n */\n async initTsserverClient(\n projectPath: string,\n options: TsserverClientOpts = {},\n files: string[] = []\n ): Promise<TsserverClient> {\n this.tsServer = new TsserverClient(projectPath, this.logger, options, files);\n await this.tsServer.init();\n return this.tsServer;\n }\n\n /**\n * starts a tsserver process to communicate with its API. use only when running on the workspace.\n * @param options TsserverClientOpts\n * @param files optionally, if check-types is enabled, provide files to open and type check.\n * @returns TsserverClient\n */\n async initTsserverClientFromWorkspace(\n options: TsserverClientOpts = {},\n files: string[] = []\n ): Promise<TsserverClient> {\n if (!this.workspace) {\n throw new Error(`initTsserverClientFromWorkspace: workspace was not found`);\n }\n return this.initTsserverClient(this.workspace.path, options, files);\n }\n\n /**\n * Create a compiler instance and run the cjs transformer for it\n * @param options\n * @param transformers\n * @param tsModule\n * @returns\n */\n createCjsCompiler(options: TypeScriptCompilerOptions, transformers: TsConfigTransformer[] = [], tsModule = ts) {\n return this.createCompiler(options, [this.getCjsTransformer(), ...transformers], tsModule);\n }\n\n /**\n * Create a compiler instance and run the esm transformer for it\n * @param options\n * @param transformers\n * @param tsModule\n * @returns\n */\n createEsmCompiler(options: TypeScriptCompilerOptions, transformers: TsConfigTransformer[] = [], tsModule = ts) {\n return this.createCompiler(options, [this.getEsmTransformer(), ...transformers], tsModule);\n }\n\n /**\n * Create a transformer that change the ts module to CommonJS\n * @returns\n */\n getCjsTransformer(): TsConfigTransformer {\n const cjsTransformer = (config: TypescriptConfigMutator) => {\n config.setModule('CommonJS');\n return config;\n };\n return cjsTransformer;\n }\n\n /**\n * Create a transformer that change the ts module to ES2020\n * @returns\n */\n getEsmTransformer(): TsConfigTransformer {\n const esmTransformer = (config: TypescriptConfigMutator) => {\n config.setTarget('ES2017');\n config.raw.tsconfig.compilerOptions.module = 'es2020';\n config.raw.tsconfig.compilerOptions.lib = ['es2021', 'dom', 'ESNext.String', 'dom.Iterable'];\n return config;\n };\n return esmTransformer;\n }\n\n /**\n * create an instance of a typescript semantic schema extractor.\n */\n createSchemaExtractor(tsconfig: any, path?: string): SchemaExtractor {\n return new TypeScriptExtractor(\n tsconfig,\n this.schemaTransformerSlot,\n this,\n path || this.workspace?.path || '',\n this.depResolver,\n this.workspace,\n this.scope,\n this.aspectLoader,\n this.logger\n );\n }\n\n /**\n * add the default package json properties to the component\n * :TODO @gilad why do we need this DSL? can't I just get the args here.\n */\n getCjsPackageJsonProps(): PackageJsonProps {\n return {\n main: 'dist/{main}.js',\n types: '{main}.ts',\n };\n }\n\n /**\n * add type: module to the package.json props and the default props\n * :TODO @gilad why do we need this DSL? can't I just get the args here.\n */\n getEsmPackageJsonProps(): PackageJsonProps {\n return {\n // main: 'dist-esm/{main}.js',\n main: 'dist/{main}.js',\n type: 'module',\n types: '{main}.ts',\n };\n }\n\n getSupportedFilesForTsserver(components: Component[]): string[] {\n const files = components\n .map((c) => c.filesystem.files)\n .flat()\n .map((f) => f.path);\n return files.filter((f) => f.endsWith('.ts') || f.endsWith('.tsx'));\n }\n\n async cleanTsconfigJson(options: TsconfigWriterOptions = {}) {\n const components = await this.workspace.list();\n const runtime = await this.envs.createEnvironment(components);\n const execContext = runtime.getEnvExecutionContext();\n\n const results = await new TsconfigWriter(this.workspace, this.logger).clean(execContext, options);\n\n return results;\n }\n\n async writeTsconfigJson(options: TsconfigWriterOptions = {}): Promise<{\n cleanResults?: string[];\n writeResults: TsconfigPathsPerEnv[];\n }> {\n const components = await this.workspace.list();\n const runtime = await this.envs.createEnvironment(components);\n const execContext = runtime.getEnvExecutionContext();\n\n let cleanResults: string[] | undefined;\n if (options.clean) {\n cleanResults = await this.tsConfigWriter.clean(execContext, options);\n }\n\n const writeResults = await this.tsConfigWriter.write(execContext, options);\n\n return { writeResults, cleanResults };\n }\n\n private async onPreWatch(components: Component[], watchOpts: WatchOptions) {\n const workspace = this.workspace;\n if (!workspace || !watchOpts.spawnTSServer) {\n return;\n }\n const { verbose, checkTypes } = watchOpts;\n const files = checkTypes ? this.getSupportedFilesForTsserver(components) : [];\n const printTypeErrors = Boolean(checkTypes);\n await this.initTsserverClientFromWorkspace({ verbose, checkTypes, printTypeErrors }, files);\n }\n\n private async onComponentChange(component: Component, files: string[]) {\n if (!this.tsServer) {\n return {\n results: 'N/A',\n };\n }\n await pMapSeries(files, (file) => this.tsServer.onFileChange(file));\n return {\n results: 'succeed',\n };\n }\n\n static runtime = MainRuntime;\n static dependencies = [\n SchemaAspect,\n LoggerAspect,\n AspectLoaderAspect,\n WorkspaceAspect,\n CLIAspect,\n DependencyResolverAspect,\n EnvsAspect,\n WatcherAspect,\n WorkspaceConfigFilesAspect,\n CompilerAspect,\n ScopeAspect,\n ];\n static slots = [Slot.withType<SchemaTransformer[]>()];\n\n static async provider(\n [\n schema,\n loggerExt,\n aspectLoader,\n workspace,\n cli,\n depResolver,\n envs,\n watcher,\n workspaceConfigFiles,\n compiler,\n scope,\n ]: [\n SchemaMain,\n LoggerMain,\n AspectLoaderMain,\n Workspace,\n CLIMain,\n DependencyResolverMain,\n EnvsMain,\n WatcherMain,\n WorkspaceConfigFilesMain,\n CompilerMain,\n ScopeMain\n ],\n config,\n [schemaTransformerSlot]: [SchemaTransformerSlot]\n ) {\n schema.registerParser(new TypeScriptParser());\n const logger = loggerExt.createLogger(TypescriptAspect.id);\n workspaceConfigFiles.registerConfigWriter(new TypescriptConfigWriter(compiler, logger));\n\n aspectLoader.registerPlugins([new SchemaTransformerPlugin(schemaTransformerSlot)]);\n const tsconfigWriter = new TsconfigWriter(workspace, logger);\n const tsMain = new TypescriptMain(\n logger,\n schemaTransformerSlot,\n workspace,\n scope,\n depResolver,\n envs,\n tsconfigWriter,\n aspectLoader\n );\n schemaTransformerSlot.register([\n new ExportDeclarationTransformer(),\n new ExportAssignmentTransformer(),\n new FunctionLikeTransformer(),\n new ParameterTransformer(),\n new SetAccessorTransformer(),\n new GetAccessorTransformer(),\n new IndexSignatureTransformer(),\n new PropertyDeclarationTransformer(),\n new VariableStatementTransformer(),\n new VariableDeclaration(),\n new SourceFileTransformer(),\n new TypeAliasTransformer(),\n new ClassDeclarationTransformer(),\n new InterfaceDeclarationTransformer(),\n new EnumDeclarationTransformer(),\n new BindingElementTransformer(),\n new IntersectionTypeTransformer(),\n new UnionTypeTransformer(),\n new TypeReferenceTransformer(),\n new TypeLiteralTransformer(),\n new LiteralTypeTransformer(),\n new TypeQueryTransformer(),\n new ArrayTypeTransformer(),\n new TypeOperatorTransformer(),\n new KeywordTypeTransformer(),\n new TupleTypeTransformer(),\n new ParenthesizedTypeTransformer(),\n new TypePredicateTransformer(),\n new IndexedAccessTypeTransformer(),\n new TemplateLiteralTypeSpanTransformer(),\n new TemplateLiteralTypeTransformer(),\n new ThisTypeTransformer(),\n new ConditionalTypeTransformer(),\n new NamedTupleTransformer(),\n new ConstructorTransformer(),\n new ImportDeclarationTransformer(),\n ]);\n\n if (workspace) {\n watcher.registerOnPreWatch(tsMain.onPreWatch.bind(tsMain));\n workspace.registerOnComponentChange(tsMain.onComponentChange.bind(tsMain));\n workspace.registerOnComponentAdd(tsMain.onComponentChange.bind(tsMain));\n }\n\n const checkTypesCmd = new CheckTypesCmd(tsMain, workspace, logger);\n const writeTsconfigCmd = new WriteTsconfigCmd(tsMain);\n cli.register(checkTypesCmd, writeTsconfigCmd);\n\n return tsMain;\n }\n}\n\nTypescriptAspect.addRuntime(TypescriptMain);\n\nexport function runTransformersWithContext(\n config: TypescriptConfigMutator,\n transformers: TsConfigTransformer[] = [],\n context: TsConfigTransformContext\n): TypescriptConfigMutator {\n if (!Array.isArray(transformers)) return config;\n const newConfig = transformers.reduce((acc, transformer) => {\n return transformer(acc, context);\n }, config);\n return newConfig;\n}\n\nexport default TypescriptMain;\n"],"mappings":";;;;;;;;;;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TypescriptMain","constructor","logger","schemaTransformerSlot","workspace","scope","depResolver","envs","tsConfigWriter","aspectLoader","createCompiler","options","transformers","tsModule","ts","configMutator","TypescriptConfigMutator","transformerContext","afterMutation","runTransformersWithContext","clone","TypescriptCompiler","TypescriptAspect","id","raw","getTsserverClient","tsServer","initTsserverClient","projectPath","files","TsserverClient","init","initTsserverClientFromWorkspace","Error","path","createCjsCompiler","getCjsTransformer","createEsmCompiler","getEsmTransformer","cjsTransformer","config","setModule","esmTransformer","setTarget","tsconfig","compilerOptions","module","lib","createSchemaExtractor","TypeScriptExtractor","getCjsPackageJsonProps","main","types","getEsmPackageJsonProps","type","getSupportedFilesForTsserver","components","map","c","filesystem","flat","f","filter","endsWith","cleanTsconfigJson","list","runtime","createEnvironment","execContext","getEnvExecutionContext","results","TsconfigWriter","clean","writeTsconfigJson","cleanResults","writeResults","write","onPreWatch","watchOpts","spawnTSServer","verbose","checkTypes","printTypeErrors","Boolean","onComponentChange","component","pMapSeries","file","onFileChange","provider","schema","loggerExt","cli","watcher","workspaceConfigFiles","compiler","builder","registerParser","TypeScriptParser","createLogger","registerConfigWriter","TypescriptConfigWriter","registerPlugins","SchemaTransformerPlugin","tsconfigWriter","tsMain","register","ExportDeclarationTransformer","ExportAssignmentTransformer","FunctionLikeTransformer","ParameterTransformer","SetAccessorTransformer","GetAccessorTransformer","IndexSignatureTransformer","PropertyDeclarationTransformer","VariableStatementTransformer","VariableDeclaration","SourceFileTransformer","TypeAliasTransformer","ClassDeclarationTransformer","InterfaceDeclarationTransformer","EnumDeclarationTransformer","BindingElementTransformer","IntersectionTypeTransformer","UnionTypeTransformer","TypeReferenceTransformer","TypeLiteralTransformer","LiteralTypeTransformer","TypeQueryTransformer","ArrayTypeTransformer","TypeOperatorTransformer","KeywordTypeTransformer","TupleTypeTransformer","ParenthesizedTypeTransformer","TypePredicateTransformer","IndexedAccessTypeTransformer","TemplateLiteralTypeSpanTransformer","TemplateLiteralTypeTransformer","ThisTypeTransformer","ConditionalTypeTransformer","NamedTupleTransformer","ConstructorTransformer","ImportDeclarationTransformer","registerOnPreWatch","bind","registerOnComponentChange","registerOnComponentAdd","removeTypesTask","RemoveTypesTask","registerSnapTasks","registerTagTasks","checkTypesCmd","CheckTypesCmd","writeTsconfigCmd","WriteTsconfigCmd","MainRuntime","SchemaAspect","LoggerAspect","AspectLoaderAspect","WorkspaceAspect","CLIAspect","DependencyResolverAspect","EnvsAspect","WatcherAspect","WorkspaceConfigFilesAspect","CompilerAspect","ScopeAspect","BuilderAspect","Slot","withType","addRuntime","context","Array","isArray","newConfig","reduce","acc","transformer"],"sources":["typescript.main.runtime.ts"],"sourcesContent":["import ts from 'typescript';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { Compiler, CompilerAspect, CompilerMain } from '@teambit/compiler';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { SchemaAspect, SchemaExtractor, SchemaMain } from '@teambit/schema';\nimport { PackageJsonProps } from '@teambit/pkg';\nimport { TypescriptConfigMutator } from '@teambit/typescript.modules.ts-config-mutator';\nimport { WorkspaceAspect } from '@teambit/workspace';\nimport type { Workspace } from '@teambit/workspace';\nimport { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport pMapSeries from 'p-map-series';\nimport { TsserverClient, TsserverClientOpts } from '@teambit/ts-server';\nimport AspectLoaderAspect, { AspectLoaderMain } from '@teambit/aspect-loader';\nimport WorkspaceConfigFilesAspect, { WorkspaceConfigFilesMain } from '@teambit/workspace-config-files';\nimport WatcherAspect, { WatcherMain, WatchOptions } from '@teambit/watcher';\nimport type { Component } from '@teambit/component';\nimport { BuilderAspect, BuilderMain } from '@teambit/builder';\nimport EnvsAspect, { EnvsMain } from '@teambit/envs';\nimport { ScopeMain, ScopeAspect } from '@teambit/scope';\nimport { TypeScriptExtractor } from './typescript.extractor';\nimport { TypeScriptCompilerOptions } from './compiler-options';\nimport { TypescriptAspect } from './typescript.aspect';\nimport { TypescriptCompiler } from './typescript.compiler';\nimport { TypeScriptParser } from './typescript.parser';\nimport { SchemaTransformer } from './schema-transformer';\nimport { SchemaTransformerPlugin } from './schema-transformer.plugin';\nimport {\n ExportDeclarationTransformer,\n TypeAliasTransformer,\n FunctionLikeTransformer,\n SetAccessorTransformer,\n GetAccessorTransformer,\n IndexSignatureTransformer,\n PropertyDeclarationTransformer,\n ParameterTransformer,\n VariableStatementTransformer,\n VariableDeclaration,\n SourceFileTransformer,\n ClassDeclarationTransformer,\n InterfaceDeclarationTransformer,\n EnumDeclarationTransformer,\n BindingElementTransformer,\n ExportAssignmentTransformer,\n ImportDeclarationTransformer,\n IntersectionTypeTransformer,\n UnionTypeTransformer,\n TypeReferenceTransformer,\n TypeLiteralTransformer,\n LiteralTypeTransformer,\n TypeQueryTransformer,\n ArrayTypeTransformer,\n TypeOperatorTransformer,\n KeywordTypeTransformer,\n TupleTypeTransformer,\n ParenthesizedTypeTransformer,\n TypePredicateTransformer,\n IndexedAccessTypeTransformer,\n TemplateLiteralTypeSpanTransformer,\n TemplateLiteralTypeTransformer,\n ThisTypeTransformer,\n ConditionalTypeTransformer,\n NamedTupleTransformer,\n ConstructorTransformer,\n} from './transformers';\nimport { CheckTypesCmd } from './cmds/check-types.cmd';\nimport { TsconfigPathsPerEnv, TsconfigWriter } from './tsconfig-writer';\nimport WriteTsconfigCmd from './cmds/write-tsconfig.cmd';\nimport { TypescriptConfigWriter } from './ts-config-writer';\nimport { RemoveTypesTask } from './remove-types-task';\n\nexport type TsMode = 'build' | 'dev';\n\nexport type SchemaTransformerSlot = SlotRegistry<SchemaTransformer[]>;\n\nexport type TsConfigTransformContext = {\n // mode: TsMode;\n};\n\nexport type TsconfigWriterOptions = {\n clean?: boolean;\n silent?: boolean; // no prompt\n dedupe?: boolean;\n dryRun?: boolean;\n dryRunWithTsconfig?: boolean;\n};\n\nexport type TsConfigTransformer = (\n config: TypescriptConfigMutator,\n context: TsConfigTransformContext\n) => TypescriptConfigMutator;\n\nexport class TypescriptMain {\n constructor(\n private logger: Logger,\n readonly schemaTransformerSlot: SchemaTransformerSlot,\n readonly workspace: Workspace,\n readonly scope: ScopeMain,\n readonly depResolver: DependencyResolverMain,\n private envs: EnvsMain,\n private tsConfigWriter: TsconfigWriter,\n private aspectLoader: AspectLoaderMain\n ) {}\n\n private tsServer: TsserverClient;\n /**\n * create a new compiler.\n */\n createCompiler(\n options: TypeScriptCompilerOptions,\n transformers: TsConfigTransformer[] = [],\n tsModule = ts\n ): Compiler {\n const configMutator = new TypescriptConfigMutator(options);\n const transformerContext: TsConfigTransformContext = {};\n const afterMutation = runTransformersWithContext(configMutator.clone(), transformers, transformerContext);\n return new TypescriptCompiler(TypescriptAspect.id, this.logger, afterMutation.raw, tsModule);\n }\n\n /**\n * get TsserverClient instance if initiated already, otherwise, return undefined.\n */\n getTsserverClient(): TsserverClient | undefined {\n return this.tsServer;\n }\n\n /**\n * starts a tsserver process to communicate with its API.\n * @param projectPath absolute path of the project root directory\n * @param options TsserverClientOpts\n * @param files optionally, if check-types is enabled, provide files to open and type check.\n * @returns TsserverClient\n */\n async initTsserverClient(\n projectPath: string,\n options: TsserverClientOpts = {},\n files: string[] = []\n ): Promise<TsserverClient> {\n this.tsServer = new TsserverClient(projectPath, this.logger, options, files);\n await this.tsServer.init();\n return this.tsServer;\n }\n\n /**\n * starts a tsserver process to communicate with its API. use only when running on the workspace.\n * @param options TsserverClientOpts\n * @param files optionally, if check-types is enabled, provide files to open and type check.\n * @returns TsserverClient\n */\n async initTsserverClientFromWorkspace(\n options: TsserverClientOpts = {},\n files: string[] = []\n ): Promise<TsserverClient> {\n if (!this.workspace) {\n throw new Error(`initTsserverClientFromWorkspace: workspace was not found`);\n }\n return this.initTsserverClient(this.workspace.path, options, files);\n }\n\n /**\n * Create a compiler instance and run the cjs transformer for it\n * @param options\n * @param transformers\n * @param tsModule\n * @returns\n */\n createCjsCompiler(options: TypeScriptCompilerOptions, transformers: TsConfigTransformer[] = [], tsModule = ts) {\n return this.createCompiler(options, [this.getCjsTransformer(), ...transformers], tsModule);\n }\n\n /**\n * Create a compiler instance and run the esm transformer for it\n * @param options\n * @param transformers\n * @param tsModule\n * @returns\n */\n createEsmCompiler(options: TypeScriptCompilerOptions, transformers: TsConfigTransformer[] = [], tsModule = ts) {\n return this.createCompiler(options, [this.getEsmTransformer(), ...transformers], tsModule);\n }\n\n /**\n * Create a transformer that change the ts module to CommonJS\n * @returns\n */\n getCjsTransformer(): TsConfigTransformer {\n const cjsTransformer = (config: TypescriptConfigMutator) => {\n config.setModule('CommonJS');\n return config;\n };\n return cjsTransformer;\n }\n\n /**\n * Create a transformer that change the ts module to ES2020\n * @returns\n */\n getEsmTransformer(): TsConfigTransformer {\n const esmTransformer = (config: TypescriptConfigMutator) => {\n config.setTarget('ES2017');\n config.raw.tsconfig.compilerOptions.module = 'es2020';\n config.raw.tsconfig.compilerOptions.lib = ['es2021', 'dom', 'ESNext.String', 'dom.Iterable'];\n return config;\n };\n return esmTransformer;\n }\n\n /**\n * create an instance of a typescript semantic schema extractor.\n */\n createSchemaExtractor(tsconfig: any, path?: string): SchemaExtractor {\n return new TypeScriptExtractor(\n tsconfig,\n this.schemaTransformerSlot,\n this,\n path || this.workspace?.path || '',\n this.depResolver,\n this.workspace,\n this.scope,\n this.aspectLoader,\n this.logger\n );\n }\n\n /**\n * add the default package json properties to the component\n * :TODO @gilad why do we need this DSL? can't I just get the args here.\n */\n getCjsPackageJsonProps(): PackageJsonProps {\n return {\n main: 'dist/{main}.js',\n types: '{main}.ts',\n };\n }\n\n /**\n * add type: module to the package.json props and the default props\n * :TODO @gilad why do we need this DSL? can't I just get the args here.\n */\n getEsmPackageJsonProps(): PackageJsonProps {\n return {\n // main: 'dist-esm/{main}.js',\n main: 'dist/{main}.js',\n type: 'module',\n types: '{main}.ts',\n };\n }\n\n getSupportedFilesForTsserver(components: Component[]): string[] {\n const files = components\n .map((c) => c.filesystem.files)\n .flat()\n .map((f) => f.path);\n return files.filter((f) => f.endsWith('.ts') || f.endsWith('.tsx'));\n }\n\n async cleanTsconfigJson(options: TsconfigWriterOptions = {}) {\n const components = await this.workspace.list();\n const runtime = await this.envs.createEnvironment(components);\n const execContext = runtime.getEnvExecutionContext();\n\n const results = await new TsconfigWriter(this.workspace, this.logger).clean(execContext, options);\n\n return results;\n }\n\n async writeTsconfigJson(options: TsconfigWriterOptions = {}): Promise<{\n cleanResults?: string[];\n writeResults: TsconfigPathsPerEnv[];\n }> {\n const components = await this.workspace.list();\n const runtime = await this.envs.createEnvironment(components);\n const execContext = runtime.getEnvExecutionContext();\n\n let cleanResults: string[] | undefined;\n if (options.clean) {\n cleanResults = await this.tsConfigWriter.clean(execContext, options);\n }\n\n const writeResults = await this.tsConfigWriter.write(execContext, options);\n\n return { writeResults, cleanResults };\n }\n\n private async onPreWatch(components: Component[], watchOpts: WatchOptions) {\n const workspace = this.workspace;\n if (!workspace || !watchOpts.spawnTSServer) {\n return;\n }\n const { verbose, checkTypes } = watchOpts;\n const files = checkTypes ? this.getSupportedFilesForTsserver(components) : [];\n const printTypeErrors = Boolean(checkTypes);\n await this.initTsserverClientFromWorkspace({ verbose, checkTypes, printTypeErrors }, files);\n }\n\n private async onComponentChange(component: Component, files: string[]) {\n if (!this.tsServer) {\n return {\n results: 'N/A',\n };\n }\n await pMapSeries(files, (file) => this.tsServer.onFileChange(file));\n return {\n results: 'succeed',\n };\n }\n\n static runtime = MainRuntime;\n static dependencies = [\n SchemaAspect,\n LoggerAspect,\n AspectLoaderAspect,\n WorkspaceAspect,\n CLIAspect,\n DependencyResolverAspect,\n EnvsAspect,\n WatcherAspect,\n WorkspaceConfigFilesAspect,\n CompilerAspect,\n ScopeAspect,\n BuilderAspect,\n ];\n static slots = [Slot.withType<SchemaTransformer[]>()];\n\n static async provider(\n [\n schema,\n loggerExt,\n aspectLoader,\n workspace,\n cli,\n depResolver,\n envs,\n watcher,\n workspaceConfigFiles,\n compiler,\n scope,\n builder,\n ]: [\n SchemaMain,\n LoggerMain,\n AspectLoaderMain,\n Workspace,\n CLIMain,\n DependencyResolverMain,\n EnvsMain,\n WatcherMain,\n WorkspaceConfigFilesMain,\n CompilerMain,\n ScopeMain,\n BuilderMain\n ],\n config,\n [schemaTransformerSlot]: [SchemaTransformerSlot]\n ) {\n schema.registerParser(new TypeScriptParser());\n const logger = loggerExt.createLogger(TypescriptAspect.id);\n workspaceConfigFiles.registerConfigWriter(new TypescriptConfigWriter(compiler, logger));\n\n aspectLoader.registerPlugins([new SchemaTransformerPlugin(schemaTransformerSlot)]);\n const tsconfigWriter = new TsconfigWriter(workspace, logger);\n const tsMain = new TypescriptMain(\n logger,\n schemaTransformerSlot,\n workspace,\n scope,\n depResolver,\n envs,\n tsconfigWriter,\n aspectLoader\n );\n schemaTransformerSlot.register([\n new ExportDeclarationTransformer(),\n new ExportAssignmentTransformer(),\n new FunctionLikeTransformer(),\n new ParameterTransformer(),\n new SetAccessorTransformer(),\n new GetAccessorTransformer(),\n new IndexSignatureTransformer(),\n new PropertyDeclarationTransformer(),\n new VariableStatementTransformer(),\n new VariableDeclaration(),\n new SourceFileTransformer(),\n new TypeAliasTransformer(),\n new ClassDeclarationTransformer(),\n new InterfaceDeclarationTransformer(),\n new EnumDeclarationTransformer(),\n new BindingElementTransformer(),\n new IntersectionTypeTransformer(),\n new UnionTypeTransformer(),\n new TypeReferenceTransformer(),\n new TypeLiteralTransformer(),\n new LiteralTypeTransformer(),\n new TypeQueryTransformer(),\n new ArrayTypeTransformer(),\n new TypeOperatorTransformer(),\n new KeywordTypeTransformer(),\n new TupleTypeTransformer(),\n new ParenthesizedTypeTransformer(),\n new TypePredicateTransformer(),\n new IndexedAccessTypeTransformer(),\n new TemplateLiteralTypeSpanTransformer(),\n new TemplateLiteralTypeTransformer(),\n new ThisTypeTransformer(),\n new ConditionalTypeTransformer(),\n new NamedTupleTransformer(),\n new ConstructorTransformer(),\n new ImportDeclarationTransformer(),\n ]);\n\n if (workspace) {\n watcher.registerOnPreWatch(tsMain.onPreWatch.bind(tsMain));\n workspace.registerOnComponentChange(tsMain.onComponentChange.bind(tsMain));\n workspace.registerOnComponentAdd(tsMain.onComponentChange.bind(tsMain));\n }\n\n const removeTypesTask = new RemoveTypesTask();\n builder.registerSnapTasks([removeTypesTask]);\n builder.registerTagTasks([removeTypesTask]);\n\n const checkTypesCmd = new CheckTypesCmd(tsMain, workspace, logger);\n const writeTsconfigCmd = new WriteTsconfigCmd(tsMain);\n cli.register(checkTypesCmd, writeTsconfigCmd);\n\n return tsMain;\n }\n}\n\nTypescriptAspect.addRuntime(TypescriptMain);\n\nexport function runTransformersWithContext(\n config: TypescriptConfigMutator,\n transformers: TsConfigTransformer[] = [],\n context: TsConfigTransformContext\n): TypescriptConfigMutator {\n if (!Array.isArray(transformers)) return config;\n const newConfig = transformers.reduce((acc, transformer) => {\n return transformer(acc, context);\n }, config);\n return newConfig;\n}\n\nexport default TypescriptMain;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA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MAAM,CAAC;IACrDb,GAAG,CAACc,QAAQ,CAAC6C,aAAa,EAAEE,gBAAgB,CAAC;IAE7C,OAAOhD,MAAM;EACf;AACF;AAAC;AAAA,gCA9UYzG,cAAc,aAuNR2J,kBAAW;AAAA,gCAvNjB3J,cAAc,kBAwNH,CACpB4J,sBAAY,EACZC,sBAAY,EACZC,uBAAkB,EAClBC,4BAAe,EACfC,gBAAS,EACTC,8CAAwB,EACxBC,eAAU,EACVC,kBAAa,EACbC,+BAA0B,EAC1BC,0BAAc,EACdC,oBAAW,EACXC,wBAAa,CACd;AAAA,gCArOUvK,cAAc,WAsOV,CAACwK,eAAI,CAACC,QAAQ,EAAuB,CAAC;AA0GvDnJ,+BAAgB,CAACoJ,UAAU,CAAC1K,cAAc,CAAC;AAEpC,SAASmB,0BAA0B,CACxCqB,MAA+B,EAC/B5B,YAAmC,GAAG,EAAE,EACxC+J,OAAiC,EACR;EACzB,IAAI,CAACC,KAAK,CAACC,OAAO,CAACjK,YAAY,CAAC,EAAE,OAAO4B,MAAM;EAC/C,MAAMsI,SAAS,GAAGlK,YAAY,CAACmK,MAAM,CAAC,CAACC,GAAG,EAAEC,WAAW,KAAK;IAC1D,OAAOA,WAAW,CAACD,GAAG,EAAEL,OAAO,CAAC;EAClC,CAAC,EAAEnI,MAAM,CAAC;EACV,OAAOsI,SAAS;AAClB;AAAC,eAEc9K,cAAc;AAAA"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/typescript",
3
- "version": "0.0.1075",
3
+ "version": "0.0.1076",
4
4
  "homepage": "https://bit.cloud/teambit/typescript/typescript",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.typescript",
8
8
  "name": "typescript",
9
- "version": "0.0.1075"
9
+ "version": "0.0.1076"
10
10
  },
11
11
  "dependencies": {
12
12
  "get-tsconfig": "4.2.0",
@@ -21,26 +21,26 @@
21
21
  "core-js": "^3.0.0",
22
22
  "@babel/runtime": "7.20.0",
23
23
  "@teambit/harmony": "0.4.6",
24
- "@teambit/compiler": "0.0.1075",
24
+ "@teambit/compiler": "0.0.1076",
25
25
  "@teambit/typescript.modules.ts-config-mutator": "0.0.76",
26
- "@teambit/component": "0.0.1075",
27
- "@teambit/dependency-resolver": "0.0.1075",
28
- "@teambit/formatter": "0.0.626",
26
+ "@teambit/builder": "0.0.1076",
27
+ "@teambit/isolator": "0.0.1076",
28
+ "@teambit/component": "0.0.1076",
29
+ "@teambit/dependency-resolver": "0.0.1076",
30
+ "@teambit/formatter": "0.0.627",
29
31
  "@teambit/semantics.entities.semantic-schema": "0.0.53",
30
32
  "@teambit/ts-server": "0.0.46",
31
- "@teambit/aspect-loader": "0.0.1075",
32
- "@teambit/envs": "0.0.1075",
33
- "@teambit/logger": "0.0.817",
34
- "@teambit/workspace-config-files": "0.0.55",
35
- "@teambit/workspace": "0.0.1075",
33
+ "@teambit/aspect-loader": "0.0.1076",
34
+ "@teambit/envs": "0.0.1076",
35
+ "@teambit/logger": "0.0.818",
36
+ "@teambit/workspace-config-files": "0.0.56",
37
+ "@teambit/workspace": "0.0.1076",
36
38
  "@teambit/bit-error": "0.0.402",
37
- "@teambit/builder": "0.0.1075",
38
- "@teambit/isolator": "0.0.1075",
39
- "@teambit/schema": "0.0.1075",
40
- "@teambit/scope": "0.0.1075",
41
- "@teambit/cli": "0.0.724",
42
- "@teambit/pkg": "0.0.1075",
43
- "@teambit/watcher": "0.0.87"
39
+ "@teambit/schema": "0.0.1076",
40
+ "@teambit/scope": "0.0.1076",
41
+ "@teambit/cli": "0.0.725",
42
+ "@teambit/pkg": "0.0.1076",
43
+ "@teambit/watcher": "0.0.88"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/lodash": "4.14.165",
@@ -56,7 +56,7 @@
56
56
  "@teambit/typescript.aspect-docs.typescript": "0.0.153"
57
57
  },
58
58
  "peerDependencies": {
59
- "@teambit/legacy": "1.0.504",
59
+ "@teambit/legacy": "1.0.505",
60
60
  "react": "^16.8.0 || ^17.0.0",
61
61
  "react-dom": "^16.8.0 || ^17.0.0"
62
62
  },