@teambit/preview 0.0.748 → 0.0.751
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/preview.graphql.d.ts +3 -0
- package/dist/preview.graphql.js +6 -0
- package/dist/preview.graphql.js.map +1 -1
- package/dist/preview.main.runtime.d.ts +7 -0
- package/dist/preview.main.runtime.js +25 -0
- package/dist/preview.main.runtime.js.map +1 -1
- package/dist/strategies/env-strategy.d.ts +1 -0
- package/dist/strategies/env-strategy.js +6 -2
- package/dist/strategies/env-strategy.js.map +1 -1
- package/package-tar/teambit-preview-0.0.751.tgz +0 -0
- package/package.json +20 -20
- package/{preview-1654053813292.js → preview-1654313169583.js} +2 -2
- package/preview.main.runtime.tsx +20 -0
- package/strategies/env-strategy.ts +3 -1
- package/tsconfig.json +2 -1
- package/package-tar/teambit-preview-0.0.748.tgz +0 -0
|
@@ -12,6 +12,9 @@ export declare function previewSchema(previewExtension: PreviewMain): {
|
|
|
12
12
|
includesEnvTemplate: ({ component }: {
|
|
13
13
|
component: any;
|
|
14
14
|
}) => Promise<boolean>;
|
|
15
|
+
legacyHeader: ({ component }: {
|
|
16
|
+
component: any;
|
|
17
|
+
}) => Promise<boolean>;
|
|
15
18
|
};
|
|
16
19
|
};
|
|
17
20
|
};
|
package/dist/preview.graphql.js
CHANGED
|
@@ -23,6 +23,7 @@ function previewSchema(previewExtension) {
|
|
|
23
23
|
type Preview {
|
|
24
24
|
# url: String!
|
|
25
25
|
includesEnvTemplate: Boolean
|
|
26
|
+
legacyHeader: Boolean
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
extend type Component {
|
|
@@ -43,6 +44,11 @@ function previewSchema(previewExtension) {
|
|
|
43
44
|
component
|
|
44
45
|
}) => {
|
|
45
46
|
return previewExtension.isBundledWithEnv(component);
|
|
47
|
+
},
|
|
48
|
+
legacyHeader: ({
|
|
49
|
+
component
|
|
50
|
+
}) => {
|
|
51
|
+
return previewExtension.isLegacyHeader(component);
|
|
46
52
|
}
|
|
47
53
|
}
|
|
48
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["previewSchema","previewExtension","typeDefs","gql","resolvers","Component","preview","component","Preview","includesEnvTemplate","isBundledWithEnv"],"sources":["preview.graphql.ts"],"sourcesContent":["import { Component } from '@teambit/component';\nimport gql from 'graphql-tag';\n\nimport { PreviewMain } from './preview.main.runtime';\n\nexport function previewSchema(previewExtension: PreviewMain) {\n return {\n typeDefs: gql`\n type Preview {\n # url: String!\n includesEnvTemplate: Boolean\n }\n\n extend type Component {\n preview: Preview\n }\n `,\n resolvers: {\n Component: {\n preview: (component: Component) => {\n // return previewExtension.getPreview(component);\n return { component };\n },\n },\n Preview: {\n includesEnvTemplate: ({ component }) => {\n return previewExtension.isBundledWithEnv(component);\n },\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIO,SAASA,aAAT,CAAuBC,gBAAvB,EAAsD;EAC3D,OAAO;IACLC,QAAQ,EAAE,IAAAC,qBAAA,CAAI;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,
|
|
1
|
+
{"version":3,"names":["previewSchema","previewExtension","typeDefs","gql","resolvers","Component","preview","component","Preview","includesEnvTemplate","isBundledWithEnv","legacyHeader","isLegacyHeader"],"sources":["preview.graphql.ts"],"sourcesContent":["import { Component } from '@teambit/component';\nimport gql from 'graphql-tag';\n\nimport { PreviewMain } from './preview.main.runtime';\n\nexport function previewSchema(previewExtension: PreviewMain) {\n return {\n typeDefs: gql`\n type Preview {\n # url: String!\n includesEnvTemplate: Boolean\n legacyHeader: Boolean\n }\n\n extend type Component {\n preview: Preview\n }\n `,\n resolvers: {\n Component: {\n preview: (component: Component) => {\n // return previewExtension.getPreview(component);\n return { component };\n },\n },\n Preview: {\n includesEnvTemplate: ({ component }) => {\n return previewExtension.isBundledWithEnv(component);\n },\n legacyHeader: ({ component }) => {\n return previewExtension.isLegacyHeader(component);\n },\n },\n },\n };\n}\n"],"mappings":";;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIO,SAASA,aAAT,CAAuBC,gBAAvB,EAAsD;EAC3D,OAAO;IACLC,QAAQ,EAAE,IAAAC,qBAAA,CAAI;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAXS;IAYLC,SAAS,EAAE;MACTC,SAAS,EAAE;QACTC,OAAO,EAAGC,SAAD,IAA0B;UACjC;UACA,OAAO;YAAEA;UAAF,CAAP;QACD;MAJQ,CADF;MAOTC,OAAO,EAAE;QACPC,mBAAmB,EAAE,CAAC;UAAEF;QAAF,CAAD,KAAmB;UACtC,OAAON,gBAAgB,CAACS,gBAAjB,CAAkCH,SAAlC,CAAP;QACD,CAHM;QAIPI,YAAY,EAAE,CAAC;UAAEJ;QAAF,CAAD,KAAmB;UAC/B,OAAON,gBAAgB,CAACW,cAAjB,CAAgCL,SAAhC,CAAP;QACD;MANM;IAPA;EAZN,CAAP;AA6BD"}
|
|
@@ -94,6 +94,13 @@ export declare class PreviewMain {
|
|
|
94
94
|
* @returns
|
|
95
95
|
*/
|
|
96
96
|
isBundledWithEnv(component: Component): Promise<boolean>;
|
|
97
|
+
/**
|
|
98
|
+
* Check if the component preview bundle contain the header inside of it (legacy)
|
|
99
|
+
* today we are not including the header inside anymore
|
|
100
|
+
* @param component
|
|
101
|
+
* @returns
|
|
102
|
+
*/
|
|
103
|
+
isLegacyHeader(component: Component): Promise<boolean>;
|
|
97
104
|
/**
|
|
98
105
|
* Getting the env template artifact
|
|
99
106
|
* This should be called with the env itself or it will return undefined
|
|
@@ -361,6 +361,16 @@ function _componentStrategy() {
|
|
|
361
361
|
return data;
|
|
362
362
|
}
|
|
363
363
|
|
|
364
|
+
function _envStrategy() {
|
|
365
|
+
const data = require("./strategies/env-strategy");
|
|
366
|
+
|
|
367
|
+
_envStrategy = function () {
|
|
368
|
+
return data;
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
return data;
|
|
372
|
+
}
|
|
373
|
+
|
|
364
374
|
function _preview5() {
|
|
365
375
|
const data = require("./preview.graphql");
|
|
366
376
|
|
|
@@ -485,6 +495,21 @@ class PreviewMain {
|
|
|
485
495
|
if (!artifacts || !artifacts.length) return true;
|
|
486
496
|
return false;
|
|
487
497
|
}
|
|
498
|
+
/**
|
|
499
|
+
* Check if the component preview bundle contain the header inside of it (legacy)
|
|
500
|
+
* today we are not including the header inside anymore
|
|
501
|
+
* @param component
|
|
502
|
+
* @returns
|
|
503
|
+
*/
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
async isLegacyHeader(component) {
|
|
507
|
+
// these envs had header in their docs
|
|
508
|
+
const ENV_WITH_LEGACY_DOCS = ['react', 'env', 'aspect', 'lit', 'html', 'node', 'mdx', 'react-native', 'readme'];
|
|
509
|
+
const artifacts = await this.builder.getArtifactsVinylByExtensionAndName(component, _preview().PreviewAspect.id, _envStrategy().ENV_STRATEGY_ARTIFACT_NAME);
|
|
510
|
+
const envType = this.envs.getEnvData(component).type;
|
|
511
|
+
return !!artifacts && !!artifacts.length && ENV_WITH_LEGACY_DOCS.includes(envType);
|
|
512
|
+
}
|
|
488
513
|
/**
|
|
489
514
|
* Getting the env template artifact
|
|
490
515
|
* This should be called with the env itself or it will return undefined
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["noopResult","results","toString","DEFAULT_TEMP_DIR","join","CACHE_ROOT","PreviewAspect","id","PreviewMain","constructor","harmony","previewSlot","ui","envs","componentAspect","pkg","aspectLoader","config","bundlingStrategySlot","builder","workspace","logger","dependencyResolver","Map","Date","now","c","updater","env","getEnv","envId","executionRef","executionRefs","get","warn","updateLinkFiles","currentComponents","executionCtx","cId","component","forEach","components","found","Promise","resolve","handleComponentChange","remove","tempFolder","getTempDir","getComponentBundleSize","data","getDataByAspect","undefined","COMPONENT_STRATEGY_SIZE_KEY_NAME","getPreview","artifacts","getArtifactsVinylByExtensionAndTaskName","PREVIEW_TASK_NAME","PreviewArtifact","getPreviewFiles","isBundledWithEnv","files","getPaths","getArtifactsVinylByExtensionAndName","COMPONENT_STRATEGY_ARTIFACT_NAME","length","getEnvTemplate","GENERATE_ENV_TEMPLATE_TASK_NAME","getCoreEnvTemplate","coreEnvDir","getAspectDir","artifactDef","getEnvTemplateArtifactDef","artifactFactory","ArtifactFactory","rootDir","getRootDir","existsSync","coreEnvDirFromBvm","getAspectDirFromBvm","paths","resolvePaths","artifactFiles","ArtifactFiles","populateVinylsFromPaths","vinyls","getEnvTemplateFromComponentEnv","getEnvId","getEnvTemplateByEnvId","isCoreEnv","host","getHost","resolvedEnvId","resolveComponentId","envComponent","BitError","getDefs","values","writeLink","prefix","moduleMap","defaultModule","dirName","isSplitComponentBundle","contents","generateLink","writeLinkContents","targetDir","hash","objectHash","targetPath","timestamp","writeHash","writeFileSync","set","getPreviewTarget","context","relatedContexts","ctxId","ExecutionRef","previewRuntime","writePreviewRuntime","linkFiles","previews","map","previewDef","templatePath","renderTemplatePath","getModuleMap","getEnvPreviewConfig","splitComponentBundle","withPaths","environment","compilerInstance","getCompiler","modulePath","getPreviewComponentRootPath","getModulePath","file","path","distRelativePath","getDistPathBySrcPath","relative","dirPath","mkdirSync","recursive","link","all","aspectsIdsToNotFilterOut","getUi","Error","name","uiRoot","resolvedAspects","resolveAspects","PreviewRuntime","filteredAspects","filterAspectsByExecutionContext","filePath","generateRoot","aspects","allComponentContextAspects","reduce","acc","curr","concat","state","ids","hostAspects","Object","keys","toObject","allAspectsToInclude","uniq","filtered","filter","aspect","getId","isCoreAspect","includes","getDefaultStrategies","EnvBundlingStrategy","ComponentBundlingStrategy","getPreviewConfig","getBundlingStrategy","defaultStrategies","envPreviewConfig","strategyFromEnv","strategyName","bundlingStrategy","strategies","selected","find","strategy","BundlingStrategyNotFound","registerBundlingStrategy","register","registerDefinition","provider","bundler","componentExtension","uiMain","pubsub","loggerMain","graphql","createLogger","preview","registerStartPlugin","PreviewStartPlugin","registerRoute","PreviewRoute","ComponentPreviewRoute","EnvTemplateRoute","PreviewAssetsRoute","registerTarget","entry","bind","disabled","registerBuildTasks","EnvPreviewTemplateTask","PreviewTask","registerOnComponentAdd","add","registerOnComponentChange","update","registerOnComponentRemove","handleComponentRemoval","previewSchema","Slot","withType","MainRuntime","BundlerAspect","BuilderAspect","ComponentAspect","UIAspect","EnvsAspect","WorkspaceAspect","PkgAspect","PubsubAspect","AspectLoaderAspect","LoggerAspect","DependencyResolverAspect","GraphqlAspect","addRuntime"],"sources":["preview.main.runtime.tsx"],"sourcesContent":["import { ArtifactFactory, BuilderAspect } from '@teambit/builder';\nimport type { BuilderMain } from '@teambit/builder';\nimport { Asset, BundlerAspect, BundlerMain } from '@teambit/bundler';\nimport { PubsubAspect, PubsubMain } from '@teambit/pubsub';\nimport { MainRuntime } from '@teambit/cli';\nimport { Component, ComponentAspect, ComponentMain, ComponentMap, ComponentID } from '@teambit/component';\nimport { EnvsAspect } from '@teambit/envs';\nimport type { EnvsMain, ExecutionContext, PreviewEnv } from '@teambit/envs';\nimport { Slot, SlotRegistry, Harmony } from '@teambit/harmony';\nimport { UIAspect, UiMain } from '@teambit/ui';\nimport { CACHE_ROOT } from '@teambit/legacy/dist/constants';\nimport { BitError } from '@teambit/bit-error';\nimport objectHash from 'object-hash';\nimport { uniq } from 'lodash';\nimport { writeFileSync, existsSync, mkdirSync } from 'fs-extra';\nimport { join } from 'path';\nimport { PkgAspect, PkgMain } from '@teambit/pkg';\nimport { AspectLoaderAspect, getAspectDir, getAspectDirFromBvm } from '@teambit/aspect-loader';\nimport type { AspectDefinition, AspectLoaderMain } from '@teambit/aspect-loader';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport { LoggerAspect, LoggerMain, Logger } from '@teambit/logger';\nimport { DependencyResolverAspect } from '@teambit/dependency-resolver';\nimport type { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { ArtifactFiles } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';\nimport GraphqlAspect, { GraphqlMain } from '@teambit/graphql';\nimport { BundlingStrategyNotFound } from './exceptions';\nimport { generateLink } from './generate-link';\nimport { PreviewArtifact } from './preview-artifact';\nimport { PreviewDefinition } from './preview-definition';\nimport { PreviewAspect, PreviewRuntime } from './preview.aspect';\nimport { PreviewRoute } from './preview.route';\nimport { PreviewTask, PREVIEW_TASK_NAME } from './preview.task';\nimport { BundlingStrategy } from './bundling-strategy';\nimport { EnvBundlingStrategy, ComponentBundlingStrategy } from './strategies';\nimport { ExecutionRef } from './execution-ref';\nimport { PreviewStartPlugin } from './preview.start-plugin';\nimport {\n EnvPreviewTemplateTask,\n GENERATE_ENV_TEMPLATE_TASK_NAME,\n getArtifactDef as getEnvTemplateArtifactDef,\n} from './env-preview-template.task';\nimport { EnvTemplateRoute } from './env-template.route';\nimport { ComponentPreviewRoute } from './component-preview.route';\nimport { COMPONENT_STRATEGY_ARTIFACT_NAME, COMPONENT_STRATEGY_SIZE_KEY_NAME } from './strategies/component-strategy';\nimport { previewSchema } from './preview.graphql';\nimport { PreviewAssetsRoute } from './preview-assets.route';\n\nconst noopResult = {\n results: [],\n toString: () => `updating link file`,\n};\n\nconst DEFAULT_TEMP_DIR = join(CACHE_ROOT, PreviewAspect.id);\n\nexport type PreviewDefinitionRegistry = SlotRegistry<PreviewDefinition>;\n\ntype PreviewFiles = {\n files: string[];\n isBundledWithEnv: boolean;\n};\n\nexport type ComponentPreviewSizedFile = Asset;\n\nexport type ComponentPreviewSize = {\n files: ComponentPreviewSizedFile[];\n assets: ComponentPreviewSizedFile[];\n totalFiles: number;\n compressedTotalFiles?: number;\n totalAssets: number;\n compressedTotalAssets?: number;\n total: number;\n compressedTotal?: number;\n};\n\nexport type ComponentPreviewMetaData = {\n size?: ComponentPreviewSize;\n};\n\nexport type PreviewConfig = {\n bundlingStrategy?: string;\n disabled: boolean;\n /**\n * limit concurrent components when running the bundling step for your bundler during generate components preview task.\n * this helps mitigate large memory consumption for the build pipeline. This may increase the overall time for the generate-preview task, but reduce memory footprint.\n * default - no limit.\n */\n maxChunkSize?: number;\n};\n\nexport type EnvPreviewConfig = {\n strategyName?: string;\n splitComponentBundle?: boolean;\n};\n\nexport type BundlingStrategySlot = SlotRegistry<BundlingStrategy>;\n\nexport type GenerateLinkFn = (prefix: string, componentMap: ComponentMap<string[]>, defaultModule?: string) => string;\n\nexport class PreviewMain {\n constructor(\n /**\n * harmony context.\n */\n private harmony: Harmony,\n\n /**\n * slot for preview definitions.\n */\n private previewSlot: PreviewDefinitionRegistry,\n\n private ui: UiMain,\n\n private envs: EnvsMain,\n\n private componentAspect: ComponentMain,\n\n private pkg: PkgMain,\n\n private aspectLoader: AspectLoaderMain,\n\n readonly config: PreviewConfig,\n\n private bundlingStrategySlot: BundlingStrategySlot,\n\n private builder: BuilderMain,\n\n private workspace: Workspace | undefined,\n\n private logger: Logger,\n\n private dependencyResolver: DependencyResolverMain\n ) {}\n\n get tempFolder(): string {\n return this.workspace?.getTempDir(PreviewAspect.id) || DEFAULT_TEMP_DIR;\n }\n\n getComponentBundleSize(component: Component): ComponentPreviewSize | undefined {\n const data = this.builder.getDataByAspect(component, PreviewAspect.id);\n\n if (!data) return undefined;\n return data[COMPONENT_STRATEGY_SIZE_KEY_NAME];\n }\n\n async getPreview(component: Component): Promise<PreviewArtifact | undefined> {\n const artifacts = await this.builder.getArtifactsVinylByExtensionAndTaskName(\n component,\n PreviewAspect.id,\n PREVIEW_TASK_NAME\n );\n if (!artifacts) return undefined;\n return new PreviewArtifact(artifacts);\n }\n\n /**\n * Get a list of all the artifact files generated during the GeneratePreview task\n * @param component\n * @returns\n */\n async getPreviewFiles(component: Component): Promise<PreviewFiles | undefined> {\n const artifacts = await this.getPreview(component);\n const isBundledWithEnv = await this.isBundledWithEnv(component);\n if (!artifacts) return undefined;\n return {\n files: artifacts.getPaths(),\n isBundledWithEnv,\n };\n }\n\n /**\n * Check if the component preview bundle contain the env as part of the bundle or only the component code\n * (we used in the past to bundle them together, there might also be specific envs which still uses the env strategy)\n * @param component\n * @returns\n */\n async isBundledWithEnv(component: Component): Promise<boolean> {\n const artifacts = await this.builder.getArtifactsVinylByExtensionAndName(\n component,\n PreviewAspect.id,\n COMPONENT_STRATEGY_ARTIFACT_NAME\n );\n if (!artifacts || !artifacts.length) return true;\n\n return false;\n }\n\n /**\n * Getting the env template artifact\n * This should be called with the env itself or it will return undefined\n * If you want to get the env template from the env of the component,\n * use: getEnvTemplateFromComponentEnv below\n *\n * @param component\n * @returns\n */\n async getEnvTemplate(component: Component): Promise<PreviewArtifact | undefined> {\n const artifacts = await this.builder.getArtifactsVinylByExtensionAndTaskName(\n component,\n PreviewAspect.id,\n GENERATE_ENV_TEMPLATE_TASK_NAME\n );\n if (!artifacts || !artifacts.length) return undefined;\n\n return new PreviewArtifact(artifacts);\n }\n\n /**\n * This is a special method to get a core env template\n * As the core envs doesn't exist in the scope we need to bring it from other place\n * We will bring it from the core env package files\n */\n private async getCoreEnvTemplate(envId: string): Promise<PreviewArtifact | undefined> {\n const coreEnvDir = getAspectDir(envId);\n // const finalDir = join(coreEnvDir, getEnvTemplateArtifactDirectory());\n const artifactDef = getEnvTemplateArtifactDef()[0];\n const artifactFactory = new ArtifactFactory();\n\n let rootDir = artifactFactory.getRootDir(coreEnvDir, artifactDef);\n if (!existsSync(rootDir)) {\n // fallback to the bvm folder\n const coreEnvDirFromBvm = getAspectDirFromBvm(envId);\n rootDir = artifactFactory.getRootDir(coreEnvDirFromBvm, artifactDef);\n }\n if (!existsSync(rootDir)) {\n return undefined;\n }\n const paths = artifactFactory.resolvePaths(rootDir, artifactDef);\n if (!paths || !paths.length) {\n return undefined;\n }\n const artifactFiles = new ArtifactFiles(paths);\n\n artifactFiles.populateVinylsFromPaths(rootDir);\n return new PreviewArtifact(artifactFiles.vinyls);\n }\n\n /**\n * This will fetch the component env, then will take the env template from the component env\n * @param component\n */\n async getEnvTemplateFromComponentEnv(component: Component): Promise<PreviewArtifact | undefined> {\n const envId = this.envs.getEnvId(component);\n return this.getEnvTemplateByEnvId(envId);\n }\n\n /**\n * This will fetch the component env, then will take the env template from the component env\n * @param component\n */\n async getEnvTemplateByEnvId(envId: string): Promise<PreviewArtifact | undefined> {\n // Special treatment for core envs\n if (this.aspectLoader.isCoreEnv(envId)) {\n return this.getCoreEnvTemplate(envId);\n }\n const host = this.componentAspect.getHost();\n const resolvedEnvId = await host.resolveComponentId(envId);\n const envComponent = await host.get(resolvedEnvId);\n if (!envComponent) {\n throw new BitError(`can't load env. env id is ${envId}`);\n }\n return this.getEnvTemplate(envComponent);\n }\n\n getDefs(): PreviewDefinition[] {\n return this.previewSlot.values();\n }\n\n private writeHash = new Map<string, string>();\n private timestamp = Date.now();\n\n /**\n * write a link to load custom modules dynamically.\n * @param prefix write\n * @param moduleMap map of components to module paths to require.\n * @param defaultModule\n * @param dirName\n */\n writeLink(\n prefix: string,\n moduleMap: ComponentMap<string[]>,\n defaultModule: string | undefined,\n dirName: string,\n isSplitComponentBundle: boolean\n ) {\n const contents = generateLink(prefix, moduleMap, defaultModule, isSplitComponentBundle);\n return this.writeLinkContents(contents, dirName, prefix);\n }\n\n writeLinkContents(contents: string, targetDir: string, prefix: string) {\n const hash = objectHash(contents);\n const targetPath = join(targetDir, `${prefix}-${this.timestamp}.js`);\n\n // write only if link has changed (prevents triggering fs watches)\n if (this.writeHash.get(targetPath) !== hash) {\n writeFileSync(targetPath, contents);\n this.writeHash.set(targetPath, hash);\n }\n\n return targetPath;\n }\n\n private executionRefs = new Map<string, ExecutionRef>();\n\n private async getPreviewTarget(\n /** execution context (of the specific env) */\n context: ExecutionContext\n ): Promise<string[]> {\n // store context for later link-file updates\n // also register related envs that this context is acting on their behalf\n [context.id, ...context.relatedContexts].forEach((ctxId) => {\n this.executionRefs.set(ctxId, new ExecutionRef(context));\n });\n\n const previewRuntime = await this.writePreviewRuntime(context);\n const linkFiles = await this.updateLinkFiles(context.components, context);\n\n return [...linkFiles, previewRuntime];\n }\n\n private updateLinkFiles(components: Component[] = [], context: ExecutionContext) {\n const previews = this.previewSlot.values();\n const paths = previews.map(async (previewDef) => {\n const templatePath = await previewDef.renderTemplatePath?.(context);\n\n const map = await previewDef.getModuleMap(components);\n const isSplitComponentBundle = this.getEnvPreviewConfig().splitComponentBundle ?? false;\n const withPaths = map.map<string[]>((files, component) => {\n const environment = this.envs.getEnv(component).env;\n const compilerInstance = environment.getCompiler?.();\n const modulePath =\n compilerInstance?.getPreviewComponentRootPath?.(component) || this.pkg.getModulePath(component);\n return files.map((file) => {\n if (!this.workspace || !compilerInstance) {\n return file.path;\n }\n const distRelativePath = compilerInstance.getDistPathBySrcPath(file.relative);\n return join(this.workspace.path, modulePath, distRelativePath);\n });\n // return files.map((file) => file.path);\n });\n\n const dirPath = join(this.tempFolder, context.id);\n if (!existsSync(dirPath)) mkdirSync(dirPath, { recursive: true });\n\n const link = this.writeLink(previewDef.prefix, withPaths, templatePath, dirPath, isSplitComponentBundle);\n return link;\n });\n\n return Promise.all(paths);\n }\n\n async writePreviewRuntime(context: { components: Component[] }, aspectsIdsToNotFilterOut: string[] = []) {\n const ui = this.ui.getUi();\n if (!ui) throw new Error('ui not found');\n const [name, uiRoot] = ui;\n const resolvedAspects = await uiRoot.resolveAspects(PreviewRuntime.name);\n const filteredAspects = this.filterAspectsByExecutionContext(resolvedAspects, context, aspectsIdsToNotFilterOut);\n const filePath = await this.ui.generateRoot(filteredAspects, name, 'preview', PreviewAspect.id);\n return filePath;\n }\n\n /**\n * Filter the aspects to have only aspects that are:\n * 1. core aspects\n * 2. configured on the host (workspace/scope)\n * 3. used by at least one component from the context\n * @param aspects\n * @param context\n */\n private filterAspectsByExecutionContext(\n aspects: AspectDefinition[],\n context: { components: Component[] },\n aspectsIdsToNotFilterOut: string[] = []\n ) {\n let allComponentContextAspects: string[] = [];\n allComponentContextAspects = context.components.reduce((acc, curr) => {\n return acc.concat(curr.state.aspects.ids);\n }, allComponentContextAspects);\n const hostAspects = Object.keys(this.harmony.config.toObject());\n const allAspectsToInclude = uniq(hostAspects.concat(allComponentContextAspects));\n const filtered = aspects.filter((aspect) => {\n if (!aspect.getId) {\n return false;\n }\n return (\n this.aspectLoader.isCoreAspect(aspect.getId) ||\n allAspectsToInclude.includes(aspect.getId) ||\n aspectsIdsToNotFilterOut.includes(aspect.getId)\n );\n });\n\n return filtered;\n }\n\n private getDefaultStrategies() {\n return [\n new EnvBundlingStrategy(this, this.pkg, this.dependencyResolver),\n new ComponentBundlingStrategy(this, this.pkg, this.dependencyResolver),\n ];\n }\n\n // TODO - executionContext should be responsible for updating components list, and emit 'update' events\n // instead we keep track of changes\n private handleComponentChange = async (c: Component, updater: (currentComponents: ExecutionRef) => void) => {\n const env = this.envs.getEnv(c);\n const envId = env.id.toString();\n\n const executionRef = this.executionRefs.get(envId);\n if (!executionRef) {\n this.logger.warn(\n `failed to update link file for component \"${c.id.toString()}\" - could not find execution context for ${envId}`\n );\n return noopResult;\n }\n\n // add / remove / etc\n updater(executionRef);\n\n await this.updateLinkFiles(executionRef.currentComponents, executionRef.executionCtx);\n\n return noopResult;\n };\n\n private handleComponentRemoval = (cId: ComponentID) => {\n let component: Component | undefined;\n this.executionRefs.forEach((components) => {\n const found = components.get(cId);\n if (found) component = found;\n });\n if (!component) return Promise.resolve(noopResult);\n\n return this.handleComponentChange(component, (currentComponents) => currentComponents.remove(cId));\n };\n\n getEnvPreviewConfig(env?: PreviewEnv): EnvPreviewConfig {\n const config = env?.getPreviewConfig && typeof env?.getPreviewConfig === 'function' ? env?.getPreviewConfig() : {};\n\n return config;\n }\n\n /**\n * return the configured bundling strategy.\n */\n getBundlingStrategy(env?: PreviewEnv): BundlingStrategy {\n const defaultStrategies = this.getDefaultStrategies();\n const envPreviewConfig = this.getEnvPreviewConfig(env);\n const strategyFromEnv = envPreviewConfig?.strategyName;\n const strategyName = strategyFromEnv || this.config.bundlingStrategy || 'env';\n const strategies = this.bundlingStrategySlot.values().concat(defaultStrategies);\n const selected = strategies.find((strategy) => {\n return strategy.name === strategyName;\n });\n\n if (!selected) throw new BundlingStrategyNotFound(strategyName);\n\n return selected;\n }\n\n /**\n * register a new bundling strategy. default available strategies are `env` and ``\n */\n registerBundlingStrategy(bundlingStrategy: BundlingStrategy) {\n this.bundlingStrategySlot.register(bundlingStrategy);\n return this;\n }\n\n /**\n * register a new preview definition.\n */\n registerDefinition(previewDef: PreviewDefinition) {\n this.previewSlot.register(previewDef);\n }\n\n static slots = [Slot.withType<PreviewDefinition>(), Slot.withType<BundlingStrategy>()];\n\n static runtime = MainRuntime;\n static dependencies = [\n BundlerAspect,\n BuilderAspect,\n ComponentAspect,\n UIAspect,\n EnvsAspect,\n WorkspaceAspect,\n PkgAspect,\n PubsubAspect,\n AspectLoaderAspect,\n LoggerAspect,\n DependencyResolverAspect,\n GraphqlAspect,\n ];\n\n static defaultConfig = {\n disabled: false,\n };\n\n static async provider(\n // eslint-disable-next-line max-len\n [\n bundler,\n builder,\n componentExtension,\n uiMain,\n envs,\n workspace,\n pkg,\n pubsub,\n aspectLoader,\n loggerMain,\n dependencyResolver,\n graphql,\n ]: [\n BundlerMain,\n BuilderMain,\n ComponentMain,\n UiMain,\n EnvsMain,\n Workspace | undefined,\n PkgMain,\n PubsubMain,\n AspectLoaderMain,\n LoggerMain,\n DependencyResolverMain,\n GraphqlMain\n ],\n config: PreviewConfig,\n [previewSlot, bundlingStrategySlot]: [PreviewDefinitionRegistry, BundlingStrategySlot],\n harmony: Harmony\n ) {\n const logger = loggerMain.createLogger(PreviewAspect.id);\n // app.registerApp(new PreviewApp());\n const preview = new PreviewMain(\n harmony,\n previewSlot,\n uiMain,\n envs,\n componentExtension,\n pkg,\n aspectLoader,\n config,\n bundlingStrategySlot,\n builder,\n workspace,\n logger,\n dependencyResolver\n );\n\n if (workspace) uiMain.registerStartPlugin(new PreviewStartPlugin(workspace, bundler, uiMain, pubsub, logger));\n\n componentExtension.registerRoute([\n new PreviewRoute(preview, logger),\n new ComponentPreviewRoute(preview, logger),\n // @ts-ignore\n new EnvTemplateRoute(preview, logger),\n new PreviewAssetsRoute(preview, logger),\n ]);\n\n bundler.registerTarget([\n {\n entry: preview.getPreviewTarget.bind(preview),\n },\n ]);\n\n if (!config.disabled)\n builder.registerBuildTasks([\n new EnvPreviewTemplateTask(preview, envs, aspectLoader, dependencyResolver, logger),\n new PreviewTask(bundler, preview, dependencyResolver, logger),\n ]);\n\n if (workspace) {\n workspace.registerOnComponentAdd((c) =>\n preview.handleComponentChange(c, (currentComponents) => currentComponents.add(c))\n );\n workspace.registerOnComponentChange((c) =>\n preview.handleComponentChange(c, (currentComponents) => currentComponents.update(c))\n );\n workspace.registerOnComponentRemove((cId) => preview.handleComponentRemoval(cId));\n }\n\n graphql.register(previewSchema(preview));\n\n return preview;\n }\n}\n\nPreviewAspect.addRuntime(PreviewMain);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;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;;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;;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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AHoB,EAIpBC,cAJoB,EAKpBC,kBALoB,EAMpBC,oBANoB,EAOpBC,gBAPoB,EAQpBC,sBARoB,EASpBC,kCAToB,EAUpBC,sBAVoB,EAWpBC,8CAXoB,EAYpBC,kBAZoB,C;gCA1XX1O,W,mBAyYY;EACrBiN,QAAQ,EAAE;AADW,C;;AA6FzBnN,wBAAA,CAAc6O,UAAd,CAAyB3O,WAAzB"}
|
|
1
|
+
{"version":3,"names":["noopResult","results","toString","DEFAULT_TEMP_DIR","join","CACHE_ROOT","PreviewAspect","id","PreviewMain","constructor","harmony","previewSlot","ui","envs","componentAspect","pkg","aspectLoader","config","bundlingStrategySlot","builder","workspace","logger","dependencyResolver","Map","Date","now","c","updater","env","getEnv","envId","executionRef","executionRefs","get","warn","updateLinkFiles","currentComponents","executionCtx","cId","component","forEach","components","found","Promise","resolve","handleComponentChange","remove","tempFolder","getTempDir","getComponentBundleSize","data","getDataByAspect","undefined","COMPONENT_STRATEGY_SIZE_KEY_NAME","getPreview","artifacts","getArtifactsVinylByExtensionAndTaskName","PREVIEW_TASK_NAME","PreviewArtifact","getPreviewFiles","isBundledWithEnv","files","getPaths","getArtifactsVinylByExtensionAndName","COMPONENT_STRATEGY_ARTIFACT_NAME","length","isLegacyHeader","ENV_WITH_LEGACY_DOCS","ENV_STRATEGY_ARTIFACT_NAME","envType","getEnvData","type","includes","getEnvTemplate","GENERATE_ENV_TEMPLATE_TASK_NAME","getCoreEnvTemplate","coreEnvDir","getAspectDir","artifactDef","getEnvTemplateArtifactDef","artifactFactory","ArtifactFactory","rootDir","getRootDir","existsSync","coreEnvDirFromBvm","getAspectDirFromBvm","paths","resolvePaths","artifactFiles","ArtifactFiles","populateVinylsFromPaths","vinyls","getEnvTemplateFromComponentEnv","getEnvId","getEnvTemplateByEnvId","isCoreEnv","host","getHost","resolvedEnvId","resolveComponentId","envComponent","BitError","getDefs","values","writeLink","prefix","moduleMap","defaultModule","dirName","isSplitComponentBundle","contents","generateLink","writeLinkContents","targetDir","hash","objectHash","targetPath","timestamp","writeHash","writeFileSync","set","getPreviewTarget","context","relatedContexts","ctxId","ExecutionRef","previewRuntime","writePreviewRuntime","linkFiles","previews","map","previewDef","templatePath","renderTemplatePath","getModuleMap","getEnvPreviewConfig","splitComponentBundle","withPaths","environment","compilerInstance","getCompiler","modulePath","getPreviewComponentRootPath","getModulePath","file","path","distRelativePath","getDistPathBySrcPath","relative","dirPath","mkdirSync","recursive","link","all","aspectsIdsToNotFilterOut","getUi","Error","name","uiRoot","resolvedAspects","resolveAspects","PreviewRuntime","filteredAspects","filterAspectsByExecutionContext","filePath","generateRoot","aspects","allComponentContextAspects","reduce","acc","curr","concat","state","ids","hostAspects","Object","keys","toObject","allAspectsToInclude","uniq","filtered","filter","aspect","getId","isCoreAspect","getDefaultStrategies","EnvBundlingStrategy","ComponentBundlingStrategy","getPreviewConfig","getBundlingStrategy","defaultStrategies","envPreviewConfig","strategyFromEnv","strategyName","bundlingStrategy","strategies","selected","find","strategy","BundlingStrategyNotFound","registerBundlingStrategy","register","registerDefinition","provider","bundler","componentExtension","uiMain","pubsub","loggerMain","graphql","createLogger","preview","registerStartPlugin","PreviewStartPlugin","registerRoute","PreviewRoute","ComponentPreviewRoute","EnvTemplateRoute","PreviewAssetsRoute","registerTarget","entry","bind","disabled","registerBuildTasks","EnvPreviewTemplateTask","PreviewTask","registerOnComponentAdd","add","registerOnComponentChange","update","registerOnComponentRemove","handleComponentRemoval","previewSchema","Slot","withType","MainRuntime","BundlerAspect","BuilderAspect","ComponentAspect","UIAspect","EnvsAspect","WorkspaceAspect","PkgAspect","PubsubAspect","AspectLoaderAspect","LoggerAspect","DependencyResolverAspect","GraphqlAspect","addRuntime"],"sources":["preview.main.runtime.tsx"],"sourcesContent":["import { ArtifactFactory, BuilderAspect } from '@teambit/builder';\nimport type { BuilderMain } from '@teambit/builder';\nimport { Asset, BundlerAspect, BundlerMain } from '@teambit/bundler';\nimport { PubsubAspect, PubsubMain } from '@teambit/pubsub';\nimport { MainRuntime } from '@teambit/cli';\nimport { Component, ComponentAspect, ComponentMain, ComponentMap, ComponentID } from '@teambit/component';\nimport { EnvsAspect } from '@teambit/envs';\nimport type { EnvsMain, ExecutionContext, PreviewEnv } from '@teambit/envs';\nimport { Slot, SlotRegistry, Harmony } from '@teambit/harmony';\nimport { UIAspect, UiMain } from '@teambit/ui';\nimport { CACHE_ROOT } from '@teambit/legacy/dist/constants';\nimport { BitError } from '@teambit/bit-error';\nimport objectHash from 'object-hash';\nimport { uniq } from 'lodash';\nimport { writeFileSync, existsSync, mkdirSync } from 'fs-extra';\nimport { join } from 'path';\nimport { PkgAspect, PkgMain } from '@teambit/pkg';\nimport { AspectLoaderAspect, getAspectDir, getAspectDirFromBvm } from '@teambit/aspect-loader';\nimport type { AspectDefinition, AspectLoaderMain } from '@teambit/aspect-loader';\nimport WorkspaceAspect, { Workspace } from '@teambit/workspace';\nimport { LoggerAspect, LoggerMain, Logger } from '@teambit/logger';\nimport { DependencyResolverAspect } from '@teambit/dependency-resolver';\nimport type { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { ArtifactFiles } from '@teambit/legacy/dist/consumer/component/sources/artifact-files';\nimport GraphqlAspect, { GraphqlMain } from '@teambit/graphql';\nimport { BundlingStrategyNotFound } from './exceptions';\nimport { generateLink } from './generate-link';\nimport { PreviewArtifact } from './preview-artifact';\nimport { PreviewDefinition } from './preview-definition';\nimport { PreviewAspect, PreviewRuntime } from './preview.aspect';\nimport { PreviewRoute } from './preview.route';\nimport { PreviewTask, PREVIEW_TASK_NAME } from './preview.task';\nimport { BundlingStrategy } from './bundling-strategy';\nimport { EnvBundlingStrategy, ComponentBundlingStrategy } from './strategies';\nimport { ExecutionRef } from './execution-ref';\nimport { PreviewStartPlugin } from './preview.start-plugin';\nimport {\n EnvPreviewTemplateTask,\n GENERATE_ENV_TEMPLATE_TASK_NAME,\n getArtifactDef as getEnvTemplateArtifactDef,\n} from './env-preview-template.task';\nimport { EnvTemplateRoute } from './env-template.route';\nimport { ComponentPreviewRoute } from './component-preview.route';\nimport { COMPONENT_STRATEGY_ARTIFACT_NAME, COMPONENT_STRATEGY_SIZE_KEY_NAME } from './strategies/component-strategy';\nimport { ENV_STRATEGY_ARTIFACT_NAME } from './strategies/env-strategy';\nimport { previewSchema } from './preview.graphql';\nimport { PreviewAssetsRoute } from './preview-assets.route';\n\nconst noopResult = {\n results: [],\n toString: () => `updating link file`,\n};\n\nconst DEFAULT_TEMP_DIR = join(CACHE_ROOT, PreviewAspect.id);\n\nexport type PreviewDefinitionRegistry = SlotRegistry<PreviewDefinition>;\n\ntype PreviewFiles = {\n files: string[];\n isBundledWithEnv: boolean;\n};\n\nexport type ComponentPreviewSizedFile = Asset;\n\nexport type ComponentPreviewSize = {\n files: ComponentPreviewSizedFile[];\n assets: ComponentPreviewSizedFile[];\n totalFiles: number;\n compressedTotalFiles?: number;\n totalAssets: number;\n compressedTotalAssets?: number;\n total: number;\n compressedTotal?: number;\n};\n\nexport type ComponentPreviewMetaData = {\n size?: ComponentPreviewSize;\n};\n\nexport type PreviewConfig = {\n bundlingStrategy?: string;\n disabled: boolean;\n /**\n * limit concurrent components when running the bundling step for your bundler during generate components preview task.\n * this helps mitigate large memory consumption for the build pipeline. This may increase the overall time for the generate-preview task, but reduce memory footprint.\n * default - no limit.\n */\n maxChunkSize?: number;\n};\n\nexport type EnvPreviewConfig = {\n strategyName?: string;\n splitComponentBundle?: boolean;\n};\n\nexport type BundlingStrategySlot = SlotRegistry<BundlingStrategy>;\n\nexport type GenerateLinkFn = (prefix: string, componentMap: ComponentMap<string[]>, defaultModule?: string) => string;\n\nexport class PreviewMain {\n constructor(\n /**\n * harmony context.\n */\n private harmony: Harmony,\n\n /**\n * slot for preview definitions.\n */\n private previewSlot: PreviewDefinitionRegistry,\n\n private ui: UiMain,\n\n private envs: EnvsMain,\n\n private componentAspect: ComponentMain,\n\n private pkg: PkgMain,\n\n private aspectLoader: AspectLoaderMain,\n\n readonly config: PreviewConfig,\n\n private bundlingStrategySlot: BundlingStrategySlot,\n\n private builder: BuilderMain,\n\n private workspace: Workspace | undefined,\n\n private logger: Logger,\n\n private dependencyResolver: DependencyResolverMain\n ) {}\n\n get tempFolder(): string {\n return this.workspace?.getTempDir(PreviewAspect.id) || DEFAULT_TEMP_DIR;\n }\n\n getComponentBundleSize(component: Component): ComponentPreviewSize | undefined {\n const data = this.builder.getDataByAspect(component, PreviewAspect.id);\n\n if (!data) return undefined;\n return data[COMPONENT_STRATEGY_SIZE_KEY_NAME];\n }\n\n async getPreview(component: Component): Promise<PreviewArtifact | undefined> {\n const artifacts = await this.builder.getArtifactsVinylByExtensionAndTaskName(\n component,\n PreviewAspect.id,\n PREVIEW_TASK_NAME\n );\n if (!artifacts) return undefined;\n return new PreviewArtifact(artifacts);\n }\n\n /**\n * Get a list of all the artifact files generated during the GeneratePreview task\n * @param component\n * @returns\n */\n async getPreviewFiles(component: Component): Promise<PreviewFiles | undefined> {\n const artifacts = await this.getPreview(component);\n const isBundledWithEnv = await this.isBundledWithEnv(component);\n if (!artifacts) return undefined;\n return {\n files: artifacts.getPaths(),\n isBundledWithEnv,\n };\n }\n\n /**\n * Check if the component preview bundle contain the env as part of the bundle or only the component code\n * (we used in the past to bundle them together, there might also be specific envs which still uses the env strategy)\n * @param component\n * @returns\n */\n async isBundledWithEnv(component: Component): Promise<boolean> {\n const artifacts = await this.builder.getArtifactsVinylByExtensionAndName(\n component,\n PreviewAspect.id,\n COMPONENT_STRATEGY_ARTIFACT_NAME\n );\n if (!artifacts || !artifacts.length) return true;\n\n return false;\n }\n\n /**\n * Check if the component preview bundle contain the header inside of it (legacy)\n * today we are not including the header inside anymore\n * @param component\n * @returns\n */\n async isLegacyHeader(component: Component): Promise<boolean> {\n // these envs had header in their docs\n const ENV_WITH_LEGACY_DOCS = ['react', 'env', 'aspect', 'lit', 'html', 'node', 'mdx', 'react-native', 'readme'];\n\n const artifacts = await this.builder.getArtifactsVinylByExtensionAndName(\n component,\n PreviewAspect.id,\n ENV_STRATEGY_ARTIFACT_NAME\n );\n const envType = this.envs.getEnvData(component).type;\n return !!artifacts && !!artifacts.length && ENV_WITH_LEGACY_DOCS.includes(envType);\n }\n\n /**\n * Getting the env template artifact\n * This should be called with the env itself or it will return undefined\n * If you want to get the env template from the env of the component,\n * use: getEnvTemplateFromComponentEnv below\n *\n * @param component\n * @returns\n */\n async getEnvTemplate(component: Component): Promise<PreviewArtifact | undefined> {\n const artifacts = await this.builder.getArtifactsVinylByExtensionAndTaskName(\n component,\n PreviewAspect.id,\n GENERATE_ENV_TEMPLATE_TASK_NAME\n );\n if (!artifacts || !artifacts.length) return undefined;\n\n return new PreviewArtifact(artifacts);\n }\n\n /**\n * This is a special method to get a core env template\n * As the core envs doesn't exist in the scope we need to bring it from other place\n * We will bring it from the core env package files\n */\n private async getCoreEnvTemplate(envId: string): Promise<PreviewArtifact | undefined> {\n const coreEnvDir = getAspectDir(envId);\n // const finalDir = join(coreEnvDir, getEnvTemplateArtifactDirectory());\n const artifactDef = getEnvTemplateArtifactDef()[0];\n const artifactFactory = new ArtifactFactory();\n\n let rootDir = artifactFactory.getRootDir(coreEnvDir, artifactDef);\n if (!existsSync(rootDir)) {\n // fallback to the bvm folder\n const coreEnvDirFromBvm = getAspectDirFromBvm(envId);\n rootDir = artifactFactory.getRootDir(coreEnvDirFromBvm, artifactDef);\n }\n if (!existsSync(rootDir)) {\n return undefined;\n }\n const paths = artifactFactory.resolvePaths(rootDir, artifactDef);\n if (!paths || !paths.length) {\n return undefined;\n }\n const artifactFiles = new ArtifactFiles(paths);\n\n artifactFiles.populateVinylsFromPaths(rootDir);\n return new PreviewArtifact(artifactFiles.vinyls);\n }\n\n /**\n * This will fetch the component env, then will take the env template from the component env\n * @param component\n */\n async getEnvTemplateFromComponentEnv(component: Component): Promise<PreviewArtifact | undefined> {\n const envId = this.envs.getEnvId(component);\n return this.getEnvTemplateByEnvId(envId);\n }\n\n /**\n * This will fetch the component env, then will take the env template from the component env\n * @param component\n */\n async getEnvTemplateByEnvId(envId: string): Promise<PreviewArtifact | undefined> {\n // Special treatment for core envs\n if (this.aspectLoader.isCoreEnv(envId)) {\n return this.getCoreEnvTemplate(envId);\n }\n const host = this.componentAspect.getHost();\n const resolvedEnvId = await host.resolveComponentId(envId);\n const envComponent = await host.get(resolvedEnvId);\n if (!envComponent) {\n throw new BitError(`can't load env. env id is ${envId}`);\n }\n return this.getEnvTemplate(envComponent);\n }\n\n getDefs(): PreviewDefinition[] {\n return this.previewSlot.values();\n }\n\n private writeHash = new Map<string, string>();\n private timestamp = Date.now();\n\n /**\n * write a link to load custom modules dynamically.\n * @param prefix write\n * @param moduleMap map of components to module paths to require.\n * @param defaultModule\n * @param dirName\n */\n writeLink(\n prefix: string,\n moduleMap: ComponentMap<string[]>,\n defaultModule: string | undefined,\n dirName: string,\n isSplitComponentBundle: boolean\n ) {\n const contents = generateLink(prefix, moduleMap, defaultModule, isSplitComponentBundle);\n return this.writeLinkContents(contents, dirName, prefix);\n }\n\n writeLinkContents(contents: string, targetDir: string, prefix: string) {\n const hash = objectHash(contents);\n const targetPath = join(targetDir, `${prefix}-${this.timestamp}.js`);\n\n // write only if link has changed (prevents triggering fs watches)\n if (this.writeHash.get(targetPath) !== hash) {\n writeFileSync(targetPath, contents);\n this.writeHash.set(targetPath, hash);\n }\n\n return targetPath;\n }\n\n private executionRefs = new Map<string, ExecutionRef>();\n\n private async getPreviewTarget(\n /** execution context (of the specific env) */\n context: ExecutionContext\n ): Promise<string[]> {\n // store context for later link-file updates\n // also register related envs that this context is acting on their behalf\n [context.id, ...context.relatedContexts].forEach((ctxId) => {\n this.executionRefs.set(ctxId, new ExecutionRef(context));\n });\n\n const previewRuntime = await this.writePreviewRuntime(context);\n const linkFiles = await this.updateLinkFiles(context.components, context);\n\n return [...linkFiles, previewRuntime];\n }\n\n private updateLinkFiles(components: Component[] = [], context: ExecutionContext) {\n const previews = this.previewSlot.values();\n const paths = previews.map(async (previewDef) => {\n const templatePath = await previewDef.renderTemplatePath?.(context);\n\n const map = await previewDef.getModuleMap(components);\n const isSplitComponentBundle = this.getEnvPreviewConfig().splitComponentBundle ?? false;\n const withPaths = map.map<string[]>((files, component) => {\n const environment = this.envs.getEnv(component).env;\n const compilerInstance = environment.getCompiler?.();\n const modulePath =\n compilerInstance?.getPreviewComponentRootPath?.(component) || this.pkg.getModulePath(component);\n return files.map((file) => {\n if (!this.workspace || !compilerInstance) {\n return file.path;\n }\n const distRelativePath = compilerInstance.getDistPathBySrcPath(file.relative);\n return join(this.workspace.path, modulePath, distRelativePath);\n });\n // return files.map((file) => file.path);\n });\n\n const dirPath = join(this.tempFolder, context.id);\n if (!existsSync(dirPath)) mkdirSync(dirPath, { recursive: true });\n\n const link = this.writeLink(previewDef.prefix, withPaths, templatePath, dirPath, isSplitComponentBundle);\n return link;\n });\n\n return Promise.all(paths);\n }\n\n async writePreviewRuntime(context: { components: Component[] }, aspectsIdsToNotFilterOut: string[] = []) {\n const ui = this.ui.getUi();\n if (!ui) throw new Error('ui not found');\n const [name, uiRoot] = ui;\n const resolvedAspects = await uiRoot.resolveAspects(PreviewRuntime.name);\n const filteredAspects = this.filterAspectsByExecutionContext(resolvedAspects, context, aspectsIdsToNotFilterOut);\n const filePath = await this.ui.generateRoot(filteredAspects, name, 'preview', PreviewAspect.id);\n return filePath;\n }\n\n /**\n * Filter the aspects to have only aspects that are:\n * 1. core aspects\n * 2. configured on the host (workspace/scope)\n * 3. used by at least one component from the context\n * @param aspects\n * @param context\n */\n private filterAspectsByExecutionContext(\n aspects: AspectDefinition[],\n context: { components: Component[] },\n aspectsIdsToNotFilterOut: string[] = []\n ) {\n let allComponentContextAspects: string[] = [];\n allComponentContextAspects = context.components.reduce((acc, curr) => {\n return acc.concat(curr.state.aspects.ids);\n }, allComponentContextAspects);\n const hostAspects = Object.keys(this.harmony.config.toObject());\n const allAspectsToInclude = uniq(hostAspects.concat(allComponentContextAspects));\n const filtered = aspects.filter((aspect) => {\n if (!aspect.getId) {\n return false;\n }\n return (\n this.aspectLoader.isCoreAspect(aspect.getId) ||\n allAspectsToInclude.includes(aspect.getId) ||\n aspectsIdsToNotFilterOut.includes(aspect.getId)\n );\n });\n\n return filtered;\n }\n\n private getDefaultStrategies() {\n return [\n new EnvBundlingStrategy(this, this.pkg, this.dependencyResolver),\n new ComponentBundlingStrategy(this, this.pkg, this.dependencyResolver),\n ];\n }\n\n // TODO - executionContext should be responsible for updating components list, and emit 'update' events\n // instead we keep track of changes\n private handleComponentChange = async (c: Component, updater: (currentComponents: ExecutionRef) => void) => {\n const env = this.envs.getEnv(c);\n const envId = env.id.toString();\n\n const executionRef = this.executionRefs.get(envId);\n if (!executionRef) {\n this.logger.warn(\n `failed to update link file for component \"${c.id.toString()}\" - could not find execution context for ${envId}`\n );\n return noopResult;\n }\n\n // add / remove / etc\n updater(executionRef);\n\n await this.updateLinkFiles(executionRef.currentComponents, executionRef.executionCtx);\n\n return noopResult;\n };\n\n private handleComponentRemoval = (cId: ComponentID) => {\n let component: Component | undefined;\n this.executionRefs.forEach((components) => {\n const found = components.get(cId);\n if (found) component = found;\n });\n if (!component) return Promise.resolve(noopResult);\n\n return this.handleComponentChange(component, (currentComponents) => currentComponents.remove(cId));\n };\n\n getEnvPreviewConfig(env?: PreviewEnv): EnvPreviewConfig {\n const config = env?.getPreviewConfig && typeof env?.getPreviewConfig === 'function' ? env?.getPreviewConfig() : {};\n\n return config;\n }\n\n /**\n * return the configured bundling strategy.\n */\n getBundlingStrategy(env?: PreviewEnv): BundlingStrategy {\n const defaultStrategies = this.getDefaultStrategies();\n const envPreviewConfig = this.getEnvPreviewConfig(env);\n const strategyFromEnv = envPreviewConfig?.strategyName;\n const strategyName = strategyFromEnv || this.config.bundlingStrategy || 'env';\n const strategies = this.bundlingStrategySlot.values().concat(defaultStrategies);\n const selected = strategies.find((strategy) => {\n return strategy.name === strategyName;\n });\n\n if (!selected) throw new BundlingStrategyNotFound(strategyName);\n\n return selected;\n }\n\n /**\n * register a new bundling strategy. default available strategies are `env` and ``\n */\n registerBundlingStrategy(bundlingStrategy: BundlingStrategy) {\n this.bundlingStrategySlot.register(bundlingStrategy);\n return this;\n }\n\n /**\n * register a new preview definition.\n */\n registerDefinition(previewDef: PreviewDefinition) {\n this.previewSlot.register(previewDef);\n }\n\n static slots = [Slot.withType<PreviewDefinition>(), Slot.withType<BundlingStrategy>()];\n\n static runtime = MainRuntime;\n static dependencies = [\n BundlerAspect,\n BuilderAspect,\n ComponentAspect,\n UIAspect,\n EnvsAspect,\n WorkspaceAspect,\n PkgAspect,\n PubsubAspect,\n AspectLoaderAspect,\n LoggerAspect,\n DependencyResolverAspect,\n GraphqlAspect,\n ];\n\n static defaultConfig = {\n disabled: false,\n };\n\n static async provider(\n // eslint-disable-next-line max-len\n [\n bundler,\n builder,\n componentExtension,\n uiMain,\n envs,\n workspace,\n pkg,\n pubsub,\n aspectLoader,\n loggerMain,\n dependencyResolver,\n graphql,\n ]: [\n BundlerMain,\n BuilderMain,\n ComponentMain,\n UiMain,\n EnvsMain,\n Workspace | undefined,\n PkgMain,\n PubsubMain,\n AspectLoaderMain,\n LoggerMain,\n DependencyResolverMain,\n GraphqlMain\n ],\n config: PreviewConfig,\n [previewSlot, bundlingStrategySlot]: [PreviewDefinitionRegistry, BundlingStrategySlot],\n harmony: Harmony\n ) {\n const logger = loggerMain.createLogger(PreviewAspect.id);\n // app.registerApp(new PreviewApp());\n const preview = new PreviewMain(\n harmony,\n previewSlot,\n uiMain,\n envs,\n componentExtension,\n pkg,\n aspectLoader,\n config,\n bundlingStrategySlot,\n builder,\n workspace,\n logger,\n dependencyResolver\n );\n\n if (workspace) uiMain.registerStartPlugin(new PreviewStartPlugin(workspace, bundler, uiMain, pubsub, logger));\n\n componentExtension.registerRoute([\n new PreviewRoute(preview, logger),\n new ComponentPreviewRoute(preview, logger),\n // @ts-ignore\n new EnvTemplateRoute(preview, logger),\n new PreviewAssetsRoute(preview, logger),\n ]);\n\n bundler.registerTarget([\n {\n entry: preview.getPreviewTarget.bind(preview),\n },\n ]);\n\n if (!config.disabled)\n builder.registerBuildTasks([\n new EnvPreviewTemplateTask(preview, envs, aspectLoader, dependencyResolver, logger),\n new PreviewTask(bundler, preview, dependencyResolver, logger),\n ]);\n\n if (workspace) {\n workspace.registerOnComponentAdd((c) =>\n preview.handleComponentChange(c, (currentComponents) => currentComponents.add(c))\n );\n workspace.registerOnComponentChange((c) =>\n preview.handleComponentChange(c, (currentComponents) => currentComponents.update(c))\n );\n workspace.registerOnComponentRemove((cId) => preview.handleComponentRemoval(cId));\n }\n\n graphql.register(previewSchema(preview));\n\n return preview;\n }\n}\n\nPreviewAspect.addRuntime(PreviewMain);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;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;;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;;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;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AAqC3M,CAAD,IAClC0L,OAAO,CAACvK,qBAAR,CAA8BnB,CAA9B,EAAkCU,iBAAD,IAAuBA,iBAAiB,CAACkM,MAAlB,CAAyB5M,CAAzB,CAAxD,CADF;MAGAN,SAAS,CAACmN,yBAAV,CAAqCjM,GAAD,IAAS8K,OAAO,CAACoB,sBAAR,CAA+BlM,GAA/B,CAA7C;IACD;;IAED4K,OAAO,CAACR,QAAR,CAAiB,IAAA+B,yBAAA,EAAcrB,OAAd,CAAjB;IAEA,OAAOA,OAAP;EACD;;AAtfsB;;;gCAAZ5M,W,WA0YI,CAACkO,eAAA,CAAKC,QAAL,EAAD,EAAqCD,eAAA,CAAKC,QAAL,EAArC,C;gCA1YJnO,W,aA4YMoO,kB;gCA5YNpO,W,kBA6YW,CACpBqO,wBADoB,EAEpBC,wBAFoB,EAGpBC,4BAHoB,EAIpBC,cAJoB,EAKpBC,kBALoB,EAMpBC,oBANoB,EAOpBC,gBAPoB,EAQpBC,sBARoB,EASpBC,kCAToB,EAUpBC,sBAVoB,EAWpBC,8CAXoB,EAYpBC,kBAZoB,C;gCA7YXhP,W,mBA4ZY;EACrBuN,QAAQ,EAAE;AADW,C;;AA6FzBzN,wBAAA,CAAcmP,UAAd,CAAyBjP,WAAzB"}
|
|
@@ -5,6 +5,7 @@ import { PkgMain } from '@teambit/pkg';
|
|
|
5
5
|
import type { BundlingStrategy, ComputeTargetsContext } from '../bundling-strategy';
|
|
6
6
|
import { PreviewDefinition } from '../preview-definition';
|
|
7
7
|
import { PreviewMain } from '../preview.main.runtime';
|
|
8
|
+
export declare const ENV_STRATEGY_ARTIFACT_NAME = "preview";
|
|
8
9
|
/**
|
|
9
10
|
* bundles all components in a given env into the same bundle.
|
|
10
11
|
*/
|
|
@@ -13,7 +13,7 @@ require("core-js/modules/es.string.replace.js");
|
|
|
13
13
|
Object.defineProperty(exports, "__esModule", {
|
|
14
14
|
value: true
|
|
15
15
|
});
|
|
16
|
-
exports.EnvBundlingStrategy = void 0;
|
|
16
|
+
exports.EnvBundlingStrategy = exports.ENV_STRATEGY_ARTIFACT_NAME = void 0;
|
|
17
17
|
|
|
18
18
|
function _defineProperty2() {
|
|
19
19
|
const data = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
@@ -75,9 +75,13 @@ function _webpack() {
|
|
|
75
75
|
return data;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
const ENV_STRATEGY_ARTIFACT_NAME = 'preview';
|
|
78
79
|
/**
|
|
79
80
|
* bundles all components in a given env into the same bundle.
|
|
80
81
|
*/
|
|
82
|
+
|
|
83
|
+
exports.ENV_STRATEGY_ARTIFACT_NAME = ENV_STRATEGY_ARTIFACT_NAME;
|
|
84
|
+
|
|
81
85
|
class EnvBundlingStrategy {
|
|
82
86
|
constructor(preview, pkg, dependencyResolver) {
|
|
83
87
|
this.preview = preview;
|
|
@@ -141,7 +145,7 @@ class EnvBundlingStrategy {
|
|
|
141
145
|
const env = 'env';
|
|
142
146
|
const rootDir = this.getDirName(context);
|
|
143
147
|
return [{
|
|
144
|
-
name:
|
|
148
|
+
name: ENV_STRATEGY_ARTIFACT_NAME,
|
|
145
149
|
globPatterns: ['public/**'],
|
|
146
150
|
rootDir,
|
|
147
151
|
context: env
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["EnvBundlingStrategy","constructor","preview","pkg","dependencyResolver","computeTargets","context","previewDefs","outputPath","getOutputPath","existsSync","mkdirpSync","htmlConfig","generateHtmlConfig","dev","peers","getPeerDependenciesListFromEnv","env","entries","computePaths","html","components","hostDependencies","aliasHostDependencies","options","config","title","templateContent","cache","minify","computeResults","results","result","componentsResults","map","component","errors","err","message","warning","warnings","startTime","endTime","artifacts","getArtifactDef","rootDir","getDirName","name","globPatterns","envName","id","replace","resolve","capsuleNetwork","capsulesRootDir","getPaths","files","capsule","compiler","getCompiler","file","join","path","getDistPathBySrcPath","relative","defs","previewMain","writePreviewRuntime","moduleMapsPromise","previewDef","moduleMap","getModuleMap","paths","ComponentMap","as","graphCapsules","getCapsule","maybeFiles","get","compiledPaths","template","renderTemplatePath","link","writeLink","prefix","undefined","flatten","toArray","concat","moduleMaps","Promise","all"],"sources":["env-strategy.ts"],"sourcesContent":["import { join, resolve } from 'path';\nimport { existsSync, mkdirpSync } from 'fs-extra';\nimport { flatten } from 'lodash';\nimport { ComponentMap } from '@teambit/component';\nimport { Compiler } from '@teambit/compiler';\nimport { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { Capsule } from '@teambit/isolator';\nimport { ComponentResult } from '@teambit/builder';\nimport { BundlerContext, BundlerHtmlConfig, BundlerResult } from '@teambit/bundler';\nimport { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { PkgMain } from '@teambit/pkg';\nimport type { BundlingStrategy, ComputeTargetsContext } from '../bundling-strategy';\nimport { PreviewDefinition } from '../preview-definition';\nimport { PreviewMain } from '../preview.main.runtime';\nimport { html } from '../webpack';\n\n/**\n * bundles all components in a given env into the same bundle.\n */\nexport class EnvBundlingStrategy implements BundlingStrategy {\n name = 'env';\n\n constructor(private preview: PreviewMain, private pkg: PkgMain, private dependencyResolver: DependencyResolverMain) {}\n\n async computeTargets(context: ComputeTargetsContext, previewDefs: PreviewDefinition[]) {\n const outputPath = this.getOutputPath(context);\n if (!existsSync(outputPath)) mkdirpSync(outputPath);\n const htmlConfig = this.generateHtmlConfig({ dev: context.dev });\n const peers = await this.dependencyResolver.getPeerDependenciesListFromEnv(context.env);\n\n return [\n {\n entries: await this.computePaths(outputPath, previewDefs, context),\n html: [htmlConfig],\n components: context.components,\n outputPath,\n /* It's a path to the root of the host component. */\n // hostRootDir, handle this\n hostDependencies: peers,\n aliasHostDependencies: true,\n },\n ];\n }\n\n private generateHtmlConfig(options: { dev?: boolean }): BundlerHtmlConfig {\n const config = {\n title: 'Preview',\n templateContent: html('Preview'),\n cache: false,\n minify: options?.dev ?? true,\n };\n return config;\n }\n\n async computeResults(context: BundlerContext, results: BundlerResult[]) {\n const result = results[0];\n\n const componentsResults: ComponentResult[] = result.components.map((component) => {\n return {\n component,\n errors: result.errors.map((err) => (typeof err === 'string' ? err : err.message)),\n warning: result.warnings,\n startTime: result.startTime,\n endTime: result.endTime,\n };\n });\n\n const artifacts = this.getArtifactDef(context);\n\n return {\n componentsResults,\n artifacts,\n };\n }\n\n private getArtifactDef(context: ComputeTargetsContext) {\n // eslint-disable-next-line @typescript-eslint/prefer-as-const\n const env: 'env' = 'env';\n const rootDir = this.getDirName(context);\n\n return [\n {\n name: 'preview',\n globPatterns: ['public/**'],\n rootDir,\n context: env,\n },\n ];\n }\n\n getDirName(context: ComputeTargetsContext) {\n const envName = context.id.replace('/', '__');\n return `${envName}-preview`;\n }\n\n private getOutputPath(context: ComputeTargetsContext) {\n return resolve(`${context.capsuleNetwork.capsulesRootDir}/${this.getDirName(context)}`);\n }\n\n private getPaths(context: ComputeTargetsContext, files: AbstractVinyl[], capsule: Capsule) {\n const compiler: Compiler = context.env.getCompiler();\n return files.map((file) => join(capsule.path, compiler.getDistPathBySrcPath(file.relative)));\n }\n\n private async computePaths(\n outputPath: string,\n defs: PreviewDefinition[],\n context: ComputeTargetsContext\n ): Promise<string[]> {\n const previewMain = await this.preview.writePreviewRuntime(context);\n const moduleMapsPromise = defs.map(async (previewDef) => {\n const moduleMap = await previewDef.getModuleMap(context.components);\n\n const paths = ComponentMap.as(context.components, (component) => {\n const capsule = context.capsuleNetwork.graphCapsules.getCapsule(component.id);\n const maybeFiles = moduleMap.get(component);\n if (!maybeFiles || !capsule) return [];\n const [, files] = maybeFiles;\n const compiledPaths = this.getPaths(context, files, capsule);\n return compiledPaths;\n });\n\n const template = previewDef.renderTemplatePath ? await previewDef.renderTemplatePath(context) : 'undefined';\n\n const link = this.preview.writeLink(\n previewDef.prefix,\n paths,\n previewDef.renderTemplatePath ? await previewDef.renderTemplatePath(context) : undefined,\n outputPath,\n false\n );\n\n const files = flatten(paths.toArray().map(([, file]) => file)).concat([link]);\n\n if (template) return files.concat([template]);\n return files;\n });\n\n const moduleMaps = await Promise.all(moduleMapsPromise);\n\n return flatten(moduleMaps.concat([previewMain]));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAWA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;AACA;AACA;AACO,MAAMA,mBAAN,CAAsD;EAG3DC,WAAW,CAASC,OAAT,EAAuCC,GAAvC,EAA6DC,kBAA7D,EAAyG;IAAA,KAAhGF,OAAgG,GAAhGA,OAAgG;IAAA,KAAlEC,GAAkE,GAAlEA,GAAkE;IAAA,KAA5CC,kBAA4C,GAA5CA,kBAA4C;IAAA,8CAF7G,KAE6G;EAAE;;EAElG,MAAdC,cAAc,CAACC,OAAD,EAAiCC,WAAjC,EAAmE;IACrF,MAAMC,UAAU,GAAG,KAAKC,aAAL,CAAmBH,OAAnB,CAAnB;IACA,IAAI,CAAC,IAAAI,qBAAA,EAAWF,UAAX,CAAL,EAA6B,IAAAG,qBAAA,EAAWH,UAAX;IAC7B,MAAMI,UAAU,GAAG,KAAKC,kBAAL,CAAwB;MAAEC,GAAG,EAAER,OAAO,CAACQ;IAAf,CAAxB,CAAnB;IACA,MAAMC,KAAK,GAAG,MAAM,KAAKX,kBAAL,CAAwBY,8BAAxB,CAAuDV,OAAO,CAACW,GAA/D,CAApB;IAEA,OAAO,CACL;MACEC,OAAO,EAAE,MAAM,KAAKC,YAAL,CAAkBX,UAAlB,EAA8BD,WAA9B,EAA2CD,OAA3C,CADjB;MAEEc,IAAI,EAAE,CAACR,UAAD,CAFR;MAGES,UAAU,EAAEf,OAAO,CAACe,UAHtB;MAIEb,UAJF;;MAKE;MACA;MACAc,gBAAgB,EAAE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V,CAAc3C,SAAd,CAAnB;QACA,IAAI,CAAC0C,UAAD,IAAe,CAACpB,OAApB,EAA6B,OAAO,EAAP;QAC7B,MAAM,GAAGD,KAAH,IAAYqB,UAAlB;QACA,MAAME,aAAa,GAAG,KAAKxB,QAAL,CAAcjD,OAAd,EAAuBkD,KAAvB,EAA8BC,OAA9B,CAAtB;QACA,OAAOsB,aAAP;MACD,CAPa,CAAd;;MASA,MAAMC,QAAQ,GAAGX,UAAU,CAACY,kBAAX,GAAgC,MAAMZ,UAAU,CAACY,kBAAX,CAA8B3E,OAA9B,CAAtC,GAA+E,WAAhG;MAEA,MAAM4E,IAAI,GAAG,KAAKhF,OAAL,CAAaiF,SAAb,CACXd,UAAU,CAACe,MADA,EAEXZ,KAFW,EAGXH,UAAU,CAACY,kBAAX,GAAgC,MAAMZ,UAAU,CAACY,kBAAX,CAA8B3E,OAA9B,CAAtC,GAA+E+E,SAHpE,EAIX7E,UAJW,EAKX,KALW,CAAb;MAQA,MAAMgD,KAAK,GAAG,IAAA8B,iBAAA,EAAQd,KAAK,CAACe,OAAN,GAAgBrD,GAAhB,CAAoB,CAAC,GAAG0B,IAAH,CAAD,KAAcA,IAAlC,CAAR,EAAiD4B,MAAjD,CAAwD,CAACN,IAAD,CAAxD,CAAd;MAEA,IAAIF,QAAJ,EAAc,OAAOxB,KAAK,CAACgC,MAAN,CAAa,CAACR,QAAD,CAAb,CAAP;MACd,OAAOxB,KAAP;IACD,CA1ByB,CAA1B;IA4BA,MAAMiC,UAAU,GAAG,MAAMC,OAAO,CAACC,GAAR,CAAYvB,iBAAZ,CAAzB;IAEA,OAAO,IAAAkB,iBAAA,EAAQG,UAAU,CAACD,MAAX,CAAkB,CAACtB,WAAD,CAAlB,CAAR,CAAP;EACD;;AA1H0D"}
|
|
1
|
+
{"version":3,"names":["ENV_STRATEGY_ARTIFACT_NAME","EnvBundlingStrategy","constructor","preview","pkg","dependencyResolver","computeTargets","context","previewDefs","outputPath","getOutputPath","existsSync","mkdirpSync","htmlConfig","generateHtmlConfig","dev","peers","getPeerDependenciesListFromEnv","env","entries","computePaths","html","components","hostDependencies","aliasHostDependencies","options","config","title","templateContent","cache","minify","computeResults","results","result","componentsResults","map","component","errors","err","message","warning","warnings","startTime","endTime","artifacts","getArtifactDef","rootDir","getDirName","name","globPatterns","envName","id","replace","resolve","capsuleNetwork","capsulesRootDir","getPaths","files","capsule","compiler","getCompiler","file","join","path","getDistPathBySrcPath","relative","defs","previewMain","writePreviewRuntime","moduleMapsPromise","previewDef","moduleMap","getModuleMap","paths","ComponentMap","as","graphCapsules","getCapsule","maybeFiles","get","compiledPaths","template","renderTemplatePath","link","writeLink","prefix","undefined","flatten","toArray","concat","moduleMaps","Promise","all"],"sources":["env-strategy.ts"],"sourcesContent":["import { join, resolve } from 'path';\nimport { existsSync, mkdirpSync } from 'fs-extra';\nimport { flatten } from 'lodash';\nimport { ComponentMap } from '@teambit/component';\nimport { Compiler } from '@teambit/compiler';\nimport { AbstractVinyl } from '@teambit/legacy/dist/consumer/component/sources';\nimport { Capsule } from '@teambit/isolator';\nimport { ComponentResult } from '@teambit/builder';\nimport { BundlerContext, BundlerHtmlConfig, BundlerResult } from '@teambit/bundler';\nimport { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { PkgMain } from '@teambit/pkg';\nimport type { BundlingStrategy, ComputeTargetsContext } from '../bundling-strategy';\nimport { PreviewDefinition } from '../preview-definition';\nimport { PreviewMain } from '../preview.main.runtime';\nimport { html } from '../webpack';\n\nexport const ENV_STRATEGY_ARTIFACT_NAME = 'preview';\n\n/**\n * bundles all components in a given env into the same bundle.\n */\nexport class EnvBundlingStrategy implements BundlingStrategy {\n name = 'env';\n\n constructor(private preview: PreviewMain, private pkg: PkgMain, private dependencyResolver: DependencyResolverMain) {}\n\n async computeTargets(context: ComputeTargetsContext, previewDefs: PreviewDefinition[]) {\n const outputPath = this.getOutputPath(context);\n if (!existsSync(outputPath)) mkdirpSync(outputPath);\n const htmlConfig = this.generateHtmlConfig({ dev: context.dev });\n const peers = await this.dependencyResolver.getPeerDependenciesListFromEnv(context.env);\n\n return [\n {\n entries: await this.computePaths(outputPath, previewDefs, context),\n html: [htmlConfig],\n components: context.components,\n outputPath,\n /* It's a path to the root of the host component. */\n // hostRootDir, handle this\n hostDependencies: peers,\n aliasHostDependencies: true,\n },\n ];\n }\n\n private generateHtmlConfig(options: { dev?: boolean }): BundlerHtmlConfig {\n const config = {\n title: 'Preview',\n templateContent: html('Preview'),\n cache: false,\n minify: options?.dev ?? true,\n };\n return config;\n }\n\n async computeResults(context: BundlerContext, results: BundlerResult[]) {\n const result = results[0];\n\n const componentsResults: ComponentResult[] = result.components.map((component) => {\n return {\n component,\n errors: result.errors.map((err) => (typeof err === 'string' ? err : err.message)),\n warning: result.warnings,\n startTime: result.startTime,\n endTime: result.endTime,\n };\n });\n\n const artifacts = this.getArtifactDef(context);\n\n return {\n componentsResults,\n artifacts,\n };\n }\n\n private getArtifactDef(context: ComputeTargetsContext) {\n // eslint-disable-next-line @typescript-eslint/prefer-as-const\n const env: 'env' = 'env';\n const rootDir = this.getDirName(context);\n\n return [\n {\n name: ENV_STRATEGY_ARTIFACT_NAME,\n globPatterns: ['public/**'],\n rootDir,\n context: env,\n },\n ];\n }\n\n getDirName(context: ComputeTargetsContext) {\n const envName = context.id.replace('/', '__');\n return `${envName}-preview`;\n }\n\n private getOutputPath(context: ComputeTargetsContext) {\n return resolve(`${context.capsuleNetwork.capsulesRootDir}/${this.getDirName(context)}`);\n }\n\n private getPaths(context: ComputeTargetsContext, files: AbstractVinyl[], capsule: Capsule) {\n const compiler: Compiler = context.env.getCompiler();\n return files.map((file) => join(capsule.path, compiler.getDistPathBySrcPath(file.relative)));\n }\n\n private async computePaths(\n outputPath: string,\n defs: PreviewDefinition[],\n context: ComputeTargetsContext\n ): Promise<string[]> {\n const previewMain = await this.preview.writePreviewRuntime(context);\n const moduleMapsPromise = defs.map(async (previewDef) => {\n const moduleMap = await previewDef.getModuleMap(context.components);\n\n const paths = ComponentMap.as(context.components, (component) => {\n const capsule = context.capsuleNetwork.graphCapsules.getCapsule(component.id);\n const maybeFiles = moduleMap.get(component);\n if (!maybeFiles || !capsule) return [];\n const [, files] = maybeFiles;\n const compiledPaths = this.getPaths(context, files, capsule);\n return compiledPaths;\n });\n\n const template = previewDef.renderTemplatePath ? await previewDef.renderTemplatePath(context) : 'undefined';\n\n const link = this.preview.writeLink(\n previewDef.prefix,\n paths,\n previewDef.renderTemplatePath ? await previewDef.renderTemplatePath(context) : undefined,\n outputPath,\n false\n );\n\n const files = flatten(paths.toArray().map(([, file]) => file)).concat([link]);\n\n if (template) return files.concat([template]);\n return files;\n });\n\n const moduleMaps = await Promise.all(moduleMapsPromise);\n\n return flatten(moduleMaps.concat([previewMain]));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAWA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,0BAA0B,GAAG,SAAnC;AAEP;AACA;AACA;;;;AACO,MAAMC,mBAAN,CAAsD;EAG3DC,WAAW,CAASC,OAAT,EAAuCC,GAAvC,EAA6DC,kBAA7D,EAAyG;IAAA,KAAhGF,OAAgG,GAAhGA,OAAgG;IAAA,KAAlEC,GAAkE,GAAlEA,GAAkE;IAAA,KAA5CC,kBAA4C,GAA5CA,kBAA4C;IAAA,8CAF7G,KAE6G;EAAE;;EAElG,MAAdC,cAAc,CAACC,OAAD,EAAiCC,WAAjC,EAAmE;IACrF,MAAMC,UAAU,GAAG,KAAKC,aAAL,CAAmBH,OAAnB,CAAnB;IACA,IAAI,CAAC,IAAAI,qBAAA,EAAWF,UAAX,CAAL,EAA6B,IAAAG,qBAAA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d;MAEA,IAAIF,QAAJ,EAAc,OAAOxB,KAAK,CAACgC,MAAN,CAAa,CAACR,QAAD,CAAb,CAAP;MACd,OAAOxB,KAAP;IACD,CA1ByB,CAA1B;IA4BA,MAAMiC,UAAU,GAAG,MAAMC,OAAO,CAACC,GAAR,CAAYvB,iBAAZ,CAAzB;IAEA,OAAO,IAAAkB,iBAAA,EAAQG,UAAU,CAACD,MAAX,CAAkB,CAACtB,WAAD,CAAlB,CAAR,CAAP;EACD;;AA1H0D"}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/preview",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.751",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/preview/preview",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.preview",
|
|
8
8
|
"name": "preview",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.751"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"mime": "2.5.2",
|
|
@@ -21,26 +21,26 @@
|
|
|
21
21
|
"@babel/runtime": "7.12.18",
|
|
22
22
|
"core-js": "^3.0.0",
|
|
23
23
|
"@teambit/harmony": "0.3.3",
|
|
24
|
-
"@teambit/express": "0.0.
|
|
25
|
-
"@teambit/logger": "0.0.
|
|
24
|
+
"@teambit/express": "0.0.594",
|
|
25
|
+
"@teambit/logger": "0.0.589",
|
|
26
26
|
"@teambit/ui-foundation.ui.pages.static-error": "0.0.73",
|
|
27
|
-
"@teambit/builder": "0.0.
|
|
28
|
-
"@teambit/bundler": "0.0.
|
|
29
|
-
"@teambit/component": "0.0.
|
|
30
|
-
"@teambit/aspect-loader": "0.0.
|
|
31
|
-
"@teambit/dependency-resolver": "0.0.
|
|
32
|
-
"@teambit/envs": "0.0.
|
|
33
|
-
"@teambit/isolator": "0.0.
|
|
27
|
+
"@teambit/builder": "0.0.751",
|
|
28
|
+
"@teambit/bundler": "0.0.751",
|
|
29
|
+
"@teambit/component": "0.0.751",
|
|
30
|
+
"@teambit/aspect-loader": "0.0.751",
|
|
31
|
+
"@teambit/dependency-resolver": "0.0.751",
|
|
32
|
+
"@teambit/envs": "0.0.751",
|
|
33
|
+
"@teambit/isolator": "0.0.751",
|
|
34
34
|
"@teambit/toolbox.path.to-windows-compatible-path": "0.0.483",
|
|
35
35
|
"@teambit/component-id": "0.0.402",
|
|
36
36
|
"@teambit/bit-error": "0.0.394",
|
|
37
|
-
"@teambit/cli": "0.0.
|
|
38
|
-
"@teambit/graphql": "0.0.
|
|
39
|
-
"@teambit/pkg": "0.0.
|
|
40
|
-
"@teambit/pubsub": "0.0.
|
|
41
|
-
"@teambit/ui": "0.0.
|
|
42
|
-
"@teambit/workspace": "0.0.
|
|
43
|
-
"@teambit/compiler": "0.0.
|
|
37
|
+
"@teambit/cli": "0.0.496",
|
|
38
|
+
"@teambit/graphql": "0.0.751",
|
|
39
|
+
"@teambit/pkg": "0.0.751",
|
|
40
|
+
"@teambit/pubsub": "0.0.751",
|
|
41
|
+
"@teambit/ui": "0.0.751",
|
|
42
|
+
"@teambit/workspace": "0.0.751",
|
|
43
|
+
"@teambit/compiler": "0.0.751",
|
|
44
44
|
"@teambit/preview.cli.preview-server-status": "0.0.491",
|
|
45
45
|
"@teambit/preview.cli.webpack-events-listener": "0.0.161"
|
|
46
46
|
},
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"@teambit/preview.aspect-docs.preview": "0.0.138"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@teambit/legacy": "1.0.
|
|
62
|
+
"@teambit/legacy": "1.0.276",
|
|
63
63
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
64
64
|
"react": "^16.8.0 || ^17.0.0"
|
|
65
65
|
},
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"react": "-"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
|
90
|
-
"@teambit/legacy": "1.0.
|
|
90
|
+
"@teambit/legacy": "1.0.276",
|
|
91
91
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
92
92
|
"react": "^16.8.0 || ^17.0.0"
|
|
93
93
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@0.0.
|
|
2
|
-
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@0.0.
|
|
1
|
+
export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@0.0.751/dist/preview.composition.js')]
|
|
2
|
+
export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.preview_preview@0.0.751/dist/preview.docs.mdx')]
|
package/preview.main.runtime.tsx
CHANGED
|
@@ -42,6 +42,7 @@ import {
|
|
|
42
42
|
import { EnvTemplateRoute } from './env-template.route';
|
|
43
43
|
import { ComponentPreviewRoute } from './component-preview.route';
|
|
44
44
|
import { COMPONENT_STRATEGY_ARTIFACT_NAME, COMPONENT_STRATEGY_SIZE_KEY_NAME } from './strategies/component-strategy';
|
|
45
|
+
import { ENV_STRATEGY_ARTIFACT_NAME } from './strategies/env-strategy';
|
|
45
46
|
import { previewSchema } from './preview.graphql';
|
|
46
47
|
import { PreviewAssetsRoute } from './preview-assets.route';
|
|
47
48
|
|
|
@@ -184,6 +185,25 @@ export class PreviewMain {
|
|
|
184
185
|
return false;
|
|
185
186
|
}
|
|
186
187
|
|
|
188
|
+
/**
|
|
189
|
+
* Check if the component preview bundle contain the header inside of it (legacy)
|
|
190
|
+
* today we are not including the header inside anymore
|
|
191
|
+
* @param component
|
|
192
|
+
* @returns
|
|
193
|
+
*/
|
|
194
|
+
async isLegacyHeader(component: Component): Promise<boolean> {
|
|
195
|
+
// these envs had header in their docs
|
|
196
|
+
const ENV_WITH_LEGACY_DOCS = ['react', 'env', 'aspect', 'lit', 'html', 'node', 'mdx', 'react-native', 'readme'];
|
|
197
|
+
|
|
198
|
+
const artifacts = await this.builder.getArtifactsVinylByExtensionAndName(
|
|
199
|
+
component,
|
|
200
|
+
PreviewAspect.id,
|
|
201
|
+
ENV_STRATEGY_ARTIFACT_NAME
|
|
202
|
+
);
|
|
203
|
+
const envType = this.envs.getEnvData(component).type;
|
|
204
|
+
return !!artifacts && !!artifacts.length && ENV_WITH_LEGACY_DOCS.includes(envType);
|
|
205
|
+
}
|
|
206
|
+
|
|
187
207
|
/**
|
|
188
208
|
* Getting the env template artifact
|
|
189
209
|
* This should be called with the env itself or it will return undefined
|
|
@@ -14,6 +14,8 @@ import { PreviewDefinition } from '../preview-definition';
|
|
|
14
14
|
import { PreviewMain } from '../preview.main.runtime';
|
|
15
15
|
import { html } from '../webpack';
|
|
16
16
|
|
|
17
|
+
export const ENV_STRATEGY_ARTIFACT_NAME = 'preview';
|
|
18
|
+
|
|
17
19
|
/**
|
|
18
20
|
* bundles all components in a given env into the same bundle.
|
|
19
21
|
*/
|
|
@@ -80,7 +82,7 @@ export class EnvBundlingStrategy implements BundlingStrategy {
|
|
|
80
82
|
|
|
81
83
|
return [
|
|
82
84
|
{
|
|
83
|
-
name:
|
|
85
|
+
name: ENV_STRATEGY_ARTIFACT_NAME,
|
|
84
86
|
globPatterns: ['public/**'],
|
|
85
87
|
rootDir,
|
|
86
88
|
context: env,
|
package/tsconfig.json
CHANGED
|
Binary file
|