@teambit/typescript 0.0.880 → 0.0.882
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cmds/check-types.cmd.js +0 -21
- package/dist/cmds/check-types.cmd.js.map +1 -1
- package/dist/cmds/write-tsconfig.cmd.js +2 -25
- package/dist/cmds/write-tsconfig.cmd.js.map +1 -1
- package/dist/dedupe-path.spec.js +6 -8
- package/dist/dedupe-path.spec.js.map +1 -1
- package/dist/exceptions/index.js +0 -3
- package/dist/exceptions/index.js.map +1 -1
- package/dist/exceptions/transformer-not-found.js +0 -7
- package/dist/exceptions/transformer-not-found.js.map +1 -1
- package/dist/export-identifier.js +0 -3
- package/dist/export-identifier.js.map +1 -1
- package/dist/export-list.js +0 -4
- package/dist/export-list.js.map +1 -1
- package/dist/index.js +0 -9
- package/dist/index.js.map +1 -1
- package/dist/schema-extractor-context.js +16 -120
- package/dist/schema-extractor-context.js.map +1 -1
- package/dist/schema-transformer.plugin.js +0 -8
- package/dist/schema-transformer.plugin.js.map +1 -1
- package/dist/transformers/binding-element.js +0 -23
- package/dist/transformers/binding-element.js.map +1 -1
- package/dist/transformers/class-deceleration.js +2 -34
- package/dist/transformers/class-deceleration.js.map +1 -1
- package/dist/transformers/enum-declaration.js +0 -16
- package/dist/transformers/enum-declaration.js.map +1 -1
- package/dist/transformers/export-declaration.js +8 -47
- package/dist/transformers/export-declaration.js.map +1 -1
- package/dist/transformers/function-declaration.js +2 -19
- package/dist/transformers/function-declaration.js.map +1 -1
- package/dist/transformers/index.js +0 -30
- package/dist/transformers/index.js.map +1 -1
- package/dist/transformers/interface-declaration.js +0 -25
- package/dist/transformers/interface-declaration.js.map +1 -1
- package/dist/transformers/source-file-transformer.js +3 -24
- package/dist/transformers/source-file-transformer.js.map +1 -1
- package/dist/transformers/type-alias.js +0 -23
- package/dist/transformers/type-alias.js.map +1 -1
- package/dist/transformers/utils/class-element-to-schema.js +0 -35
- package/dist/transformers/utils/class-element-to-schema.js.map +1 -1
- package/dist/transformers/utils/get-params.js +6 -33
- package/dist/transformers/utils/get-params.js.map +1 -1
- package/dist/transformers/utils/jsdoc-to-doc-schema.js +4 -49
- package/dist/transformers/utils/jsdoc-to-doc-schema.js.map +1 -1
- package/dist/transformers/utils/parse-type-from-quick-info.js +4 -16
- package/dist/transformers/utils/parse-type-from-quick-info.js.map +1 -1
- package/dist/transformers/utils/to-function-like-schema.js +0 -15
- package/dist/transformers/utils/to-function-like-schema.js.map +1 -1
- package/dist/transformers/utils/type-element-to-schema.js +0 -37
- package/dist/transformers/utils/type-element-to-schema.js.map +1 -1
- package/dist/transformers/utils/type-node-to-schema.js +5 -71
- package/dist/transformers/utils/type-node-to-schema.js.map +1 -1
- package/dist/transformers/variable-declaration.js +0 -30
- package/dist/transformers/variable-declaration.js.map +1 -1
- package/dist/transformers/variable-statement.js +0 -22
- package/dist/transformers/variable-statement.js.map +1 -1
- package/dist/tsconfig-writer.js +8 -58
- package/dist/tsconfig-writer.js.map +1 -1
- package/dist/typescript.aspect.js +0 -5
- package/dist/typescript.aspect.js.map +1 -1
- package/dist/typescript.compiler.js +16 -83
- package/dist/typescript.compiler.js.map +1 -1
- package/dist/typescript.compiler.spec.js +0 -25
- package/dist/typescript.compiler.spec.js.map +1 -1
- package/dist/typescript.composition.js +0 -6
- package/dist/typescript.composition.js.map +1 -1
- package/dist/typescript.extractor.js +6 -50
- package/dist/typescript.extractor.js.map +1 -1
- package/dist/typescript.main.runtime.js +10 -114
- package/dist/typescript.main.runtime.js.map +1 -1
- package/dist/typescript.parser.js +3 -30
- package/dist/typescript.parser.js.map +1 -1
- package/dist/typescript.parser.spec.js +0 -22
- package/dist/typescript.parser.spec.js.map +1 -1
- package/package-tar/teambit-typescript-0.0.882.tgz +0 -0
- package/package.json +15 -15
- package/{preview-1666312873430.js → preview-1666496165706.js} +2 -2
- package/package-tar/teambit-typescript-0.0.880.tgz +0 -0
|
@@ -1,80 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
require("core-js/modules/es.array.iterator.js");
|
|
6
|
-
|
|
7
5
|
require("core-js/modules/es.promise.js");
|
|
8
|
-
|
|
9
6
|
require("core-js/modules/es.regexp.constructor.js");
|
|
10
|
-
|
|
11
7
|
require("core-js/modules/es.regexp.exec.js");
|
|
12
|
-
|
|
13
8
|
require("core-js/modules/es.string.replace.js");
|
|
14
|
-
|
|
15
9
|
Object.defineProperty(exports, "__esModule", {
|
|
16
10
|
value: true
|
|
17
11
|
});
|
|
18
12
|
exports.TypescriptCompiler = void 0;
|
|
19
|
-
|
|
20
13
|
function _defineProperty2() {
|
|
21
14
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
22
|
-
|
|
23
15
|
_defineProperty2 = function () {
|
|
24
16
|
return data;
|
|
25
17
|
};
|
|
26
|
-
|
|
27
18
|
return data;
|
|
28
19
|
}
|
|
29
|
-
|
|
30
20
|
function _fsExtra() {
|
|
31
21
|
const data = _interopRequireDefault(require("fs-extra"));
|
|
32
|
-
|
|
33
22
|
_fsExtra = function () {
|
|
34
23
|
return data;
|
|
35
24
|
};
|
|
36
|
-
|
|
37
25
|
return data;
|
|
38
26
|
}
|
|
39
|
-
|
|
40
27
|
function _path() {
|
|
41
28
|
const data = _interopRequireDefault(require("path"));
|
|
42
|
-
|
|
43
29
|
_path = function () {
|
|
44
30
|
return data;
|
|
45
31
|
};
|
|
46
|
-
|
|
47
32
|
return data;
|
|
48
33
|
}
|
|
49
|
-
|
|
50
34
|
function _bitError() {
|
|
51
35
|
const data = require("@teambit/bit-error");
|
|
52
|
-
|
|
53
36
|
_bitError = function () {
|
|
54
37
|
return data;
|
|
55
38
|
};
|
|
56
|
-
|
|
57
39
|
return data;
|
|
58
40
|
}
|
|
59
|
-
|
|
60
41
|
function _packageJsonFile() {
|
|
61
42
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/component/package-json-file"));
|
|
62
|
-
|
|
63
43
|
_packageJsonFile = function () {
|
|
64
44
|
return data;
|
|
65
45
|
};
|
|
66
|
-
|
|
67
46
|
return data;
|
|
68
47
|
}
|
|
69
|
-
|
|
70
48
|
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; }
|
|
71
|
-
|
|
72
49
|
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; }
|
|
73
|
-
|
|
74
50
|
class TypescriptCompiler {
|
|
75
51
|
constructor(id, logger, options, tsModule) {
|
|
76
52
|
var _this$options, _this$options$tsconfi;
|
|
77
|
-
|
|
78
53
|
this.id = id;
|
|
79
54
|
this.logger = logger;
|
|
80
55
|
this.options = options;
|
|
@@ -90,36 +65,31 @@ class TypescriptCompiler {
|
|
|
90
65
|
this.shouldCopyNonSupportedFiles = typeof options.shouldCopyNonSupportedFiles === 'boolean' ? options.shouldCopyNonSupportedFiles : true;
|
|
91
66
|
this.artifactName = options.artifactName || 'dist';
|
|
92
67
|
(_this$options = this.options).tsconfig || (_this$options.tsconfig = {});
|
|
93
|
-
(_this$options$tsconfi = this.options.tsconfig).compilerOptions || (_this$options$tsconfi.compilerOptions = {});
|
|
94
|
-
|
|
68
|
+
(_this$options$tsconfi = this.options.tsconfig).compilerOptions || (_this$options$tsconfi.compilerOptions = {});
|
|
69
|
+
// mutate the outDir, otherwise, on capsules, the dists might be written to a different directory and make confusion
|
|
95
70
|
this.options.tsconfig.compilerOptions.outDir = this.distDir;
|
|
96
71
|
}
|
|
97
|
-
|
|
98
72
|
displayConfig() {
|
|
99
73
|
return this.stringifyTsconfig(this.options.tsconfig);
|
|
100
74
|
}
|
|
101
|
-
|
|
102
75
|
getDistDir() {
|
|
103
76
|
return this.distDir;
|
|
104
77
|
}
|
|
78
|
+
|
|
105
79
|
/**
|
|
106
80
|
* compile one file on the workspace
|
|
107
81
|
*/
|
|
108
|
-
|
|
109
|
-
|
|
110
82
|
transpileFile(fileContent, options) {
|
|
111
83
|
if (!this.isFileSupported(options.filePath)) {
|
|
112
84
|
return null; // file is not supported
|
|
113
85
|
}
|
|
114
86
|
|
|
115
87
|
const compilerOptionsFromTsconfig = this.tsModule.convertCompilerOptionsFromJson(this.options.tsconfig.compilerOptions, '.');
|
|
116
|
-
|
|
117
88
|
if (compilerOptionsFromTsconfig.errors.length) {
|
|
118
89
|
// :TODO @david replace to a more concrete error type and put in 'exceptions' directory here.
|
|
119
90
|
const formattedErrors = this.tsModule.formatDiagnosticsWithColorAndContext(compilerOptionsFromTsconfig.errors, this.getFormatDiagnosticsHost());
|
|
120
91
|
throw new Error(`failed parsing the tsconfig.json.\n${formattedErrors}`);
|
|
121
92
|
}
|
|
122
|
-
|
|
123
93
|
const compilerOptions = compilerOptionsFromTsconfig.options;
|
|
124
94
|
compilerOptions.sourceRoot = options.componentDir;
|
|
125
95
|
compilerOptions.rootDir = '.';
|
|
@@ -128,30 +98,26 @@ class TypescriptCompiler {
|
|
|
128
98
|
fileName: options.filePath,
|
|
129
99
|
reportDiagnostics: true
|
|
130
100
|
});
|
|
131
|
-
|
|
132
101
|
if (result.diagnostics && result.diagnostics.length) {
|
|
133
102
|
const formatHost = this.getFormatDiagnosticsHost();
|
|
134
|
-
const error = this.tsModule.formatDiagnosticsWithColorAndContext(result.diagnostics, formatHost);
|
|
103
|
+
const error = this.tsModule.formatDiagnosticsWithColorAndContext(result.diagnostics, formatHost);
|
|
135
104
|
|
|
105
|
+
// :TODO @david please replace to a more concrete error type and put in 'exceptions' directory here.
|
|
136
106
|
throw new Error(error);
|
|
137
107
|
}
|
|
138
|
-
|
|
139
108
|
const outputPath = this.replaceFileExtToJs(options.filePath);
|
|
140
109
|
const outputFiles = [{
|
|
141
110
|
outputText: result.outputText,
|
|
142
111
|
outputPath
|
|
143
112
|
}];
|
|
144
|
-
|
|
145
113
|
if (result.sourceMapText) {
|
|
146
114
|
outputFiles.push({
|
|
147
115
|
outputText: result.sourceMapText,
|
|
148
116
|
outputPath: `${outputPath}.map`
|
|
149
117
|
});
|
|
150
118
|
}
|
|
151
|
-
|
|
152
119
|
return outputFiles;
|
|
153
120
|
}
|
|
154
|
-
|
|
155
121
|
async preBuild(context) {
|
|
156
122
|
const capsules = context.capsuleNetwork.seedersCapsules;
|
|
157
123
|
const capsuleDirs = capsules.map(capsule => capsule.path);
|
|
@@ -159,11 +125,10 @@ class TypescriptCompiler {
|
|
|
159
125
|
await this.writeTypes(capsuleDirs);
|
|
160
126
|
await this.writeNpmIgnore(capsuleDirs);
|
|
161
127
|
}
|
|
128
|
+
|
|
162
129
|
/**
|
|
163
130
|
* compile multiple components on the capsules
|
|
164
131
|
*/
|
|
165
|
-
|
|
166
|
-
|
|
167
132
|
async build(context) {
|
|
168
133
|
const componentsResults = await this.runTscBuild(context.capsuleNetwork);
|
|
169
134
|
return {
|
|
@@ -171,20 +136,17 @@ class TypescriptCompiler {
|
|
|
171
136
|
componentsResults
|
|
172
137
|
};
|
|
173
138
|
}
|
|
174
|
-
|
|
175
139
|
async postBuild(context) {
|
|
176
140
|
await Promise.all(context.capsuleNetwork.seedersCapsules.map(async capsule => {
|
|
177
|
-
const packageJson = _packageJsonFile().default.loadFromCapsuleSync(capsule.path);
|
|
141
|
+
const packageJson = _packageJsonFile().default.loadFromCapsuleSync(capsule.path);
|
|
142
|
+
// the types['index.ts'] is needed only during the build to avoid errors when tsc finds the
|
|
178
143
|
// same type once in the d.ts and once in the ts file.
|
|
179
|
-
|
|
180
|
-
|
|
181
144
|
if (packageJson.packageJsonObject.types) {
|
|
182
145
|
delete packageJson.packageJsonObject.types;
|
|
183
146
|
await packageJson.write();
|
|
184
147
|
}
|
|
185
148
|
}));
|
|
186
149
|
}
|
|
187
|
-
|
|
188
150
|
getArtifactDefinition() {
|
|
189
151
|
return [{
|
|
190
152
|
generatedBy: this.id,
|
|
@@ -192,25 +154,24 @@ class TypescriptCompiler {
|
|
|
192
154
|
globPatterns: this.distGlobPatterns
|
|
193
155
|
}];
|
|
194
156
|
}
|
|
157
|
+
|
|
195
158
|
/**
|
|
196
159
|
* given a source file, return its parallel in the dists. e.g. index.ts => dist/index.js
|
|
197
160
|
*/
|
|
198
|
-
|
|
199
|
-
|
|
200
161
|
getDistPathBySrcPath(srcPath) {
|
|
201
162
|
const fileWithJSExtIfNeeded = this.replaceFileExtToJs(srcPath);
|
|
202
163
|
return _path().default.join(this.distDir, fileWithJSExtIfNeeded);
|
|
203
164
|
}
|
|
165
|
+
|
|
204
166
|
/**
|
|
205
167
|
* whether typescript is able to compile the given path
|
|
206
168
|
*/
|
|
207
|
-
|
|
208
|
-
|
|
209
169
|
isFileSupported(filePath) {
|
|
210
170
|
const isJsAndCompile = !!this.options.compileJs && filePath.endsWith('.js');
|
|
211
171
|
const isJsxAndCompile = !!this.options.compileJsx && filePath.endsWith('.jsx');
|
|
212
172
|
return (filePath.endsWith('.ts') || filePath.endsWith('.tsx') || isJsAndCompile || isJsxAndCompile) && !filePath.endsWith('.d.ts');
|
|
213
173
|
}
|
|
174
|
+
|
|
214
175
|
/**
|
|
215
176
|
* we have two options here:
|
|
216
177
|
* 1. pass all capsules-dir at the second parameter of createSolutionBuilder and then no
|
|
@@ -219,16 +180,12 @@ class TypescriptCompiler {
|
|
|
219
180
|
* we went with option #2 because it'll be easier for users to go to the capsule-root and run
|
|
220
181
|
* `tsc --build` to debug issues.
|
|
221
182
|
*/
|
|
222
|
-
|
|
223
|
-
|
|
224
183
|
async runTscBuild(network) {
|
|
225
184
|
const rootDir = network.capsulesRootDir;
|
|
226
185
|
const capsules = await network.getCapsulesToCompile();
|
|
227
|
-
|
|
228
186
|
if (!capsules.length) {
|
|
229
187
|
return [];
|
|
230
188
|
}
|
|
231
|
-
|
|
232
189
|
const capsuleDirs = capsules.getAllCapsuleDirs();
|
|
233
190
|
const formatHost = {
|
|
234
191
|
getCanonicalFileName: p => p,
|
|
@@ -240,42 +197,34 @@ class TypescriptCompiler {
|
|
|
240
197
|
let currentComponentResult = {
|
|
241
198
|
errors: []
|
|
242
199
|
};
|
|
243
|
-
|
|
244
200
|
const reportDiagnostic = diagnostic => {
|
|
245
201
|
const errorStr = process.stdout.isTTY ? this.tsModule.formatDiagnosticsWithColorAndContext([diagnostic], formatHost) : this.tsModule.formatDiagnostic(diagnostic, formatHost);
|
|
246
|
-
|
|
247
202
|
if (!diagnostic.file) {
|
|
248
203
|
// the error is general and not related to a specific file. e.g. tsconfig is missing.
|
|
249
204
|
throw new (_bitError().BitError)(errorStr);
|
|
250
205
|
}
|
|
251
|
-
|
|
252
206
|
this.logger.consoleFailure(errorStr);
|
|
253
|
-
|
|
254
207
|
if (!currentComponentResult.component || !currentComponentResult.errors) {
|
|
255
208
|
throw new Error(`currentComponentResult is not defined yet for ${diagnostic.file}`);
|
|
256
209
|
}
|
|
257
|
-
|
|
258
210
|
currentComponentResult.errors.push(errorStr);
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
|
|
211
|
+
};
|
|
212
|
+
// this only works when `verbose` is `true` in the `ts.createSolutionBuilder` function.
|
|
262
213
|
const reportSolutionBuilderStatus = diag => {
|
|
263
214
|
const msg = diag.messageText;
|
|
264
215
|
this.logger.debug(msg);
|
|
265
216
|
};
|
|
266
|
-
|
|
267
217
|
const errorCounter = errorCount => {
|
|
268
218
|
this.logger.info(`total error found: ${errorCount}`);
|
|
269
219
|
};
|
|
270
|
-
|
|
271
220
|
const host = this.tsModule.createSolutionBuilderHost(undefined, undefined, reportDiagnostic, reportSolutionBuilderStatus, errorCounter);
|
|
272
221
|
await this.writeProjectReferencesTsConfig(rootDir, capsuleDirs);
|
|
273
222
|
const solutionBuilder = this.tsModule.createSolutionBuilder(host, [rootDir], {
|
|
274
223
|
verbose: true
|
|
275
224
|
});
|
|
276
225
|
let nextProject;
|
|
277
|
-
const longProcessLogger = this.logger.createLongProcessLogger('compile typescript components', capsules.length);
|
|
278
|
-
|
|
226
|
+
const longProcessLogger = this.logger.createLongProcessLogger('compile typescript components', capsules.length);
|
|
227
|
+
// eslint-disable-next-line no-cond-assign
|
|
279
228
|
while (nextProject = solutionBuilder.getNextInvalidatedProject()) {
|
|
280
229
|
// regex to make sure it will work correctly for both linux and windows
|
|
281
230
|
// it replaces both /tsconfig.json and \tsocnfig.json
|
|
@@ -294,11 +243,9 @@ class TypescriptCompiler {
|
|
|
294
243
|
errors: []
|
|
295
244
|
};
|
|
296
245
|
}
|
|
297
|
-
|
|
298
246
|
longProcessLogger.end();
|
|
299
247
|
return componentsResults;
|
|
300
248
|
}
|
|
301
|
-
|
|
302
249
|
getFormatDiagnosticsHost() {
|
|
303
250
|
return {
|
|
304
251
|
getCanonicalFileName: p => p,
|
|
@@ -306,38 +253,31 @@ class TypescriptCompiler {
|
|
|
306
253
|
getNewLine: () => this.tsModule.sys.newLine
|
|
307
254
|
};
|
|
308
255
|
}
|
|
309
|
-
|
|
310
256
|
async writeTypes(dirs) {
|
|
311
257
|
await Promise.all(this.options.types.map(async typePath => {
|
|
312
258
|
const contents = await _fsExtra().default.readFile(typePath, 'utf8');
|
|
313
|
-
|
|
314
259
|
const filename = _path().default.basename(typePath);
|
|
315
|
-
|
|
316
260
|
await Promise.all(dirs.map(async dir => {
|
|
317
261
|
const filePath = _path().default.join(dir, 'types', filename);
|
|
318
|
-
|
|
319
262
|
if (!(await _fsExtra().default.pathExists(filePath))) {
|
|
320
263
|
await _fsExtra().default.outputFile(filePath, contents);
|
|
321
264
|
}
|
|
322
265
|
}));
|
|
323
266
|
}));
|
|
324
267
|
}
|
|
268
|
+
|
|
325
269
|
/**
|
|
326
270
|
* when using project-references, typescript adds a file "tsconfig.tsbuildinfo" which is not
|
|
327
271
|
* needed for the package.
|
|
328
272
|
*/
|
|
329
|
-
|
|
330
|
-
|
|
331
273
|
async writeNpmIgnore(dirs) {
|
|
332
274
|
const NPM_IGNORE_FILE = '.npmignore';
|
|
333
275
|
await Promise.all(dirs.map(async dir => {
|
|
334
276
|
const npmIgnorePath = _path().default.join(dir, NPM_IGNORE_FILE);
|
|
335
|
-
|
|
336
277
|
const npmIgnoreEntriesStr = `\n${this.distDir}/tsconfig.tsbuildinfo\n`;
|
|
337
278
|
await _fsExtra().default.appendFile(npmIgnorePath, npmIgnoreEntriesStr);
|
|
338
279
|
}));
|
|
339
280
|
}
|
|
340
|
-
|
|
341
281
|
async writeProjectReferencesTsConfig(rootDir, projects) {
|
|
342
282
|
const files = [];
|
|
343
283
|
const references = projects.map(project => ({
|
|
@@ -350,30 +290,23 @@ class TypescriptCompiler {
|
|
|
350
290
|
const tsconfigStr = this.stringifyTsconfig(tsconfig);
|
|
351
291
|
await _fsExtra().default.writeFile(_path().default.join(rootDir, 'tsconfig.json'), tsconfigStr);
|
|
352
292
|
}
|
|
353
|
-
|
|
354
293
|
async writeTsConfig(dirs) {
|
|
355
294
|
const tsconfigStr = this.stringifyTsconfig(this.options.tsconfig);
|
|
356
295
|
await Promise.all(dirs.map(dir => _fsExtra().default.writeFile(_path().default.join(dir, 'tsconfig.json'), tsconfigStr)));
|
|
357
296
|
}
|
|
358
|
-
|
|
359
297
|
stringifyTsconfig(tsconfig) {
|
|
360
298
|
return JSON.stringify(tsconfig, undefined, 2);
|
|
361
299
|
}
|
|
362
|
-
|
|
363
300
|
replaceFileExtToJs(filePath) {
|
|
364
301
|
if (!this.isFileSupported(filePath)) return filePath;
|
|
365
|
-
|
|
366
302
|
const fileExtension = _path().default.extname(filePath);
|
|
367
|
-
|
|
368
303
|
return filePath.replace(new RegExp(`${fileExtension}$`), '.js'); // makes sure it's the last occurrence
|
|
369
304
|
}
|
|
370
305
|
|
|
371
306
|
version() {
|
|
372
307
|
return this.tsModule.version;
|
|
373
308
|
}
|
|
374
|
-
|
|
375
309
|
}
|
|
376
|
-
|
|
377
310
|
exports.TypescriptCompiler = TypescriptCompiler;
|
|
378
311
|
|
|
379
312
|
//# sourceMappingURL=typescript.compiler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TypescriptCompiler","constructor","id","logger","options","tsModule","distDir","distGlobPatterns","shouldCopyNonSupportedFiles","artifactName","tsconfig","compilerOptions","outDir","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","types","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';\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 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 if (packageJson.packageJsonObject.types) {\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;;EAA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CAAqBC,QAArB,CAAL,EAAqC,OAAOA,QAAP;;IACrC,MAAM2I,aAAa,GAAG1G,eAAA,CAAK2G,OAAL,CAAa5I,QAAb,CAAtB;;IACA,OAAOA,QAAQ,CAAC0G,OAAT,CAAiB,IAAImC,MAAJ,CAAY,GAAEF,aAAc,GAA5B,CAAjB,EAAkD,KAAlD,CAAP,CAHmD,CAGc;EAClE;;EAEDG,OAAO,GAAG;IACR,OAAO,KAAK5J,QAAL,CAAc4J,OAArB;EACD;;AAhSiD"}
|
|
1
|
+
{"version":3,"names":["TypescriptCompiler","constructor","id","logger","options","tsModule","distDir","distGlobPatterns","shouldCopyNonSupportedFiles","artifactName","tsconfig","compilerOptions","outDir","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","types","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';\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 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 if (packageJson.packageJsonObject.types) {\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;EA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AAE,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,CAAC5J,QAAQ,CAAC4J,OAAO;EAC9B;AACF;AAAC"}
|
|
@@ -1,81 +1,57 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
function _defineProperty2() {
|
|
6
5
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
7
|
-
|
|
8
6
|
_defineProperty2 = function () {
|
|
9
7
|
return data;
|
|
10
8
|
};
|
|
11
|
-
|
|
12
9
|
return data;
|
|
13
10
|
}
|
|
14
|
-
|
|
15
11
|
function _logger() {
|
|
16
12
|
const data = require("@teambit/logger");
|
|
17
|
-
|
|
18
13
|
_logger = function () {
|
|
19
14
|
return data;
|
|
20
15
|
};
|
|
21
|
-
|
|
22
16
|
return data;
|
|
23
17
|
}
|
|
24
|
-
|
|
25
18
|
function _typescript() {
|
|
26
19
|
const data = _interopRequireDefault(require("typescript"));
|
|
27
|
-
|
|
28
20
|
_typescript = function () {
|
|
29
21
|
return data;
|
|
30
22
|
};
|
|
31
|
-
|
|
32
23
|
return data;
|
|
33
24
|
}
|
|
34
|
-
|
|
35
25
|
function _chai() {
|
|
36
26
|
const data = require("chai");
|
|
37
|
-
|
|
38
27
|
_chai = function () {
|
|
39
28
|
return data;
|
|
40
29
|
};
|
|
41
|
-
|
|
42
30
|
return data;
|
|
43
31
|
}
|
|
44
|
-
|
|
45
32
|
function _path() {
|
|
46
33
|
const data = _interopRequireDefault(require("path"));
|
|
47
|
-
|
|
48
34
|
_path = function () {
|
|
49
35
|
return data;
|
|
50
36
|
};
|
|
51
|
-
|
|
52
37
|
return data;
|
|
53
38
|
}
|
|
54
|
-
|
|
55
39
|
function _typescript2() {
|
|
56
40
|
const data = require("./typescript.aspect");
|
|
57
|
-
|
|
58
41
|
_typescript2 = function () {
|
|
59
42
|
return data;
|
|
60
43
|
};
|
|
61
|
-
|
|
62
44
|
return data;
|
|
63
45
|
}
|
|
64
|
-
|
|
65
46
|
function _typescript3() {
|
|
66
47
|
const data = require("./typescript.compiler");
|
|
67
|
-
|
|
68
48
|
_typescript3 = function () {
|
|
69
49
|
return data;
|
|
70
50
|
};
|
|
71
|
-
|
|
72
51
|
return data;
|
|
73
52
|
}
|
|
74
|
-
|
|
75
53
|
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; }
|
|
76
|
-
|
|
77
54
|
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; }
|
|
78
|
-
|
|
79
55
|
const defaultOpts = {
|
|
80
56
|
tsconfig: {},
|
|
81
57
|
types: []
|
|
@@ -128,7 +104,6 @@ describe('TypescriptCompiler', () => {
|
|
|
128
104
|
});
|
|
129
105
|
});
|
|
130
106
|
});
|
|
131
|
-
|
|
132
107
|
function getTsCompiler(opts = defaultOpts) {
|
|
133
108
|
const finalOpts = Object.assign({}, defaultOpts, opts);
|
|
134
109
|
return new (_typescript3().TypescriptCompiler)(_typescript2().TypescriptAspect.id, new (_logger().Logger)('test'), finalOpts, _typescript().default);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["defaultOpts","tsconfig","types","describe","it","tsCompiler","getTsCompiler","expect","getDistPathBySrcPath","to","equal","path","join","isFileSupported","be","true","false","compileJsx","compileJs","opts","finalOpts","Object","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":"
|
|
1
|
+
{"version":3,"names":["defaultOpts","tsconfig","types","describe","it","tsCompiler","getTsCompiler","expect","getDistPathBySrcPath","to","equal","path","join","isFileSupported","be","true","false","compileJsx","compileJs","opts","finalOpts","Object","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;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;EA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AU,CAACQ,eAAe,CAAC,YAAY,CAAC,CAAC,CAACJ,EAAE,CAACK,EAAE,CAACE,KAAK;IAC9D,CAAC,CAAC;EACJ,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,SAASV,aAAa,CAACa,IAAsC,GAAGnB,WAAW,EAAE;EAC3E,MAAMoB,SAAS,GAAGC,MAAM,CAACC,MAAM,CAAC,CAAC,CAAC,EAAEtB,WAAW,EAAEmB,IAAI,CAAC;EACtD,OAAO,KAAII,iCAAkB,EAACC,+BAAgB,CAACC,EAAE,EAAE,KAAIC,gBAAM,EAAC,MAAM,CAAC,EAAEN,SAAS,EAAEO,qBAAE,CAAC;AACvF"}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.Logo = void 0;
|
|
9
|
-
|
|
10
8
|
function _react() {
|
|
11
9
|
const data = _interopRequireDefault(require("react"));
|
|
12
|
-
|
|
13
10
|
_react = function () {
|
|
14
11
|
return data;
|
|
15
12
|
};
|
|
16
|
-
|
|
17
13
|
return data;
|
|
18
14
|
}
|
|
19
|
-
|
|
20
15
|
const Logo = () => /*#__PURE__*/_react().default.createElement("div", {
|
|
21
16
|
style: {
|
|
22
17
|
height: '100%',
|
|
@@ -29,7 +24,6 @@ const Logo = () => /*#__PURE__*/_react().default.createElement("div", {
|
|
|
29
24
|
},
|
|
30
25
|
src: "https://static.bit.dev/brands/logo-typescript.svg"
|
|
31
26
|
}));
|
|
32
|
-
|
|
33
27
|
exports.Logo = Logo;
|
|
34
28
|
|
|
35
29
|
//# sourceMappingURL=typescript.composition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Logo","height","display","justifyContent","width"],"sources":["typescript.composition.tsx"],"sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/brands/logo-typescript.svg\" />\n </div>\n);\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["Logo","height","display","justifyContent","width"],"sources":["typescript.composition.tsx"],"sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/brands/logo-typescript.svg\" />\n </div>\n);\n"],"mappings":";;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,IAAI,GAAG,mBAClB;EAAK,KAAK,EAAE;IAAEC,MAAM,EAAE,MAAM;IAAEC,OAAO,EAAE,MAAM;IAAEC,cAAc,EAAE;EAAS;AAAE,gBACxE;EAAK,KAAK,EAAE;IAAEC,KAAK,EAAE;EAAG,CAAE;EAAC,GAAG,EAAC;AAAmD,EAAG,CAExF;AAAC"}
|