@teambit/babel 0.0.881 → 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.
@@ -4,21 +4,16 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.BabelAspect = void 0;
7
-
8
7
  function _harmony() {
9
8
  const data = require("@teambit/harmony");
10
-
11
9
  _harmony = function () {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  const BabelAspect = _harmony().Aspect.create({
19
15
  id: 'teambit.compilation/babel'
20
16
  });
21
-
22
17
  exports.BabelAspect = BabelAspect;
23
18
 
24
19
  //# sourceMappingURL=babel.aspect.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["BabelAspect","Aspect","create","id"],"sources":["babel.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const BabelAspect = Aspect.create({\n id: 'teambit.compilation/babel',\n});\n"],"mappings":";;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,WAAW,GAAGC,iBAAA,CAAOC,MAAP,CAAc;EACvCC,EAAE,EAAE;AADmC,CAAd,CAApB"}
1
+ {"version":3,"names":["BabelAspect","Aspect","create","id"],"sources":["babel.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const BabelAspect = Aspect.create({\n id: 'teambit.compilation/babel',\n});\n"],"mappings":";;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEO,MAAMA,WAAW,GAAGC,iBAAM,CAACC,MAAM,CAAC;EACvCC,EAAE,EAAE;AACN,CAAC,CAAC;AAAC"}
@@ -1,104 +1,72 @@
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
  Object.defineProperty(exports, "__esModule", {
10
7
  value: true
11
8
  });
12
9
  exports.BabelCompiler = void 0;
13
-
14
10
  function _defineProperty2() {
15
11
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
-
17
12
  _defineProperty2 = function () {
18
13
  return data;
19
14
  };
20
-
21
15
  return data;
22
16
  }
23
-
24
17
  function babel() {
25
18
  const data = _interopRequireWildcard(require("@babel/core"));
26
-
27
19
  babel = function () {
28
20
  return data;
29
21
  };
30
-
31
22
  return data;
32
23
  }
33
-
34
24
  function _multimatch() {
35
25
  const data = _interopRequireDefault(require("multimatch"));
36
-
37
26
  _multimatch = function () {
38
27
  return data;
39
28
  };
40
-
41
29
  return data;
42
30
  }
43
-
44
31
  function _lodash() {
45
32
  const data = require("lodash");
46
-
47
33
  _lodash = function () {
48
34
  return data;
49
35
  };
50
-
51
36
  return data;
52
37
  }
53
-
54
38
  function _pMapSeries() {
55
39
  const data = _interopRequireDefault(require("p-map-series"));
56
-
57
40
  _pMapSeries = function () {
58
41
  return data;
59
42
  };
60
-
61
43
  return data;
62
44
  }
63
-
64
45
  function _fsExtra() {
65
46
  const data = _interopRequireDefault(require("fs-extra"));
66
-
67
47
  _fsExtra = function () {
68
48
  return data;
69
49
  };
70
-
71
50
  return data;
72
51
  }
73
-
74
52
  function _path() {
75
53
  const data = _interopRequireDefault(require("path"));
76
-
77
54
  _path = function () {
78
55
  return data;
79
56
  };
80
-
81
57
  return data;
82
58
  }
83
-
84
59
  function _compilationModules() {
85
60
  const data = require("@teambit/compilation.modules.babel-compiler");
86
-
87
61
  _compilationModules = function () {
88
62
  return data;
89
63
  };
90
-
91
64
  return data;
92
65
  }
93
-
94
66
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
95
-
96
67
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
97
-
98
68
  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; }
99
-
100
69
  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; }
