@teambit/compiler 0.0.800 → 0.0.803
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 +6 -3
- package/dist/compiler.main.runtime.js +17 -6
- package/dist/compiler.main.runtime.js.map +1 -1
- package/dist/compiler.task.d.ts +9 -1
- package/dist/compiler.task.js +32 -1
- package/dist/compiler.task.js.map +1 -1
- package/dist/workspace-compiler.d.ts +7 -3
- package/dist/workspace-compiler.js +49 -33
- package/dist/workspace-compiler.js.map +1 -1
- package/package-tar/teambit-compiler-0.0.803.tgz +0 -0
- package/package.json +17 -15
- package/{preview-1658978882481.js → preview-1659271062546.js} +2 -2
- package/package-tar/teambit-compiler-0.0.800.tgz +0 -0
|
@@ -4,6 +4,7 @@ import { CLIMain } from '@teambit/cli';
|
|
|
4
4
|
import { Component, ComponentID } from '@teambit/component';
|
|
5
5
|
import { EnvsMain } from '@teambit/envs';
|
|
6
6
|
import { BitId } from '@teambit/legacy-bit-id';
|
|
7
|
+
import { DependencyResolverMain } from '@teambit/dependency-resolver';
|
|
7
8
|
import { LoggerMain } from '@teambit/logger';
|
|
8
9
|
import { GeneratorMain } from '@teambit/generator';
|
|
9
10
|
import { PubsubMain } from '@teambit/pubsub';
|
|
@@ -19,7 +20,8 @@ export declare class CompilerMain {
|
|
|
19
20
|
private envs;
|
|
20
21
|
private builder;
|
|
21
22
|
private workspace;
|
|
22
|
-
|
|
23
|
+
private dependencyResolver;
|
|
24
|
+
constructor(pubsub: PubsubMain, workspaceCompiler: WorkspaceCompiler, envs: EnvsMain, builder: BuilderMain, workspace: Workspace, dependencyResolver: DependencyResolverMain);
|
|
23
25
|
/**
|
|
24
26
|
* Run compilation on `bit new` and when new components are imported
|
|
25
27
|
*/
|
|
@@ -48,7 +50,7 @@ export declare class CompilerMain {
|
|
|
48
50
|
addMissingDistsIssue(component: Component): Promise<undefined>;
|
|
49
51
|
static runtime: import("@teambit/harmony").RuntimeDefinition;
|
|
50
52
|
static dependencies: import("@teambit/harmony").Aspect[];
|
|
51
|
-
static provider([cli, workspace, envs, loggerMain, pubsub, aspectLoader, builder, ui, generator]: [
|
|
53
|
+
static provider([cli, workspace, envs, loggerMain, pubsub, aspectLoader, builder, ui, generator, dependencyResolver,]: [
|
|
52
54
|
CLIMain,
|
|
53
55
|
Workspace,
|
|
54
56
|
EnvsMain,
|
|
@@ -57,7 +59,8 @@ export declare class CompilerMain {
|
|
|
57
59
|
AspectLoaderMain,
|
|
58
60
|
BuilderMain,
|
|
59
61
|
UiMain,
|
|
60
|
-
GeneratorMain
|
|
62
|
+
GeneratorMain,
|
|
63
|
+
DependencyResolverMain
|
|
61
64
|
]): Promise<CompilerMain>;
|
|
62
65
|
}
|
|
63
66
|
export default CompilerMain;
|
|
@@ -101,6 +101,16 @@ function _envs() {
|
|
|
101
101
|
return data;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
function _dependencyResolver() {
|
|
105
|
+
const data = require("@teambit/dependency-resolver");
|
|
106
|
+
|
|
107
|
+
_dependencyResolver = function () {
|
|
108
|
+
return data;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
return data;
|
|
112
|
+
}
|
|
113
|
+
|
|
104
114
|
function _manyComponentsWriter() {
|
|
105
115
|
const data = _interopRequireDefault(require("@teambit/legacy/dist/consumer/component-ops/many-components-writer"));
|
|
106
116
|
|
|
@@ -256,12 +266,13 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
256
266
|
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; }
|
|
257
267
|
|
|
258
268
|
class CompilerMain {
|
|
259
|
-
constructor(pubsub, workspaceCompiler, envs, builder, workspace) {
|
|
269
|
+
constructor(pubsub, workspaceCompiler, envs, builder, workspace, dependencyResolver) {
|
|
260
270
|
this.pubsub = pubsub;
|
|
261
271
|
this.workspaceCompiler = workspaceCompiler;
|
|
262
272
|
this.envs = envs;
|
|
263
273
|
this.builder = builder;
|
|
264
274
|
this.workspace = workspace;
|
|
275
|
+
this.dependencyResolver = dependencyResolver;
|
|
265
276
|
}
|
|
266
277
|
/**
|
|
267
278
|
* Run compilation on `bit new` and when new components are imported
|
|
@@ -281,7 +292,7 @@ class CompilerMain {
|
|
|
281
292
|
|
|
282
293
|
|
|
283
294
|
createTask(name, compiler) {
|
|
284
|
-
return new (_compiler4().CompilerTask)(_compiler().CompilerAspect.id, name, compiler);
|
|
295
|
+
return new (_compiler4().CompilerTask)(_compiler().CompilerAspect.id, name, compiler, this.dependencyResolver);
|
|
285
296
|
}
|
|
286
297
|
/**
|
|
287
298
|
* find the compiler configured on the workspace and ask for the dist path.
|
|
@@ -340,11 +351,11 @@ class CompilerMain {
|
|
|
340
351
|
return undefined;
|
|
341
352
|
}
|
|
342
353
|
|
|
343
|
-
static async provider([cli, workspace, envs, loggerMain, pubsub, aspectLoader, builder, ui, generator]) {
|
|
354
|
+
static async provider([cli, workspace, envs, loggerMain, pubsub, aspectLoader, builder, ui, generator, dependencyResolver]) {
|
|
344
355
|
const logger = loggerMain.createLogger(_compiler().CompilerAspect.id);
|
|
345
|
-
const workspaceCompiler = new (_workspaceCompiler().WorkspaceCompiler)(workspace, envs, pubsub, aspectLoader, ui, logger);
|
|
356
|
+
const workspaceCompiler = new (_workspaceCompiler().WorkspaceCompiler)(workspace, envs, pubsub, aspectLoader, ui, logger, dependencyResolver);
|
|
346
357
|
envs.registerService(new (_compiler3().CompilerService)());
|
|
347
|
-
const compilerMain = new CompilerMain(pubsub, workspaceCompiler, envs, builder, workspace);
|
|
358
|
+
const compilerMain = new CompilerMain(pubsub, workspaceCompiler, envs, builder, workspace, dependencyResolver);
|
|
348
359
|
cli.register(new (_compiler2().CompileCmd)(workspaceCompiler, logger, pubsub));
|
|
349
360
|
|
|
350
361
|
if (workspace) {
|
|
@@ -360,7 +371,7 @@ class CompilerMain {
|
|
|
360
371
|
|
|
361
372
|
exports.CompilerMain = CompilerMain;
|
|
362
373
|
(0, _defineProperty2().default)(CompilerMain, "runtime", _cli().MainRuntime);
|
|
363
|
-
(0, _defineProperty2().default)(CompilerMain, "dependencies", [_cli().CLIAspect, _workspace().WorkspaceAspect, _envs().EnvsAspect, _logger().LoggerAspect, _pubsub().PubsubAspect, _aspectLoader().default, _builder().BuilderAspect, _ui().default, _generator().GeneratorAspect]);
|
|
374
|
+
(0, _defineProperty2().default)(CompilerMain, "dependencies", [_cli().CLIAspect, _workspace().WorkspaceAspect, _envs().EnvsAspect, _logger().LoggerAspect, _pubsub().PubsubAspect, _aspectLoader().default, _builder().BuilderAspect, _ui().default, _generator().GeneratorAspect, _dependencyResolver().DependencyResolverAspect]);
|
|
364
375
|
|
|
365
376
|
_compiler().CompilerAspect.addRuntime(CompilerMain);
|
|
366
377
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CompilerMain","constructor","pubsub","workspaceCompiler","envs","builder","workspace","compileOnWorkspace","componentsIds","options","initiator","CompilationInitiator","ComponentAdded","compileComponents","createTask","name","compiler","CompilerTask","CompilerAspect","id","getDistPathBySrcPath","component","srcPath","environment","getEnv","env","compilerInstance","getCompiler","getRelativeDistFolder","getOrCalculateEnv","getDistDir","DEFAULT_DIST_DIRNAME","isDistDirExists","packageDir","getComponentPackagePath","distDir","pathToCheck","path","join","fs","existsSync","getDistsFiles","artifacts","getArtifactsVinylByExtension","length","DistArtifactNotFound","DistArtifact","addMissingDistsIssue","exist","state","issues","getOrCreate","IssuesClasses","MissingDists","data","undefined","provider","cli","loggerMain","aspectLoader","ui","generator","logger","createLogger","WorkspaceCompiler","registerService","CompilerService","compilerMain","register","CompileCmd","onComponentLoad","bind","registerComponentTemplate","compilerTemplate","ManyComponentsWriter","externalCompiler","MainRuntime","CLIAspect","WorkspaceAspect","EnvsAspect","LoggerAspect","PubsubAspect","AspectLoaderAspect","BuilderAspect","UIAspect","GeneratorAspect","addRuntime"],"sources":["compiler.main.runtime.ts"],"sourcesContent":["import * as path from 'path';\nimport fs from 'fs-extra';\nimport AspectLoaderAspect, { AspectLoaderMain } from '@teambit/aspect-loader';\nimport { BuilderAspect, BuilderMain } from '@teambit/builder';\nimport { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { Component, ComponentID } from '@teambit/component';\nimport { DEFAULT_DIST_DIRNAME } from '@teambit/legacy/dist/constants';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { BitId } from '@teambit/legacy-bit-id';\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 private workspace: Workspace\n ) {}\n\n /**\n * Run compilation on `bit new` and when new components are imported\n */\n compileOnWorkspace(\n componentsIds: string[] | BitId[] | ComponentID[] = [], // 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 /**\n * find the compiler configured on the workspace and ask for the dist folder path.\n */\n getRelativeDistFolder(component: Component): string {\n const environment = this.envs.getOrCalculateEnv(component).env;\n const compilerInstance: Compiler | undefined = environment.getCompiler?.();\n if (!compilerInstance || !compilerInstance.getDistDir) return DEFAULT_DIST_DIRNAME;\n return compilerInstance.getDistDir();\n }\n\n /**\n * Check if the dist folder (in the component package under node_modules) exist\n * @param component\n * @returns\n */\n isDistDirExists(component: Component): boolean {\n const packageDir = this.workspace.getComponentPackagePath(component);\n const distDir = this.getRelativeDistFolder(component);\n const pathToCheck = path.join(packageDir, distDir);\n return fs.existsSync(pathToCheck);\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 async addMissingDistsIssue(component: Component) {\n const exist = this.isDistDirExists(component);\n if (!exist) {\n component.state.issues.getOrCreate(IssuesClasses.MissingDists).data = true;\n }\n // we don't want to add any data to the compiler aspect, only to add issues on the component\n return undefined;\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, workspace);\n cli.register(new CompileCmd(workspaceCompiler, logger, pubsub));\n if (workspace) {\n workspace.onComponentLoad(compilerMain.addMissingDistsIssue.bind(compilerMain));\n }\n generator.registerComponentTemplate([compilerTemplate]);\n ManyComponentsWriter.externalCompiler = compilerMain.compileOnWorkspace.bind(compilerMain);\n\n return compilerMain;\n }\n}\n\nCompilerAspect.addRuntime(CompilerMain);\n\nexport default CompilerMain;\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;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAA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AlC,CAAuCJ,YAAvC,CAA1B;IACD;;IACDN,SAAS,CAACW,yBAAV,CAAoC,CAACC,6BAAD,CAApC;IACAC,+BAAA,CAAqBC,gBAArB,GAAwCR,YAAY,CAAC5D,kBAAb,CAAgCgE,IAAhC,CAAqCJ,YAArC,CAAxC;IAEA,OAAOA,YAAP;EACD;;AA/GuB;;;gCAAbnE,Y,aA0EM4E,kB;gCA1EN5E,Y,kBA4EW,CACpB6E,gBADoB,EAEpBC,4BAFoB,EAGpBC,kBAHoB,EAIpBC,sBAJoB,EAKpBC,sBALoB,EAMpBC,uBANoB,EAOpBC,wBAPoB,EAQpBC,aARoB,EASpBC,4BAToB,C;;AAsCxBnE,0BAAA,CAAeoE,UAAf,CAA0BtF,YAA1B;;eAEeA,Y"}
|
|
1
|
+
{"version":3,"names":["CompilerMain","constructor","pubsub","workspaceCompiler","envs","builder","workspace","dependencyResolver","compileOnWorkspace","componentsIds","options","initiator","CompilationInitiator","ComponentAdded","compileComponents","createTask","name","compiler","CompilerTask","CompilerAspect","id","getDistPathBySrcPath","component","srcPath","environment","getEnv","env","compilerInstance","getCompiler","getRelativeDistFolder","getOrCalculateEnv","getDistDir","DEFAULT_DIST_DIRNAME","isDistDirExists","packageDir","getComponentPackagePath","distDir","pathToCheck","path","join","fs","existsSync","getDistsFiles","artifacts","getArtifactsVinylByExtension","length","DistArtifactNotFound","DistArtifact","addMissingDistsIssue","exist","state","issues","getOrCreate","IssuesClasses","MissingDists","data","undefined","provider","cli","loggerMain","aspectLoader","ui","generator","logger","createLogger","WorkspaceCompiler","registerService","CompilerService","compilerMain","register","CompileCmd","onComponentLoad","bind","registerComponentTemplate","compilerTemplate","ManyComponentsWriter","externalCompiler","MainRuntime","CLIAspect","WorkspaceAspect","EnvsAspect","LoggerAspect","PubsubAspect","AspectLoaderAspect","BuilderAspect","UIAspect","GeneratorAspect","DependencyResolverAspect","addRuntime"],"sources":["compiler.main.runtime.ts"],"sourcesContent":["import * as path from 'path';\nimport fs from 'fs-extra';\nimport AspectLoaderAspect, { AspectLoaderMain } from '@teambit/aspect-loader';\nimport { BuilderAspect, BuilderMain } from '@teambit/builder';\nimport { CLIAspect, CLIMain, MainRuntime } from '@teambit/cli';\nimport { IssuesClasses } from '@teambit/component-issues';\nimport { Component, ComponentID } from '@teambit/component';\nimport { DEFAULT_DIST_DIRNAME } from '@teambit/legacy/dist/constants';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';\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 private workspace: Workspace,\n private dependencyResolver: DependencyResolverMain\n ) {}\n\n /**\n * Run compilation on `bit new` and when new components are imported\n */\n compileOnWorkspace(\n componentsIds: string[] | BitId[] | ComponentID[] = [], // 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, this.dependencyResolver);\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 /**\n * find the compiler configured on the workspace and ask for the dist folder path.\n */\n getRelativeDistFolder(component: Component): string {\n const environment = this.envs.getOrCalculateEnv(component).env;\n const compilerInstance: Compiler | undefined = environment.getCompiler?.();\n if (!compilerInstance || !compilerInstance.getDistDir) return DEFAULT_DIST_DIRNAME;\n return compilerInstance.getDistDir();\n }\n\n /**\n * Check if the dist folder (in the component package under node_modules) exist\n * @param component\n * @returns\n */\n isDistDirExists(component: Component): boolean {\n const packageDir = this.workspace.getComponentPackagePath(component);\n const distDir = this.getRelativeDistFolder(component);\n const pathToCheck = path.join(packageDir, distDir);\n return fs.existsSync(pathToCheck);\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 async addMissingDistsIssue(component: Component) {\n const exist = this.isDistDirExists(component);\n if (!exist) {\n component.state.issues.getOrCreate(IssuesClasses.MissingDists).data = true;\n }\n // we don't want to add any data to the compiler aspect, only to add issues on the component\n return undefined;\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 DependencyResolverAspect,\n ];\n\n static async provider([\n cli,\n workspace,\n envs,\n loggerMain,\n pubsub,\n aspectLoader,\n builder,\n ui,\n generator,\n dependencyResolver,\n ]: [\n CLIMain,\n Workspace,\n EnvsMain,\n LoggerMain,\n PubsubMain,\n AspectLoaderMain,\n BuilderMain,\n UiMain,\n GeneratorMain,\n DependencyResolverMain\n ]) {\n const logger = loggerMain.createLogger(CompilerAspect.id);\n const workspaceCompiler = new WorkspaceCompiler(\n workspace,\n envs,\n pubsub,\n aspectLoader,\n ui,\n logger,\n dependencyResolver\n );\n envs.registerService(new CompilerService());\n const compilerMain = new CompilerMain(pubsub, workspaceCompiler, envs, builder, workspace, dependencyResolver);\n cli.register(new CompileCmd(workspaceCompiler, logger, pubsub));\n if (workspace) {\n workspace.onComponentLoad(compilerMain.addMissingDistsIssue.bind(compilerMain));\n }\n generator.registerComponentTemplate([compilerTemplate]);\n ManyComponentsWriter.externalCompiler = compilerMain.compileOnWorkspace.bind(compilerMain);\n\n return compilerMain;\n }\n}\n\nCompilerAspect.addRuntime(CompilerMain);\n\nexport default CompilerMain;\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;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;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;;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;;AACA;EAAA;;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AACW,yBAAV,CAAoC,CAACC,6BAAD,CAApC;IACAC,+BAAA,CAAqBC,gBAArB,GAAwCR,YAAY,CAAC5D,kBAAb,CAAgCgE,IAAhC,CAAqCJ,YAArC,CAAxC;IAEA,OAAOA,YAAP;EACD;;AArIuB;;;gCAAbpE,Y,aA2EM6E,kB;gCA3EN7E,Y,kBA6EW,CACpB8E,gBADoB,EAEpBC,4BAFoB,EAGpBC,kBAHoB,EAIpBC,sBAJoB,EAKpBC,sBALoB,EAMpBC,uBANoB,EAOpBC,wBAPoB,EAQpBC,aARoB,EASpBC,4BAToB,EAUpBC,8CAVoB,C;;AA2DxBpE,0BAAA,CAAeqE,UAAf,CAA0BxF,YAA1B;;eAEeA,Y"}
|
package/dist/compiler.task.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BuildContext, BuiltTaskResult, BuildTask, TaskResultsList } from '@teambit/builder';
|
|
2
2
|
import { Capsule } from '@teambit/isolator';
|
|
3
|
+
import { DependencyResolverMain } from '@teambit/dependency-resolver';
|
|
3
4
|
import { Compiler } from './types';
|
|
4
5
|
/**
|
|
5
6
|
* compiler build task. Allows to compile components during component build.
|
|
@@ -8,10 +9,17 @@ export declare class CompilerTask implements BuildTask {
|
|
|
8
9
|
readonly aspectId: string;
|
|
9
10
|
readonly name: string;
|
|
10
11
|
private compilerInstance;
|
|
12
|
+
private dependencyResolver;
|
|
11
13
|
readonly description = "compile components";
|
|
12
|
-
constructor(aspectId: string, name: string, compilerInstance: Compiler);
|
|
14
|
+
constructor(aspectId: string, name: string, compilerInstance: Compiler, dependencyResolver: DependencyResolverMain);
|
|
13
15
|
preBuild(context: BuildContext): Promise<void>;
|
|
14
16
|
execute(context: BuildContext): Promise<BuiltTaskResult>;
|
|
17
|
+
/**
|
|
18
|
+
* This function hard links the compiled artifacts to the `node_modules` of other component capsules.
|
|
19
|
+
* For instance, if we have a `button` component that is a dependency of the `card` component,
|
|
20
|
+
* then the `dist` folder of the `button` component will be copied to `<card_capsule>/node_modules/button/dist`.
|
|
21
|
+
*/
|
|
22
|
+
private _hardLinkBuildArtifactsOnCapsules;
|
|
15
23
|
postBuild?(context: BuildContext, tasksResults: TaskResultsList): Promise<void>;
|
|
16
24
|
copyNonSupportedFiles(capsule: Capsule, compiler: Compiler): Promise<void>;
|
|
17
25
|
}
|
package/dist/compiler.task.js
CHANGED
|
@@ -8,6 +8,10 @@ require("core-js/modules/es.array.iterator.js");
|
|
|
8
8
|
|
|
9
9
|
require("core-js/modules/es.promise.js");
|
|
10
10
|
|
|
11
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
12
|
+
|
|
13
|
+
require("core-js/modules/es.string.replace.js");
|
|
14
|
+
|
|
11
15
|
Object.defineProperty(exports, "__esModule", {
|
|
12
16
|
value: true
|
|
13
17
|
});
|
|
@@ -23,6 +27,16 @@ function _defineProperty2() {
|
|
|
23
27
|
return data;
|
|
24
28
|
}
|
|
25
29
|
|
|
30
|
+
function _toolboxFs() {
|
|
31
|
+
const data = require("@teambit/toolbox.fs.hard-link-directory");
|
|
32
|
+
|
|
33
|
+
_toolboxFs = function () {
|
|
34
|
+
return data;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return data;
|
|
38
|
+
}
|
|
39
|
+
|
|
26
40
|
function _fsExtra() {
|
|
27
41
|
const data = _interopRequireDefault(require("fs-extra"));
|
|
28
42
|
|
|
@@ -47,10 +61,11 @@ function _path() {
|
|
|
47
61
|
* compiler build task. Allows to compile components during component build.
|
|
48
62
|
*/
|
|
49
63
|
class CompilerTask {
|
|
50
|
-
constructor(aspectId, name, compilerInstance) {
|
|
64
|
+
constructor(aspectId, name, compilerInstance, dependencyResolver) {
|
|
51
65
|
this.aspectId = aspectId;
|
|
52
66
|
this.name = name;
|
|
53
67
|
this.compilerInstance = compilerInstance;
|
|
68
|
+
this.dependencyResolver = dependencyResolver;
|
|
54
69
|
(0, _defineProperty2().default)(this, "description", 'compile components');
|
|
55
70
|
|
|
56
71
|
if (compilerInstance.artifactName) {
|
|
@@ -66,8 +81,24 @@ class CompilerTask {
|
|
|
66
81
|
|
|
67
82
|
async execute(context) {
|
|
68
83
|
const buildResults = await this.compilerInstance.build(context);
|
|
84
|
+
await this._hardLinkBuildArtifactsOnCapsules(context);
|
|
69
85
|
return buildResults;
|
|
70
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* This function hard links the compiled artifacts to the `node_modules` of other component capsules.
|
|
89
|
+
* For instance, if we have a `button` component that is a dependency of the `card` component,
|
|
90
|
+
* then the `dist` folder of the `button` component will be copied to `<card_capsule>/node_modules/button/dist`.
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
async _hardLinkBuildArtifactsOnCapsules(context) {
|
|
95
|
+
await Promise.all(context.capsuleNetwork.seedersCapsules.map(async capsule => {
|
|
96
|
+
const relCompDir = _path().default.relative(context.capsuleNetwork.capsulesRootDir, capsule.path).replace(/\\/g, '/');
|
|
97
|
+
|
|
98
|
+
const injectedDirs = await this.dependencyResolver.getInjectedDirs(context.capsuleNetwork.capsulesRootDir, relCompDir, this.dependencyResolver.getPackageName(capsule.component));
|
|
99
|
+
return (0, _toolboxFs().hardLinkDirectory)(capsule.path, injectedDirs.map(injectedDir => _path().default.join(context.capsuleNetwork.capsulesRootDir, injectedDir)));
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
71
102
|
|
|
72
103
|
async postBuild(context, tasksResults) {
|
|
73
104
|
if (!this.compilerInstance.postBuild) return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CompilerTask","constructor","aspectId","name","compilerInstance","artifactName","description","preBuild","context","Promise","all","capsuleNetwork","seedersCapsules","map","capsule","copyNonSupportedFiles","execute","buildResults","build","postBuild","tasksResults","compiler","shouldCopyNonSupportedFiles","
|
|
1
|
+
{"version":3,"names":["CompilerTask","constructor","aspectId","name","compilerInstance","dependencyResolver","artifactName","description","preBuild","context","Promise","all","capsuleNetwork","seedersCapsules","map","capsule","copyNonSupportedFiles","execute","buildResults","build","_hardLinkBuildArtifactsOnCapsules","relCompDir","path","relative","capsulesRootDir","replace","injectedDirs","getInjectedDirs","getPackageName","component","hardLinkDirectory","injectedDir","join","postBuild","tasksResults","compiler","shouldCopyNonSupportedFiles","filesystem","files","file","isFileSupported","content","contents","fs","outputFile","distDir"],"sources":["compiler.task.ts"],"sourcesContent":["import { BuildContext, BuiltTaskResult, BuildTask, TaskResultsList } from '@teambit/builder';\nimport { Capsule } from '@teambit/isolator';\nimport { hardLinkDirectory } from '@teambit/toolbox.fs.hard-link-directory';\nimport { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport fs from 'fs-extra';\nimport path from 'path';\n\nimport { Compiler } from './types';\n\n/**\n * compiler build task. Allows to compile components during component build.\n */\nexport class CompilerTask implements BuildTask {\n readonly description = 'compile components';\n constructor(\n readonly aspectId: string,\n readonly name: string,\n private compilerInstance: Compiler,\n private dependencyResolver: DependencyResolverMain\n ) {\n if (compilerInstance.artifactName) {\n this.description += ` for artifact ${compilerInstance.artifactName}`;\n }\n }\n\n async preBuild(context: BuildContext) {\n await Promise.all(\n context.capsuleNetwork.seedersCapsules.map((capsule) =>\n this.copyNonSupportedFiles(capsule, this.compilerInstance)\n )\n );\n if (!this.compilerInstance.preBuild) return;\n await this.compilerInstance.preBuild(context);\n }\n\n async execute(context: BuildContext): Promise<BuiltTaskResult> {\n const buildResults = await this.compilerInstance.build(context);\n await this._hardLinkBuildArtifactsOnCapsules(context);\n return buildResults;\n }\n\n /**\n * This function hard links the compiled artifacts to the `node_modules` of other component capsules.\n * For instance, if we have a `button` component that is a dependency of the `card` component,\n * then the `dist` folder of the `button` component will be copied to `<card_capsule>/node_modules/button/dist`.\n */\n private async _hardLinkBuildArtifactsOnCapsules(context: BuildContext): Promise<void> {\n await Promise.all(\n context.capsuleNetwork.seedersCapsules.map(async (capsule) => {\n const relCompDir = path.relative(context.capsuleNetwork.capsulesRootDir, capsule.path).replace(/\\\\/g, '/');\n const injectedDirs = await this.dependencyResolver.getInjectedDirs(\n context.capsuleNetwork.capsulesRootDir,\n relCompDir,\n this.dependencyResolver.getPackageName(capsule.component)\n );\n return hardLinkDirectory(\n capsule.path,\n injectedDirs.map((injectedDir) => path.join(context.capsuleNetwork.capsulesRootDir, injectedDir))\n );\n })\n );\n }\n\n async postBuild?(context: BuildContext, tasksResults: TaskResultsList): Promise<void> {\n if (!this.compilerInstance.postBuild) return;\n await this.compilerInstance.postBuild(context, tasksResults);\n }\n\n async copyNonSupportedFiles(capsule: Capsule, compiler: Compiler) {\n if (!compiler.shouldCopyNonSupportedFiles) {\n return;\n }\n const component = capsule.component;\n await Promise.all(\n component.filesystem.files.map(async (file) => {\n if (compiler.isFileSupported(file.path)) return;\n const content = file.contents;\n await fs.outputFile(path.join(capsule.path, compiler.distDir, file.relative), content);\n })\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIA;AACA;AACA;AACO,MAAMA,YAAN,CAAwC;EAE7CC,WAAW,CACAC,QADA,EAEAC,IAFA,EAGDC,gBAHC,EAIDC,kBAJC,EAKT;IAAA,KAJSH,QAIT,GAJSA,QAIT;IAAA,KAHSC,IAGT,GAHSA,IAGT;IAAA,KAFQC,gBAER,GAFQA,gBAER;IAAA,KADQC,kBACR,GADQA,kBACR;IAAA,qDANqB,oBAMrB;;IACA,IAAID,gBAAgB,CAACE,YAArB,EAAmC;MACjC,KAAKC,WAAL,IAAqB,iBAAgBH,gBAAgB,CAACE,YAAa,EAAnE;IACD;EACF;;EAEa,MAARE,QAAQ,CAACC,OAAD,EAAwB;IACpC,MAAMC,OAAO,CAACC,GAAR,CACJF,OAAO,CAACG,cAAR,CAAuBC,eAAvB,CAAuCC,GAAvC,CAA4CC,OAAD,IACzC,KAAKC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K9B,gBAAL,CAAsB6B,SAA3B,EAAsC;IACtC,MAAM,KAAK7B,gBAAL,CAAsB6B,SAAtB,CAAgCxB,OAAhC,EAAyCyB,YAAzC,CAAN;EACD;;EAE0B,MAArBlB,qBAAqB,CAACD,OAAD,EAAmBoB,QAAnB,EAAuC;IAChE,IAAI,CAACA,QAAQ,CAACC,2BAAd,EAA2C;MACzC;IACD;;IACD,MAAMP,SAAS,GAAGd,OAAO,CAACc,SAA1B;IACA,MAAMnB,OAAO,CAACC,GAAR,CACJkB,SAAS,CAACQ,UAAV,CAAqBC,KAArB,CAA2BxB,GAA3B,CAA+B,MAAOyB,IAAP,IAAgB;MAC7C,IAAIJ,QAAQ,CAACK,eAAT,CAAyBD,IAAI,CAACjB,IAA9B,CAAJ,EAAyC;MACzC,MAAMmB,OAAO,GAAGF,IAAI,CAACG,QAArB;MACA,MAAMC,kBAAA,CAAGC,UAAH,CAActB,eAAA,CAAKU,IAAL,CAAUjB,OAAO,CAACO,IAAlB,EAAwBa,QAAQ,CAACU,OAAjC,EAA0CN,IAAI,CAAChB,QAA/C,CAAd,EAAwEkB,OAAxE,CAAN;IACD,CAJD,CADI,CAAN;EAOD;;AApE4C"}
|
|
@@ -6,6 +6,7 @@ import { BitId } from '@teambit/legacy-bit-id';
|
|
|
6
6
|
import { Logger } from '@teambit/logger';
|
|
7
7
|
import { Dist } from '@teambit/legacy/dist/consumer/component/sources';
|
|
8
8
|
import { AspectLoaderMain } from '@teambit/aspect-loader';
|
|
9
|
+
import { DependencyResolverMain } from '@teambit/dependency-resolver';
|
|
9
10
|
import { UiMain } from '@teambit/ui';
|
|
10
11
|
import type { PreStartOpts } from '@teambit/ui';
|
|
11
12
|
import { Compiler, CompilationInitiator } from './types';
|
|
@@ -35,12 +36,14 @@ export declare class ComponentCompiler {
|
|
|
35
36
|
private compilerInstance;
|
|
36
37
|
private compilerId;
|
|
37
38
|
private logger;
|
|
39
|
+
private dependencyResolver;
|
|
38
40
|
private dists;
|
|
39
41
|
private compileErrors;
|
|
40
|
-
constructor(pubsub: PubsubMain, workspace: Workspace, component: Component, compilerInstance: Compiler, compilerId: string, logger: Logger, dists?: Dist[], compileErrors?: CompileError[]);
|
|
42
|
+
constructor(pubsub: PubsubMain, workspace: Workspace, component: Component, compilerInstance: Compiler, compilerId: string, logger: Logger, dependencyResolver: DependencyResolverMain, dists?: Dist[], compileErrors?: CompileError[]);
|
|
41
43
|
compile(noThrow: boolean | undefined, options: CompileOptions): Promise<BuildResult>;
|
|
42
44
|
private throwOnCompileErrors;
|
|
43
|
-
private
|
|
45
|
+
private distDirs;
|
|
46
|
+
private getInjectedDirs;
|
|
44
47
|
private get componentDir();
|
|
45
48
|
private compileOneFile;
|
|
46
49
|
private compileAllFiles;
|
|
@@ -52,7 +55,8 @@ export declare class WorkspaceCompiler {
|
|
|
52
55
|
private aspectLoader;
|
|
53
56
|
private ui;
|
|
54
57
|
private logger;
|
|
55
|
-
|
|
58
|
+
private dependencyResolver;
|
|
59
|
+
constructor(workspace: Workspace, envs: EnvsMain, pubsub: PubsubMain, aspectLoader: AspectLoaderMain, ui: UiMain, logger: Logger, dependencyResolver: DependencyResolverMain);
|
|
56
60
|
onPreStart(preStartOpts: PreStartOpts): Promise<void>;
|
|
57
61
|
onAspectLoadFail(err: Error & {
|
|
58
62
|
code?: string;
|
|
@@ -133,13 +133,14 @@ function _types() {
|
|
|
133
133
|
|
|
134
134
|
/* eslint-disable max-classes-per-file */
|
|
135
135
|
class ComponentCompiler {
|
|
136
|
-
constructor(pubsub, workspace, component, compilerInstance, compilerId, logger, dists = [], compileErrors = []) {
|
|
136
|
+
constructor(pubsub, workspace, component, compilerInstance, compilerId, logger, dependencyResolver, dists = [], compileErrors = []) {
|
|
137
137
|
this.pubsub = pubsub;
|
|
138
138
|
this.workspace = workspace;
|
|
139
139
|
this.component = component;
|
|
140
140
|
this.compilerInstance = compilerInstance;
|
|
141
141
|
this.compilerId = compilerId;
|
|
142
142
|
this.logger = logger;
|
|
143
|
+
this.dependencyResolver = dependencyResolver;
|
|
143
144
|
this.dists = dists;
|
|
144
145
|
this.compileErrors = compileErrors;
|
|
145
146
|
}
|
|
@@ -152,7 +153,11 @@ class ComponentCompiler {
|
|
|
152
153
|
|
|
153
154
|
if (deleteDistDir) {
|
|
154
155
|
dataToPersist = new (_dataToPersist().default)();
|
|
155
|
-
|
|
156
|
+
|
|
157
|
+
for (const distDir of await this.distDirs()) {
|
|
158
|
+
dataToPersist.removePath(new (_removePath().default)(distDir));
|
|
159
|
+
}
|
|
160
|
+
|
|
156
161
|
dataToPersist.addBasePath(this.workspace.path);
|
|
157
162
|
await dataToPersist.persistAllToFS();
|
|
158
163
|
}
|
|
@@ -209,7 +214,7 @@ ${this.compileErrors.map(formatError).join('\n')}`);
|
|
|
209
214
|
}
|
|
210
215
|
}
|
|
211
216
|
|
|
212
|
-
|
|
217
|
+
async distDirs() {
|
|
213
218
|
var _this$compilerInstanc, _this$compilerInstanc2;
|
|
214
219
|
|
|
215
220
|
const packageName = (0, _componentIdToPackageName().default)(this.component.state._consumer);
|
|
@@ -218,7 +223,15 @@ ${this.compileErrors.map(formatError).join('\n')}`);
|
|
|
218
223
|
|
|
219
224
|
const distDirName = ((_this$compilerInstanc = (_this$compilerInstanc2 = this.compilerInstance).getDistDir) === null || _this$compilerInstanc === void 0 ? void 0 : _this$compilerInstanc.call(_this$compilerInstanc2)) || _constants().DEFAULT_DIST_DIRNAME;
|
|
220
225
|
|
|
221
|
-
|
|
226
|
+
const injectedDirs = await this.getInjectedDirs(packageName);
|
|
227
|
+
return [packageDir, ...injectedDirs].map(dist => _path().default.join(dist, distDirName));
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
async getInjectedDirs(packageName) {
|
|
231
|
+
const relativeCompDir = this.workspace.componentDir(this.component.id, undefined, {
|
|
232
|
+
relative: true
|
|
233
|
+
});
|
|
234
|
+
return this.dependencyResolver.getInjectedDirs(this.workspace.path, relativeCompDir, packageName);
|
|
222
235
|
}
|
|
223
236
|
|
|
224
237
|
get componentDir() {
|
|
@@ -248,32 +261,13 @@ ${this.compileErrors.map(formatError).join('\n')}`);
|
|
|
248
261
|
}
|
|
249
262
|
}
|
|
250
263
|
|
|
251
|
-
const base
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
})));
|
|
259
|
-
} else if (this.compilerInstance.shouldCopyNonSupportedFiles) {
|
|
260
|
-
// compiler doesn't support this file type. copy the file as is to the dist dir.
|
|
261
|
-
this.dists.push(new (_sources().Dist)({
|
|
262
|
-
base,
|
|
263
|
-
path: _path().default.join(base, file.relative),
|
|
264
|
-
contents: file.contents
|
|
265
|
-
}));
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
async compileAllFiles(component, initiator) {
|
|
270
|
-
const base = this.distDir;
|
|
271
|
-
const filesToCompile = [];
|
|
272
|
-
component.filesystem.files.forEach(file => {
|
|
273
|
-
const isFileSupported = this.compilerInstance.isFileSupported(file.path);
|
|
274
|
-
|
|
275
|
-
if (isFileSupported) {
|
|
276
|
-
filesToCompile.push(file);
|
|
264
|
+
for (const base of await this.distDirs()) {
|
|
265
|
+
if (isFileSupported && compileResults) {
|
|
266
|
+
this.dists.push(...compileResults.map(result => new (_sources().Dist)({
|
|
267
|
+
base,
|
|
268
|
+
path: _path().default.join(base, result.outputPath),
|
|
269
|
+
contents: Buffer.from(result.outputText)
|
|
270
|
+
})));
|
|
277
271
|
} else if (this.compilerInstance.shouldCopyNonSupportedFiles) {
|
|
278
272
|
// compiler doesn't support this file type. copy the file as is to the dist dir.
|
|
279
273
|
this.dists.push(new (_sources().Dist)({
|
|
@@ -282,7 +276,28 @@ ${this.compileErrors.map(formatError).join('\n')}`);
|
|
|
282
276
|
contents: file.contents
|
|
283
277
|
}));
|
|
284
278
|
}
|
|
285
|
-
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
async compileAllFiles(component, initiator) {
|
|
283
|
+
const filesToCompile = [];
|
|
284
|
+
|
|
285
|
+
for (const base of await this.distDirs()) {
|
|
286
|
+
component.filesystem.files.forEach(file => {
|
|
287
|
+
const isFileSupported = this.compilerInstance.isFileSupported(file.path);
|
|
288
|
+
|
|
289
|
+
if (isFileSupported) {
|
|
290
|
+
filesToCompile.push(file);
|
|
291
|
+
} else if (this.compilerInstance.shouldCopyNonSupportedFiles) {
|
|
292
|
+
// compiler doesn't support this file type. copy the file as is to the dist dir.
|
|
293
|
+
this.dists.push(new (_sources().Dist)({
|
|
294
|
+
base,
|
|
295
|
+
path: _path().default.join(base, file.relative),
|
|
296
|
+
contents: file.contents
|
|
297
|
+
}));
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
286
301
|
|
|
287
302
|
if (filesToCompile.length) {
|
|
288
303
|
try {
|
|
@@ -308,13 +323,14 @@ ${this.compileErrors.map(formatError).join('\n')}`);
|
|
|
308
323
|
exports.ComponentCompiler = ComponentCompiler;
|
|
309
324
|
|
|
310
325
|
class WorkspaceCompiler {
|
|
311
|
-
constructor(workspace, envs, pubsub, aspectLoader, ui, logger) {
|
|
326
|
+
constructor(workspace, envs, pubsub, aspectLoader, ui, logger, dependencyResolver) {
|
|
312
327
|
this.workspace = workspace;
|
|
313
328
|
this.envs = envs;
|
|
314
329
|
this.pubsub = pubsub;
|
|
315
330
|
this.aspectLoader = aspectLoader;
|
|
316
331
|
this.ui = ui;
|
|
317
332
|
this.logger = logger;
|
|
333
|
+
this.dependencyResolver = dependencyResolver;
|
|
318
334
|
|
|
319
335
|
if (this.workspace) {
|
|
320
336
|
this.workspace.registerOnComponentChange(this.onComponentChange.bind(this));
|
|
@@ -395,7 +411,7 @@ class WorkspaceCompiler {
|
|
|
395
411
|
|
|
396
412
|
if (compilerInstance && (_c$state$_consumer$co = c.state._consumer.componentMap) !== null && _c$state$_consumer$co !== void 0 && _c$state$_consumer$co.getComponentDir()) {
|
|
397
413
|
const compilerName = compilerInstance.constructor.name || 'compiler';
|
|
398
|
-
componentsCompilers.push(new ComponentCompiler(this.pubsub, this.workspace, c, compilerInstance, compilerName, this.logger));
|
|
414
|
+
componentsCompilers.push(new ComponentCompiler(this.pubsub, this.workspace, c, compilerInstance, compilerName, this.logger, this.dependencyResolver));
|
|
399
415
|
}
|
|
400
416
|
});
|
|
401
417
|
const resultOnWorkspace = await (0, _pMapSeries().default)(componentsCompilers, componentCompiler => componentCompiler.compile(noThrow, options));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ComponentCompiler","constructor","pubsub","workspace","component","compilerInstance","compilerId","logger","dists","compileErrors","compile","noThrow","options","dataToPersist","deleteDistDir","DataToPersist","removePath","RemovePath","distDir","addBasePath","path","persistAllToFS","compilers","canTranspileFile","find","c","transpileFile","canTranspileComponent","transpileComponent","Promise","all","filesystem","files","map","file","compileOneFile","initiator","compileAllFiles","Error","toString","throwOnCompileErrors","addManyFiles","buildResults","distFile","state","_consumer","compiler","loader","succeed","pub","CompilerAspect","id","ComponentCompilationOnDoneEvent","length","forEach","errorItem","error","formatError","err","join","CompilerErrorEvent","console","message","packageName","componentIdToPackageName","packageDir","distDirName","getDistDir","DEFAULT_DIST_DIRNAME","componentDir","filePath","relative","isFileSupported","compileResults","contents","push","base","result","Dist","outputPath","Buffer","from","outputText","shouldCopyNonSupportedFiles","filesToCompile","outputDir","getComponentPackagePath","WorkspaceCompiler","envs","aspectLoader","ui","registerOnComponentChange","onComponentChange","bind","registerOnComponentAdd","registerOnPreWatch","onPreWatch","registerPreStart","onPreStart","registerOnAspectLoadErrorSlot","onAspectLoadFail","preStartOpts","skipCompilation","compileComponents","changed","verbose","CompilationInitiator","PreStart","code","AspectLoadFail","ComponentChanged","results","components","watchOpts","preCompile","start","Date","now","_legacy","PreWatch","end","consoleSuccess","componentsIds","ConsumerNotFound","componentIds","getIdsToCompile","getMany","componentsCompilers","environment","getEnv","env","getCompiler","componentMap","getComponentDir","compilerName","name","resultOnWorkspace","mapSeries","componentCompiler","resolveMultipleComponentIds","getNewAndModifiedIds","getAllComponentIds"],"sources":["workspace-compiler.ts"],"sourcesContent":["/* eslint-disable max-classes-per-file */\nimport mapSeries from 'p-map-series';\nimport { Component, ComponentID } from '@teambit/component';\nimport { EnvsMain } from '@teambit/envs';\nimport type { PubsubMain } from '@teambit/pubsub';\nimport { SerializableResults, Workspace, WatchOptions } from '@teambit/workspace';\nimport path from 'path';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { Logger } from '@teambit/logger';\nimport loader from '@teambit/legacy/dist/cli/loader';\nimport { DEFAULT_DIST_DIRNAME } from '@teambit/legacy/dist/constants';\nimport { AbstractVinyl, Dist } from '@teambit/legacy/dist/consumer/component/sources';\nimport DataToPersist from '@teambit/legacy/dist/consumer/component/sources/data-to-persist';\nimport { AspectLoaderMain } from '@teambit/aspect-loader';\nimport { ConsumerNotFound } from '@teambit/legacy/dist/consumer/exceptions';\nimport componentIdToPackageName from '@teambit/legacy/dist/utils/bit/component-id-to-package-name';\nimport RemovePath from '@teambit/legacy/dist/consumer/component/sources/remove-path';\nimport { UiMain } from '@teambit/ui';\nimport type { PreStartOpts } from '@teambit/ui';\nimport { PathOsBasedAbsolute, PathOsBasedRelative } from '@teambit/legacy/dist/utils/path';\nimport { MultiCompiler } from '@teambit/multi-compiler';\nimport { CompilerAspect } from './compiler.aspect';\nimport { CompilerErrorEvent, ComponentCompilationOnDoneEvent } from './events';\nimport { Compiler, CompilationInitiator } from './types';\n\nexport type BuildResult = { component: string; buildResults: string[] | null | undefined };\n\nexport type CompileOptions = {\n changed?: boolean; // compile only new and modified components\n verbose?: boolean; // show more data, such as, dist paths\n /**\n * whether the dist root dir should be deleted before writing new dists.\n * defaults to true for `bit compile` and false everywhere else, such as `bit watch` and `bit\n * start` to avoid webpack \"EINTR\" error.\n */\n deleteDistDir?: boolean;\n initiator: CompilationInitiator; // describes where the compilation is coming from\n};\n\nexport type CompileError = { path: string; error: Error };\n\nexport class ComponentCompiler {\n constructor(\n private pubsub: PubsubMain,\n private workspace: Workspace,\n private component: Component,\n private compilerInstance: Compiler,\n private compilerId: string,\n private logger: Logger,\n private dists: Dist[] = [],\n private compileErrors: CompileError[] = []\n ) {}\n\n async compile(noThrow = true, options: CompileOptions): Promise<BuildResult> {\n let dataToPersist;\n const deleteDistDir = options.deleteDistDir ?? this.compilerInstance.deleteDistDir;\n // delete dist folder before transpilation (because some compilers (like ngPackagr) can generate files there during the compilation process)\n if (deleteDistDir) {\n dataToPersist = new DataToPersist();\n dataToPersist.removePath(new RemovePath(this.distDir));\n dataToPersist.addBasePath(this.workspace.path);\n await dataToPersist.persistAllToFS();\n }\n\n const compilers: Compiler[] = (this.compilerInstance as MultiCompiler).compilers\n ? (this.compilerInstance as MultiCompiler).compilers\n : [this.compilerInstance];\n const canTranspileFile = compilers.find((c) => c.transpileFile);\n const canTranspileComponent = compilers.find((c) => c.transpileComponent);\n\n if (canTranspileFile) {\n await Promise.all(\n this.component.filesystem.files.map((file: AbstractVinyl) => this.compileOneFile(file, options.initiator))\n );\n }\n\n if (canTranspileComponent) {\n await this.compileAllFiles(this.component, options.initiator);\n }\n\n if (!canTranspileFile && !canTranspileComponent) {\n throw new Error(\n `compiler ${this.compilerId.toString()} doesn't implement either \"transpileFile\" or \"transpileComponent\" methods`\n );\n }\n this.throwOnCompileErrors(noThrow);\n\n // writing the dists with `component.setDists(dists); component.dists.writeDists` is tricky\n // as it uses other base-paths and doesn't respect the new node-modules base path.\n dataToPersist = new DataToPersist();\n dataToPersist.addManyFiles(this.dists);\n dataToPersist.addBasePath(this.workspace.path);\n await dataToPersist.persistAllToFS();\n const buildResults = this.dists.map((distFile) => distFile.path);\n if (this.component.state._consumer.compiler) loader.succeed();\n this.pubsub.pub(\n CompilerAspect.id,\n new ComponentCompilationOnDoneEvent(this.compileErrors, this.component, buildResults)\n );\n return { component: this.component.id.toString(), buildResults };\n }\n\n private throwOnCompileErrors(noThrow = true) {\n if (this.compileErrors.length) {\n this.compileErrors.forEach((errorItem) => {\n this.logger.error(`compilation error at ${errorItem.path}`, errorItem.error);\n });\n const formatError = (errorItem) => `${errorItem.path}\\n${errorItem.error}`;\n const err = new Error(`compilation failed. see the following errors from the compiler\n${this.compileErrors.map(formatError).join('\\n')}`);\n\n this.pubsub.pub(CompilerAspect.id, new CompilerErrorEvent(err));\n\n if (!noThrow) {\n throw err;\n }\n\n this.logger.console(err.message);\n }\n }\n\n private get distDir(): PathOsBasedRelative {\n const packageName = componentIdToPackageName(this.component.state._consumer);\n const packageDir = path.join('node_modules', packageName);\n const distDirName = this.compilerInstance.getDistDir?.() || DEFAULT_DIST_DIRNAME;\n return path.join(packageDir, distDirName);\n }\n\n private get componentDir(): PathOsBasedAbsolute {\n return this.workspace.componentDir(this.component.id);\n }\n\n private async compileOneFile(file: AbstractVinyl, initiator: CompilationInitiator): Promise<void> {\n const options = { componentDir: this.componentDir, filePath: file.relative, initiator };\n const isFileSupported = this.compilerInstance.isFileSupported(file.path);\n let compileResults;\n if (isFileSupported) {\n try {\n compileResults = this.compilerInstance.transpileFile?.(file.contents.toString(), options);\n } catch (error: any) {\n this.compileErrors.push({ path: file.path, error });\n return;\n }\n }\n const base = this.distDir;\n if (isFileSupported && compileResults) {\n this.dists.push(\n ...compileResults.map(\n (result) =>\n new Dist({\n base,\n path: path.join(base, result.outputPath),\n contents: Buffer.from(result.outputText),\n })\n )\n );\n } else if (this.compilerInstance.shouldCopyNonSupportedFiles) {\n // compiler doesn't support this file type. copy the file as is to the dist dir.\n this.dists.push(new Dist({ base, path: path.join(base, file.relative), contents: file.contents }));\n }\n }\n\n private async compileAllFiles(component: Component, initiator: CompilationInitiator): Promise<void> {\n const base = this.distDir;\n const filesToCompile: AbstractVinyl[] = [];\n component.filesystem.files.forEach((file: AbstractVinyl) => {\n const isFileSupported = this.compilerInstance.isFileSupported(file.path);\n if (isFileSupported) {\n filesToCompile.push(file);\n } else if (this.compilerInstance.shouldCopyNonSupportedFiles) {\n // compiler doesn't support this file type. copy the file as is to the dist dir.\n this.dists.push(\n new Dist({\n base,\n path: path.join(base, file.relative),\n contents: file.contents,\n })\n );\n }\n });\n\n if (filesToCompile.length) {\n try {\n await this.compilerInstance.transpileComponent?.({\n component,\n componentDir: this.componentDir,\n outputDir: this.workspace.getComponentPackagePath(component),\n initiator,\n });\n } catch (error: any) {\n this.compileErrors.push({ path: this.componentDir, error });\n }\n }\n }\n}\n\nexport class WorkspaceCompiler {\n constructor(\n private workspace: Workspace,\n private envs: EnvsMain,\n private pubsub: PubsubMain,\n private aspectLoader: AspectLoaderMain,\n private ui: UiMain,\n private logger: Logger\n ) {\n if (this.workspace) {\n this.workspace.registerOnComponentChange(this.onComponentChange.bind(this));\n this.workspace.registerOnComponentAdd(this.onComponentChange.bind(this));\n this.workspace.registerOnPreWatch(this.onPreWatch.bind(this));\n this.ui.registerPreStart(this.onPreStart.bind(this));\n }\n if (this.aspectLoader) {\n this.aspectLoader.registerOnAspectLoadErrorSlot(this.onAspectLoadFail.bind(this));\n }\n }\n\n async onPreStart(preStartOpts: PreStartOpts): Promise<void> {\n if (preStartOpts.skipCompilation) {\n return;\n }\n await this.compileComponents([], {\n changed: true,\n verbose: false,\n deleteDistDir: false,\n initiator: CompilationInitiator.PreStart,\n });\n }\n\n async onAspectLoadFail(err: Error & { code?: string }, id: ComponentID): Promise<boolean> {\n if (err.code && err.code === 'MODULE_NOT_FOUND' && this.workspace) {\n await this.compileComponents([id.toString()], { initiator: CompilationInitiator.AspectLoadFail }, true);\n return true;\n }\n return false;\n }\n\n async onComponentChange(\n component: Component,\n files: string[],\n initiator?: CompilationInitiator\n ): Promise<SerializableResults> {\n const buildResults = await this.compileComponents(\n [component.id.toString()],\n { initiator: initiator || CompilationInitiator.ComponentChanged },\n true\n );\n return {\n results: buildResults,\n toString() {\n return `${buildResults[0]?.buildResults?.join('\\n\\t')}`;\n },\n };\n }\n\n async onPreWatch(components: Component[], watchOpts: WatchOptions) {\n if (watchOpts.preCompile) {\n const start = Date.now();\n this.logger.console(`compiling ${components.length} components`);\n await this.compileComponents(\n components.map((c) => c.id._legacy),\n { initiator: CompilationInitiator.PreWatch }\n );\n const end = Date.now() - start;\n this.logger.consoleSuccess(`compiled ${components.length} components successfully (${end / 1000} sec)`);\n }\n }\n\n async compileComponents(\n componentsIds: string[] | BitId[] | ComponentID[], // when empty, it compiles new+modified (unless options.all is set),\n options: CompileOptions,\n noThrow?: boolean\n ): Promise<BuildResult[]> {\n if (!this.workspace) throw new ConsumerNotFound();\n const componentIds = await this.getIdsToCompile(componentsIds, options.changed);\n const components = await this.workspace.getMany(componentIds);\n\n const componentsCompilers: ComponentCompiler[] = [];\n components.forEach((c) => {\n const environment = this.envs.getEnv(c).env;\n const compilerInstance = environment.getCompiler?.();\n // if there is no componentDir (e.g. author that added files, not dir), then we can't write the dists\n // inside the component dir.\n if (compilerInstance && c.state._consumer.componentMap?.getComponentDir()) {\n const compilerName = compilerInstance.constructor.name || 'compiler';\n componentsCompilers.push(\n new ComponentCompiler(this.pubsub, this.workspace, c, compilerInstance, compilerName, this.logger)\n );\n }\n });\n const resultOnWorkspace = await mapSeries(componentsCompilers, (componentCompiler) =>\n componentCompiler.compile(noThrow, options)\n );\n\n return resultOnWorkspace;\n }\n\n private async getIdsToCompile(\n componentsIds: Array<string | ComponentID | BitId>,\n changed = false\n ): Promise<ComponentID[]> {\n if (componentsIds.length) {\n return this.workspace.resolveMultipleComponentIds(componentsIds);\n }\n if (changed) {\n return this.workspace.getNewAndModifiedIds();\n }\n return this.workspace.getAllComponentIds();\n }\n}\n"],"mappings":";;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAKA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA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BAAmB,CAACpD,IAApB,CACE,IAAI3E,iBAAJ,CAAsB,KAAKE,MAA3B,EAAmC,KAAKC,SAAxC,EAAmDsB,CAAnD,EAAsDpB,gBAAtD,EAAwEiI,YAAxE,EAAsF,KAAK/H,MAA3F,CADF;MAGD;IACF,CAXD;IAYA,MAAMiI,iBAAiB,GAAG,MAAM,IAAAC,qBAAA,EAAUV,mBAAV,EAAgCW,iBAAD,IAC7DA,iBAAiB,CAAChI,OAAlB,CAA0BC,OAA1B,EAAmCC,OAAnC,CAD8B,CAAhC;IAIA,OAAO4H,iBAAP;EACD;;EAE4B,MAAfX,eAAe,CAC3BH,aAD2B,EAE3BlB,OAAO,GAAG,KAFiB,EAGH;IACxB,IAAIkB,aAAa,CAACrE,MAAlB,EAA0B;MACxB,OAAO,KAAKlD,SAAL,CAAewI,2BAAf,CAA2CjB,aAA3C,CAAP;IACD;;IACD,IAAIlB,OAAJ,EAAa;MACX,OAAO,KAAKrG,SAAL,CAAeyI,oBAAf,EAAP;IACD;;IACD,OAAO,KAAKzI,SAAL,CAAe0I,kBAAf,EAAP;EACD;;AA/G4B"}
|
|
1
|
+
{"version":3,"names":["ComponentCompiler","constructor","pubsub","workspace","component","compilerInstance","compilerId","logger","dependencyResolver","dists","compileErrors","compile","noThrow","options","dataToPersist","deleteDistDir","DataToPersist","distDir","distDirs","removePath","RemovePath","addBasePath","path","persistAllToFS","compilers","canTranspileFile","find","c","transpileFile","canTranspileComponent","transpileComponent","Promise","all","filesystem","files","map","file","compileOneFile","initiator","compileAllFiles","Error","toString","throwOnCompileErrors","addManyFiles","buildResults","distFile","state","_consumer","compiler","loader","succeed","pub","CompilerAspect","id","ComponentCompilationOnDoneEvent","length","forEach","errorItem","error","formatError","err","join","CompilerErrorEvent","console","message","packageName","componentIdToPackageName","packageDir","distDirName","getDistDir","DEFAULT_DIST_DIRNAME","injectedDirs","getInjectedDirs","dist","relativeCompDir","componentDir","undefined","relative","filePath","isFileSupported","compileResults","contents","push","base","result","Dist","outputPath","Buffer","from","outputText","shouldCopyNonSupportedFiles","filesToCompile","outputDir","getComponentPackagePath","WorkspaceCompiler","envs","aspectLoader","ui","registerOnComponentChange","onComponentChange","bind","registerOnComponentAdd","registerOnPreWatch","onPreWatch","registerPreStart","onPreStart","registerOnAspectLoadErrorSlot","onAspectLoadFail","preStartOpts","skipCompilation","compileComponents","changed","verbose","CompilationInitiator","PreStart","code","AspectLoadFail","ComponentChanged","results","components","watchOpts","preCompile","start","Date","now","_legacy","PreWatch","end","consoleSuccess","componentsIds","ConsumerNotFound","componentIds","getIdsToCompile","getMany","componentsCompilers","environment","getEnv","env","getCompiler","componentMap","getComponentDir","compilerName","name","resultOnWorkspace","mapSeries","componentCompiler","resolveMultipleComponentIds","getNewAndModifiedIds","getAllComponentIds"],"sources":["workspace-compiler.ts"],"sourcesContent":["/* eslint-disable max-classes-per-file */\nimport mapSeries from 'p-map-series';\nimport { Component, ComponentID } from '@teambit/component';\nimport { EnvsMain } from '@teambit/envs';\nimport type { PubsubMain } from '@teambit/pubsub';\nimport { SerializableResults, Workspace, WatchOptions } from '@teambit/workspace';\nimport path from 'path';\nimport { BitId } from '@teambit/legacy-bit-id';\nimport { Logger } from '@teambit/logger';\nimport loader from '@teambit/legacy/dist/cli/loader';\nimport { DEFAULT_DIST_DIRNAME } from '@teambit/legacy/dist/constants';\nimport { AbstractVinyl, Dist } from '@teambit/legacy/dist/consumer/component/sources';\nimport DataToPersist from '@teambit/legacy/dist/consumer/component/sources/data-to-persist';\nimport { AspectLoaderMain } from '@teambit/aspect-loader';\nimport { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { ConsumerNotFound } from '@teambit/legacy/dist/consumer/exceptions';\nimport componentIdToPackageName from '@teambit/legacy/dist/utils/bit/component-id-to-package-name';\nimport RemovePath from '@teambit/legacy/dist/consumer/component/sources/remove-path';\nimport { UiMain } from '@teambit/ui';\nimport type { PreStartOpts } from '@teambit/ui';\nimport { PathOsBasedAbsolute, PathOsBasedRelative } from '@teambit/legacy/dist/utils/path';\nimport { MultiCompiler } from '@teambit/multi-compiler';\nimport { CompilerAspect } from './compiler.aspect';\nimport { CompilerErrorEvent, ComponentCompilationOnDoneEvent } from './events';\nimport { Compiler, CompilationInitiator } from './types';\n\nexport type BuildResult = { component: string; buildResults: string[] | null | undefined };\n\nexport type CompileOptions = {\n changed?: boolean; // compile only new and modified components\n verbose?: boolean; // show more data, such as, dist paths\n /**\n * whether the dist root dir should be deleted before writing new dists.\n * defaults to true for `bit compile` and false everywhere else, such as `bit watch` and `bit\n * start` to avoid webpack \"EINTR\" error.\n */\n deleteDistDir?: boolean;\n initiator: CompilationInitiator; // describes where the compilation is coming from\n};\n\nexport type CompileError = { path: string; error: Error };\n\nexport class ComponentCompiler {\n constructor(\n private pubsub: PubsubMain,\n private workspace: Workspace,\n private component: Component,\n private compilerInstance: Compiler,\n private compilerId: string,\n private logger: Logger,\n private dependencyResolver: DependencyResolverMain,\n private dists: Dist[] = [],\n private compileErrors: CompileError[] = []\n ) {}\n\n async compile(noThrow = true, options: CompileOptions): Promise<BuildResult> {\n let dataToPersist;\n const deleteDistDir = options.deleteDistDir ?? this.compilerInstance.deleteDistDir;\n // delete dist folder before transpilation (because some compilers (like ngPackagr) can generate files there during the compilation process)\n if (deleteDistDir) {\n dataToPersist = new DataToPersist();\n for (const distDir of await this.distDirs()) {\n dataToPersist.removePath(new RemovePath(distDir));\n }\n dataToPersist.addBasePath(this.workspace.path);\n await dataToPersist.persistAllToFS();\n }\n\n const compilers: Compiler[] = (this.compilerInstance as MultiCompiler).compilers\n ? (this.compilerInstance as MultiCompiler).compilers\n : [this.compilerInstance];\n const canTranspileFile = compilers.find((c) => c.transpileFile);\n const canTranspileComponent = compilers.find((c) => c.transpileComponent);\n\n if (canTranspileFile) {\n await Promise.all(\n this.component.filesystem.files.map((file: AbstractVinyl) => this.compileOneFile(file, options.initiator))\n );\n }\n\n if (canTranspileComponent) {\n await this.compileAllFiles(this.component, options.initiator);\n }\n\n if (!canTranspileFile && !canTranspileComponent) {\n throw new Error(\n `compiler ${this.compilerId.toString()} doesn't implement either \"transpileFile\" or \"transpileComponent\" methods`\n );\n }\n this.throwOnCompileErrors(noThrow);\n\n // writing the dists with `component.setDists(dists); component.dists.writeDists` is tricky\n // as it uses other base-paths and doesn't respect the new node-modules base path.\n dataToPersist = new DataToPersist();\n dataToPersist.addManyFiles(this.dists);\n dataToPersist.addBasePath(this.workspace.path);\n await dataToPersist.persistAllToFS();\n const buildResults = this.dists.map((distFile) => distFile.path);\n if (this.component.state._consumer.compiler) loader.succeed();\n this.pubsub.pub(\n CompilerAspect.id,\n new ComponentCompilationOnDoneEvent(this.compileErrors, this.component, buildResults)\n );\n return { component: this.component.id.toString(), buildResults };\n }\n\n private throwOnCompileErrors(noThrow = true) {\n if (this.compileErrors.length) {\n this.compileErrors.forEach((errorItem) => {\n this.logger.error(`compilation error at ${errorItem.path}`, errorItem.error);\n });\n const formatError = (errorItem) => `${errorItem.path}\\n${errorItem.error}`;\n const err = new Error(`compilation failed. see the following errors from the compiler\n${this.compileErrors.map(formatError).join('\\n')}`);\n\n this.pubsub.pub(CompilerAspect.id, new CompilerErrorEvent(err));\n\n if (!noThrow) {\n throw err;\n }\n\n this.logger.console(err.message);\n }\n }\n\n private async distDirs(): Promise<PathOsBasedRelative[]> {\n const packageName = componentIdToPackageName(this.component.state._consumer);\n const packageDir = path.join('node_modules', packageName);\n const distDirName = this.compilerInstance.getDistDir?.() || DEFAULT_DIST_DIRNAME;\n const injectedDirs = await this.getInjectedDirs(packageName);\n return [packageDir, ...injectedDirs].map((dist) => path.join(dist,distDirName));\n }\n\n private async getInjectedDirs(packageName: string): Promise<PathOsBasedRelative[]> {\n const relativeCompDir = this.workspace.componentDir(this.component.id, undefined, {\n relative: true,\n });\n return this.dependencyResolver.getInjectedDirs(this.workspace.path, relativeCompDir, packageName);\n }\n\n private get componentDir(): PathOsBasedAbsolute {\n return this.workspace.componentDir(this.component.id);\n }\n\n private async compileOneFile(file: AbstractVinyl, initiator: CompilationInitiator): Promise<void> {\n const options = { componentDir: this.componentDir, filePath: file.relative, initiator };\n const isFileSupported = this.compilerInstance.isFileSupported(file.path);\n let compileResults;\n if (isFileSupported) {\n try {\n compileResults = this.compilerInstance.transpileFile?.(file.contents.toString(), options);\n } catch (error: any) {\n this.compileErrors.push({ path: file.path, error });\n return;\n }\n }\n for (const base of await this.distDirs()) {\n if (isFileSupported && compileResults) {\n this.dists.push(\n ...compileResults.map(\n (result) =>\n new Dist({\n base,\n path: path.join(base, result.outputPath),\n contents: Buffer.from(result.outputText),\n })\n )\n );\n } else if (this.compilerInstance.shouldCopyNonSupportedFiles) {\n // compiler doesn't support this file type. copy the file as is to the dist dir.\n this.dists.push(new Dist({ base, path: path.join(base, file.relative), contents: file.contents }));\n }\n }\n }\n\n private async compileAllFiles(component: Component, initiator: CompilationInitiator): Promise<void> {\n const filesToCompile: AbstractVinyl[] = [];\n for (const base of await this.distDirs()) {\n component.filesystem.files.forEach((file: AbstractVinyl) => {\n const isFileSupported = this.compilerInstance.isFileSupported(file.path);\n if (isFileSupported) {\n filesToCompile.push(file);\n } else if (this.compilerInstance.shouldCopyNonSupportedFiles) {\n // compiler doesn't support this file type. copy the file as is to the dist dir.\n this.dists.push(\n new Dist({\n base,\n path: path.join(base, file.relative),\n contents: file.contents,\n })\n );\n }\n });\n }\n\n if (filesToCompile.length) {\n try {\n await this.compilerInstance.transpileComponent?.({\n component,\n componentDir: this.componentDir,\n outputDir: this.workspace.getComponentPackagePath(component),\n initiator,\n });\n } catch (error: any) {\n this.compileErrors.push({ path: this.componentDir, error });\n }\n }\n }\n}\n\nexport class WorkspaceCompiler {\n constructor(\n private workspace: Workspace,\n private envs: EnvsMain,\n private pubsub: PubsubMain,\n private aspectLoader: AspectLoaderMain,\n private ui: UiMain,\n private logger: Logger,\n private dependencyResolver: DependencyResolverMain\n ) {\n if (this.workspace) {\n this.workspace.registerOnComponentChange(this.onComponentChange.bind(this));\n this.workspace.registerOnComponentAdd(this.onComponentChange.bind(this));\n this.workspace.registerOnPreWatch(this.onPreWatch.bind(this));\n this.ui.registerPreStart(this.onPreStart.bind(this));\n }\n if (this.aspectLoader) {\n this.aspectLoader.registerOnAspectLoadErrorSlot(this.onAspectLoadFail.bind(this));\n }\n }\n\n async onPreStart(preStartOpts: PreStartOpts): Promise<void> {\n if (preStartOpts.skipCompilation) {\n return;\n }\n await this.compileComponents([], {\n changed: true,\n verbose: false,\n deleteDistDir: false,\n initiator: CompilationInitiator.PreStart,\n });\n }\n\n async onAspectLoadFail(err: Error & { code?: string }, id: ComponentID): Promise<boolean> {\n if (err.code && err.code === 'MODULE_NOT_FOUND' && this.workspace) {\n await this.compileComponents([id.toString()], { initiator: CompilationInitiator.AspectLoadFail }, true);\n return true;\n }\n return false;\n }\n\n async onComponentChange(\n component: Component,\n files: string[],\n initiator?: CompilationInitiator\n ): Promise<SerializableResults> {\n const buildResults = await this.compileComponents(\n [component.id.toString()],\n { initiator: initiator || CompilationInitiator.ComponentChanged },\n true\n );\n return {\n results: buildResults,\n toString() {\n return `${buildResults[0]?.buildResults?.join('\\n\\t')}`;\n },\n };\n }\n\n async onPreWatch(components: Component[], watchOpts: WatchOptions) {\n if (watchOpts.preCompile) {\n const start = Date.now();\n this.logger.console(`compiling ${components.length} components`);\n await this.compileComponents(\n components.map((c) => c.id._legacy),\n { initiator: CompilationInitiator.PreWatch }\n );\n const end = Date.now() - start;\n this.logger.consoleSuccess(`compiled ${components.length} components successfully (${end / 1000} sec)`);\n }\n }\n\n async compileComponents(\n componentsIds: string[] | BitId[] | ComponentID[], // when empty, it compiles new+modified (unless options.all is set),\n options: CompileOptions,\n noThrow?: boolean\n ): Promise<BuildResult[]> {\n if (!this.workspace) throw new ConsumerNotFound();\n const componentIds = await this.getIdsToCompile(componentsIds, options.changed);\n const components = await this.workspace.getMany(componentIds);\n\n const componentsCompilers: ComponentCompiler[] = [];\n components.forEach((c) => {\n const environment = this.envs.getEnv(c).env;\n const compilerInstance = environment.getCompiler?.();\n // if there is no componentDir (e.g. author that added files, not dir), then we can't write the dists\n // inside the component dir.\n if (compilerInstance && c.state._consumer.componentMap?.getComponentDir()) {\n const compilerName = compilerInstance.constructor.name || 'compiler';\n componentsCompilers.push(\n new ComponentCompiler(\n this.pubsub,\n this.workspace,\n c,\n compilerInstance,\n compilerName,\n this.logger,\n this.dependencyResolver\n )\n );\n }\n });\n const resultOnWorkspace = await mapSeries(componentsCompilers, (componentCompiler) =>\n componentCompiler.compile(noThrow, options)\n );\n\n return resultOnWorkspace;\n }\n\n private async getIdsToCompile(\n componentsIds: Array<string | ComponentID | BitId>,\n changed = false\n ): Promise<ComponentID[]> {\n if (componentsIds.length) {\n return this.workspace.resolveMultipleComponentIds(componentsIds);\n }\n if (changed) {\n return this.workspace.getNewAndModifiedIds();\n }\n return this.workspace.getAllComponentIds();\n }\n}\n"],"mappings":";;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAKA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;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;;AAGA;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;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAxBA;AA0CO,MAAMA,iBAAN,CAAwB;EAC7BC,WAAW,CACDC,MADC,EAEDC,SAFC,EAGDC,SAHC,EAIDC,gBAJC,EAKDC,UALC,EAMDC,MANC,EAOD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AG,2BAAAH,WAAW,CAApC,CAFwB,CAGxB;MACA;;MACA,IAAIlI,gBAAgB,6BAAIsB,CAAC,CAACmB,KAAF,CAAQC,SAAR,CAAkB4F,YAAtB,kDAAI,sBAAgCC,eAAhC,EAAxB,EAA2E;QACzE,MAAMC,YAAY,GAAGxI,gBAAgB,CAACJ,WAAjB,CAA6B6I,IAA7B,IAAqC,UAA1D;QACAR,mBAAmB,CAACpD,IAApB,CACE,IAAIlF,iBAAJ,CACE,KAAKE,MADP,EAEE,KAAKC,SAFP,EAGEwB,CAHF,EAIEtB,gBAJF,EAKEwI,YALF,EAME,KAAKtI,MANP,EAOE,KAAKC,kBAPP,CADF;MAWD;IACF,CAnBD;IAoBA,MAAMuI,iBAAiB,GAAG,MAAM,IAAAC,qBAAA,EAAUV,mBAAV,EAAgCW,iBAAD,IAC7DA,iBAAiB,CAACtI,OAAlB,CAA0BC,OAA1B,EAAmCC,OAAnC,CAD8B,CAAhC;IAIA,OAAOkI,iBAAP;EACD;;EAE4B,MAAfX,eAAe,CAC3BH,aAD2B,EAE3BlB,OAAO,GAAG,KAFiB,EAGH;IACxB,IAAIkB,aAAa,CAAC1E,MAAlB,EAA0B;MACxB,OAAO,KAAKpD,SAAL,CAAe+I,2BAAf,CAA2CjB,aAA3C,CAAP;IACD;;IACD,IAAIlB,OAAJ,EAAa;MACX,OAAO,KAAK5G,SAAL,CAAegJ,oBAAf,EAAP;IACD;;IACD,OAAO,KAAKhJ,SAAL,CAAeiJ,kBAAf,EAAP;EACD;;AAxH4B"}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/compiler",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.803",
|
|
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.803"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"chalk": "2.4.2",
|
|
@@ -18,20 +18,22 @@
|
|
|
18
18
|
"@babel/runtime": "7.12.18",
|
|
19
19
|
"core-js": "^3.0.0",
|
|
20
20
|
"@teambit/harmony": "0.3.3",
|
|
21
|
-
"@teambit/cli": "0.0.
|
|
22
|
-
"@teambit/component": "0.0.
|
|
23
|
-
"@teambit/logger": "0.0.
|
|
24
|
-
"@teambit/pubsub": "0.0.
|
|
25
|
-
"@teambit/aspect-loader": "0.0.
|
|
26
|
-
"@teambit/builder": "0.0.
|
|
21
|
+
"@teambit/cli": "0.0.535",
|
|
22
|
+
"@teambit/component": "0.0.803",
|
|
23
|
+
"@teambit/logger": "0.0.628",
|
|
24
|
+
"@teambit/pubsub": "0.0.803",
|
|
25
|
+
"@teambit/aspect-loader": "0.0.803",
|
|
26
|
+
"@teambit/builder": "0.0.803",
|
|
27
27
|
"@teambit/component-issues": "0.0.60",
|
|
28
|
-
"@teambit/
|
|
29
|
-
"@teambit/
|
|
28
|
+
"@teambit/dependency-resolver": "0.0.803",
|
|
29
|
+
"@teambit/envs": "0.0.803",
|
|
30
|
+
"@teambit/generator": "0.0.803",
|
|
30
31
|
"@teambit/legacy-bit-id": "0.0.402",
|
|
31
|
-
"@teambit/ui": "0.0.
|
|
32
|
-
"@teambit/workspace": "0.0.
|
|
33
|
-
"@teambit/isolator": "0.0.
|
|
34
|
-
"@teambit/
|
|
32
|
+
"@teambit/ui": "0.0.803",
|
|
33
|
+
"@teambit/workspace": "0.0.803",
|
|
34
|
+
"@teambit/isolator": "0.0.803",
|
|
35
|
+
"@teambit/toolbox.fs.hard-link-directory": "0.0.1",
|
|
36
|
+
"@teambit/multi-compiler": "0.0.803",
|
|
35
37
|
"@teambit/bit-error": "0.0.394"
|
|
36
38
|
},
|
|
37
39
|
"devDependencies": {
|
|
@@ -45,7 +47,7 @@
|
|
|
45
47
|
"@teambit/compilation.content.compiler-overview": "1.95.0"
|
|
46
48
|
},
|
|
47
49
|
"peerDependencies": {
|
|
48
|
-
"@teambit/legacy": "1.0.
|
|
50
|
+
"@teambit/legacy": "1.0.317",
|
|
49
51
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
50
52
|
"react": "^16.8.0 || ^17.0.0"
|
|
51
53
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compilation_compiler@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compilation_compiler@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compilation_compiler@0.0.803/dist/compiler.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compilation_compiler@0.0.803/dist/compiler.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
Binary file
|