@teambit/typescript 1.0.185 → 1.0.186

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,284 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.TypescriptCompiler = void 0;
7
- function _fsExtra() {
8
- const data = _interopRequireDefault(require("fs-extra"));
9
- _fsExtra = function () {
10
- return data;
11
- };
12
- return data;
13
- }
14
- function _path() {
15
- const data = _interopRequireDefault(require("path"));
16
- _path = function () {
17
- return data;
18
- };
19
- return data;
20
- }
21
- function _bitError() {
22
- const data = require("@teambit/bit-error");
23
- _bitError = function () {
24
- return data;
25
- };
26
- return data;
27
- }
28
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
30
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
31
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
32
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
33
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
34
- class TypescriptCompiler {
35
- constructor(id, logger, options, tsModule) {
36
- this.id = id;
37
- this.logger = logger;
38
- this.options = options;
39
- this.tsModule = tsModule;
40
- _defineProperty(this, "distDir", void 0);
41
- _defineProperty(this, "distGlobPatterns", void 0);
42
- _defineProperty(this, "shouldCopyNonSupportedFiles", void 0);
43
- _defineProperty(this, "artifactName", void 0);
44
- _defineProperty(this, "displayName", 'TypeScript');
45
- _defineProperty(this, "deleteDistDir", false);
46
- this.distDir = options.distDir || 'dist';
47
- this.distGlobPatterns = options.distGlobPatterns || [`${this.distDir}/**`, `!${this.distDir}/tsconfig.tsbuildinfo`];
48
- this.shouldCopyNonSupportedFiles = typeof options.shouldCopyNonSupportedFiles === 'boolean' ? options.shouldCopyNonSupportedFiles : true;
49
- this.artifactName = options.artifactName || 'dist';
50
- this.options.tsconfig ||= {};
51
- this.options.tsconfig.compilerOptions ||= {};
52
- // mutate the outDir, otherwise, on capsules, the dists might be written to a different directory and make confusion
53
- this.options.tsconfig.compilerOptions.outDir = this.distDir;
54
- }
55
- displayConfig() {
56
- return this.stringifyTsconfig(this.options.tsconfig);
57
- }
58
- getDistDir() {
59
- return this.distDir;
60
- }
61
-
62
- /**
63
- * compile one file on the workspace
64
- */
65
- transpileFile(fileContent, options) {
66
- if (!this.isFileSupported(options.filePath)) {
67
- return null; // file is not supported
68
- }
69
- const compilerOptionsFromTsconfig = this.tsModule.convertCompilerOptionsFromJson(this.options.tsconfig.compilerOptions, '.');
70
- if (compilerOptionsFromTsconfig.errors.length) {
71
- // :TODO @david replace to a more concrete error type and put in 'exceptions' directory here.
72
- const formattedErrors = this.tsModule.formatDiagnosticsWithColorAndContext(compilerOptionsFromTsconfig.errors, this.getFormatDiagnosticsHost());
73
- throw new Error(`failed parsing the tsconfig.json.\n${formattedErrors}`);
74
- }
75
- const compilerOptions = compilerOptionsFromTsconfig.options;
76
- compilerOptions.sourceRoot = options.componentDir;
77
- compilerOptions.rootDir = '.';
78
- const result = this.tsModule.transpileModule(fileContent, {
79
- compilerOptions,
80
- fileName: options.filePath,
81
- reportDiagnostics: true
82
- });
83
- if (result.diagnostics && result.diagnostics.length) {
84
- const formatHost = this.getFormatDiagnosticsHost();
85
- const error = this.tsModule.formatDiagnosticsWithColorAndContext(result.diagnostics, formatHost);
86
-
87
- // :TODO @david please replace to a more concrete error type and put in 'exceptions' directory here.
88
- throw new Error(error);
89
- }
90
- const outputPath = this.replaceFileExtToJs(options.filePath);
91
- const outputFiles = [{
92
- outputText: result.outputText,
93
- outputPath
94
- }];
95
- if (result.sourceMapText) {
96
- outputFiles.push({
97
- outputText: result.sourceMapText,
98
- outputPath: `${outputPath}.map`
99
- });
100
- }
101
- return outputFiles;
102
- }
103
- async preBuild(context) {
104
- const capsules = context.capsuleNetwork.seedersCapsules;
105
- const capsuleDirs = capsules.map(capsule => capsule.path);
106
- await this.writeTsConfig(capsuleDirs);
107
- await this.writeTypes(capsuleDirs);
108
- await this.writeNpmIgnore(capsuleDirs);
109
- }
110
-
111
- /**
112
- * compile multiple components on the capsules
113
- */
114
- async build(context) {
115
- const componentsResults = await this.runTscBuild(context.capsuleNetwork);
116
- return {
117
- artifacts: this.getArtifactDefinition(),
118
- componentsResults
119
- };
120
- }
121
- getArtifactDefinition() {
122
- return [{
123
- generatedBy: this.id,
124
- name: this.artifactName,
125
- globPatterns: this.distGlobPatterns
126
- }];
127
- }
128
-
129
- /**
130
- * given a source file, return its parallel in the dists. e.g. index.ts => dist/index.js
131
- */
132
- getDistPathBySrcPath(srcPath) {
133
- const fileWithJSExtIfNeeded = this.replaceFileExtToJs(srcPath);
134
- return _path().default.join(this.distDir, fileWithJSExtIfNeeded);
135
- }
136
-
137
- /**
138
- * whether typescript is able to compile the given path
139
- */
140
- isFileSupported(filePath) {
141
- const isJsAndCompile = !!this.options.compileJs && filePath.endsWith('.js');
142
- const isJsxAndCompile = !!this.options.compileJsx && filePath.endsWith('.jsx');
143
- return (['.ts', '.tsx', '.mts', '.cts', '.mtsx', '.ctsx'].some(ext => filePath.endsWith(ext)) || isJsAndCompile || isJsxAndCompile) && !filePath.endsWith('.d.ts');
144
- }
145
-
146
- /**
147
- * we have two options here:
148
- * 1. pass all capsules-dir at the second parameter of createSolutionBuilder and then no
149
- * need to write the main tsconfig.json with all the references.
150
- * 2. write main tsconfig.json and pass the capsules root-dir.
151
- * we went with option #2 because it'll be easier for users to go to the capsule-root and run
152
- * `tsc --build` to debug issues.
153
- */
154
- async runTscBuild(network) {
155
- const rootDir = network.capsulesRootDir;
156
- const capsules = await network.getCapsulesToCompile();
157
- if (!capsules.length) {
158
- return [];
159
- }
160
- const capsuleDirs = capsules.getAllCapsuleDirs();
161
- const formatHost = {
162
- getCanonicalFileName: p => p,
163
- getCurrentDirectory: () => '',
164
- // it helps to get the files with absolute paths
165
- getNewLine: () => this.tsModule.sys.newLine
166
- };
167
- const componentsResults = [];
168
- let currentComponentResult = {
169
- errors: []
170
- };
171
- const reportDiagnostic = diagnostic => {
172
- const errorStr = process.stdout.isTTY ? this.tsModule.formatDiagnosticsWithColorAndContext([diagnostic], formatHost) : this.tsModule.formatDiagnostic(diagnostic, formatHost);
173
- if (!diagnostic.file) {
174
- // the error is general and not related to a specific file. e.g. tsconfig is missing.
175
- throw new (_bitError().BitError)(errorStr);
176
- }
177
- this.logger.consoleFailure(errorStr);
178
- if (!currentComponentResult.component || !currentComponentResult.errors) {
179
- throw new Error(`currentComponentResult is not defined yet for ${diagnostic.file}`);
180
- }
181
- currentComponentResult.errors.push(errorStr);
182
- };
183
- // this only works when `verbose` is `true` in the `ts.createSolutionBuilder` function.
184
- const reportSolutionBuilderStatus = diag => {
185
- const msg = diag.messageText;
186
- this.logger.debug(msg);
187
- };
188
- const errorCounter = errorCount => {
189
- this.logger.info(`total error found: ${errorCount}`);
190
- };
191
- const host = this.tsModule.createSolutionBuilderHost(undefined, undefined, reportDiagnostic, reportSolutionBuilderStatus, errorCounter);
192
- await this.writeProjectReferencesTsConfig(rootDir, capsuleDirs);
193
- const solutionBuilder = this.tsModule.createSolutionBuilder(host, [rootDir], {
194
- verbose: true
195
- });
196
- let nextProject;
197
- const longProcessLogger = this.logger.createLongProcessLogger('compile typescript components', capsules.length);
198
- // eslint-disable-next-line no-cond-assign
199
- while (nextProject = solutionBuilder.getNextInvalidatedProject()) {
200
- // regex to make sure it will work correctly for both linux and windows
201
- // it replaces both /tsconfig.json and \tsocnfig.json
202
- const capsulePath = nextProject.project.replace(/[/\\]tsconfig.json/, '');
203
- const currentComponentId = capsules.getIdByPathInCapsule(capsulePath);
204
- if (!currentComponentId) throw new Error(`unable to find component for ${capsulePath}`);
205
- longProcessLogger.logProgress(currentComponentId.toString());
206
- const capsule = capsules.getCapsule(currentComponentId);
207
- if (!capsule) throw new Error(`unable to find capsule for ${currentComponentId.toString()}`);
208
- currentComponentResult.component = capsule.component;
209
- currentComponentResult.startTime = Date.now();
210
- nextProject.done();
211
- currentComponentResult.endTime = Date.now();
212
- componentsResults.push(_objectSpread({}, currentComponentResult));
213
- currentComponentResult = {
214
- errors: []
215
- };
216
- }
217
- longProcessLogger.end();
218
- return componentsResults;
219
- }
220
- getFormatDiagnosticsHost() {
221
- return {
222
- getCanonicalFileName: p => p,
223
- getCurrentDirectory: this.tsModule.sys.getCurrentDirectory,
224
- getNewLine: () => this.tsModule.sys.newLine
225
- };
226
- }
227
- async writeTypes(dirs) {
228
- await Promise.all(this.options.types.map(async typePath => {
229
- const contents = await _fsExtra().default.readFile(typePath, 'utf8');
230
- const filename = _path().default.basename(typePath);
231
- await Promise.all(dirs.map(async dir => {
232
- const filePath = _path().default.join(dir, 'types', filename);
233
- if (!(await _fsExtra().default.pathExists(filePath))) {
234
- await _fsExtra().default.outputFile(filePath, contents);
235
- }
236
- }));
237
- }));
238
- }
239
-
240
- /**
241
- * when using project-references, typescript adds a file "tsconfig.tsbuildinfo" which is not
242
- * needed for the package.
243
- */
244
- async writeNpmIgnore(dirs) {
245
- const NPM_IGNORE_FILE = '.npmignore';
246
- await Promise.all(dirs.map(async dir => {
247
- const npmIgnorePath = _path().default.join(dir, NPM_IGNORE_FILE);
248
- const npmIgnoreEntriesStr = `\n${this.distDir}/tsconfig.tsbuildinfo\n`;
249
- await _fsExtra().default.appendFile(npmIgnorePath, npmIgnoreEntriesStr);
250
- }));
251
- }
252
- async writeProjectReferencesTsConfig(rootDir, projects) {
253
- const files = [];
254
- const references = projects.map(project => ({
255
- path: project
256
- }));
257
- const tsconfig = {
258
- files,
259
- references
260
- };
261
- const tsconfigStr = this.stringifyTsconfig(tsconfig);
262
- await _fsExtra().default.writeFile(_path().default.join(rootDir, 'tsconfig.json'), tsconfigStr);
263
- }
264
- async writeTsConfig(dirs) {
265
- const tsconfigStr = this.stringifyTsconfig(this.options.tsconfig);
266
- await Promise.all(dirs.map(dir => _fsExtra().default.writeFile(_path().default.join(dir, 'tsconfig.json'), tsconfigStr)));
267
- }
268
- stringifyTsconfig(tsconfig) {
269
- return JSON.stringify(tsconfig, undefined, 2);
270
- }
271
- replaceFileExtToJs(filePath) {
272
- if (!this.isFileSupported(filePath)) return filePath;
273
- const fileExtension = _path().default.extname(filePath);
274
- // take into account mts, cts, mtsx, ctsx, etc.
275
- const replacement = fileExtension.replace(/([tj]sx?)$/, 'js');
276
- return filePath.replace(new RegExp(`${fileExtension}$`), replacement); // makes sure it's the last occurrence
277
- }
278
- version() {
279
- return this.tsModule.version;
280
- }
281
- }
282
- exports.TypescriptCompiler = TypescriptCompiler;
283
-
284
- //# sourceMappingURL=typescript.compiler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_fsExtra","data","_interopRequireDefault","require","_path","_bitError","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","i","_toPrimitive","String","Symbol","toPrimitive","call","TypeError","Number","TypescriptCompiler","constructor","id","logger","options","tsModule","distDir","distGlobPatterns","shouldCopyNonSupportedFiles","artifactName","tsconfig","compilerOptions","outDir","displayConfig","stringifyTsconfig","getDistDir","transpileFile","fileContent","isFileSupported","filePath","compilerOptionsFromTsconfig","convertCompilerOptionsFromJson","errors","formattedErrors","formatDiagnosticsWithColorAndContext","getFormatDiagnosticsHost","Error","sourceRoot","componentDir","rootDir","result","transpileModule","fileName","reportDiagnostics","diagnostics","formatHost","error","outputPath","replaceFileExtToJs","outputFiles","outputText","sourceMapText","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","some","ext","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","types","typePath","contents","fs","readFile","filename","basename","dir","pathExists","outputFile","NPM_IGNORE_FILE","npmIgnorePath","npmIgnoreEntriesStr","appendFile","projects","files","references","tsconfigStr","writeFile","JSON","stringify","fileExtension","extname","replacement","RegExp","version","exports"],"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';\n\nexport class TypescriptCompiler implements Compiler {\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 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 (['.ts', '.tsx', '.mts', '.cts', '.mtsx', '.ctsx'].some((ext) => filePath.endsWith(ext)) ||\n isJsAndCompile ||\n 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 // take into account mts, cts, mtsx, ctsx, etc.\n const replacement = fileExtension.replace(/([tj]sx?)$/, 'js');\n return filePath.replace(new RegExp(`${fileExtension}$`), replacement); // makes sure it's the last occurrence\n }\n\n version() {\n return this.tsModule.version;\n }\n}\n"],"mappings":";;;;;;AAIA,SAAAA,SAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,QAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,MAAA;EAAA,MAAAH,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAC,KAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,UAAA;EAAA,MAAAJ,IAAA,GAAAE,OAAA;EAAAE,SAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA8C,SAAAC,uBAAAI,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,QAAAC,CAAA,EAAAC,CAAA,QAAAC,CAAA,GAAAC,MAAA,CAAAC,IAA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AEQtI,iBAAiBA,CAACJ,QAAQ,EAAE;IAClC,OAAO4I,IAAI,CAACC,SAAS,CAAC7I,QAAQ,EAAE+F,SAAS,EAAE,CAAC,CAAC;EAC/C;EAEQnE,kBAAkBA,CAACnB,QAAgB,EAAU;IACnD,IAAI,CAAC,IAAI,CAACD,eAAe,CAACC,QAAQ,CAAC,EAAE,OAAOA,QAAQ;IACpD,MAAMqI,aAAa,GAAGtG,eAAI,CAACuG,OAAO,CAACtI,QAAQ,CAAC;IAC5C;IACA,MAAMuI,WAAW,GAAGF,aAAa,CAACpC,OAAO,CAAC,YAAY,EAAE,IAAI,CAAC;IAC7D,OAAOjG,QAAQ,CAACiG,OAAO,CAAC,IAAIuC,MAAM,CAAE,GAAEH,aAAc,GAAE,CAAC,EAAEE,WAAW,CAAC,CAAC,CAAC;EACzE;EAEAE,OAAOA,CAAA,EAAG;IACR,OAAO,IAAI,CAACvJ,QAAQ,CAACuJ,OAAO;EAC9B;AACF;AAACC,OAAA,CAAA7J,kBAAA,GAAAA,kBAAA"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,108 +0,0 @@
1
- "use strict";
2
-
3
- function _logger() {
4
- const data = require("@teambit/logger");
5
- _logger = function () {
6
- return data;
7
- };
8
- return data;
9
- }
10
- function _typescript() {
11
- const data = _interopRequireDefault(require("typescript"));
12
- _typescript = function () {
13
- return data;
14
- };
15
- return data;
16
- }
17
- function _chai() {
18
- const data = require("chai");
19
- _chai = function () {
20
- return data;
21
- };
22
- return data;
23
- }
24
- function _path() {
25
- const data = _interopRequireDefault(require("path"));
26
- _path = function () {
27
- return data;
28
- };
29
- return data;
30
- }
31
- function _typescript2() {
32
- const data = require("./typescript.aspect");
33
- _typescript2 = function () {
34
- return data;
35
- };
36
- return data;
37
- }
38
- function _typescript3() {
39
- const data = require("./typescript.compiler");
40
- _typescript3 = function () {
41
- return data;
42
- };
43
- return data;
44
- }
45
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
46
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
47
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
48
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
49
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
50
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
51
- const defaultOpts = {
52
- tsconfig: {},
53
- types: []
54
- };
55
- describe('TypescriptCompiler', () => {
56
- describe('getDistPathBySrcPath', () => {
57
- it('should replace the extension with .js and prepend the dist dir', () => {
58
- const tsCompiler = getTsCompiler();
59
- (0, _chai().expect)(tsCompiler.getDistPathBySrcPath('index.ts')).to.equal(_path().default.join('dist', 'index.js'));
60
- (0, _chai().expect)(tsCompiler.getDistPathBySrcPath('index.tsx')).to.equal(_path().default.join('dist', 'index.js'));
61
- });
62
- it('should not replace the extension if the file is not supported', () => {
63
- const tsCompiler = getTsCompiler();
64
- (0, _chai().expect)(tsCompiler.getDistPathBySrcPath('style.css')).to.equal(_path().default.join('dist', 'style.css'));
65
- (0, _chai().expect)(tsCompiler.getDistPathBySrcPath('index.d.ts')).to.equal(_path().default.join('dist', 'index.d.ts'));
66
- });
67
- });
68
- describe('isFileSupported', () => {
69
- it('should support .ts files', () => {
70
- const tsCompiler = getTsCompiler();
71
- (0, _chai().expect)(tsCompiler.isFileSupported('index.ts')).to.be.true;
72
- });
73
- it('should support .tsx files', () => {
74
- const tsCompiler = getTsCompiler();
75
- (0, _chai().expect)(tsCompiler.isFileSupported('index.tsx')).to.be.true;
76
- });
77
- it('should not support .jsx files by default', () => {
78
- const tsCompiler = getTsCompiler();
79
- (0, _chai().expect)(tsCompiler.isFileSupported('index.jsx')).to.be.false;
80
- });
81
- it('should not support .js files by default', () => {
82
- const tsCompiler = getTsCompiler();
83
- (0, _chai().expect)(tsCompiler.isFileSupported('index.js')).to.be.false;
84
- });
85
- it('should support .jsx files when passing compileJsx', () => {
86
- const tsCompiler = getTsCompiler(_objectSpread({
87
- compileJsx: true
88
- }, defaultOpts));
89
- (0, _chai().expect)(tsCompiler.isFileSupported('index.jsx')).to.be.true;
90
- });
91
- it('should support .js files when passing compileJs', () => {
92
- const tsCompiler = getTsCompiler(_objectSpread({
93
- compileJs: true
94
- }, defaultOpts));
95
- (0, _chai().expect)(tsCompiler.isFileSupported('index.js')).to.be.true;
96
- });
97
- it('should not support .d.ts files', () => {
98
- const tsCompiler = getTsCompiler();
99
- (0, _chai().expect)(tsCompiler.isFileSupported('index.d.ts')).to.be.false;
100
- });
101
- });
102
- });
103
- function getTsCompiler(opts = defaultOpts) {
104
- const finalOpts = Object.assign({}, defaultOpts, opts);
105
- return new (_typescript3().TypescriptCompiler)(_typescript2().TypescriptAspect.id, new (_logger().Logger)('test'), finalOpts, _typescript().default);
106
- }
107
-
108
- //# sourceMappingURL=typescript.compiler.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_logger","data","require","_typescript","_interopRequireDefault","_chai","_path","_typescript2","_typescript3","obj","__esModule","default","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","key","value","_toPropertyKey","configurable","writable","i","_toPrimitive","String","Symbol","toPrimitive","call","TypeError","Number","defaultOpts","tsconfig","types","describe","it","tsCompiler","getTsCompiler","expect","getDistPathBySrcPath","to","equal","path","join","isFileSupported","be","true","false","compileJsx","compileJs","opts","finalOpts","assign","TypescriptCompiler","TypescriptAspect","id","Logger","ts"],"sources":["typescript.compiler.spec.ts"],"sourcesContent":["import { Logger } from '@teambit/logger';\nimport ts from 'typescript';\nimport { expect } from 'chai';\nimport path from 'path';\nimport { TypescriptAspect } from './typescript.aspect';\n\nimport { TypescriptCompiler } from './typescript.compiler';\nimport type { TsCompilerOptionsWithoutTsConfig } from './compiler-options';\n\nconst defaultOpts = {\n tsconfig: {},\n types: [],\n};\n\ndescribe('TypescriptCompiler', () => {\n describe('getDistPathBySrcPath', () => {\n it('should replace the extension with .js and prepend the dist dir', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.getDistPathBySrcPath('index.ts')).to.equal(path.join('dist', 'index.js'));\n expect(tsCompiler.getDistPathBySrcPath('index.tsx')).to.equal(path.join('dist', 'index.js'));\n });\n it('should not replace the extension if the file is not supported', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.getDistPathBySrcPath('style.css')).to.equal(path.join('dist', 'style.css'));\n expect(tsCompiler.getDistPathBySrcPath('index.d.ts')).to.equal(path.join('dist', 'index.d.ts'));\n });\n });\n describe('isFileSupported', () => {\n it('should support .ts files', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.ts')).to.be.true;\n });\n it('should support .tsx files', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.tsx')).to.be.true;\n });\n it('should not support .jsx files by default', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.jsx')).to.be.false;\n });\n it('should not support .js files by default', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.js')).to.be.false;\n });\n it('should support .jsx files when passing compileJsx', () => {\n const tsCompiler = getTsCompiler({ compileJsx: true, ...defaultOpts });\n expect(tsCompiler.isFileSupported('index.jsx')).to.be.true;\n });\n it('should support .js files when passing compileJs', () => {\n const tsCompiler = getTsCompiler({ compileJs: true, ...defaultOpts });\n expect(tsCompiler.isFileSupported('index.js')).to.be.true;\n });\n it('should not support .d.ts files', () => {\n const tsCompiler = getTsCompiler();\n expect(tsCompiler.isFileSupported('index.d.ts')).to.be.false;\n });\n });\n});\n\nfunction getTsCompiler(opts: TsCompilerOptionsWithoutTsConfig = defaultOpts) {\n const finalOpts = Object.assign({}, defaultOpts, opts);\n return new TypescriptCompiler(TypescriptAspect.id, new Logger('test'), finalOpts, ts);\n}\n"],"mappings":";;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,YAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,WAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,MAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,KAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,MAAA;EAAA,MAAAL,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAI,KAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,aAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,YAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAO,aAAA;EAAA,MAAAP,IAAA,GAAAC,OAAA;EA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