101
-
102
70
  class BabelCompiler {
103
71
  constructor(id, logger, compiler, options, babelModule = babel()) {
104
72
  this.id = id;
@@ -119,24 +87,19 @@ class BabelCompiler {
119
87
  this.artifactName = options.artifactName || 'dist';
120
88
  this.supportedFilesGlobPatterns = options.supportedFilesGlobPatterns ? (0, _lodash().flatten)(options.supportedFilesGlobPatterns) : null;
121
89
  }
122
-
123
90
  version() {
124
91
  return this.babelModule.version;
125
92
  }
126
-
127
93
  getDistDir() {
128
94
  return this.distDir;
129
95
  }
96
+
130
97
  /**
131
98
  * compile one file on the workspace
132
99
  */
133
-
134
-
135
100
  transpileFile(fileContent, options) {
136
101
  const supportedExtensions = ['.ts', '.tsx', '.js', '.jsx'];
137
-
138
102
  const fileExtension = _path().default.extname(options.filePath);
139
-
140
103
  if (!supportedExtensions.includes(fileExtension) || options.filePath.endsWith('.d.ts')) {
141
104
  return null; // file is not supported
142
105
  }
@@ -149,11 +112,10 @@ class BabelCompiler {
149
112
  const outputFiles = (0, _compilationModules().transpileFileContent)(fileContent, context, transformOptions, this.babelModule);
150
113
  return outputFiles;
151
114
  }
115
+
152
116
  /**
153
117
  * compile multiple components on the capsules
154
118
  */
155
-
156
-
157
119
  async build(context) {
158
120
  const capsules = context.capsuleNetwork.seedersCapsules;
159
121
  const componentsResults = [];
@@ -172,11 +134,9 @@ class BabelCompiler {
172
134
  componentsResults
173
135
  };
174
136
  }
175
-
176
137
  createTask(name = 'BabelCompiler') {
177
138
  return this.compiler.createTask(name, this);
178
139
  }
179
-
180
140
  async buildOneCapsule(capsule, componentResult) {
181
141
  componentResult.startTime = Date.now();
182
142
  const sourceFiles = capsule.component.filesystem.files.map(file => file.relative);
@@ -184,40 +144,32 @@ class BabelCompiler {
184
144
  await Promise.all(sourceFiles.map(async filePath => {
185
145
  if (this.isFileSupported(filePath)) {
186
146
  var _this$options;
187
-
188
147
  const absoluteFilePath = _path().default.join(capsule.path, filePath);
189
-
190
148
  (_this$options = this.options).babelTransformOptions || (_this$options.babelTransformOptions = {});
191
149
  this.options.babelTransformOptions.sourceFileName = _path().default.basename(filePath);
192
150
  this.options.babelTransformOptions.filename = _path().default.basename(filePath);
193
-
194
151
  try {
195
152
  const result = await (0, _compilationModules().transpileFilePathAsync)(absoluteFilePath, this.options.babelTransformOptions || {}, this.babelModule);
196
-
197
153
  if (!result || !result.length) {
198
154
  this.logger.debug(`getting an empty response from Babel for the file ${filePath}. it might be configured to be ignored`);
199
155
  return;
200
- } // Make sure to get only the relative path of the dist because we want to add the dist dir.
156
+ }
157
+ // Make sure to get only the relative path of the dist because we want to add the dist dir.
201
158
  // If we use the result outputPath we will get an absolute path here
202
-
203
-
204
159
  const distPath = this.replaceFileExtToJs(filePath);
205
160
  const distPathMap = `${distPath}.map`;
206
161
  await _fsExtra().default.outputFile(_path().default.join(capsule.path, this.distDir, distPath), result[0].outputText);
207
-
208
162
  if (result.length > 1) {
209
163
  await _fsExtra().default.outputFile(_path().default.join(capsule.path, this.distDir, distPathMap), result[1].outputText);
210
164
  }
211
165
  } catch (err) {
212
166
  var _componentResult$erro;
213
-
214
167
  (_componentResult$erro = componentResult.errors) === null || _componentResult$erro === void 0 ? void 0 : _componentResult$erro.push(err);
215
168
  }
216
169
  }
217
170
  }));
218
171
  componentResult.endTime = Date.now();
219
172
  }
220
-
221
173
  getArtifactDefinition() {
222
174
  return [{
223
175
  generatedBy: this.id,
@@ -225,39 +177,32 @@ class BabelCompiler {
225
177
  globPatterns: this.distGlobPatterns
226
178
  }];
227
179
  }
180
+
228
181
  /**
229
182
  * given a source file, return its parallel in the dists. e.g. index.ts => dist/index.js
230
183
  */
231
-
232
-
233
184
  getDistPathBySrcPath(srcPath) {
234
185
  const fileWithJSExtIfNeeded = this.replaceFileExtToJs(srcPath);
235
186
  return _path().default.join(this.distDir, fileWithJSExtIfNeeded);
236
187
  }
188
+
237
189
  /**
238
190
  * whether babel is able to compile the given path
239
191
  */
240
-
241
-
242
192
  isFileSupported(filePath) {
243
193
  if (this.supportedFilesGlobPatterns) {
244
194
  return (0, _compilationModules().isFileSupported)(filePath) && !!(0, _multimatch().default)(filePath, this.supportedFilesGlobPatterns).length;
245
195
  }
246
-
247
196
  return (0, _compilationModules().isFileSupported)(filePath);
248
197
  }
249
-
250
198
  displayConfig() {
251
199
  return JSON.stringify(this.options.babelTransformOptions || {}, null, 2);
252
200
  }
253
-
254
201
  replaceFileExtToJs(filePath) {
255
202
  if (!this.isFileSupported(filePath)) return filePath;
256
203
  return (0, _compilationModules().replaceFileExtToJs)(filePath);
257
204
  }
258
-
259
205
  }
260
-
261
206
  exports.BabelCompiler = BabelCompiler;
262
207
 
263
208
  //# sourceMappingURL=babel.compiler.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["BabelCompiler","constructor","id","logger","compiler","options","babelModule","babel","distDir","distGlobPatterns","shouldCopyNonSupportedFiles","artifactName","supportedFilesGlobPatterns","flatten","version","getDistDir","transpileFile","fileContent","supportedExtensions","fileExtension","path","extname","filePath","includes","endsWith","transformOptions","babelTransformOptions","context","rootDir","componentDir","outputFiles","transpileFileContent","build","capsules","capsuleNetwork","seedersCapsules","componentsResults","longProcessLogger","createLongProcessLogger","length","mapSeries","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","transpileFilePathAsync","debug","distPath","replaceFileExtToJs","distPathMap","outputFile","outputText","err","endTime","generatedBy","globPatterns","getDistPathBySrcPath","srcPath","fileWithJSExtIfNeeded","multimatch","displayConfig","JSON","stringify"],"sources":["babel.compiler.ts"],"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)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B,GAAG;IACtB,OAAO,CACL;MACEiC,WAAW,EAAE,KAAKjF,EADpB;MAEEkD,IAAI,EAAE,KAAKzC,YAFb;MAGEyE,YAAY,EAAE,KAAK3E;IAHrB,CADK,CAAP;EAOD;EAED;AACF;AACA;;;EACE4E,oBAAoB,CAACC,OAAD,EAAkB;IACpC,MAAMC,qBAAqB,GAAG,KAAKV,kBAAL,CAAwBS,OAAxB,CAA9B;IACA,OAAOlE,eAAA,CAAK6C,IAAL,CAAU,KAAKzD,OAAf,EAAwB+E,qBAAxB,CAAP;EACD;EAED;AACF;AACA;;;EACEnB,eAAe,CAAC9C,QAAD,EAA4B;IACzC,IAAI,KAAKV,0BAAT,EAAqC;MACnC,OAAO,IAAAwD,qCAAA,EAAgB9C,QAAhB,KAA6B,CAAC,CAAC,IAAAkE,qBAAA,EAAWlE,QAAX,EAAqB,KAAKV,0BAA1B,EAAsD2B,MAA5F;IACD;;IACD,OAAO,IAAA6B,qCAAA,EAAgB9C,QAAhB,CAAP;EACD;;EAEDmE,aAAa,GAAG;IACd,OAAOC,IAAI,CAACC,SAAL,CAAe,KAAKtF,OAAL,CAAaqB,qBAAb,IAAsC,EAArD,EAAyD,IAAzD,EAA+D,CAA/D,CAAP;EACD;;EAEOmD,kBAAkB,CAACvD,QAAD,EAA2B;IACnD,IAAI,CAAC,KAAK8C,eAAL,CAAqB9C,QAArB,CAAL,EAAqC,OAAOA,QAAP;IACrC,OAAO,IAAAuD,wCAAA,EAAmBvD,QAAnB,CAAP;EACD;;AA1J4C"}
1
+ {"version":3,"names":["BabelCompiler","constructor","id","logger","compiler","options","babelModule","babel","distDir","distGlobPatterns","shouldCopyNonSupportedFiles","artifactName","supportedFilesGlobPatterns","flatten","version","getDistDir","transpileFile","fileContent","supportedExtensions","fileExtension","path","extname","filePath","includes","endsWith","transformOptions","babelTransformOptions","context","rootDir","componentDir","outputFiles","transpileFileContent","build","capsules","capsuleNetwork","seedersCapsules","componentsResults","longProcessLogger","createLongProcessLogger","length","mapSeries","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","transpileFilePathAsync","debug","distPath","replaceFileExtToJs","distPathMap","outputFile","outputText","err","endTime","generatedBy","globPatterns","getDistPathBySrcPath","srcPath","fileWithJSExtIfNeeded","multimatch","displayConfig","JSON","stringify"],"sources":["babel.compiler.ts"],"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"],"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;AAKA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAMqD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OAAO,EAAE+E,qBAAqB,CAAC;EACvD;;EAEA;AACF;AACA;EACEnB,eAAe,CAAC9C,QAAgB,EAAW;IACzC,IAAI,IAAI,CAACV,0BAA0B,EAAE;MACnC,OAAO,IAAAwD,qCAAe,EAAC9C,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAAkE,qBAAU,EAAClE,QAAQ,EAAE,IAAI,CAACV,0BAA0B,CAAC,CAAC2B,MAAM;IACpG;IACA,OAAO,IAAA6B,qCAAe,EAAC9C,QAAQ,CAAC;EAClC;EAEAmE,aAAa,GAAG;IACd,OAAOC,IAAI,CAACC,SAAS,CAAC,IAAI,CAACtF,OAAO,CAACqB,qBAAqB,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;EAC1E;EAEQmD,kBAAkB,CAACvD,QAAgB,EAAU;IACnD,IAAI,CAAC,IAAI,CAAC8C,eAAe,CAAC9C,QAAQ,CAAC,EAAE,OAAOA,QAAQ;IACpD,OAAO,IAAAuD,wCAAkB,EAACvD,QAAQ,CAAC;EACrC;AACF;AAAC"}
@@ -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/extensions-icons/babel.svg"
31
26
  }));
