@teambit/compiler 0.0.555 → 0.0.559
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 +4 -2
- package/dist/compiler.main.runtime.js +23 -2
- package/dist/compiler.main.runtime.js.map +1 -1
- 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/package.json +33 -17
- package/tsconfig.json +1 -1
- package/compiler.aspect.ts +0 -5
- package/compiler.cmd.ts +0 -115
- 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.555.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
package/compiler.main.runtime.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import AspectLoaderAspect, { AspectLoaderMain } from '@teambit/aspect-loader';
|
|
2
|
-
import { BuilderAspect, BuilderMain } from '@teambit/builder';
|
|
3
|
-
import { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';
|
|
4
|
-
import { Component } from '@teambit/component';
|
|
5
|
-
import { EnvsAspect, EnvsMain } from '@teambit/envs';
|
|
6
|
-
import { BitId } from '@teambit/legacy-bit-id';
|
|
7
|
-
|
|
8
|
-
import ManyComponentsWriter from '@teambit/legacy/dist/consumer/component-ops/many-components-writer';
|
|
9
|
-
import { LoggerAspect, LoggerMain } from '@teambit/logger';
|
|
10
|
-
import { PubsubAspect, PubsubMain } from '@teambit/pubsub';
|
|
11
|
-
import UIAspect, { UiMain } from '@teambit/ui';
|
|
12
|
-
import { Workspace, WorkspaceAspect } from '@teambit/workspace';
|
|
13
|
-
import { CompilerAspect } from './compiler.aspect';
|
|
14
|
-
import { CompileCmd } from './compiler.cmd';
|
|
15
|
-
import { CompilerService } from './compiler.service';
|
|
16
|
-
import { CompilerTask } from './compiler.task';
|
|
17
|
-
import { DistArtifact } from './dist-artifact';
|
|
18
|
-
import { DistArtifactNotFound } from './exceptions';
|
|
19
|
-
import { CompilationInitiator, Compiler } from './types';
|
|
20
|
-
import { CompileOptions, WorkspaceCompiler } from './workspace-compiler';
|
|
21
|
-
|
|
22
|
-
export class CompilerMain {
|
|
23
|
-
constructor(
|
|
24
|
-
private pubsub: PubsubMain,
|
|
25
|
-
private workspaceCompiler: WorkspaceCompiler,
|
|
26
|
-
private envs: EnvsMain,
|
|
27
|
-
private builder: BuilderMain
|
|
28
|
-
) {}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Run compilation on `bit new` and when new components are imported
|
|
32
|
-
*/
|
|
33
|
-
compileOnWorkspace(
|
|
34
|
-
componentsIds: string[] | BitId[] = [], // when empty, it compiles all
|
|
35
|
-
options: CompileOptions = { initiator: CompilationInitiator.ComponentAdded }
|
|
36
|
-
) {
|
|
37
|
-
return this.workspaceCompiler.compileComponents(componentsIds, options);
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* API to create a new compiler task, it facilitates the usage of multiple compilers.
|
|
41
|
-
* with this method you can create any number of compilers and add them to the buildPipeline.
|
|
42
|
-
*/
|
|
43
|
-
createTask(name: string, compiler: Compiler): CompilerTask {
|
|
44
|
-
return new CompilerTask(CompilerAspect.id, name, compiler);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* find the compiler configured on the workspace and ask for the dist path.
|
|
49
|
-
*/
|
|
50
|
-
getDistPathBySrcPath(component: Component, srcPath: string): string | null {
|
|
51
|
-
const environment = this.envs.getEnv(component).env;
|
|
52
|
-
const compilerInstance = environment.getCompiler?.();
|
|
53
|
-
if (!compilerInstance) return null;
|
|
54
|
-
return compilerInstance.getDistPathBySrcPath(srcPath);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async getDistsFiles(component: Component): Promise<DistArtifact> {
|
|
58
|
-
const artifacts = await this.builder.getArtifactsVinylByExtension(component, CompilerAspect.id);
|
|
59
|
-
if (!artifacts.length) throw new DistArtifactNotFound(component.id);
|
|
60
|
-
|
|
61
|
-
return new DistArtifact(artifacts);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
static runtime = MainRuntime;
|
|
65
|
-
|
|
66
|
-
static dependencies = [
|
|
67
|
-
CLIAspect,
|
|
68
|
-
WorkspaceAspect,
|
|
69
|
-
EnvsAspect,
|
|
70
|
-
LoggerAspect,
|
|
71
|
-
PubsubAspect,
|
|
72
|
-
AspectLoaderAspect,
|
|
73
|
-
BuilderAspect,
|
|
74
|
-
UIAspect,
|
|
75
|
-
];
|
|
76
|
-
|
|
77
|
-
static async provider([cli, workspace, envs, loggerMain, pubsub, aspectLoader, builder, ui]: [
|
|
78
|
-
CLIMain,
|
|
79
|
-
Workspace,
|
|
80
|
-
EnvsMain,
|
|
81
|
-
LoggerMain,
|
|
82
|
-
PubsubMain,
|
|
83
|
-
AspectLoaderMain,
|
|
84
|
-
BuilderMain,
|
|
85
|
-
UiMain
|
|
86
|
-
]) {
|
|
87
|
-
const logger = loggerMain.createLogger(CompilerAspect.id);
|
|
88
|
-
const workspaceCompiler = new WorkspaceCompiler(workspace, envs, pubsub, aspectLoader, ui, logger);
|
|
89
|
-
envs.registerService(new CompilerService());
|
|
90
|
-
const compilerMain = new CompilerMain(pubsub, workspaceCompiler, envs, builder);
|
|
91
|
-
cli.register(new CompileCmd(workspaceCompiler, logger, pubsub));
|
|
92
|
-
|
|
93
|
-
ManyComponentsWriter.externalCompiler = compilerMain.compileOnWorkspace.bind(compilerMain);
|
|
94
|
-
|
|
95
|
-
return compilerMain;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
CompilerAspect.addRuntime(CompilerMain);
|
package/compiler.service.tsx
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Text, Newline } from 'ink';
|
|
3
|
-
import { EnvService, EnvDefinition } from '@teambit/envs';
|
|
4
|
-
import highlight from 'cli-highlight';
|
|
5
|
-
|
|
6
|
-
export type CompilerDescriptor = {
|
|
7
|
-
id: string;
|
|
8
|
-
icon?: string;
|
|
9
|
-
config?: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export class CompilerService implements EnvService<{}, CompilerDescriptor> {
|
|
13
|
-
name = 'Compile';
|
|
14
|
-
|
|
15
|
-
render(env: EnvDefinition) {
|
|
16
|
-
const descriptor = this.getDescriptor(env);
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<Text key={descriptor?.id}>
|
|
20
|
-
<Text color="cyan">configured compiler: </Text>
|
|
21
|
-
<Text>
|
|
22
|
-
{descriptor?.id} ({descriptor?.displayName} @ {descriptor?.version})
|
|
23
|
-
</Text>
|
|
24
|
-
<Newline />
|
|
25
|
-
<Text color="cyan">compiler config:</Text>
|
|
26
|
-
<Newline />
|
|
27
|
-
<Text>
|
|
28
|
-
{descriptor?.config && highlight(descriptor?.config, { language: 'javascript', ignoreIllegals: true })}
|
|
29
|
-
</Text>
|
|
30
|
-
<Newline />
|
|
31
|
-
</Text>
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
getDescriptor(env: EnvDefinition) {
|
|
36
|
-
if (!env.env.getCompiler) return undefined;
|
|
37
|
-
const compiler = env.env.getCompiler();
|
|
38
|
-
|
|
39
|
-
return {
|
|
40
|
-
id: compiler.id,
|
|
41
|
-
icon: compiler.icon,
|
|
42
|
-
config: compiler.displayConfig ? compiler.displayConfig() : undefined,
|
|
43
|
-
version: compiler.version ? compiler.version() : '?',
|
|
44
|
-
displayName: compiler.displayName ? compiler.displayName : '?',
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
}
|
package/compiler.task.ts
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { BuildContext, BuiltTaskResult, BuildTask, TaskResultsList } from '@teambit/builder';
|
|
2
|
-
import { Capsule } from '@teambit/isolator';
|
|
3
|
-
import fs from 'fs-extra';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
|
|
6
|
-
import { Compiler } from './types';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* compiler build task. Allows to compile components during component build.
|
|
10
|
-
*/
|
|
11
|
-
export class CompilerTask implements BuildTask {
|
|
12
|
-
readonly description = 'compile components';
|
|
13
|
-
constructor(readonly aspectId: string, readonly name: string, private compilerInstance: Compiler) {
|
|
14
|
-
if (compilerInstance.artifactName) {
|
|
15
|
-
this.description += ` for artifact ${compilerInstance.artifactName}`;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async preBuild(context: BuildContext) {
|
|
20
|
-
await Promise.all(
|
|
21
|
-
context.capsuleNetwork.seedersCapsules.map((capsule) =>
|
|
22
|
-
this.copyNonSupportedFiles(capsule, this.compilerInstance)
|
|
23
|
-
)
|
|
24
|
-
);
|
|
25
|
-
if (!this.compilerInstance.preBuild) return;
|
|
26
|
-
await this.compilerInstance.preBuild(context);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async execute(context: BuildContext): Promise<BuiltTaskResult> {
|
|
30
|
-
const buildResults = await this.compilerInstance.build(context);
|
|
31
|
-
return buildResults;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async postBuild?(context: BuildContext, tasksResults: TaskResultsList): Promise<void> {
|
|
35
|
-
if (!this.compilerInstance.postBuild) return;
|
|
36
|
-
await this.compilerInstance.postBuild(context, tasksResults);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async copyNonSupportedFiles(capsule: Capsule, compiler: Compiler) {
|
|
40
|
-
if (!compiler.shouldCopyNonSupportedFiles) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const component = capsule.component;
|
|
44
|
-
await Promise.all(
|
|
45
|
-
component.filesystem.files.map(async (file) => {
|
|
46
|
-
if (compiler.isFileSupported(file.path)) return;
|
|
47
|
-
const content = file.contents;
|
|
48
|
-
await fs.outputFile(path.join(capsule.path, compiler.distDir, file.relative), content);
|
|
49
|
-
})
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
}
|
package/dist-artifact.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';
|
|
2
|
-
import { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';
|
|
3
|
-
|
|
4
|
-
export class DistArtifact {
|
|
5
|
-
constructor(private artifacts: AbstractVinyl[]) {}
|
|
6
|
-
|
|
7
|
-
getFile(path: string) {
|
|
8
|
-
return this.artifacts.find((file) => {
|
|
9
|
-
return pathNormalizeToLinux(file.relative) === path;
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
}
|
package/events/compiler-error.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-classes-per-file */
|
|
2
|
-
import { BitBaseEvent } from '@teambit/pubsub';
|
|
3
|
-
|
|
4
|
-
class CompilerErrorEventData {
|
|
5
|
-
constructor(readonly error: any) {}
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export class CompilerErrorEvent extends BitBaseEvent<CompilerErrorEventData> {
|
|
9
|
-
static readonly TYPE = 'compiler-error';
|
|
10
|
-
|
|
11
|
-
constructor(readonly error, readonly timestamp = Date.now()) {
|
|
12
|
-
super(CompilerErrorEvent.TYPE, '0.0.1', timestamp, new CompilerErrorEventData(error));
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-classes-per-file */
|
|
2
|
-
import { BitBaseEvent } from '@teambit/pubsub';
|
|
3
|
-
import type ConsumerComponent from '@teambit/legacy/dist/consumer/component';
|
|
4
|
-
import { CompileError } from '../workspace-compiler';
|
|
5
|
-
|
|
6
|
-
class ComponentCompilationOnDoneEventData {
|
|
7
|
-
constructor(
|
|
8
|
-
readonly errors: Array<CompileError>,
|
|
9
|
-
readonly component: ConsumerComponent,
|
|
10
|
-
readonly buildResults: string[]
|
|
11
|
-
) {}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export class ComponentCompilationOnDoneEvent extends BitBaseEvent<ComponentCompilationOnDoneEventData> {
|
|
15
|
-
static readonly TYPE = 'component-compilation-on-done';
|
|
16
|
-
|
|
17
|
-
constructor(
|
|
18
|
-
readonly errors: Array<CompileError>,
|
|
19
|
-
readonly component: ConsumerComponent,
|
|
20
|
-
readonly buildResults: string[],
|
|
21
|
-
readonly timestamp = Date.now()
|
|
22
|
-
) {
|
|
23
|
-
super(
|
|
24
|
-
ComponentCompilationOnDoneEvent.TYPE,
|
|
25
|
-
'0.0.1',
|
|
26
|
-
timestamp,
|
|
27
|
-
new ComponentCompilationOnDoneEventData(errors, component, buildResults)
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
}
|
package/events/index.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ComponentID } from '@teambit/component';
|
|
2
|
-
import { BitError } from '@teambit/bit-error';
|
|
3
|
-
|
|
4
|
-
export class DistArtifactNotFound extends BitError {
|
|
5
|
-
constructor(readonly componentId: ComponentID) {
|
|
6
|
-
super(`dist artifact for component ${componentId.toString()} was not found`);
|
|
7
|
-
}
|
|
8
|
-
}
|
package/exceptions/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { DistArtifactNotFound } from './dist-artifact-not-found';
|
package/index.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type { CompilerMain } from './compiler.main.runtime';
|
|
2
|
-
export { CompilerAspect } from './compiler.aspect';
|
|
3
|
-
export {
|
|
4
|
-
Compiler,
|
|
5
|
-
CompilerOptions,
|
|
6
|
-
CompilationInitiator,
|
|
7
|
-
TranspileFileOutput,
|
|
8
|
-
TranspileFileParams,
|
|
9
|
-
TranspileComponentParams,
|
|
10
|
-
} from './types';
|
|
11
|
-
export * from './events';
|
package/output-formatter.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk';
|
|
2
|
-
|
|
3
|
-
export const formatCompileResults = (compileResults, verbose) =>
|
|
4
|
-
compileResults
|
|
5
|
-
.map((componentResult) => ({
|
|
6
|
-
componentId: componentResult.component.name,
|
|
7
|
-
files: componentResult.buildResults,
|
|
8
|
-
status: componentResult.errors.length ? 'FAILURE' : 'SUCCESS',
|
|
9
|
-
icon: componentResult.errors.length ? chalk.red('✗') : chalk.green('✔'),
|
|
10
|
-
}))
|
|
11
|
-
.reduce((outputString, result) => {
|
|
12
|
-
outputString += `${result.icon} ${result.status}\t${result.componentId}`;
|
|
13
|
-
if (verbose) {
|
|
14
|
-
outputString += ':';
|
|
15
|
-
outputString += result?.files?.reduce((fileList, file) => `${fileList}\t\t - ${file}\n`, '\n');
|
|
16
|
-
}
|
|
17
|
-
outputString += '\n';
|
|
18
|
-
return outputString;
|
|
19
|
-
}, '');
|
|
Binary file
|
package/types/asset.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
declare module '*.png' {
|
|
2
|
-
const value: any;
|
|
3
|
-
export = value;
|
|
4
|
-
}
|
|
5
|
-
declare module '*.svg' {
|
|
6
|
-
import type { FunctionComponent, SVGProps } from 'react';
|
|
7
|
-
|
|
8
|
-
export const ReactComponent: FunctionComponent<SVGProps<SVGSVGElement> & { title?: string }>;
|
|
9
|
-
const src: string;
|
|
10
|
-
export default src;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// @TODO Gilad
|
|
14
|
-
declare module '*.jpg' {
|
|
15
|
-
const value: any;
|
|
16
|
-
export = value;
|
|
17
|
-
}
|
|
18
|
-
declare module '*.jpeg' {
|
|
19
|
-
const value: any;
|
|
20
|
-
export = value;
|
|
21
|
-
}
|
|
22
|
-
declare module '*.gif' {
|
|
23
|
-
const value: any;
|
|
24
|
-
export = value;
|
|
25
|
-
}
|
|
26
|
-
declare module '*.bmp' {
|
|
27
|
-
const value: any;
|
|
28
|
-
export = value;
|
|
29
|
-
}
|
package/types/style.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
declare module '*.module.css' {
|
|
2
|
-
const classes: { readonly [key: string]: string };
|
|
3
|
-
export default classes;
|
|
4
|
-
}
|
|
5
|
-
declare module '*.module.scss' {
|
|
6
|
-
const classes: { readonly [key: string]: string };
|
|
7
|
-
export default classes;
|
|
8
|
-
}
|
|
9
|
-
declare module '*.module.sass' {
|
|
10
|
-
const classes: { readonly [key: string]: string };
|
|
11
|
-
export default classes;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
declare module '*.module.less' {
|
|
15
|
-
const classes: { readonly [key: string]: string };
|
|
16
|
-
export default classes;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
declare module '*.less' {
|
|
20
|
-
const classes: { readonly [key: string]: string };
|
|
21
|
-
export default classes;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
declare module '*.css' {
|
|
25
|
-
const classes: { readonly [key: string]: string };
|
|
26
|
-
export default classes;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
declare module '*.sass' {
|
|
30
|
-
const classes: { readonly [key: string]: string };
|
|
31
|
-
export default classes;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
declare module '*.scss' {
|
|
35
|
-
const classes: { readonly [key: string]: string };
|
|
36
|
-
export default classes;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
declare module '*.mdx' {
|
|
40
|
-
const component: any;
|
|
41
|
-
export default component;
|
|
42
|
-
}
|
package/types.ts
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { BuildContext, BuildTask, BuiltTaskResult, TaskResultsList } from '@teambit/builder';
|
|
2
|
-
import ConsumerComponent from '@teambit/legacy/dist/consumer/component';
|
|
3
|
-
import type { Component } from '@teambit/component';
|
|
4
|
-
|
|
5
|
-
export type TranspileFileParams = {
|
|
6
|
-
componentDir: string; // absolute path of the component's root directory
|
|
7
|
-
filePath: string; // relative path of the file inside the component directory
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export enum CompilationInitiator {
|
|
11
|
-
CmdReport,
|
|
12
|
-
CmdJson,
|
|
13
|
-
PreStart,
|
|
14
|
-
PreWatch,
|
|
15
|
-
Start,
|
|
16
|
-
ComponentChanged,
|
|
17
|
-
AspectLoadFail,
|
|
18
|
-
ComponentAdded,
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type TranspileComponentParams = {
|
|
22
|
-
component: ConsumerComponent;
|
|
23
|
-
componentDir: string; // absolute path of the component's root directory
|
|
24
|
-
outputDir: string; // absolute path of the component's output directory
|
|
25
|
-
initiator: CompilationInitiator; // origin of the compilation's request
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export type TranspileFileOutput =
|
|
29
|
-
| {
|
|
30
|
-
outputText: string;
|
|
31
|
-
outputPath: string;
|
|
32
|
-
}[]
|
|
33
|
-
| null;
|
|
34
|
-
|
|
35
|
-
export interface CompilerOptions {
|
|
36
|
-
/**
|
|
37
|
-
* name of the compiler.
|
|
38
|
-
*/
|
|
39
|
-
name?: string;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* relative path of the dist directory inside the capsule. e.g. "dist".
|
|
43
|
-
*/
|
|
44
|
-
distDir: string;
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* determines which ones of the generated files will be saved in the bit objects when tagging.
|
|
48
|
-
* e.g. distGlobPatterns = [`${this.distDir}/**`, `!${this.distDir}/tsconfig.tsbuildinfo`];
|
|
49
|
-
* see https://github.com/mrmlnc/fast-glob for the supported glob patters syntax.
|
|
50
|
-
*/
|
|
51
|
-
distGlobPatterns?: string[];
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* whether or not unsupported files (such as assets) should be copied into the dist directory
|
|
55
|
-
*/
|
|
56
|
-
shouldCopyNonSupportedFiles?: boolean;
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* optional. default to "dist".
|
|
60
|
-
* useful when the build pipeline has multiple compiler tasks of the same compiler.
|
|
61
|
-
* e.g. using the same Babel compiler for two different tasks, one for creating "es5" files, and
|
|
62
|
-
* the second for creating "esm". the artifact names would be "es5" and "esm" accordingly.
|
|
63
|
-
*/
|
|
64
|
-
artifactName?: string;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export interface Compiler extends CompilerOptions {
|
|
68
|
-
/**
|
|
69
|
-
* id of the compiler.
|
|
70
|
-
*/
|
|
71
|
-
id: string;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* serialized config of the compiler.
|
|
75
|
-
*/
|
|
76
|
-
displayConfig?(): string;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* transpile a single file that gets saved into the workspace, used by `bit compile` and during
|
|
80
|
-
* development
|
|
81
|
-
*/
|
|
82
|
-
transpileFile?: (fileContent: string, params: TranspileFileParams) => TranspileFileOutput;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* transpile all the files of a component, use this when you can't use `transpileFile`
|
|
86
|
-
*/
|
|
87
|
-
transpileComponent?: (params: TranspileComponentParams) => Promise<void>;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* compile components inside isolated capsules. this being used during tag for the release.
|
|
91
|
-
* meaning, the final package of the component has the dists generated by this method.
|
|
92
|
-
*/
|
|
93
|
-
build(context: BuildContext): Promise<BuiltTaskResult>;
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* given a source file, return its parallel in the dists. e.g. "index.ts" => "dist/index.js"
|
|
97
|
-
* both, the return path and the given path are relative paths.
|
|
98
|
-
*/
|
|
99
|
-
getDistPathBySrcPath(srcPath: string): string;
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* given a component, returns the path to the source folder to use for the preview, uses the one
|
|
103
|
-
* in node_modules by default
|
|
104
|
-
*/
|
|
105
|
-
getPreviewComponentRootPath?(component: Component): string;
|
|
106
|
-
|
|
107
|
-
/**
|
|
108
|
-
* only supported files matching get compiled. others, are copied to the dist dir.
|
|
109
|
-
*/
|
|
110
|
-
isFileSupported(filePath: string): boolean;
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* sugar to create a Compiler task via the concrete compiler
|
|
114
|
-
*/
|
|
115
|
-
createTask?(name?: string): BuildTask;
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* run before the build pipeline has started. this is useful when some preparation are needed to
|
|
119
|
-
* be done on all envs before the build starts.
|
|
120
|
-
*/
|
|
121
|
-
preBuild?(context: BuildContext): Promise<void>;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* run after the build pipeline completed for all envs. useful for some cleanups
|
|
125
|
-
*/
|
|
126
|
-
postBuild?(context: BuildContext, tasksResults: TaskResultsList): Promise<void>;
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* returns the version of the current compiler instance (e.g. '4.0.1').
|
|
130
|
-
*/
|
|
131
|
-
version(): string;
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* returns the display name of the current compiler instance (e.g. 'TypeScript')
|
|
135
|
-
*/
|
|
136
|
-
displayName: string;
|
|
137
|
-
}
|