@teambit/babel 0.0.699 → 0.0.702
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/babel.compiler.d.ts +1 -0
- package/dist/babel.compiler.js +4 -0
- package/dist/babel.compiler.js.map +1 -1
- package/package-tar/teambit-babel-0.0.702.tgz +0 -0
- package/package.json +9 -9
- package/{preview-1649042627943.js → preview-1649215446132.js} +2 -2
- package/tsconfig.json +4 -3
- package/package-tar/teambit-babel-0.0.699.tgz +0 -0
package/dist/babel.compiler.d.ts
CHANGED
package/dist/babel.compiler.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["babel.compiler.ts"],"names":["BabelCompiler","constructor","id","logger","compiler","options","babelModule","babel","distDir","distGlobPatterns","shouldCopyNonSupportedFiles","artifactName","supportedFilesGlobPatterns","version","transpileFile","fileContent","supportedExtensions","fileExtension","path","extname","filePath","includes","endsWith","transformOptions","babelTransformOptions","context","rootDir","componentDir","outputFiles","build","capsules","capsuleNetwork","seedersCapsules","componentsResults","longProcessLogger","createLongProcessLogger","length","capsule","currentComponentResult","errors","component","logProgress","toString","buildOneCapsule","push","artifacts","getArtifactDefinition","createTask","name","componentResult","startTime","Date","now","sourceFiles","filesystem","files","map","file","relative","fs","ensureDir","join","Promise","all","isFileSupported","absoluteFilePath","sourceFileName","basename","filename","result","debug","distPath","replaceFileExtToJs","distPathMap","outputFile","outputText","err","endTime","generatedBy","globPatterns","getDistPathBySrcPath","srcPath","fileWithJSExtIfNeeded","displayConfig","JSON","stringify"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AA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AAxB,CAAP;AACD;AAED;AACF;AACA;;;AACElB,EAAAA,eAAe,CAAC5C,QAAD,EAA4B;AACzC,QAAI,KAAKR,0BAAT,EAAqC;AACnC,aAAO,2CAAgBQ,QAAhB,KAA6B,CAAC,CAAC,2BAAWA,QAAX,EAAqB,KAAKR,0BAA1B,EAAsDwB,MAA5F;AACD;;AACD,WAAO,2CAAgBhB,QAAhB,CAAP;AACD;;AAED+D,EAAAA,aAAa,GAAG;AACd,WAAOC,IAAI,CAACC,SAAL,CAAe,KAAKhF,OAAL,CAAamB,qBAAb,IAAsC,EAArD,EAAyD,IAAzD,EAA+D,CAA/D,CAAP;AACD;;AAEOgD,EAAAA,kBAAkB,CAACpD,QAAD,EAA2B;AACnD,QAAI,CAAC,KAAK4C,eAAL,CAAqB5C,QAArB,CAAL,EAAqC,OAAOA,QAAP;AACrC,WAAO,8CAAmBA,QAAnB,CAAP;AACD;;AAtJ4C","sourcesContent":["import * as babel from '@babel/core';\nimport multimatch from 'multimatch';\nimport { flatten } from 'lodash';\nimport mapSeries from 'p-map-series';\nimport fs from 'fs-extra';\nimport { BuildContext, BuiltTaskResult, ComponentResult } from '@teambit/builder';\nimport { Compiler, CompilerMain, TranspileFileParams, TranspileFileOutput } from '@teambit/compiler';\nimport { Capsule } from '@teambit/isolator';\nimport { Logger } from '@teambit/logger';\nimport path from 'path';\nimport {\n isFileSupported,\n transpileFileContent,\n transpileFilePathAsync,\n replaceFileExtToJs,\n TranspileContext,\n} from '@teambit/compilation.modules.babel-compiler';\nimport { BabelCompilerOptions } from './compiler-options';\n\nexport class BabelCompiler implements Compiler {\n distDir: string;\n distGlobPatterns: string[];\n shouldCopyNonSupportedFiles: boolean;\n artifactName: string;\n supportedFilesGlobPatterns: string[] | null;\n constructor(\n readonly id: string,\n private logger: Logger,\n private compiler: CompilerMain,\n private options: BabelCompilerOptions,\n private babelModule = babel\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.supportedFilesGlobPatterns = options.supportedFilesGlobPatterns\n ? flatten(options.supportedFilesGlobPatterns)\n : null;\n }\n\n displayName = 'Babel';\n deleteDistDir = false;\n\n version() {\n return this.babelModule.version;\n }\n\n /**\n * compile one file on the workspace\n */\n transpileFile(fileContent: string, options: TranspileFileParams): TranspileFileOutput {\n const supportedExtensions = ['.ts', '.tsx', '.js', '.jsx'];\n const fileExtension = path.extname(options.filePath);\n if (!supportedExtensions.includes(fileExtension) || options.filePath.endsWith('.d.ts')) {\n return null; // file is not supported\n }\n const transformOptions = this.options.babelTransformOptions || {};\n const context: TranspileContext = {\n filePath: options.filePath,\n rootDir: options.componentDir,\n };\n const outputFiles = transpileFileContent(fileContent, context, transformOptions, this.babelModule);\n return outputFiles;\n }\n\n /**\n * compile multiple components on the capsules\n */\n async build(context: BuildContext): Promise<BuiltTaskResult> {\n const capsules = context.capsuleNetwork.seedersCapsules;\n const componentsResults: ComponentResult[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('compile babel components', capsules.length);\n await mapSeries(capsules, async (capsule) => {\n const currentComponentResult: ComponentResult = {\n errors: [],\n component: capsule.component,\n };\n longProcessLogger.logProgress(capsule.component.id.toString());\n await this.buildOneCapsule(capsule, currentComponentResult);\n componentsResults.push({ ...currentComponentResult });\n });\n\n return {\n artifacts: this.getArtifactDefinition(),\n componentsResults,\n };\n }\n\n createTask(name = 'BabelCompiler') {\n return this.compiler.createTask(name, this);\n }\n\n private async buildOneCapsule(capsule: Capsule, componentResult: ComponentResult) {\n componentResult.startTime = Date.now();\n const sourceFiles = capsule.component.filesystem.files.map((file) => file.relative);\n await fs.ensureDir(path.join(capsule.path, this.distDir));\n await Promise.all(\n sourceFiles.map(async (filePath) => {\n if (this.isFileSupported(filePath)) {\n const absoluteFilePath = path.join(capsule.path, filePath);\n this.options.babelTransformOptions ||= {};\n this.options.babelTransformOptions.sourceFileName = path.basename(filePath);\n this.options.babelTransformOptions.filename = path.basename(filePath);\n try {\n const result = await transpileFilePathAsync(\n absoluteFilePath,\n this.options.babelTransformOptions || {},\n this.babelModule\n );\n if (!result || !result.length) {\n this.logger.debug(\n `getting an empty response from Babel for the file ${filePath}. it might be configured to be ignored`\n );\n return;\n }\n // Make sure to get only the relative path of the dist because we want to add the dist dir.\n // If we use the result outputPath we will get an absolute path here\n const distPath = this.replaceFileExtToJs(filePath);\n const distPathMap = `${distPath}.map`;\n await fs.outputFile(path.join(capsule.path, this.distDir, distPath), result[0].outputText);\n if (result.length > 1) {\n await fs.outputFile(path.join(capsule.path, this.distDir, distPathMap), result[1].outputText);\n }\n } catch (err: any) {\n componentResult.errors?.push(err);\n }\n }\n })\n );\n componentResult.endTime = Date.now();\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 babel is able to compile the given path\n */\n isFileSupported(filePath: string): boolean {\n if (this.supportedFilesGlobPatterns) {\n return isFileSupported(filePath) && !!multimatch(filePath, this.supportedFilesGlobPatterns).length;\n }\n return isFileSupported(filePath);\n }\n\n displayConfig() {\n return JSON.stringify(this.options.babelTransformOptions || {}, null, 2);\n }\n\n private replaceFileExtToJs(filePath: string): string {\n if (!this.isFileSupported(filePath)) return filePath;\n return replaceFileExtToJs(filePath);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["babel.compiler.ts"],"names":["BabelCompiler","constructor","id","logger","compiler","options","babelModule","babel","distDir","distGlobPatterns","shouldCopyNonSupportedFiles","artifactName","supportedFilesGlobPatterns","version","getDistDir","transpileFile","fileContent","supportedExtensions","fileExtension","path","extname","filePath","includes","endsWith","transformOptions","babelTransformOptions","context","rootDir","componentDir","outputFiles","build","capsules","capsuleNetwork","seedersCapsules","componentsResults","longProcessLogger","createLongProcessLogger","length","capsule","currentComponentResult","errors","component","logProgress","toString","buildOneCapsule","push","artifacts","getArtifactDefinition","createTask","name","componentResult","startTime","Date","now","sourceFiles","filesystem","files","map","file","relative","fs","ensureDir","join","Promise","all","isFileSupported","absoluteFilePath","sourceFileName","basename","filename","result","debug","distPath","replaceFileExtToJs","distPathMap","outputFile","outputText","err","endTime","generatedBy","globPatterns","getDistPathBySrcPath","srcPath","fileWithJSExtIfNeeded","displayConfig","JSON","stringify"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAKA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;;;;;AASO,MAAMA,aAAN,CAAwC;AAM7CC,EAAAA,WAAW,CACAC,EADA,EAEDC,MAFC,EAGDC,QAHC,EAIDC,OAJC,EAKDC,WAAW,GAAGC,KAAK,EALlB,EAMT;AAAA,SALSL,EAKT,GALSA,EAKT;AAAA,SAJQC,MAIR,GAJQA,MAIR;AAAA,SAHQC,QAGR,GAHQA,QAGR;AAAA,SAFQC,OAER,GAFQA,OAER;AAAA,SADQC,WACR,GADQA,WACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yDAWY,OAXZ;AAAA,2DAYc,KAZd;AACA,SAAKE,OAAL,GAAeH,OAAO,CAACG,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ACpD,QAAD,EAA2B;AACnD,QAAI,CAAC,KAAK4C,eAAL,CAAqB5C,QAArB,CAAL,EAAqC,OAAOA,QAAP;AACrC,WAAO,8CAAmBA,QAAnB,CAAP;AACD;;AA1J4C","sourcesContent":["import * as babel from '@babel/core';\nimport multimatch from 'multimatch';\nimport { flatten } from 'lodash';\nimport mapSeries from 'p-map-series';\nimport fs from 'fs-extra';\nimport { BuildContext, BuiltTaskResult, ComponentResult } from '@teambit/builder';\nimport { Compiler, CompilerMain, TranspileFileParams, TranspileFileOutput } from '@teambit/compiler';\nimport { Capsule } from '@teambit/isolator';\nimport { Logger } from '@teambit/logger';\nimport path from 'path';\nimport {\n isFileSupported,\n transpileFileContent,\n transpileFilePathAsync,\n replaceFileExtToJs,\n TranspileContext,\n} from '@teambit/compilation.modules.babel-compiler';\nimport { BabelCompilerOptions } from './compiler-options';\n\nexport class BabelCompiler implements Compiler {\n distDir: string;\n distGlobPatterns: string[];\n shouldCopyNonSupportedFiles: boolean;\n artifactName: string;\n supportedFilesGlobPatterns: string[] | null;\n constructor(\n readonly id: string,\n private logger: Logger,\n private compiler: CompilerMain,\n private options: BabelCompilerOptions,\n private babelModule = babel\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.supportedFilesGlobPatterns = options.supportedFilesGlobPatterns\n ? flatten(options.supportedFilesGlobPatterns)\n : null;\n }\n\n displayName = 'Babel';\n deleteDistDir = false;\n\n version() {\n return this.babelModule.version;\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 const supportedExtensions = ['.ts', '.tsx', '.js', '.jsx'];\n const fileExtension = path.extname(options.filePath);\n if (!supportedExtensions.includes(fileExtension) || options.filePath.endsWith('.d.ts')) {\n return null; // file is not supported\n }\n const transformOptions = this.options.babelTransformOptions || {};\n const context: TranspileContext = {\n filePath: options.filePath,\n rootDir: options.componentDir,\n };\n const outputFiles = transpileFileContent(fileContent, context, transformOptions, this.babelModule);\n return outputFiles;\n }\n\n /**\n * compile multiple components on the capsules\n */\n async build(context: BuildContext): Promise<BuiltTaskResult> {\n const capsules = context.capsuleNetwork.seedersCapsules;\n const componentsResults: ComponentResult[] = [];\n const longProcessLogger = this.logger.createLongProcessLogger('compile babel components', capsules.length);\n await mapSeries(capsules, async (capsule) => {\n const currentComponentResult: ComponentResult = {\n errors: [],\n component: capsule.component,\n };\n longProcessLogger.logProgress(capsule.component.id.toString());\n await this.buildOneCapsule(capsule, currentComponentResult);\n componentsResults.push({ ...currentComponentResult });\n });\n\n return {\n artifacts: this.getArtifactDefinition(),\n componentsResults,\n };\n }\n\n createTask(name = 'BabelCompiler') {\n return this.compiler.createTask(name, this);\n }\n\n private async buildOneCapsule(capsule: Capsule, componentResult: ComponentResult) {\n componentResult.startTime = Date.now();\n const sourceFiles = capsule.component.filesystem.files.map((file) => file.relative);\n await fs.ensureDir(path.join(capsule.path, this.distDir));\n await Promise.all(\n sourceFiles.map(async (filePath) => {\n if (this.isFileSupported(filePath)) {\n const absoluteFilePath = path.join(capsule.path, filePath);\n this.options.babelTransformOptions ||= {};\n this.options.babelTransformOptions.sourceFileName = path.basename(filePath);\n this.options.babelTransformOptions.filename = path.basename(filePath);\n try {\n const result = await transpileFilePathAsync(\n absoluteFilePath,\n this.options.babelTransformOptions || {},\n this.babelModule\n );\n if (!result || !result.length) {\n this.logger.debug(\n `getting an empty response from Babel for the file ${filePath}. it might be configured to be ignored`\n );\n return;\n }\n // Make sure to get only the relative path of the dist because we want to add the dist dir.\n // If we use the result outputPath we will get an absolute path here\n const distPath = this.replaceFileExtToJs(filePath);\n const distPathMap = `${distPath}.map`;\n await fs.outputFile(path.join(capsule.path, this.distDir, distPath), result[0].outputText);\n if (result.length > 1) {\n await fs.outputFile(path.join(capsule.path, this.distDir, distPathMap), result[1].outputText);\n }\n } catch (err: any) {\n componentResult.errors?.push(err);\n }\n }\n })\n );\n componentResult.endTime = Date.now();\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 babel is able to compile the given path\n */\n isFileSupported(filePath: string): boolean {\n if (this.supportedFilesGlobPatterns) {\n return isFileSupported(filePath) && !!multimatch(filePath, this.supportedFilesGlobPatterns).length;\n }\n return isFileSupported(filePath);\n }\n\n displayConfig() {\n return JSON.stringify(this.options.babelTransformOptions || {}, null, 2);\n }\n\n private replaceFileExtToJs(filePath: string): string {\n if (!this.isFileSupported(filePath)) return filePath;\n return replaceFileExtToJs(filePath);\n }\n}\n"]}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/babel",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.702",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/compilation/babel",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.compilation",
|
|
8
8
|
"name": "babel",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.702"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@teambit/harmony": "0.2.11",
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
"p-map-series": "2.1.0",
|
|
18
18
|
"@babel/runtime": "7.12.18",
|
|
19
19
|
"core-js": "^3.0.0",
|
|
20
|
-
"@teambit/builder": "0.0.
|
|
20
|
+
"@teambit/builder": "0.0.702",
|
|
21
21
|
"@teambit/compilation.modules.babel-compiler": "0.0.124",
|
|
22
|
-
"@teambit/compiler": "0.0.
|
|
23
|
-
"@teambit/isolator": "0.0.
|
|
24
|
-
"@teambit/logger": "0.0.
|
|
25
|
-
"@teambit/cli": "0.0.
|
|
22
|
+
"@teambit/compiler": "0.0.702",
|
|
23
|
+
"@teambit/isolator": "0.0.702",
|
|
24
|
+
"@teambit/logger": "0.0.558",
|
|
25
|
+
"@teambit/cli": "0.0.466"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/fs-extra": "9.0.7",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@teambit/compilation.aspect-docs.babel": "0.0.136"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@teambit/legacy": "1.0.
|
|
39
|
+
"@teambit/legacy": "1.0.244",
|
|
40
40
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
41
41
|
"react": "^16.8.0 || ^17.0.0"
|
|
42
42
|
},
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"react": "-"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"@teambit/legacy": "1.0.
|
|
67
|
+
"@teambit/legacy": "1.0.244",
|
|
68
68
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
69
69
|
"react": "^16.8.0 || ^17.0.0"
|
|
70
70
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compilation_babel@0.0.
|
|
2
|
-
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compilation_babel@0.0.
|
|
1
|
+
export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compilation_babel@0.0.702/dist/babel.composition.js')]
|
|
2
|
+
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compilation_babel@0.0.702/dist/babel.docs.mdx')]
|
package/tsconfig.json
CHANGED
|
@@ -10,22 +10,23 @@
|
|
|
10
10
|
"target": "es2015",
|
|
11
11
|
"module": "commonjs",
|
|
12
12
|
"jsx": "react",
|
|
13
|
+
"allowJs": true,
|
|
14
|
+
"composite": true,
|
|
13
15
|
"declaration": true,
|
|
14
16
|
"sourceMap": true,
|
|
15
17
|
"skipLibCheck": true,
|
|
18
|
+
"outDir": "dist",
|
|
16
19
|
"moduleResolution": "node",
|
|
17
20
|
"esModuleInterop": true,
|
|
21
|
+
"rootDir": ".",
|
|
18
22
|
"resolveJsonModule": true,
|
|
19
|
-
"composite": true,
|
|
20
23
|
"emitDeclarationOnly": true,
|
|
21
|
-
"outDir": "dist",
|
|
22
24
|
"experimentalDecorators": true,
|
|
23
25
|
"emitDecoratorMetadata": true,
|
|
24
26
|
"allowSyntheticDefaultImports": true,
|
|
25
27
|
"strictPropertyInitialization": false,
|
|
26
28
|
"strict": true,
|
|
27
29
|
"noImplicitAny": false,
|
|
28
|
-
"rootDir": ".",
|
|
29
30
|
"preserveConstEnums": true
|
|
30
31
|
},
|
|
31
32
|
"exclude": [
|
|
Binary file
|