@teambit/typescript 0.0.1109 → 0.0.1111
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{preview-1689585411475.js → preview-1689823719636.js} +2 -2
- package/dist/sourceFileTransformers/empty-line-encoder.js +2 -1
- package/dist/sourceFileTransformers/empty-line-encoder.js.map +1 -1
- package/dist/sourceFileTransformers/transform.js +9 -2
- package/dist/sourceFileTransformers/transform.js.map +1 -1
- package/package-tar/teambit-typescript-0.0.1111.tgz +0 -0
- package/package.json +19 -19
- package/sourceFileTransformers/empty-line-encoder.ts +1 -1
- package/sourceFileTransformers/transform.ts +9 -2
- package/package-tar/teambit-typescript-0.0.1109.tgz +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.1111/dist/typescript.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.1111/dist/typescript.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
require("core-js/modules/es.regexp.exec.js");
|
|
5
|
+
require("core-js/modules/es.string.replace.js");
|
|
5
6
|
require("core-js/modules/es.string.trim.js");
|
|
6
7
|
Object.defineProperty(exports, "__esModule", {
|
|
7
8
|
value: true
|
|
@@ -53,7 +54,7 @@ function encodeEmptyLines(text, emptyLineMarker, newLine) {
|
|
|
53
54
|
function decodeEmptyLines(text, emptyLineMarker, newLine) {
|
|
54
55
|
const marker = toComment(emptyLineMarker || EmptyLineEncoder.defaultEmptyLineMarker);
|
|
55
56
|
const lines = text.split(/\r?\n/);
|
|
56
|
-
const uncommentedLines = lines.map(line => line ===
|
|
57
|
+
const uncommentedLines = lines.map(line => line.replace(marker, '').trim() === '' ? '' : line);
|
|
57
58
|
return uncommentedLines.join(newLine || EmptyLineEncoder.defaultNewLine);
|
|
58
59
|
}
|
|
59
60
|
function addLeadingEmptyLineMarker(node, emptyLineMarker) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["EmptyLineEncoder","constructor","emptyLineMarker","newLine","defaultEmptyLineMarker","defaultNewLine","encode","text","encodeEmptyLines","decode","decodeEmptyLines","addLeadingEmptyLineMarker","node","marker","toComment","lines","split","commentedLines","map","line","trim","join","uncommentedLines","ts","addSyntheticLeadingComment","SyntaxKind","MultiLineCommentTrivia"],"sources":["empty-line-encoder.ts"],"sourcesContent":["import ts from 'typescript';\n\nexport class EmptyLineEncoder {\n static readonly defaultEmptyLineMarker: string = '!--empty-line--!';\n static readonly defaultNewLine: string = '\\r\\n';\n constructor(emptyLineMarker?: string, newLine?: string) {\n this.emptyLineMarker = emptyLineMarker || EmptyLineEncoder.defaultEmptyLineMarker;\n this.newLine = newLine || EmptyLineEncoder.defaultNewLine;\n }\n emptyLineMarker: string;\n newLine: string;\n\n encode(text: string) {\n return encodeEmptyLines(text, this.emptyLineMarker, this.newLine);\n }\n decode(text: string) {\n return decodeEmptyLines(text, this.emptyLineMarker, this.newLine);\n }\n addLeadingEmptyLineMarker<T extends ts.Node>(node: T) {\n return addLeadingEmptyLineMarker(node, this.emptyLineMarker);\n }\n}\n\nexport function encodeEmptyLines(text: string, emptyLineMarker?: string, newLine?: string) {\n const marker = toComment(emptyLineMarker || EmptyLineEncoder.defaultEmptyLineMarker);\n\n const lines = text.split(/\\r?\\n/);\n\n const commentedLines = lines.map((line) => (line.trim() === '' ? marker : line));\n\n return commentedLines.join(newLine || EmptyLineEncoder.defaultNewLine);\n}\n\nexport function decodeEmptyLines(text: string, emptyLineMarker?: string, newLine?: string) {\n const marker = toComment(emptyLineMarker || EmptyLineEncoder.defaultEmptyLineMarker);\n\n const lines = text.split(/\\r?\\n/);\n\n const uncommentedLines = lines.map((line) => (line ===
|
|
1
|
+
{"version":3,"names":["EmptyLineEncoder","constructor","emptyLineMarker","newLine","defaultEmptyLineMarker","defaultNewLine","encode","text","encodeEmptyLines","decode","decodeEmptyLines","addLeadingEmptyLineMarker","node","marker","toComment","lines","split","commentedLines","map","line","trim","join","uncommentedLines","replace","ts","addSyntheticLeadingComment","SyntaxKind","MultiLineCommentTrivia"],"sources":["empty-line-encoder.ts"],"sourcesContent":["import ts from 'typescript';\n\nexport class EmptyLineEncoder {\n static readonly defaultEmptyLineMarker: string = '!--empty-line--!';\n static readonly defaultNewLine: string = '\\r\\n';\n constructor(emptyLineMarker?: string, newLine?: string) {\n this.emptyLineMarker = emptyLineMarker || EmptyLineEncoder.defaultEmptyLineMarker;\n this.newLine = newLine || EmptyLineEncoder.defaultNewLine;\n }\n emptyLineMarker: string;\n newLine: string;\n\n encode(text: string) {\n return encodeEmptyLines(text, this.emptyLineMarker, this.newLine);\n }\n decode(text: string) {\n return decodeEmptyLines(text, this.emptyLineMarker, this.newLine);\n }\n addLeadingEmptyLineMarker<T extends ts.Node>(node: T) {\n return addLeadingEmptyLineMarker(node, this.emptyLineMarker);\n }\n}\n\nexport function encodeEmptyLines(text: string, emptyLineMarker?: string, newLine?: string) {\n const marker = toComment(emptyLineMarker || EmptyLineEncoder.defaultEmptyLineMarker);\n\n const lines = text.split(/\\r?\\n/);\n\n const commentedLines = lines.map((line) => (line.trim() === '' ? marker : line));\n\n return commentedLines.join(newLine || EmptyLineEncoder.defaultNewLine);\n}\n\nexport function decodeEmptyLines(text: string, emptyLineMarker?: string, newLine?: string) {\n const marker = toComment(emptyLineMarker || EmptyLineEncoder.defaultEmptyLineMarker);\n\n const lines = text.split(/\\r?\\n/);\n\n const uncommentedLines = lines.map((line) => (line.replace(marker, '').trim() === '' ? '' : line));\n\n return uncommentedLines.join(newLine || EmptyLineEncoder.defaultNewLine);\n}\n\nexport function addLeadingEmptyLineMarker<T extends ts.Node>(node: T, emptyLineMarker?: string) {\n return ts.addSyntheticLeadingComment(\n node,\n ts.SyntaxKind.MultiLineCommentTrivia,\n emptyLineMarker || EmptyLineEncoder.defaultEmptyLineMarker,\n // hasTrailingNewLine\n true\n );\n}\n\nfunction toComment(marker: string) {\n return `/*${marker}*/`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,gBAAgB,CAAC;EAG5BC,WAAW,CAACC,eAAwB,EAAEC,OAAgB,EAAE;IAAA;IAAA;IACtD,IAAI,CAACD,eAAe,GAAGA,eAAe,IAAIF,gBAAgB,CAACI,sBAAsB;IACjF,IAAI,CAACD,OAAO,GAAGA,OAAO,IAAIH,gBAAgB,CAACK,cAAc;EAC3D;EAIAC,MAAM,CAACC,IAAY,EAAE;IACnB,OAAOC,gBAAgB,CAACD,IAAI,EAAE,IAAI,CAACL,eAAe,EAAE,IAAI,CAACC,OAAO,CAAC;EACnE;EACAM,MAAM,CAACF,IAAY,EAAE;IACnB,OAAOG,gBAAgB,CAACH,IAAI,EAAE,IAAI,CAACL,eAAe,EAAE,IAAI,CAACC,OAAO,CAAC;EACnE;EACAQ,yBAAyB,CAAoBC,IAAO,EAAE;IACpD,OAAOD,yBAAyB,CAACC,IAAI,EAAE,IAAI,CAACV,eAAe,CAAC;EAC9D;AACF;AAAC;AAAA,gCAnBYF,gBAAgB,4BACsB,kBAAkB;AAAA,gCADxDA,gBAAgB,oBAEc,MAAM;AAmB1C,SAASQ,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ourceFilePath, sourceFileContent, transforme
|
|
|
76
76
|
const emptyLineComment = `\\s*\\/\\*${encoder.emptyLineMarker}\\*\\/\\s*$`;
|
|
77
77
|
const regex = new RegExp(emptyLineComment, 'g');
|
|
78
78
|
transformedSourceFileStr = transformedSourceFileStr.replace(regex, '');
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
try {
|
|
80
|
+
const formattedSourceFileStr = await (formatter === null || formatter === void 0 ? void 0 : formatter.formatSnippet(transformedSourceFileStr));
|
|
81
|
+
return formattedSourceFileStr || transformedSourceFileStr;
|
|
82
|
+
} catch (_unused) {
|
|
83
|
+
// We can ignore if the formatter fails
|
|
84
|
+
// TODO: log the error
|
|
85
|
+
// ignore
|
|
86
|
+
}
|
|
87
|
+
return transformedSourceFileStr;
|
|
81
88
|
}
|
|
82
89
|
|
|
83
90
|
// function createMarkingTransformer<T extends ts.Node>(innerTransformer: ts.TransformerFactory<T>)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["transformSourceFile","sourceFilePath","sourceFileContent","transformers","formatter","updates","ext","path","extname","compatibleExts","includes","transformed","Object","entries","forEach","oldStr","newStr","oldStringRegex","RegExp","replace","encoder","EmptyLineEncoder","encode","sourceFile","ts","createSourceFile","ScriptTarget","Latest","ScriptKind","TSX","transformedResult","transform","transformedSourceFile","printer","createPrinter","removeComments","transformedSourceFileStr","printFile","decode","emptyLineComment","emptyLineMarker","regex","formattedSourceFileStr","formatSnippet"],"sources":["transform.ts"],"sourcesContent":["import { Formatter } from '@teambit/formatter';\nimport ts from 'typescript';\nimport * as path from 'path';\nimport { EmptyLineEncoder } from './empty-line-encoder';\n/**\n * Transforms a TypeScript source file using the provided transformer.\n *\n * @param sourceFilePath Path to the TypeScript source file.\n * @param sourceFileContent The content of the source file.\n * @param transformers The transformers to be applied on the source file.\n * @param formatter (Optional) An optional formatter to format the transformed code. If no formatter is provided, the function returns the transformed source file as a string without any formatting.\n * @returns A promise that resolves to the transformed source file as a string.\n */\nexport async function transformSourceFile(\n sourceFilePath: string,\n sourceFileContent: string,\n transformers: ts.TransformerFactory<ts.SourceFile>[],\n formatter?: Formatter,\n updates?: Record<string, string>\n): Promise<string> {\n const ext = path.extname(sourceFilePath);\n const compatibleExts = ['.ts', '.tsx', '.js', '.jsx'];\n if (!compatibleExts.includes(ext)) {\n if (!updates) return sourceFileContent;\n let transformed = sourceFileContent;\n Object.entries(updates).forEach(([oldStr, newStr]) => {\n const oldStringRegex = new RegExp(oldStr, 'g');\n transformed = transformed.replace(oldStringRegex, newStr);\n });\n return transformed;\n }\n\n const encoder = new EmptyLineEncoder();\n sourceFileContent = encoder.encode(sourceFileContent);\n\n const sourceFile = ts.createSourceFile(\n sourceFilePath,\n sourceFileContent,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TSX\n );\n\n const transformedResult: ts.TransformationResult<ts.SourceFile> = ts.transform<ts.SourceFile>(\n sourceFile,\n transformers\n );\n const transformedSourceFile: ts.SourceFile = transformedResult.transformed[0] as ts.SourceFile;\n\n // const _identifierTransformer = identifierTransformer(updates || {});\n\n // const transformedResultWithIdentifiers: ts.TransformationResult<ts.SourceFile> =\n // ts.transform<ts.SourceFile>(transformedSourceFile, []);\n // const transformedSourceFileWithIdentifiers: ts.SourceFile\n // = transformedResultWithIdentifiers.transformed[0] as ts.SourceFile;\n\n const printer: ts.Printer = ts.createPrinter({\n removeComments: false,\n });\n\n let transformedSourceFileStr = printer.printFile(transformedSourceFile);\n transformedSourceFileStr = encoder.decode(transformedSourceFileStr);\n // Remove trailing empty line markers\n const emptyLineComment = `\\\\s*\\\\/\\\\*${encoder.emptyLineMarker}\\\\*\\\\/\\\\s*$`;\n const regex = new RegExp(emptyLineComment, 'g');\n transformedSourceFileStr = transformedSourceFileStr.replace(regex, '');\n\n const formattedSourceFileStr = await formatter?.formatSnippet(transformedSourceFileStr);\n
|
|
1
|
+
{"version":3,"names":["transformSourceFile","sourceFilePath","sourceFileContent","transformers","formatter","updates","ext","path","extname","compatibleExts","includes","transformed","Object","entries","forEach","oldStr","newStr","oldStringRegex","RegExp","replace","encoder","EmptyLineEncoder","encode","sourceFile","ts","createSourceFile","ScriptTarget","Latest","ScriptKind","TSX","transformedResult","transform","transformedSourceFile","printer","createPrinter","removeComments","transformedSourceFileStr","printFile","decode","emptyLineComment","emptyLineMarker","regex","formattedSourceFileStr","formatSnippet"],"sources":["transform.ts"],"sourcesContent":["import { Formatter } from '@teambit/formatter';\nimport ts from 'typescript';\nimport * as path from 'path';\nimport { EmptyLineEncoder } from './empty-line-encoder';\n/**\n * Transforms a TypeScript source file using the provided transformer.\n *\n * @param sourceFilePath Path to the TypeScript source file.\n * @param sourceFileContent The content of the source file.\n * @param transformers The transformers to be applied on the source file.\n * @param formatter (Optional) An optional formatter to format the transformed code. If no formatter is provided, the function returns the transformed source file as a string without any formatting.\n * @returns A promise that resolves to the transformed source file as a string.\n */\nexport async function transformSourceFile(\n sourceFilePath: string,\n sourceFileContent: string,\n transformers: ts.TransformerFactory<ts.SourceFile>[],\n formatter?: Formatter,\n updates?: Record<string, string>\n): Promise<string> {\n const ext = path.extname(sourceFilePath);\n const compatibleExts = ['.ts', '.tsx', '.js', '.jsx'];\n if (!compatibleExts.includes(ext)) {\n if (!updates) return sourceFileContent;\n let transformed = sourceFileContent;\n Object.entries(updates).forEach(([oldStr, newStr]) => {\n const oldStringRegex = new RegExp(oldStr, 'g');\n transformed = transformed.replace(oldStringRegex, newStr);\n });\n return transformed;\n }\n\n const encoder = new EmptyLineEncoder();\n sourceFileContent = encoder.encode(sourceFileContent);\n\n const sourceFile = ts.createSourceFile(\n sourceFilePath,\n sourceFileContent,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TSX\n );\n\n const transformedResult: ts.TransformationResult<ts.SourceFile> = ts.transform<ts.SourceFile>(\n sourceFile,\n transformers\n );\n const transformedSourceFile: ts.SourceFile = transformedResult.transformed[0] as ts.SourceFile;\n\n // const _identifierTransformer = identifierTransformer(updates || {});\n\n // const transformedResultWithIdentifiers: ts.TransformationResult<ts.SourceFile> =\n // ts.transform<ts.SourceFile>(transformedSourceFile, []);\n // const transformedSourceFileWithIdentifiers: ts.SourceFile\n // = transformedResultWithIdentifiers.transformed[0] as ts.SourceFile;\n\n const printer: ts.Printer = ts.createPrinter({\n removeComments: false,\n });\n\n let transformedSourceFileStr = printer.printFile(transformedSourceFile);\n transformedSourceFileStr = encoder.decode(transformedSourceFileStr);\n // Remove trailing empty line markers\n const emptyLineComment = `\\\\s*\\\\/\\\\*${encoder.emptyLineMarker}\\\\*\\\\/\\\\s*$`;\n const regex = new RegExp(emptyLineComment, 'g');\n transformedSourceFileStr = transformedSourceFileStr.replace(regex, '');\n\n try {\n const formattedSourceFileStr = await formatter?.formatSnippet(transformedSourceFileStr);\n return formattedSourceFileStr || transformedSourceFileStr;\n } catch {\n // We can ignore if the formatter fails\n // TODO: log the error\n // ignore\n }\n return transformedSourceFileStr;\n}\n\n// function createMarkingTransformer<T extends ts.Node>(innerTransformer: ts.TransformerFactory<T>)\n// : ts.TransformerFactory<T> {\n// return context => {\n// const innerTransform = innerTransformer(context);\n\n// return node => {\n// const result = innerTransform(node);\n\n// // Add a custom property to the node to mark it as transformed\n// // Note: this relies on TypeScript's internal behavior and may not be stable across versions\n// (result as any).__transformed = true;\n\n// return result;\n// };\n// };\n// }\n\n// const defaultTransformer: ts.TransformerFactory<ts.SourceFile> = () => {\n// const visit: ts.Visitor = node => {\n// // If the node has been marked as transformed by a specific transformer, don't transform it\n// if ((node as any).__transformed) {\n// return node;\n// }\n\n// // Your transformation logic goes here...\n// };\n\n// return node => ts.visitNode(node, visit);\n// };\n"],"mappings":";;;;;;;;;;;;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAwD;AAAA;AACxD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeA,mB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BAAwB,GAAGH,OAAO,CAACI,SAAS,CAACL,qBAAqB,CAAC;EACvEI,wBAAwB,GAAGhB,OAAO,CAACkB,MAAM,CAACF,wBAAwB,CAAC;EACnE;EACA,MAAMG,gBAAgB,GAAI,aAAYnB,OAAO,CAACoB,eAAgB,aAAY;EAC1E,MAAMC,KAAK,GAAG,IAAIvB,MAAM,CAACqB,gBAAgB,EAAE,GAAG,CAAC;EAC/CH,wBAAwB,GAAGA,wBAAwB,CAACjB,OAAO,CAACsB,KAAK,EAAE,EAAE,CAAC;EAEtE,IAAI;IACF,MAAMC,sBAAsB,GAAG,OAAMtC,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEuC,aAAa,CAACP,wBAAwB,CAAC;IACvF,OAAOM,sBAAsB,IAAIN,wBAAwB;EAC3D,CAAC,CAAC,gBAAM;IACN;IACA;IACA;EAAA;EAEF,OAAOA,wBAAwB;AACjC;;AAEA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA"}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/typescript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1111",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/typescript/typescript",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.typescript",
|
|
8
8
|
"name": "typescript",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.1111"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"lodash": "4.17.21",
|
|
@@ -20,25 +20,25 @@
|
|
|
20
20
|
"core-js": "^3.0.0",
|
|
21
21
|
"@babel/runtime": "7.20.0",
|
|
22
22
|
"@teambit/harmony": "0.4.6",
|
|
23
|
-
"@teambit/compiler": "0.0.
|
|
23
|
+
"@teambit/compiler": "0.0.1111",
|
|
24
24
|
"@teambit/typescript.modules.ts-config-mutator": "0.0.76",
|
|
25
|
-
"@teambit/builder": "0.0.
|
|
26
|
-
"@teambit/isolator": "0.0.
|
|
27
|
-
"@teambit/component": "0.0.
|
|
28
|
-
"@teambit/dependency-resolver": "0.0.
|
|
29
|
-
"@teambit/formatter": "0.0.
|
|
25
|
+
"@teambit/builder": "0.0.1111",
|
|
26
|
+
"@teambit/isolator": "0.0.1111",
|
|
27
|
+
"@teambit/component": "0.0.1111",
|
|
28
|
+
"@teambit/dependency-resolver": "0.0.1111",
|
|
29
|
+
"@teambit/formatter": "0.0.662",
|
|
30
30
|
"@teambit/semantics.entities.semantic-schema": "0.0.53",
|
|
31
31
|
"@teambit/ts-server": "0.0.48",
|
|
32
|
-
"@teambit/aspect-loader": "0.0.
|
|
33
|
-
"@teambit/envs": "0.0.
|
|
34
|
-
"@teambit/logger": "0.0.
|
|
35
|
-
"@teambit/workspace": "0.0.
|
|
32
|
+
"@teambit/aspect-loader": "0.0.1111",
|
|
33
|
+
"@teambit/envs": "0.0.1111",
|
|
34
|
+
"@teambit/logger": "0.0.836",
|
|
35
|
+
"@teambit/workspace": "0.0.1111",
|
|
36
36
|
"@teambit/bit-error": "0.0.402",
|
|
37
|
-
"@teambit/schema": "0.0.
|
|
38
|
-
"@teambit/scope": "0.0.
|
|
39
|
-
"@teambit/cli": "0.0.
|
|
40
|
-
"@teambit/pkg": "0.0.
|
|
41
|
-
"@teambit/watcher": "0.0.
|
|
37
|
+
"@teambit/schema": "0.0.1111",
|
|
38
|
+
"@teambit/scope": "0.0.1111",
|
|
39
|
+
"@teambit/cli": "0.0.743",
|
|
40
|
+
"@teambit/pkg": "0.0.1111",
|
|
41
|
+
"@teambit/watcher": "0.0.123"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/lodash": "4.14.165",
|
|
@@ -51,10 +51,10 @@
|
|
|
51
51
|
"@types/react-dom": "^17.0.5",
|
|
52
52
|
"@types/jest": "^26.0.0",
|
|
53
53
|
"@types/testing-library__jest-dom": "5.9.5",
|
|
54
|
-
"@teambit/typescript.aspect-docs.typescript": "0.0.
|
|
54
|
+
"@teambit/typescript.aspect-docs.typescript": "0.0.154"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@teambit/legacy": "1.0.
|
|
57
|
+
"@teambit/legacy": "1.0.523",
|
|
58
58
|
"react": "^16.8.0 || ^17.0.0",
|
|
59
59
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
60
60
|
},
|
|
@@ -36,7 +36,7 @@ export function decodeEmptyLines(text: string, emptyLineMarker?: string, newLine
|
|
|
36
36
|
|
|
37
37
|
const lines = text.split(/\r?\n/);
|
|
38
38
|
|
|
39
|
-
const uncommentedLines = lines.map((line) => (line ===
|
|
39
|
+
const uncommentedLines = lines.map((line) => (line.replace(marker, '').trim() === '' ? '' : line));
|
|
40
40
|
|
|
41
41
|
return uncommentedLines.join(newLine || EmptyLineEncoder.defaultNewLine);
|
|
42
42
|
}
|
|
@@ -65,8 +65,15 @@ export async function transformSourceFile(
|
|
|
65
65
|
const regex = new RegExp(emptyLineComment, 'g');
|
|
66
66
|
transformedSourceFileStr = transformedSourceFileStr.replace(regex, '');
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
try {
|
|
69
|
+
const formattedSourceFileStr = await formatter?.formatSnippet(transformedSourceFileStr);
|
|
70
|
+
return formattedSourceFileStr || transformedSourceFileStr;
|
|
71
|
+
} catch {
|
|
72
|
+
// We can ignore if the formatter fails
|
|
73
|
+
// TODO: log the error
|
|
74
|
+
// ignore
|
|
75
|
+
}
|
|
76
|
+
return transformedSourceFileStr;
|
|
70
77
|
}
|
|
71
78
|
|
|
72
79
|
// function createMarkingTransformer<T extends ts.Node>(innerTransformer: ts.TransformerFactory<T>)
|
|
Binary file
|