32
-
33
27
  exports.Logo = Logo;
34
28
 
35
29
  //# sourceMappingURL=babel.composition.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Logo","height","display","justifyContent","width"],"sources":["babel.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/extensions-icons/babel.svg\" />\n </div>\n);\n"],"mappings":";;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,IAAI,GAAG,mBAClB;EAAK,KAAK,EAAE;IAAEC,MAAM,EAAE,MAAV;IAAkBC,OAAO,EAAE,MAA3B;IAAmCC,cAAc,EAAE;EAAnD;AAAZ,gBACE;EAAK,KAAK,EAAE;IAAEC,KAAK,EAAE;EAAT,CAAZ;EAA2B,GAAG,EAAC;AAA/B,EADF,CADK"}
1
+ {"version":3,"names":["Logo","height","display","justifyContent","width"],"sources":["babel.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/extensions-icons/babel.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"}
@@ -1,117 +1,84 @@
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
  Object.defineProperty(exports, "__esModule", {
10
7
  value: true
11
8
  });
12
9
  exports.BabelMain = void 0;
13
-
14
10
  function _defineProperty2() {
15
11
  const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
-
17
12
  _defineProperty2 = function () {
18
13
  return data;
19
14
  };
20
-
21
15
  return data;
22
16
  }
23
-
24
17
  function _cli() {
25
18
  const data = require("@teambit/cli");
26
-
27
19
  _cli = function () {
28
20
  return data;
29
21
  };
30
-
31
22
  return data;
32
23
  }
33
-
34
24
  function _compiler() {
35
25
  const data = require("@teambit/compiler");
36
-
37
26
  _compiler = function () {
38
27
  return data;
39
28
  };
40
-
41
29
  return data;
42
30
  }
43
-
44
31
  function _logger() {
45
32
  const data = require("@teambit/logger");
46
-
47
33
  _logger = function () {
48
34
  return data;
49
35
  };
50
-
51
36
  return data;
52
37
  }
53
-
54
38
  function babel() {
55
39
  const data = _interopRequireWildcard(require("@babel/core"));
56
-
57
40
  babel = function () {
58
41
  return data;
59
42
  };
60
-
61
43
  return data;
62
44
  }
63
-
64
45
  function _babel() {
65
46
  const data = require("./babel.aspect");
66
-
67
47
  _babel = function () {
68
48
  return data;
69
49
  };
70
-
71
50
  return data;
72
51
  }
73
-
74
52
  function _babel2() {
75
53
  const data = require("./babel.compiler");
76
-
77
54
  _babel2 = function () {
78
55
  return data;
79
56
  };
80
-
81
57
  return data;
82
58
  }
83
-
84
59
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
85
-
86
60
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
87
-
88
61
  class BabelMain {
89
62
  constructor(logger, compiler) {
90
63
  this.logger = logger;
91
64
  this.compiler = compiler;
92
65
  }
93
-
94
66
  createCompiler(options, babelModule = babel()) {
95
67
  return new (_babel2().BabelCompiler)(_babel().BabelAspect.id, this.logger, this.compiler, options, babelModule);
96
68
  }
97
-
98
69
  getPackageJsonProps() {
99
70
  return {
100
71
  main: 'dist/{main}.js'
101
72
  };
102
73
  }
103
-
104
74
  static async provider([loggerExt, compiler]) {
105
75
  const logger = loggerExt.createLogger(_babel().BabelAspect.id);
106
76
  return new BabelMain(logger, compiler);
107
77
  }
108
-
109
78
  }
110
-
111
79
  exports.BabelMain = BabelMain;
112
80
  (0, _defineProperty2().default)(BabelMain, "runtime", _cli().MainRuntime);
113
81
  (0, _defineProperty2().default)(BabelMain, "dependencies", [_logger().LoggerAspect, _compiler().CompilerAspect]);
114
-
115
82
  _babel().BabelAspect.addRuntime(BabelMain);
116
83
 
117
84
  //# sourceMappingURL=babel.main.runtime.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["BabelMain","constructor","logger","compiler","createCompiler","options","babelModule","babel","BabelCompiler","BabelAspect","id","getPackageJsonProps","main","provider","loggerExt","createLogger","MainRuntime","LoggerAspect","CompilerAspect","addRuntime"],"sources":["babel.main.runtime.ts"],"sourcesContent":["import { MainRuntime } from '@teambit/cli';\nimport { CompilerAspect, CompilerMain } from '@teambit/compiler';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport * as babel from '@babel/core';\nimport { BabelCompilerOptions } from './compiler-options';\nimport { BabelAspect } from './babel.aspect';\nimport { BabelCompiler } from './babel.compiler';\n\nexport class BabelMain {\n constructor(private logger: Logger, private compiler: CompilerMain) {}\n\n createCompiler(options: BabelCompilerOptions, babelModule = babel): BabelCompiler {\n return new BabelCompiler(BabelAspect.id, this.logger, this.compiler, options, babelModule);\n }\n\n getPackageJsonProps() {\n return {\n main: 'dist/{main}.js',\n };\n }\n\n static runtime = MainRuntime;\n static dependencies = [LoggerAspect, CompilerAspect];\n\n static async provider([loggerExt, compiler]: [LoggerMain, CompilerMain]) {\n const logger = loggerExt.createLogger(BabelAspect.id);\n return new BabelMain(logger, compiler);\n }\n}\n\nBabelAspect.addRuntime(BabelMain);\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;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;AAEO,MAAMA,SAAN,CAAgB;EACrBC,WAAW,CAASC,MAAT,EAAiCC,QAAjC,EAAyD;IAAA,KAAhDD,MAAgD,GAAhDA,MAAgD;IAAA,KAAxBC,QAAwB,GAAxBA,QAAwB;EAAE;;EAEtEC,cAAc,CAACC,OAAD,EAAgCC,WAAW,GAAGC,KAAK,EAAnD,EAAoE;IAChF,OAAO,KAAIC,uBAAJ,EAAkBC,oBAAA,CAAYC,EAA9B,EAAkC,KAAKR,MAAvC,EAA+C,KAAKC,QAApD,EAA8DE,OAA9D,EAAuEC,WAAvE,CAAP;EACD;;EAEDK,mBAAmB,GAAG;IACpB,OAAO;MACLC,IAAI,EAAE;IADD,CAAP;EAGD;;EAKoB,aAARC,QAAQ,CAAC,CAACC,SAAD,EAAYX,QAAZ,CAAD,EAAoD;IACvE,MAAMD,MAAM,GAAGY,SAAS,CAACC,YAAV,CAAuBN,oBAAA,CAAYC,EAAnC,CAAf;IACA,OAAO,IAAIV,SAAJ,CAAcE,MAAd,EAAsBC,QAAtB,CAAP;EACD;;AAnBoB;;;gCAAVH,S,aAaMgB,kB;gCAbNhB,S,kBAcW,CAACiB,sBAAD,EAAeC,0BAAf,C;;AAQxBT,oBAAA,CAAYU,UAAZ,CAAuBnB,SAAvB"}
1
+ {"version":3,"names":["BabelMain","constructor","logger","compiler","createCompiler","options","babelModule","babel","BabelCompiler","BabelAspect","id","getPackageJsonProps","main","provider","loggerExt","createLogger","MainRuntime","LoggerAspect","CompilerAspect","addRuntime"],"sources":["babel.main.runtime.ts"],"sourcesContent":["import { MainRuntime } from '@teambit/cli';\nimport { CompilerAspect, CompilerMain } from '@teambit/compiler';\nimport { Logger, LoggerAspect, LoggerMain } from '@teambit/logger';\nimport * as babel from '@babel/core';\nimport { BabelCompilerOptions } from './compiler-options';\nimport { BabelAspect } from './babel.aspect';\nimport { BabelCompiler } from './babel.compiler';\n\nexport class BabelMain {\n constructor(private logger: Logger, private compiler: CompilerMain) {}\n\n createCompiler(options: BabelCompilerOptions, babelModule = babel): BabelCompiler {\n return new BabelCompiler(BabelAspect.id, this.logger, this.compiler, options, babelModule);\n }\n\n getPackageJsonProps() {\n return {\n main: 'dist/{main}.js',\n };\n }\n\n static runtime = MainRuntime;\n static dependencies = [LoggerAspect, CompilerAspect];\n\n static async provider([loggerExt, compiler]: [LoggerMain, CompilerMain]) {\n const logger = loggerExt.createLogger(BabelAspect.id);\n return new BabelMain(logger, compiler);\n }\n}\n\nBabelAspect.addRuntime(BabelMain);\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;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AACA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAAiD;AAAA;AAE1C,MAAMA,SAAS,CAAC;EACrBC,WAAW,CAASC,MAAc,EAAUC,QAAsB,EAAE;IAAA,KAAhDD,MAAc,GAAdA,MAAc;IAAA,KAAUC,QAAsB,GAAtBA,QAAsB;EAAG;EAErEC,cAAc,CAACC,OAA6B,EAAEC,WAAW,GAAGC,KAAK,IAAiB;IAChF,OAAO,KAAIC,uBAAa,EAACC,oBAAW,CAACC,EAAE,EAAE,IAAI,CAACR,MAAM,EAAE,IAAI,CAACC,QAAQ,EAAEE,OAAO,EAAEC,WAAW,CAAC;EAC5F;EAEAK,mBAAmB,GAAG;IACpB,OAAO;MACLC,IAAI,EAAE;IACR,CAAC;EACH;EAKA,aAAaC,QAAQ,CAAC,CAACC,SAAS,EAAEX,QAAQ,CAA6B,EAAE;IACvE,MAAMD,MAAM,GAAGY,SAAS,CAACC,YAAY,CAACN,oBAAW,CAACC,EAAE,CAAC;IACrD,OAAO,IAAIV,SAAS,CAACE,MAAM,EAAEC,QAAQ,CAAC;EACxC;AACF;AAAC;AAAA,gCApBYH,SAAS,aAaHgB,kBAAW;AAAA,gCAbjBhB,SAAS,kBAcE,CAACiB,sBAAY,EAAEC,0BAAc,CAAC;AAQtDT,oBAAW,CAACU,UAAU,CAACnB,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -15,24 +15,18 @@ Object.defineProperty(exports, "BabelCompiler", {
15
15
  return _babel().BabelCompiler;
16
16
  }
17
17
  });
