@teambit/compiler 0.0.554 → 0.0.558
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/compiler.main.runtime.d.ts +16 -3
- package/dist/compiler.main.runtime.js +23 -2
- package/dist/compiler.main.runtime.js.map +1 -1
- package/dist/compiler.task.d.ts +3 -0
- package/dist/templates/compiler/files/aspect-file.d.ts +2 -0
- package/dist/templates/compiler/files/aspect-file.js +20 -0
- package/dist/templates/compiler/files/aspect-file.js.map +1 -0
- package/dist/templates/compiler/files/compiler-file.d.ts +2 -0
- package/dist/templates/compiler/files/compiler-file.js +84 -0
- package/dist/templates/compiler/files/compiler-file.js.map +1 -0
- package/dist/templates/compiler/files/index-file.d.ts +2 -0
- package/dist/templates/compiler/files/index-file.js +20 -0
- package/dist/templates/compiler/files/index-file.js.map +1 -0
- package/dist/templates/compiler/files/main-runtime-file.d.ts +2 -0
- package/dist/templates/compiler/files/main-runtime-file.js +47 -0
- package/dist/templates/compiler/files/main-runtime-file.js.map +1 -0
- package/dist/templates/compiler/index.d.ts +2 -0
- package/dist/templates/compiler/index.js +71 -0
- package/dist/templates/compiler/index.js.map +1 -0
- package/dist/types.d.ts +64 -0
- package/dist/workspace-compiler.d.ts +7 -1
- package/package.json +26 -17
- package/tsconfig.json +1 -2
- package/compiler.aspect.ts +0 -5
- package/compiler.cmd.ts +0 -115
- package/compiler.docs.mdx +0 -8
- package/compiler.main.runtime.ts +0 -99
- package/compiler.service.tsx +0 -47
- package/compiler.task.ts +0 -52
- package/dist-artifact.ts +0 -12
- package/events/compiler-error.ts +0 -14
- package/events/component-compilation-on-done.ts +0 -30
- package/events/index.ts +0 -2
- package/exceptions/dist-artifact-not-found.ts +0 -8
- package/exceptions/index.ts +0 -1
- package/index.ts +0 -11
- package/output-formatter.ts +0 -19
- package/package-tar/teambit-compiler-0.0.554.tgz +0 -0
- package/types/asset.d.ts +0 -29
- package/types/style.d.ts +0 -42
- package/types.ts +0 -137
- package/workspace-compiler.ts +0 -306
|
@@ -5,6 +5,7 @@ import { Component } from '@teambit/component';
|
|
|
5
5
|
import { EnvsMain } from '@teambit/envs';
|
|
6
6
|
import { BitId } from '@teambit/legacy-bit-id';
|
|
7
7
|
import { LoggerMain } from '@teambit/logger';
|
|
8
|
+
import { GeneratorMain } from '@teambit/generator';
|
|
8
9
|
import { PubsubMain } from '@teambit/pubsub';
|
|
9
10
|
import { UiMain } from '@teambit/ui';
|
|
10
11
|
import { Workspace } from '@teambit/workspace';
|
|
@@ -18,13 +19,24 @@ export declare class CompilerMain {
|
|
|
18
19
|
private envs;
|
|
19
20
|
private builder;
|
|
20
21
|
constructor(pubsub: PubsubMain, workspaceCompiler: WorkspaceCompiler, envs: EnvsMain, builder: BuilderMain);
|
|
21
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Run compilation on `bit new` and when new components are imported
|
|
24
|
+
*/
|
|
25
|
+
compileOnWorkspace(componentsIds?: string[] | BitId[], // when empty, it compiles all
|
|
26
|
+
options?: CompileOptions): Promise<import("./workspace-compiler").BuildResult[]>;
|
|
27
|
+
/**
|
|
28
|
+
* API to create a new compiler task, it facilitates the usage of multiple compilers.
|
|
29
|
+
* with this method you can create any number of compilers and add them to the buildPipeline.
|
|
30
|
+
*/
|
|
22
31
|
createTask(name: string, compiler: Compiler): CompilerTask;
|
|
32
|
+
/**
|
|
33
|
+
* find the compiler configured on the workspace and ask for the dist path.
|
|
34
|
+
*/
|
|
23
35
|
getDistPathBySrcPath(component: Component, srcPath: string): string | null;
|
|
24
36
|
getDistsFiles(component: Component): Promise<DistArtifact>;
|
|
25
37
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
26
38
|
static dependencies: import("@teambit/harmony").Aspect[];
|
|
27
|
-
static provider([cli, workspace, envs, loggerMain, pubsub, aspectLoader, builder, ui]: [
|
|
39
|
+
static provider([cli, workspace, envs, loggerMain, pubsub, aspectLoader, builder, ui, generator]: [
|
|
28
40
|
CLIMain,
|
|
29
41
|
Workspace,
|
|
30
42
|
EnvsMain,
|
|
@@ -32,6 +44,7 @@ export declare class CompilerMain {
|
|
|
32
44
|
PubsubMain,
|
|
33
45
|
AspectLoaderMain,
|
|
34
46
|
BuilderMain,
|
|
35
|
-
UiMain
|
|
47
|
+
UiMain,
|
|
48
|
+
GeneratorMain
|
|
36
49
|
]): Promise<CompilerMain>;
|
|
37
50
|
}
|
|
@@ -81,6 +81,16 @@ function _logger() {
|
|
|
81
81
|
return data;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
function _generator() {
|
|
85
|
+
const data = require("@teambit/generator");
|
|
86
|
+
|
|
87
|
+
_generator = function () {
|
|
88
|
+
return data;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
return data;
|
|
92
|
+
}
|
|
93
|
+
|
|
84
94
|
function _pubsub() {
|
|
85
95
|
const data = require("@teambit/pubsub");
|
|
86
96
|
|
|
@@ -191,6 +201,16 @@ function _workspaceCompiler() {
|
|
|
191
201
|
return data;
|
|
192
202
|
}
|
|
193
203
|
|
|
204
|
+
function _compiler5() {
|
|
205
|
+
const data = require("./templates/compiler");
|
|
206
|
+
|
|
207
|
+
_compiler5 = function () {
|
|
208
|
+
return data;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
return data;
|
|
212
|
+
}
|
|
213
|
+
|
|
194
214
|
class CompilerMain {
|
|
195
215
|
constructor(pubsub, workspaceCompiler, envs, builder) {
|
|
196
216
|
this.pubsub = pubsub;
|
|
@@ -238,12 +258,13 @@ class CompilerMain {
|
|
|
238
258
|
return new (_distArtifact().DistArtifact)(artifacts);
|
|
239
259
|
}
|
|
240
260
|
|
|
241
|
-
static async provider([cli, workspace, envs, loggerMain, pubsub, aspectLoader, builder, ui]) {
|
|
261
|
+
static async provider([cli, workspace, envs, loggerMain, pubsub, aspectLoader, builder, ui, generator]) {
|
|
242
262
|
const logger = loggerMain.createLogger(_compiler().CompilerAspect.id);
|
|
243
263
|
const workspaceCompiler = new (_workspaceCompiler().WorkspaceCompiler)(workspace, envs, pubsub, aspectLoader, ui, logger);
|
|
244
264
|
envs.registerService(new (_compiler3().CompilerService)());
|
|
245
265
|
const compilerMain = new CompilerMain(pubsub, workspaceCompiler, envs, builder);
|
|
246
266
|
cli.register(new (_compiler2().CompileCmd)(workspaceCompiler, logger, pubsub));
|
|
267
|
+
generator.registerComponentTemplate([_compiler5().compilerTemplate]);
|
|
247
268
|
_manyComponentsWriter().default.externalCompiler = compilerMain.compileOnWorkspace.bind(compilerMain);
|
|
248
269
|
return compilerMain;
|
|
249
270
|
}
|
|
@@ -252,7 +273,7 @@ class CompilerMain {
|
|
|
252
273
|
|
|
253
274
|
exports.CompilerMain = CompilerMain;
|
|
254
275
|
(0, _defineProperty2().default)(CompilerMain, "runtime", _cli().MainRuntime);
|
|
255
|
-
(0, _defineProperty2().default)(CompilerMain, "dependencies", [_cli().CLIAspect, _workspace().WorkspaceAspect, _envs().EnvsAspect, _logger().LoggerAspect, _pubsub().PubsubAspect, _aspectLoader().default, _builder().BuilderAspect, _ui().default]);
|
|
276
|
+
(0, _defineProperty2().default)(CompilerMain, "dependencies", [_cli().CLIAspect, _workspace().WorkspaceAspect, _envs().EnvsAspect, _logger().LoggerAspect, _pubsub().PubsubAspect, _aspectLoader().default, _builder().BuilderAspect, _ui().default, _generator().GeneratorAspect]);
|
|
256
277
|
|
|
257
278
|
_compiler().CompilerAspect.addRuntime(CompilerMain);
|
|
258
279
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["compiler.main.runtime.ts"],"names":["CompilerMain","constructor","pubsub","workspaceCompiler","envs","builder","compileOnWorkspace","componentsIds","options","initiator","CompilationInitiator","ComponentAdded","compileComponents","createTask","name","compiler","CompilerTask","CompilerAspect","id","getDistPathBySrcPath","component","srcPath","environment","getEnv","env","compilerInstance","getCompiler","getDistsFiles","artifacts","getArtifactsVinylByExtension","length","DistArtifactNotFound","DistArtifact","provider","cli","workspace","loggerMain","aspectLoader","ui","logger","createLogger","WorkspaceCompiler","registerService","CompilerService","compilerMain","register","CompileCmd","ManyComponentsWriter","externalCompiler","bind","MainRuntime","CLIAspect","WorkspaceAspect","EnvsAspect","LoggerAspect","PubsubAspect","AspectLoaderAspect","BuilderAspect","UIAspect","addRuntime"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;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;;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;;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;;AAEO,MAAMA,YAAN,CAAmB;AACxBC,EAAAA,WAAW,CACDC,MADC,EAEDC,iBAFC,EAGDC,IAHC,EAIDC,OAJC,EAKT;AAAA,SAJQH,MAIR,GAJQA,MAIR;AAAA,SAHQC,iBAGR,GAHQA,iBAGR;AAAA,SAFQC,IAER,GAFQA,IAER;AAAA,SADQC,OACR,GADQA,OACR;AAAE;AAEJ;AACF;AACA;;;AACEC,EAAAA,kBAAkB,CAChBC,aAAiC,GAAG,EADpB,EACwB;AACxCC,EAAAA,OAAuB,GAAG;AAAEC,IAAAA,SAAS,EAAEC,8BAAqBC;AAAlC,GAFV,EAGhB;AACA,WAAO,KAAKR,iBAAL,CAAuBS,iBAAvB,CAAyCL,aAAzC,EAAwDC,OAAxD,CAAP;AACD;AACD;AACF;AACA;AACA;;;AACEK,EAAAA,UAAU,CAACC,IAAD,EAAeC,QAAf,EAAiD;AACzD,WAAO,KAAIC,yBAAJ,EAAiBC,2BAAeC,EAAhC,EAAoCJ,IAApC,EAA0CC,QAA1C,CAAP;AACD;AAED;AACF;AACA;;;AACEI,EAAAA,oBAAoB,CAACC,SAAD,EAAuBC,OAAvB,EAAuD;AAAA;;AACzE,UAAMC,WAAW,GAAG,KAAKlB,IAAL,CAAUmB,MAAV,CAAiBH,SAAjB,EAA4BI,GAAhD;AACA,UAAMC,gBAAgB,4BAAGH,WAAW,CAACI,WAAf,0DAAG,2BAAAJ,WAAW,CAApC;AACA,QAAI,CAACG,gBAAL,EAAuB,OAAO,IAAP;AACvB,WAAOA,gBAAgB,CAACN,oBAAjB,CAAsCE,OAAtC,CAAP;AACD;;AAEkB,QAAbM,aAAa,CAACP,SAAD,EAA8C;AAC/D,UAAMQ,SAAS,GAAG,MAAM,KAAKvB,OAAL,CAAawB,4BAAb,CAA0CT,SAA1C,EAAqDH,2BAAeC,EAApE,CAAxB;AACA,QAAI,CAACU,SAAS,CAACE,MAAf,EAAuB,MAAM,KAAIC,kCAAJ,EAAyBX,SAAS,CAACF,EAAnC,CAAN;AAEvB,WAAO,KAAIc,4BAAJ,EAAiBJ,SAAjB,CAAP;AACD;;
|
|
1
|
+
{"version":3,"sources":["compiler.main.runtime.ts"],"names":["CompilerMain","constructor","pubsub","workspaceCompiler","envs","builder","compileOnWorkspace","componentsIds","options","initiator","CompilationInitiator","ComponentAdded","compileComponents","createTask","name","compiler","CompilerTask","CompilerAspect","id","getDistPathBySrcPath","component","srcPath","environment","getEnv","env","compilerInstance","getCompiler","getDistsFiles","artifacts","getArtifactsVinylByExtension","length","DistArtifactNotFound","DistArtifact","provider","cli","workspace","loggerMain","aspectLoader","ui","generator","logger","createLogger","WorkspaceCompiler","registerService","CompilerService","compilerMain","register","CompileCmd","registerComponentTemplate","compilerTemplate","ManyComponentsWriter","externalCompiler","bind","MainRuntime","CLIAspect","WorkspaceAspect","EnvsAspect","LoggerAspect","PubsubAspect","AspectLoaderAspect","BuilderAspect","UIAspect","GeneratorAspect","addRuntime"],"mappings":"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","sourcesContent":["import AspectLoaderAspect, { AspectLoaderMain } from '@teambit/aspect-loader';\nimport { BuilderAspect, BuilderMain } from '@teambit/builder';\nimport { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { Component } from '@teambit/component';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { BitId } from '@teambit/legacy-bit-id';\n\nimport ManyComponentsWriter from '@teambit/legacy/dist/consumer/component-ops/many-components-writer';\nimport { LoggerAspect, LoggerMain } from '@teambit/logger';\nimport { GeneratorAspect, GeneratorMain } from '@teambit/generator';\nimport { PubsubAspect, PubsubMain } from '@teambit/pubsub';\nimport UIAspect, { UiMain } from '@teambit/ui';\nimport { Workspace, WorkspaceAspect } from '@teambit/workspace';\nimport { CompilerAspect } from './compiler.aspect';\nimport { CompileCmd } from './compiler.cmd';\nimport { CompilerService } from './compiler.service';\nimport { CompilerTask } from './compiler.task';\nimport { DistArtifact } from './dist-artifact';\nimport { DistArtifactNotFound } from './exceptions';\nimport { CompilationInitiator, Compiler } from './types';\nimport { CompileOptions, WorkspaceCompiler } from './workspace-compiler';\nimport { compilerTemplate } from './templates/compiler';\n\nexport class CompilerMain {\n constructor(\n private pubsub: PubsubMain,\n private workspaceCompiler: WorkspaceCompiler,\n private envs: EnvsMain,\n private builder: BuilderMain\n ) {}\n\n /**\n * Run compilation on `bit new` and when new components are imported\n */\n compileOnWorkspace(\n componentsIds: string[] | BitId[] = [], // when empty, it compiles all\n options: CompileOptions = { initiator: CompilationInitiator.ComponentAdded }\n ) {\n return this.workspaceCompiler.compileComponents(componentsIds, options);\n }\n /**\n * API to create a new compiler task, it facilitates the usage of multiple compilers.\n * with this method you can create any number of compilers and add them to the buildPipeline.\n */\n createTask(name: string, compiler: Compiler): CompilerTask {\n return new CompilerTask(CompilerAspect.id, name, compiler);\n }\n\n /**\n * find the compiler configured on the workspace and ask for the dist path.\n */\n getDistPathBySrcPath(component: Component, srcPath: string): string | null {\n const environment = this.envs.getEnv(component).env;\n const compilerInstance = environment.getCompiler?.();\n if (!compilerInstance) return null;\n return compilerInstance.getDistPathBySrcPath(srcPath);\n }\n\n async getDistsFiles(component: Component): Promise<DistArtifact> {\n const artifacts = await this.builder.getArtifactsVinylByExtension(component, CompilerAspect.id);\n if (!artifacts.length) throw new DistArtifactNotFound(component.id);\n\n return new DistArtifact(artifacts);\n }\n\n static runtime = MainRuntime;\n\n static dependencies = [\n CLIAspect,\n WorkspaceAspect,\n EnvsAspect,\n LoggerAspect,\n PubsubAspect,\n AspectLoaderAspect,\n BuilderAspect,\n UIAspect,\n GeneratorAspect\n ];\n\n static async provider([cli, workspace, envs, loggerMain, pubsub, aspectLoader, builder, ui, generator]: [\n CLIMain,\n Workspace,\n EnvsMain,\n LoggerMain,\n PubsubMain,\n AspectLoaderMain,\n BuilderMain,\n UiMain,\n GeneratorMain\n ]) {\n const logger = loggerMain.createLogger(CompilerAspect.id);\n const workspaceCompiler = new WorkspaceCompiler(workspace, envs, pubsub, aspectLoader, ui, logger);\n envs.registerService(new CompilerService());\n const compilerMain = new CompilerMain(pubsub, workspaceCompiler, envs, builder);\n cli.register(new CompileCmd(workspaceCompiler, logger, pubsub));\n generator.registerComponentTemplate([compilerTemplate]);\n ManyComponentsWriter.externalCompiler = compilerMain.compileOnWorkspace.bind(compilerMain);\n\n return compilerMain;\n }\n}\n\nCompilerAspect.addRuntime(CompilerMain);\n"]}
|
package/dist/compiler.task.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { BuildContext, BuiltTaskResult, BuildTask, TaskResultsList } from '@teambit/builder';
|
|
2
2
|
import { Capsule } from '@teambit/isolator';
|
|
3
3
|
import { Compiler } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* compiler build task. Allows to compile components during component build.
|
|
6
|
+
*/
|
|
4
7
|
export declare class CompilerTask implements BuildTask {
|
|
5
8
|
readonly aspectId: string;
|
|
6
9
|
readonly name: string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.aspectFile = aspectFile;
|
|
7
|
+
|
|
8
|
+
function aspectFile({
|
|
9
|
+
namePascalCase,
|
|
10
|
+
componentId
|
|
11
|
+
}) {
|
|
12
|
+
return `import { Aspect } from '@teambit/harmony';
|
|
13
|
+
|
|
14
|
+
export const ${namePascalCase}Aspect = Aspect.create({
|
|
15
|
+
id: '${componentId}',
|
|
16
|
+
});
|
|
17
|
+
`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=aspect-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["aspect-file.ts"],"names":["aspectFile","namePascalCase","componentId"],"mappings":";;;;;;;AAEO,SAASA,UAAT,CAAoB;AAAEC,EAAAA,cAAF;AAAkBC,EAAAA;AAAlB,CAApB,EAAuE;AAC5E,SAAQ;AACV;AACA,eAAeD,cAAe;AAC9B,SAASC,WAAY;AACrB;AACA,GALE;AAMD","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport function aspectFile({ namePascalCase, componentId }: ComponentContext) {\n return `import { Aspect } from '@teambit/harmony';\n\nexport const ${namePascalCase}Aspect = Aspect.create({\n id: '${componentId}',\n});\n `;\n}\n"]}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.compilerFile = compilerFile;
|
|
7
|
+
|
|
8
|
+
function compilerFile({
|
|
9
|
+
namePascalCase
|
|
10
|
+
}) {
|
|
11
|
+
return `import {
|
|
12
|
+
BuildContext,
|
|
13
|
+
BuiltTaskResult,
|
|
14
|
+
ComponentResult,
|
|
15
|
+
} from '@teambit/builder';
|
|
16
|
+
import {
|
|
17
|
+
Compiler,
|
|
18
|
+
CompilerMain,
|
|
19
|
+
TranspileFileParams,
|
|
20
|
+
TranspileFileOutput,
|
|
21
|
+
} from '@teambit/compiler';
|
|
22
|
+
|
|
23
|
+
export class ${namePascalCase} implements Compiler {
|
|
24
|
+
|
|
25
|
+
constructor(readonly id: string, readonly distDir, private compiler: CompilerMain) {}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Detemines whether unsupported files (such as assets)
|
|
29
|
+
* should be copied by Compiler aspect into the 'dist' directory
|
|
30
|
+
*/
|
|
31
|
+
shouldCopyNonSupportedFiles = true;
|
|
32
|
+
|
|
33
|
+
/* The name of the compiler being used. For example, TypeScript, Babel, etc. */
|
|
34
|
+
displayName = '';
|
|
35
|
+
|
|
36
|
+
/* The version of the compiler being used. For example '1.0.0' */
|
|
37
|
+
version(): string {};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Use this for compilation in the workspace.
|
|
41
|
+
* This will compile one file content at a time (alternatively, use 'transpileComponent') */
|
|
42
|
+
transpileFile( fileContent: string, transpileFileParams: TranspileFileParams): TranspileFileOutput {}
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
async build(context: BuildContext): Promise<BuiltTaskResult> {
|
|
46
|
+
let componentsResults: ComponentResult[] = [];
|
|
47
|
+
return {
|
|
48
|
+
/* Sets the files to persist as the Component's artifacts,
|
|
49
|
+
and describes them. */
|
|
50
|
+
artifacts: [
|
|
51
|
+
{
|
|
52
|
+
generatedBy: this.id,
|
|
53
|
+
name: 'compilation output',
|
|
54
|
+
globPatterns: [\`\${this.distDir}/**\`],
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
componentsResults,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* This is optional but recommended.
|
|
62
|
+
Not using it will require consumers of your compiler to use two APIs and have two depndencies
|
|
63
|
+
to their Envs - your compiler
|
|
64
|
+
*/
|
|
65
|
+
createTask() {
|
|
66
|
+
return this.compiler.createTask('${namePascalCase}', this);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Given a source file, return its parallel in the dists. e.g. index.ts => dist/index.js.
|
|
71
|
+
* Needed by aspects such as Pkg to determine the main prop.
|
|
72
|
+
*/
|
|
73
|
+
getDistPathBySrcPath(srcPath: string): string {}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Returns a boolean indicating whether a file is supported by the compiler or not.
|
|
77
|
+
* For example, this API is used by Compiler aspect to copy unsupported files to the dist directory.
|
|
78
|
+
*/
|
|
79
|
+
isFileSupported(filePath: string): boolean {}
|
|
80
|
+
}
|
|
81
|
+
`;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
//# sourceMappingURL=compiler-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["compiler-file.ts"],"names":["compilerFile","namePascalCase"],"mappings":";;;;;;;AAEO,SAASA,YAAT,CAAsB;AAAEC,EAAAA;AAAF,CAAtB,EAA4D;AACjE,SAAQ;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAeA,cAAe;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,2CAA2CA,cAAe;AAC1D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAtEE;AAuED","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport function compilerFile({ namePascalCase }: ComponentContext) {\n return `import {\n BuildContext,\n BuiltTaskResult,\n ComponentResult,\n} from '@teambit/builder';\nimport {\n Compiler,\n CompilerMain,\n TranspileFileParams,\n TranspileFileOutput,\n} from '@teambit/compiler';\n\nexport class ${namePascalCase} implements Compiler {\n\n constructor(readonly id: string, readonly distDir, private compiler: CompilerMain) {}\n\n /**\n * Detemines whether unsupported files (such as assets)\n * should be copied by Compiler aspect into the 'dist' directory\n */\n shouldCopyNonSupportedFiles = true;\n\n /* The name of the compiler being used. For example, TypeScript, Babel, etc. */\n displayName = '';\n\n /* The version of the compiler being used. For example '1.0.0' */\n version(): string {};\n\n /**\n * Use this for compilation in the workspace.\n * This will compile one file content at a time (alternatively, use 'transpileComponent') */\n transpileFile( fileContent: string, transpileFileParams: TranspileFileParams): TranspileFileOutput {}\n\n\n async build(context: BuildContext): Promise<BuiltTaskResult> {\n let componentsResults: ComponentResult[] = [];\n return {\n /* Sets the files to persist as the Component's artifacts,\n and describes them. */\n artifacts: [\n {\n generatedBy: this.id,\n name: 'compilation output',\n globPatterns: [\\`\\${this.distDir}/**\\`],\n },\n ],\n componentsResults,\n };\n }\n\n /* This is optional but recommended.\n Not using it will require consumers of your compiler to use two APIs and have two depndencies\n to their Envs - your compiler\n */\n createTask() {\n return this.compiler.createTask('${namePascalCase}', this);\n }\n\n /**\n * Given a source file, return its parallel in the dists. e.g. index.ts => dist/index.js.\n * Needed by aspects such as Pkg to determine the main prop.\n */\n getDistPathBySrcPath(srcPath: string): string {}\n\n /**\n * Returns a boolean indicating whether a file is supported by the compiler or not.\n * For example, this API is used by Compiler aspect to copy unsupported files to the dist directory.\n */\n isFileSupported(filePath: string): boolean {}\n}\n `;\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.indexFile = indexFile;
|
|
7
|
+
|
|
8
|
+
function indexFile({
|
|
9
|
+
namePascalCase,
|
|
10
|
+
name
|
|
11
|
+
}) {
|
|
12
|
+
return `import { ${namePascalCase}Aspect } from './${name}.aspect';
|
|
13
|
+
|
|
14
|
+
export type { ${namePascalCase}Main } from './${name}.main.runtime';
|
|
15
|
+
export default ${namePascalCase}Aspect;
|
|
16
|
+
export { ${namePascalCase}Aspect };
|
|
17
|
+
`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
//# sourceMappingURL=index-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index-file.ts"],"names":["indexFile","namePascalCase","name"],"mappings":";;;;;;;AAEO,SAASA,SAAT,CAAmB;AAAEC,EAAAA,cAAF;AAAkBC,EAAAA;AAAlB,CAAnB,EAA+D;AACpE,SAAQ,YAAWD,cAAe,oBAAmBC,IAAK;AAC5D;AACA,gBAAgBD,cAAe,kBAAiBC,IAAK;AACrD,iBAAiBD,cAAe;AAChC,WAAWA,cAAe;AAC1B,CALE;AAMD","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport function indexFile({ namePascalCase, name }: ComponentContext) {\n return `import { ${namePascalCase}Aspect } from './${name}.aspect';\n\nexport type { ${namePascalCase}Main } from './${name}.main.runtime';\nexport default ${namePascalCase}Aspect;\nexport { ${namePascalCase}Aspect };\n`;\n}\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.mainRuntimeFile = mainRuntimeFile;
|
|
7
|
+
|
|
8
|
+
function mainRuntimeFile({
|
|
9
|
+
name,
|
|
10
|
+
namePascalCase
|
|
11
|
+
}) {
|
|
12
|
+
return `import { MainRuntime } from '@teambit/cli';
|
|
13
|
+
import { CompilerAspect, CompilerMain } from '@teambit/compiler';
|
|
14
|
+
import { ${namePascalCase} } from './${name}.compiler';
|
|
15
|
+
import { ${namePascalCase}Aspect } from './${name}.aspect';
|
|
16
|
+
|
|
17
|
+
export class ${namePascalCase}Main {
|
|
18
|
+
constructor(private compiler: CompilerMain) {}
|
|
19
|
+
|
|
20
|
+
static slots = [];
|
|
21
|
+
static dependencies = [CompilerAspect];
|
|
22
|
+
static runtime = MainRuntime;
|
|
23
|
+
|
|
24
|
+
distDir = 'dist';
|
|
25
|
+
|
|
26
|
+
/* Set the main property of the component's package with
|
|
27
|
+
the relative output path for the main file */
|
|
28
|
+
getPackageJsonProps() {
|
|
29
|
+
return {
|
|
30
|
+
main: '\${this.distDir}/{main}.js',
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
createCompiler(): ${namePascalCase} {
|
|
35
|
+
return new ${namePascalCase}(${namePascalCase}Aspect.id, this.distDir, this.compiler);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
static async provider([compiler]: [CompilerMain]) {
|
|
39
|
+
return new ${namePascalCase}Main(compiler);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
${namePascalCase}Aspect.addRuntime(${namePascalCase}Main);
|
|
44
|
+
`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=main-runtime-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["main-runtime-file.ts"],"names":["mainRuntimeFile","name","namePascalCase"],"mappings":";;;;;;;AAEO,SAASA,eAAT,CAAyB;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,CAAzB,EAAqE;AAC1E,SAAQ;AACV;AACA,WAAWA,cAAe,cAAaD,IAAK;AAC5C,WAAWC,cAAe,oBAAmBD,IAAK;AAClD;AACA,eAAeC,cAAe;AAC9B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,sBAAsBA,cAAe;AACrC,iBAAiBA,cAAe,IAAGA,cAAe;AAClD;AACA;AACA;AACA,iBAAiBA,cAAe;AAChC;AACA;AACA;AACA,EAAEA,cAAe,qBAAoBA,cAAe;AACpD,CAhCE;AAiCD","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport function mainRuntimeFile({ name, namePascalCase }: ComponentContext) {\n return `import { MainRuntime } from '@teambit/cli';\nimport { CompilerAspect, CompilerMain } from '@teambit/compiler';\nimport { ${namePascalCase} } from './${name}.compiler';\nimport { ${namePascalCase}Aspect } from './${name}.aspect';\n\nexport class ${namePascalCase}Main {\n constructor(private compiler: CompilerMain) {}\n\n static slots = [];\n static dependencies = [CompilerAspect];\n static runtime = MainRuntime;\n\n distDir = 'dist';\n\n /* Set the main property of the component's package with\n the relative output path for the main file */\n getPackageJsonProps() {\n return {\n main: '\\${this.distDir}/{main}.js',\n };\n }\n\n createCompiler(): ${namePascalCase} {\n return new ${namePascalCase}(${namePascalCase}Aspect.id, this.distDir, this.compiler);\n }\n\n static async provider([compiler]: [CompilerMain]) {\n return new ${namePascalCase}Main(compiler);\n }\n}\n\n${namePascalCase}Aspect.addRuntime(${namePascalCase}Main);\n`;\n}\n"]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.compilerTemplate = void 0;
|
|
7
|
+
|
|
8
|
+
function _indexFile() {
|
|
9
|
+
const data = require("./files/index-file");
|
|
10
|
+
|
|
11
|
+
_indexFile = function () {
|
|
12
|
+
return data;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function _aspectFile() {
|
|
19
|
+
const data = require("./files/aspect-file");
|
|
20
|
+
|
|
21
|
+
_aspectFile = function () {
|
|
22
|
+
return data;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function _mainRuntimeFile() {
|
|
29
|
+
const data = require("./files/main-runtime-file");
|
|
30
|
+
|
|
31
|
+
_mainRuntimeFile = function () {
|
|
32
|
+
return data;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function _compilerFile() {
|
|
39
|
+
const data = require("./files/compiler-file");
|
|
40
|
+
|
|
41
|
+
_compilerFile = function () {
|
|
42
|
+
return data;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return data;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const compilerTemplate = {
|
|
49
|
+
name: 'compiler',
|
|
50
|
+
description: 'A compiler implementation',
|
|
51
|
+
hidden: true,
|
|
52
|
+
generateFiles: context => {
|
|
53
|
+
return [{
|
|
54
|
+
relativePath: 'index.ts',
|
|
55
|
+
content: (0, _indexFile().indexFile)(context),
|
|
56
|
+
isMain: true
|
|
57
|
+
}, {
|
|
58
|
+
relativePath: `${context.name}.aspect.ts`,
|
|
59
|
+
content: (0, _aspectFile().aspectFile)(context)
|
|
60
|
+
}, {
|
|
61
|
+
relativePath: `${context.name}.compiler.ts`,
|
|
62
|
+
content: (0, _compilerFile().compilerFile)(context)
|
|
63
|
+
}, {
|
|
64
|
+
relativePath: `${context.name}.main.runtime.ts`,
|
|
65
|
+
content: (0, _mainRuntimeFile().mainRuntimeFile)(context)
|
|
66
|
+
}];
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
exports.compilerTemplate = compilerTemplate;
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":["compilerTemplate","name","description","hidden","generateFiles","context","relativePath","content","isMain"],"mappings":";;;;;;;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;;AAEO,MAAMA,gBAAmC,GAAG;AACjDC,EAAAA,IAAI,EAAE,UAD2C;AAEjDC,EAAAA,WAAW,EAAE,2BAFoC;AAGjDC,EAAAA,MAAM,EAAE,IAHyC;AAIjDC,EAAAA,aAAa,EAAGC,OAAD,IAA+B;AAC5C,WAAO,CACL;AACEC,MAAAA,YAAY,EAAE,UADhB;AAEEC,MAAAA,OAAO,EAAE,4BAAUF,OAAV,CAFX;AAGEG,MAAAA,MAAM,EAAE;AAHV,KADK,EAML;AACEF,MAAAA,YAAY,EAAG,GAAED,OAAO,CAACJ,IAAK,YADhC;AAEEM,MAAAA,OAAO,EAAE,8BAAWF,OAAX;AAFX,KANK,EAUL;AACEC,MAAAA,YAAY,EAAG,GAAED,OAAO,CAACJ,IAAK,cADhC;AAEEM,MAAAA,OAAO,EAAE,kCAAaF,OAAb;AAFX,KAVK,EAcL;AACEC,MAAAA,YAAY,EAAG,GAAED,OAAO,CAACJ,IAAK,kBADhC;AAEEM,MAAAA,OAAO,EAAE,wCAAgBF,OAAhB;AAFX,KAdK,CAAP;AAmBD;AAxBgD,CAA5C","sourcesContent":["import { ComponentContext, ComponentTemplate } from '@teambit/generator';\nimport { indexFile } from './files/index-file';\nimport { aspectFile } from './files/aspect-file';\nimport { mainRuntimeFile } from './files/main-runtime-file';\nimport { compilerFile } from './files/compiler-file';\n\nexport const compilerTemplate: ComponentTemplate = {\n name: 'compiler',\n description: 'A compiler implementation',\n hidden: true,\n generateFiles: (context: ComponentContext) => {\n return [\n {\n relativePath: 'index.ts',\n content: indexFile(context),\n isMain: true,\n },\n {\n relativePath: `${context.name}.aspect.ts`,\n content: aspectFile(context),\n },\n {\n relativePath: `${context.name}.compiler.ts`,\n content: compilerFile(context),\n },\n {\n relativePath: `${context.name}.main.runtime.ts`,\n content: mainRuntimeFile(context),\n },\n ];\n },\n};\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -26,24 +26,88 @@ export declare type TranspileFileOutput = {
|
|
|
26
26
|
outputPath: string;
|
|
27
27
|
}[] | null;
|
|
28
28
|
export interface CompilerOptions {
|
|
29
|
+
/**
|
|
30
|
+
* name of the compiler.
|
|
31
|
+
*/
|
|
29
32
|
name?: string;
|
|
33
|
+
/**
|
|
34
|
+
* relative path of the dist directory inside the capsule. e.g. "dist".
|
|
35
|
+
*/
|
|
30
36
|
distDir: string;
|
|
37
|
+
/**
|
|
38
|
+
* determines which ones of the generated files will be saved in the bit objects when tagging.
|
|
39
|
+
* e.g. distGlobPatterns = [`${this.distDir}/**`, `!${this.distDir}/tsconfig.tsbuildinfo`];
|
|
40
|
+
* see https://github.com/mrmlnc/fast-glob for the supported glob patters syntax.
|
|
41
|
+
*/
|
|
31
42
|
distGlobPatterns?: string[];
|
|
43
|
+
/**
|
|
44
|
+
* whether or not unsupported files (such as assets) should be copied into the dist directory
|
|
45
|
+
*/
|
|
32
46
|
shouldCopyNonSupportedFiles?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* optional. default to "dist".
|
|
49
|
+
* useful when the build pipeline has multiple compiler tasks of the same compiler.
|
|
50
|
+
* e.g. using the same Babel compiler for two different tasks, one for creating "es5" files, and
|
|
51
|
+
* the second for creating "esm". the artifact names would be "es5" and "esm" accordingly.
|
|
52
|
+
*/
|
|
33
53
|
artifactName?: string;
|
|
34
54
|
}
|
|
35
55
|
export interface Compiler extends CompilerOptions {
|
|
56
|
+
/**
|
|
57
|
+
* id of the compiler.
|
|
58
|
+
*/
|
|
36
59
|
id: string;
|
|
60
|
+
/**
|
|
61
|
+
* serialized config of the compiler.
|
|
62
|
+
*/
|
|
37
63
|
displayConfig?(): string;
|
|
64
|
+
/**
|
|
65
|
+
* transpile a single file that gets saved into the workspace, used by `bit compile` and during
|
|
66
|
+
* development
|
|
67
|
+
*/
|
|
38
68
|
transpileFile?: (fileContent: string, params: TranspileFileParams) => TranspileFileOutput;
|
|
69
|
+
/**
|
|
70
|
+
* transpile all the files of a component, use this when you can't use `transpileFile`
|
|
71
|
+
*/
|
|
39
72
|
transpileComponent?: (params: TranspileComponentParams) => Promise<void>;
|
|
73
|
+
/**
|
|
74
|
+
* compile components inside isolated capsules. this being used during tag for the release.
|
|
75
|
+
* meaning, the final package of the component has the dists generated by this method.
|
|
76
|
+
*/
|
|
40
77
|
build(context: BuildContext): Promise<BuiltTaskResult>;
|
|
78
|
+
/**
|
|
79
|
+
* given a source file, return its parallel in the dists. e.g. "index.ts" => "dist/index.js"
|
|
80
|
+
* both, the return path and the given path are relative paths.
|
|
81
|
+
*/
|
|
41
82
|
getDistPathBySrcPath(srcPath: string): string;
|
|
83
|
+
/**
|
|
84
|
+
* given a component, returns the path to the source folder to use for the preview, uses the one
|
|
85
|
+
* in node_modules by default
|
|
86
|
+
*/
|
|
42
87
|
getPreviewComponentRootPath?(component: Component): string;
|
|
88
|
+
/**
|
|
89
|
+
* only supported files matching get compiled. others, are copied to the dist dir.
|
|
90
|
+
*/
|
|
43
91
|
isFileSupported(filePath: string): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* sugar to create a Compiler task via the concrete compiler
|
|
94
|
+
*/
|
|
44
95
|
createTask?(name?: string): BuildTask;
|
|
96
|
+
/**
|
|
97
|
+
* run before the build pipeline has started. this is useful when some preparation are needed to
|
|
98
|
+
* be done on all envs before the build starts.
|
|
99
|
+
*/
|
|
45
100
|
preBuild?(context: BuildContext): Promise<void>;
|
|
101
|
+
/**
|
|
102
|
+
* run after the build pipeline completed for all envs. useful for some cleanups
|
|
103
|
+
*/
|
|
46
104
|
postBuild?(context: BuildContext, tasksResults: TaskResultsList): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* returns the version of the current compiler instance (e.g. '4.0.1').
|
|
107
|
+
*/
|
|
47
108
|
version(): string;
|
|
109
|
+
/**
|
|
110
|
+
* returns the display name of the current compiler instance (e.g. 'TypeScript')
|
|
111
|
+
*/
|
|
48
112
|
displayName: string;
|
|
49
113
|
}
|
|
@@ -17,6 +17,11 @@ export declare type BuildResult = {
|
|
|
17
17
|
export declare type CompileOptions = {
|
|
18
18
|
changed?: boolean;
|
|
19
19
|
verbose?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* whether the dist root dir should be deleted before writing new dists.
|
|
22
|
+
* defaults to true for `bit compile` and false everywhere else, such as `bit watch` and `bit
|
|
23
|
+
* start` to avoid webpack "EINTR" error.
|
|
24
|
+
*/
|
|
20
25
|
deleteDistDir?: boolean;
|
|
21
26
|
initiator: CompilationInitiator;
|
|
22
27
|
};
|
|
@@ -55,6 +60,7 @@ export declare class WorkspaceCompiler {
|
|
|
55
60
|
}, id: ComponentID): Promise<boolean>;
|
|
56
61
|
onComponentChange(component: Component, files: string[], initiator?: CompilationInitiator): Promise<SerializableResults>;
|
|
57
62
|
onPreWatch(components: Component[], watchOpts: WatchOptions): Promise<void>;
|
|
58
|
-
compileComponents(componentsIds: string[] | BitId[],
|
|
63
|
+
compileComponents(componentsIds: string[] | BitId[], // when empty, it compiles new+modified (unless options.all is set),
|
|
64
|
+
options: CompileOptions, noThrow?: boolean): Promise<BuildResult[]>;
|
|
59
65
|
private getIdsToCompile;
|
|
60
66
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/compiler",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.558",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/compilation/compiler",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.compilation",
|
|
8
8
|
"name": "compiler",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.558"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@teambit/harmony": "0.2.11",
|
|
@@ -18,18 +18,19 @@
|
|
|
18
18
|
"p-map-series": "2.1.0",
|
|
19
19
|
"@babel/runtime": "7.12.18",
|
|
20
20
|
"core-js": "^3.0.0",
|
|
21
|
-
"@teambit/cli": "0.0.
|
|
22
|
-
"@teambit/logger": "0.0.
|
|
23
|
-
"@teambit/pubsub": "0.0.
|
|
24
|
-
"@teambit/aspect-loader": "0.0.
|
|
25
|
-
"@teambit/builder": "0.0.
|
|
26
|
-
"@teambit/component": "0.0.
|
|
27
|
-
"@teambit/envs": "0.0.
|
|
28
|
-
"@teambit/
|
|
29
|
-
"@teambit/
|
|
30
|
-
"@teambit/
|
|
31
|
-
"@teambit/
|
|
32
|
-
"@teambit/
|
|
21
|
+
"@teambit/cli": "0.0.388",
|
|
22
|
+
"@teambit/logger": "0.0.473",
|
|
23
|
+
"@teambit/pubsub": "0.0.558",
|
|
24
|
+
"@teambit/aspect-loader": "0.0.558",
|
|
25
|
+
"@teambit/builder": "0.0.558",
|
|
26
|
+
"@teambit/component": "0.0.558",
|
|
27
|
+
"@teambit/envs": "0.0.558",
|
|
28
|
+
"@teambit/generator": "0.0.558",
|
|
29
|
+
"@teambit/legacy-bit-id": "0.0.377",
|
|
30
|
+
"@teambit/ui": "0.0.558",
|
|
31
|
+
"@teambit/workspace": "0.0.558",
|
|
32
|
+
"@teambit/isolator": "0.0.558",
|
|
33
|
+
"@teambit/bit-error": "0.0.374"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"@types/react": "^17.0.8",
|
|
@@ -39,10 +40,10 @@
|
|
|
39
40
|
"@types/jest": "^26.0.0",
|
|
40
41
|
"@types/react-dom": "^17.0.5",
|
|
41
42
|
"@types/node": "12.20.4",
|
|
42
|
-
"@teambit/compilation.aspect-docs.compiler": "0.0.
|
|
43
|
+
"@teambit/compilation.aspect-docs.compiler": "0.0.107"
|
|
43
44
|
},
|
|
44
45
|
"peerDependencies": {
|
|
45
|
-
"@teambit/legacy": "1.0.
|
|
46
|
+
"@teambit/legacy": "1.0.174",
|
|
46
47
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
47
48
|
"react": "^16.8.0 || ^17.0.0"
|
|
48
49
|
},
|
|
@@ -70,12 +71,20 @@
|
|
|
70
71
|
"react": "-"
|
|
71
72
|
},
|
|
72
73
|
"peerDependencies": {
|
|
73
|
-
"@teambit/legacy": "1.0.
|
|
74
|
+
"@teambit/legacy": "1.0.174",
|
|
74
75
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
75
76
|
"react": "^16.8.0 || ^17.0.0"
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
},
|
|
80
|
+
"files": [
|
|
81
|
+
"dist",
|
|
82
|
+
"!dist/tsconfig.tsbuildinfo",
|
|
83
|
+
"README.md",
|
|
84
|
+
"README.mdx",
|
|
85
|
+
"*.js",
|
|
86
|
+
"*.json"
|
|
87
|
+
],
|
|
79
88
|
"private": false,
|
|
80
89
|
"engines": {
|
|
81
90
|
"node": ">=12.22.0"
|