18
-
19
18
  function _babel() {
20
19
  const data = require("./babel.compiler");
21
-
22
20
  _babel = function () {
23
21
  return data;
24
22
  };
25
-
26
23
  return data;
27
24
  }
28
-
29
25
  function _babel2() {
30
26
  const data = require("./babel.aspect");
31
-
32
27
  _babel2 = function () {
33
28
  return data;
34
29
  };
35
-
36
30
  return data;
37
31
  }
38
32
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { BabelCompiler } from './babel.compiler';\nexport type { BabelMain } from './babel.main.runtime';\nexport { BabelAspect } from './babel.aspect';\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA"}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { BabelCompiler } from './babel.compiler';\nexport type { BabelMain } from './babel.main.runtime';\nexport { BabelAspect } from './babel.aspect';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA;AAEA;EAAA;EAAA;IAAA;EAAA;EAAA;AAAA"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/babel",
3
- "version": "0.0.881",
3
+ "version": "0.0.882",
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.881"
9
+ "version": "0.0.882"
10
10
  },
11
11
  "dependencies": {
12
12
  "@babel/core": "7.12.17",
@@ -17,10 +17,10 @@
17
17
  "@babel/runtime": "7.12.18",
18
18
  "core-js": "^3.0.0",
19
19
  "@teambit/harmony": "0.3.3",
20
- "@teambit/builder": "0.0.881",
20
+ "@teambit/builder": "0.0.882",
21
21
  "@teambit/compilation.modules.babel-compiler": "0.0.130",
22
- "@teambit/compiler": "0.0.881",
23
- "@teambit/isolator": "0.0.881",
22
+ "@teambit/compiler": "0.0.882",
23
+ "@teambit/isolator": "0.0.882",
24
24
  "@teambit/logger": "0.0.684",
25
25
  "@teambit/cli": "0.0.591"
26
26
  },
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compilation_babel@0.0.881/dist/babel.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compilation_babel@0.0.881/dist/babel.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compilation_babel@0.0.882/dist/babel.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compilation_babel@0.0.882/dist/babel.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];