@teambit/bundler 1.0.666 → 1.0.668

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.
@@ -1,6 +1,6 @@
1
- import { EnvService, Env, EnvContext, ServiceTransformationMap } from '@teambit/envs';
2
- import { Bundler } from './bundler';
3
- import { BundlerContext } from './bundler-context';
1
+ import type { EnvService, Env, EnvContext, ServiceTransformationMap } from '@teambit/envs';
2
+ import type { Bundler } from './bundler';
3
+ import type { BundlerContext } from './bundler-context';
4
4
 
5
5
  type BundlerTransformationMap = ServiceTransformationMap & {
6
6
  getBundler?: (context: BundlerContext) => Promise<Bundler>;
@@ -1,4 +1,4 @@
1
- import { ExecutionContext } from '@teambit/envs';
1
+ import type { ExecutionContext } from '@teambit/envs';
2
2
  export type BrowserRuntime = {
3
3
  entry: (context: ExecutionContext) => Promise<string[]>;
4
4
  };
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["browser-runtime.ts"],"sourcesContent":["import { ExecutionContext } from '@teambit/envs';\n\nexport type BrowserRuntime = {\n entry: (context: ExecutionContext) => Promise<string[]>;\n};\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["browser-runtime.ts"],"sourcesContent":["import type { ExecutionContext } from '@teambit/envs';\n\nexport type BrowserRuntime = {\n entry: (context: ExecutionContext) => Promise<string[]>;\n};\n"],"mappings":"","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import { Component } from '@teambit/component';
2
- import { BuildContext } from '@teambit/builder';
1
+ import type { Component } from '@teambit/component';
2
+ import type { BuildContext } from '@teambit/builder';
3
3
  export type LibraryOptions = {
4
4
  /**
5
5
  * Specify a name for the library
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["bundler-context.ts"],"sourcesContent":["import { Component } from '@teambit/component';\nimport { BuildContext } from '@teambit/builder';\n\nexport type LibraryOptions = {\n /**\n * Specify a name for the library\n */\n name: string;\n // TODO: decide which exact types we want to support and their exact names\n /**\n * Configure how the library will be exposed\n * could be values like: 'umd', 'umd2', 'amd', 'commonjs',\n */\n type?: string;\n};\n\nexport type Entry = {\n /**\n * Specifies the name of each output file on disk\n */\n filename: string;\n /**\n * Module(s) that are loaded upon startup\n */\n import: string | string[];\n\n /**\n * Specify library options to bundle a library from current entry\n */\n library?: LibraryOptions;\n};\n\nexport type EntryMap = {\n [entryName: string]: Entry;\n};\n\nexport type Target = {\n /**\n * entries of the target.\n */\n entries: string[] | EntryMap;\n\n /**\n * array of components included in the target.\n */\n components: Component[];\n\n componentDirectoryMap?: {\n [componentId: string]: string;\n };\n\n /**\n * output path of the target\n */\n outputPath: string;\n\n /**\n * This option determines the name of each output bundle\n */\n filename?: string;\n\n /**\n * This option determines the name of non-initial chunk files\n */\n chunkFilename?: string;\n\n /**\n * Whether to run compression by the bundler\n */\n compress?: boolean;\n\n /**\n * List of peer dependencies\n */\n peers?: string[];\n\n /**\n * config for html generation\n */\n html?: HtmlConfig[];\n\n /**\n * module targets to expose.\n */\n modules?: ModuleTarget[];\n\n /**\n * Name for the runtime chunk\n */\n runtimeChunkName?: string;\n\n /**\n * Different configuration related to chunking\n */\n chunking?: Chunking;\n\n /**\n * A path for the host root dir\n * Host root dir is usually the env root dir\n * This can be used in different bundle options which run require.resolve\n * for example when configuring webpack aliases or webpack expose loader on the peers deps\n */\n hostRootDir?: string;\n\n /**\n * Array of host dependencies, they are used later in case you use one of the following:\n *\n */\n hostDependencies?: string[];\n\n /**\n * Make the hostDependencies externals. externals (from webpack docs):\n * The externals configuration option provides a way of excluding dependencies from the output bundles.\n * Instead, the created bundle relies on that dependency to be present in the consumer's (any end-user application) environment.\n */\n externalizeHostDependencies?: boolean;\n\n /**\n * Make aliases for the hostDependencies.\n * the path of each one will be resolved by [hostRootDir, process.cwd(), __dirname]\n * this will usually replace the instance of import one of the host dependencies by the instance of the env provided it\n */\n aliasHostDependencies?: boolean;\n};\n\nexport type ModuleTarget = {\n /**\n * name of the module.\n */\n name: string;\n\n /**\n * module exposes.\n */\n exposes: {\n [internalPath: string]: string;\n };\n\n shared: {\n [key: string]: any;\n };\n};\n\nexport type HtmlConfig = {\n /**\n * The title to use for the generated HTML document\n */\n title: string;\n /**\n * The file to write the HTML to. Defaults to index.html\n */\n filename?: string;\n /**\n * Allows you to add only some chunks (e.g only the unit-test chunk)\n */\n chunks?: string[];\n /**\n * Load chunks according to their order in the `chunks` array\n * @default auto\n */\n chunkOrder?: 'auto' | 'manual';\n /**\n * provide an inline template\n */\n templateContent: string;\n /**\n * Controls if and in what ways the output should be minified\n */\n minify?: boolean;\n\n /**\n * The favicon for the html page\n */\n favicon?: string;\n\n // TODO: consider add chunksSortMode if there are more needs\n};\n\nexport type Chunking = {\n /**\n * include all types of chunks (async / non-async) in splitting\n */\n splitChunks: boolean;\n};\n\nexport type MetaData = {\n /**\n * Who initiate the bundling process\n */\n initiator?: string;\n /**\n * Env id (used usually to calculate the config)\n */\n envId?: string;\n\n /**\n * Whether the config is for an env template bundling\n */\n isEnvTemplate?: boolean;\n};\nexport interface BundlerContext extends BuildContext {\n /**\n * targets for bundling.\n */\n targets: Target[];\n\n /**\n * determines whether it is a production build, default is `true`.\n * in development, expect the bundler to favour debugging on the expanse of optimization.\n */\n development?: boolean;\n\n /**\n * public path output of the bundle.\n */\n publicPath?: string;\n\n /**\n * root path\n */\n rootPath?: string;\n\n /**\n * Whether to run compression by the bundler\n */\n compress?: boolean;\n\n /**\n * config for html generation for all targets\n */\n html?: HtmlConfig[];\n\n /**\n * modules for bundle to expose. used by module federation at webpack, or with different methods applied by various bundlers.\n */\n modules?: {\n name: string;\n fileName: string;\n exposes: { [key: string]: string };\n };\n\n /**\n * Additional info that can be used by the bundler for different stuff like logging info\n */\n metaData?: MetaData;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["bundler-context.ts"],"sourcesContent":["import type { Component } from '@teambit/component';\nimport type { BuildContext } from '@teambit/builder';\n\nexport type LibraryOptions = {\n /**\n * Specify a name for the library\n */\n name: string;\n // TODO: decide which exact types we want to support and their exact names\n /**\n * Configure how the library will be exposed\n * could be values like: 'umd', 'umd2', 'amd', 'commonjs',\n */\n type?: string;\n};\n\nexport type Entry = {\n /**\n * Specifies the name of each output file on disk\n */\n filename: string;\n /**\n * Module(s) that are loaded upon startup\n */\n import: string | string[];\n\n /**\n * Specify library options to bundle a library from current entry\n */\n library?: LibraryOptions;\n};\n\nexport type EntryMap = {\n [entryName: string]: Entry;\n};\n\nexport type Target = {\n /**\n * entries of the target.\n */\n entries: string[] | EntryMap;\n\n /**\n * array of components included in the target.\n */\n components: Component[];\n\n componentDirectoryMap?: {\n [componentId: string]: string;\n };\n\n /**\n * output path of the target\n */\n outputPath: string;\n\n /**\n * This option determines the name of each output bundle\n */\n filename?: string;\n\n /**\n * This option determines the name of non-initial chunk files\n */\n chunkFilename?: string;\n\n /**\n * Whether to run compression by the bundler\n */\n compress?: boolean;\n\n /**\n * List of peer dependencies\n */\n peers?: string[];\n\n /**\n * config for html generation\n */\n html?: HtmlConfig[];\n\n /**\n * module targets to expose.\n */\n modules?: ModuleTarget[];\n\n /**\n * Name for the runtime chunk\n */\n runtimeChunkName?: string;\n\n /**\n * Different configuration related to chunking\n */\n chunking?: Chunking;\n\n /**\n * A path for the host root dir\n * Host root dir is usually the env root dir\n * This can be used in different bundle options which run require.resolve\n * for example when configuring webpack aliases or webpack expose loader on the peers deps\n */\n hostRootDir?: string;\n\n /**\n * Array of host dependencies, they are used later in case you use one of the following:\n *\n */\n hostDependencies?: string[];\n\n /**\n * Make the hostDependencies externals. externals (from webpack docs):\n * The externals configuration option provides a way of excluding dependencies from the output bundles.\n * Instead, the created bundle relies on that dependency to be present in the consumer's (any end-user application) environment.\n */\n externalizeHostDependencies?: boolean;\n\n /**\n * Make aliases for the hostDependencies.\n * the path of each one will be resolved by [hostRootDir, process.cwd(), __dirname]\n * this will usually replace the instance of import one of the host dependencies by the instance of the env provided it\n */\n aliasHostDependencies?: boolean;\n};\n\nexport type ModuleTarget = {\n /**\n * name of the module.\n */\n name: string;\n\n /**\n * module exposes.\n */\n exposes: {\n [internalPath: string]: string;\n };\n\n shared: {\n [key: string]: any;\n };\n};\n\nexport type HtmlConfig = {\n /**\n * The title to use for the generated HTML document\n */\n title: string;\n /**\n * The file to write the HTML to. Defaults to index.html\n */\n filename?: string;\n /**\n * Allows you to add only some chunks (e.g only the unit-test chunk)\n */\n chunks?: string[];\n /**\n * Load chunks according to their order in the `chunks` array\n * @default auto\n */\n chunkOrder?: 'auto' | 'manual';\n /**\n * provide an inline template\n */\n templateContent: string;\n /**\n * Controls if and in what ways the output should be minified\n */\n minify?: boolean;\n\n /**\n * The favicon for the html page\n */\n favicon?: string;\n\n // TODO: consider add chunksSortMode if there are more needs\n};\n\nexport type Chunking = {\n /**\n * include all types of chunks (async / non-async) in splitting\n */\n splitChunks: boolean;\n};\n\nexport type MetaData = {\n /**\n * Who initiate the bundling process\n */\n initiator?: string;\n /**\n * Env id (used usually to calculate the config)\n */\n envId?: string;\n\n /**\n * Whether the config is for an env template bundling\n */\n isEnvTemplate?: boolean;\n};\nexport interface BundlerContext extends BuildContext {\n /**\n * targets for bundling.\n */\n targets: Target[];\n\n /**\n * determines whether it is a production build, default is `true`.\n * in development, expect the bundler to favour debugging on the expanse of optimization.\n */\n development?: boolean;\n\n /**\n * public path output of the bundle.\n */\n publicPath?: string;\n\n /**\n * root path\n */\n rootPath?: string;\n\n /**\n * Whether to run compression by the bundler\n */\n compress?: boolean;\n\n /**\n * config for html generation for all targets\n */\n html?: HtmlConfig[];\n\n /**\n * modules for bundle to expose. used by module federation at webpack, or with different methods applied by various bundlers.\n */\n modules?: {\n name: string;\n fileName: string;\n exposes: { [key: string]: string };\n };\n\n /**\n * Additional info that can be used by the bundler for different stuff like logging info\n */\n metaData?: MetaData;\n}\n"],"mappings":"","ignoreList":[]}
package/dist/bundler.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Component } from '@teambit/component';
1
+ import type { Component } from '@teambit/component';
2
2
  export interface DevServer {
3
3
  start(): void;
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["bundler.ts"],"sourcesContent":["import { Component } from '@teambit/component';\n\nexport interface DevServer {\n start(): void;\n}\n\nexport type Asset = {\n /**\n * name of the asset.\n */\n name: string;\n\n /**\n * size of the asset in bytes.\n */\n size: number;\n\n /**\n * size of the compressed asset in bytes.\n */\n compressedSize?: number;\n};\n\nexport type ChunksAssetsMap = {\n [assetName: string]: string[];\n};\n\nexport type EntryAssets = {\n assets: Asset[];\n auxiliaryAssets: Asset[];\n assetsSize: number;\n compressedAssetsSize?: number;\n auxiliaryAssetsSize: number;\n compressedAuxiliaryAssetsSize: number;\n};\n\nexport type EntriesAssetsMap = {\n [entryId: string]: EntryAssets;\n};\n\nexport type BundlerResult = {\n /**\n * list of generated assets.\n */\n assets: Asset[];\n\n /**\n * A map of assets names for each chunk\n */\n assetsByChunkName?: ChunksAssetsMap;\n\n /**\n * A map of assets for each entry point\n */\n entriesAssetsMap?: EntriesAssetsMap;\n\n /**\n * errors thrown during the bundling process.\n */\n errors: Error[];\n\n /**\n * warnings thrown during the bundling process.\n */\n warnings: string[];\n\n /**\n * components included in the bundling process.\n */\n components: Component[];\n\n /**\n * timestamp in milliseconds when the task started\n */\n startTime?: number;\n\n /**\n * timestamp in milliseconds when the task ended\n */\n endTime?: number;\n\n /**\n * out put path of the Bundler Result\n */\n outputPath?: string;\n};\n\nexport interface Bundler {\n run(): Promise<BundlerResult[]>;\n}\n\nexport type BundlerMode = 'dev' | 'prod';\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["bundler.ts"],"sourcesContent":["import type { Component } from '@teambit/component';\n\nexport interface DevServer {\n start(): void;\n}\n\nexport type Asset = {\n /**\n * name of the asset.\n */\n name: string;\n\n /**\n * size of the asset in bytes.\n */\n size: number;\n\n /**\n * size of the compressed asset in bytes.\n */\n compressedSize?: number;\n};\n\nexport type ChunksAssetsMap = {\n [assetName: string]: string[];\n};\n\nexport type EntryAssets = {\n assets: Asset[];\n auxiliaryAssets: Asset[];\n assetsSize: number;\n compressedAssetsSize?: number;\n auxiliaryAssetsSize: number;\n compressedAuxiliaryAssetsSize: number;\n};\n\nexport type EntriesAssetsMap = {\n [entryId: string]: EntryAssets;\n};\n\nexport type BundlerResult = {\n /**\n * list of generated assets.\n */\n assets: Asset[];\n\n /**\n * A map of assets names for each chunk\n */\n assetsByChunkName?: ChunksAssetsMap;\n\n /**\n * A map of assets for each entry point\n */\n entriesAssetsMap?: EntriesAssetsMap;\n\n /**\n * errors thrown during the bundling process.\n */\n errors: Error[];\n\n /**\n * warnings thrown during the bundling process.\n */\n warnings: string[];\n\n /**\n * components included in the bundling process.\n */\n components: Component[];\n\n /**\n * timestamp in milliseconds when the task started\n */\n startTime?: number;\n\n /**\n * timestamp in milliseconds when the task ended\n */\n endTime?: number;\n\n /**\n * out put path of the Bundler Result\n */\n outputPath?: string;\n};\n\nexport interface Bundler {\n run(): Promise<BundlerResult[]>;\n}\n\nexport type BundlerMode = 'dev' | 'prod';\n"],"mappings":"","ignoreList":[]}
@@ -1,14 +1,14 @@
1
- import { PubsubMain } from '@teambit/pubsub';
2
- import { Component } from '@teambit/component';
3
- import { DependencyResolverMain } from '@teambit/dependency-resolver';
4
- import { EnvsMain } from '@teambit/envs';
5
- import { GraphqlMain } from '@teambit/graphql';
6
- import { SlotRegistry } from '@teambit/harmony';
7
- import { BrowserRuntime } from './browser-runtime';
8
- import { ComponentServer } from './component-server';
9
- import { BundlerContext } from './bundler-context';
1
+ import type { PubsubMain } from '@teambit/pubsub';
2
+ import type { Component } from '@teambit/component';
3
+ import type { DependencyResolverMain } from '@teambit/dependency-resolver';
4
+ import type { EnvsMain } from '@teambit/envs';
5
+ import type { GraphqlMain } from '@teambit/graphql';
6
+ import type { SlotRegistry } from '@teambit/harmony';
7
+ import type { BrowserRuntime } from './browser-runtime';
8
+ import type { ComponentServer } from './component-server';
9
+ import type { BundlerContext } from './bundler-context';
10
10
  import { DevServerService } from './dev-server.service';
11
- import { DevServer } from './dev-server';
11
+ import type { DevServer } from './dev-server';
12
12
  export type DevServerTransformer = (devServer: DevServer, { envId }: {
13
13
  envId: string;
14
14
  }) => DevServer;
@@ -1 +1 @@
1
- {"version":3,"names":["_pubsub","data","require","_cli","_dependencyResolver","_envs","_graphql","_harmony","_bundler","_events","_devServer","_devServer2","_bundler2","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","BundlerMain","constructor","config","pubsub","envs","devService","runtimeSlot","devServerTransformerSlot","onPreDevServerCreatedSlot","graphql","addNewDevServers","newCompsWithoutDevServers","newComponents","filter","component","getComponentServer","length","Promise","all","values","map","subscriberFn","devServer","configureProxy","components","opts","envRuntime","createEnvironment","servers","runOnce","dedicatedEnvDevServers","pub","BundlerAspect","id","NewDevServersCreatedEvent","Date","now","_componentServers","indexByComponent","undefined","envId","getEnvId","server","find","componentServer","context","relatedContexts","includes","computeEntries","slotEntries","browserRuntime","entry","slotPaths","reduce","acc","current","concat","registerTarget","runtime","register","registerDevServerTransformer","devServerTransformer","registerOnPreDevServerCreated","onPreDevServerCreated","provider","dependencyResolver","devServerService","DevServerService","bundler","registerService","BundlerService","devServerSchema","exports","Slot","withType","MainRuntime","PubsubAspect","EnvsAspect","GraphqlAspect","DependencyResolverAspect","addRuntime"],"sources":["bundler.main.runtime.ts"],"sourcesContent":["import { PubsubAspect, PubsubMain } from '@teambit/pubsub';\nimport { MainRuntime } from '@teambit/cli';\nimport { Component } from '@teambit/component';\nimport { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { GraphqlAspect, GraphqlMain } from '@teambit/graphql';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { BrowserRuntime } from './browser-runtime';\nimport { BundlerAspect } from './bundler.aspect';\nimport { ComponentServer } from './component-server';\nimport { NewDevServersCreatedEvent } from './events';\nimport { BundlerContext } from './bundler-context';\nimport { devServerSchema } from './dev-server.graphql';\nimport { DevServerService } from './dev-server.service';\nimport { BundlerService } from './bundler.service';\nimport { DevServer } from './dev-server';\n\nexport type DevServerTransformer = (devServer: DevServer, { envId }: { envId: string }) => DevServer;\nexport type OnPreDevServerCreated = (newCompsWithoutDevServer: Component[]) => Promise<void>;\nexport type BrowserRuntimeSlot = SlotRegistry<BrowserRuntime>;\nexport type DevServerTransformerSlot = SlotRegistry<DevServerTransformer>;\nexport type OnPreDevServerCreatedSlot = SlotRegistry<OnPreDevServerCreated>;\n\nexport type BundlerConfig = {\n dedicatedEnvDevServers: string[];\n};\n\n/**\n * bundler extension.\n */\nexport class BundlerMain {\n /**\n * component servers.\n */\n private _componentServers: ComponentServer[] = [];\n\n constructor(\n readonly config: BundlerConfig,\n /**\n * Pubsub extension.\n */\n private pubsub: PubsubMain,\n\n /**\n * environments extension.\n */\n private envs: EnvsMain,\n\n /**\n * dev server service.\n */\n private devService: DevServerService,\n\n /**\n * browser runtime slot.\n */\n private runtimeSlot: BrowserRuntimeSlot,\n\n /**\n * dev server transformer slot.\n */\n private devServerTransformerSlot: DevServerTransformerSlot,\n\n /**\n * pre-dev-server operation slot.\n */\n private onPreDevServerCreatedSlot: OnPreDevServerCreatedSlot,\n\n private graphql: GraphqlMain\n ) {}\n\n async addNewDevServers(newCompsWithoutDevServers: Component[]): Promise<ComponentServer[]> {\n const newComponents = newCompsWithoutDevServers.filter((component) => {\n return !this.getComponentServer(component);\n });\n\n if (newComponents.length === 0) {\n return [];\n }\n\n await Promise.all(this.onPreDevServerCreatedSlot.values().map((subscriberFn) => subscriberFn(newComponents)));\n\n return this.devServer(newComponents, { configureProxy: true });\n }\n\n async devServer(components: Component[], opts: { configureProxy?: boolean } = {}): Promise<ComponentServer[]> {\n const envRuntime = await this.envs.createEnvironment(components);\n const servers: ComponentServer[] = await envRuntime.runOnce<ComponentServer>(this.devService, {\n dedicatedEnvDevServers: this.config.dedicatedEnvDevServers,\n });\n if (opts.configureProxy) {\n this.pubsub.pub(BundlerAspect.id, new NewDevServersCreatedEvent(servers, Date.now(), this.graphql, true));\n }\n this._componentServers = servers;\n this.indexByComponent();\n return servers;\n }\n\n /**\n * get a dev server instance containing a component.\n * @param component\n */\n getComponentServer(component: Component): undefined | ComponentServer {\n if (!this._componentServers) return undefined;\n const envId = this.envs.getEnvId(component);\n const server = this._componentServers.find(\n (componentServer) =>\n componentServer.context.relatedContexts.includes(envId) || componentServer.context.id === envId\n );\n return server;\n }\n\n /**\n * compute entry files for bundling components in a given execution context.\n */\n async computeEntries(context: BundlerContext) {\n const slotEntries = await Promise.all(\n this.runtimeSlot.values().map(async (browserRuntime) => browserRuntime.entry(context))\n );\n\n const slotPaths = slotEntries.reduce((acc, current) => {\n acc = acc.concat(current);\n return acc;\n });\n\n return slotPaths;\n }\n\n /**\n * register a new browser runtime environment.\n * @param browserRuntime\n */\n registerTarget(browserRuntime: BrowserRuntime[]) {\n browserRuntime.map((runtime) => {\n return this.runtimeSlot.register(runtime);\n });\n\n return this;\n }\n\n /**\n * register a new dev server transformer.\n * @param devServerTransformer\n */\n registerDevServerTransformer(devServerTransformer: DevServerTransformer) {\n this.devServerTransformerSlot.register(devServerTransformer);\n return this;\n }\n\n /**\n * register a new pre-dev-server compiler.\n * @param onPreDevServerCreated\n */\n registerOnPreDevServerCreated(onPreDevServerCreated: OnPreDevServerCreated) {\n this.onPreDevServerCreatedSlot.register(onPreDevServerCreated);\n return this;\n }\n\n private indexByComponent() {}\n\n static slots = [\n Slot.withType<BrowserRuntime>(),\n Slot.withType<DevServerTransformerSlot>(),\n Slot.withType<OnPreDevServerCreatedSlot>(),\n ];\n\n static runtime = MainRuntime;\n static dependencies = [PubsubAspect, EnvsAspect, GraphqlAspect, DependencyResolverAspect];\n\n static defaultConfig = {\n dedicatedEnvDevServers: [],\n };\n\n static async provider(\n [pubsub, envs, graphql, dependencyResolver]: [PubsubMain, EnvsMain, GraphqlMain, DependencyResolverMain],\n config,\n [runtimeSlot, devServerTransformerSlot, onPreDevServerCreatedSlot]: [\n BrowserRuntimeSlot,\n DevServerTransformerSlot,\n OnPreDevServerCreatedSlot,\n ]\n ) {\n const devServerService = new DevServerService(pubsub, dependencyResolver, runtimeSlot, devServerTransformerSlot);\n const bundler = new BundlerMain(\n config,\n pubsub,\n envs,\n devServerService,\n runtimeSlot,\n devServerTransformerSlot,\n onPreDevServerCreatedSlot,\n graphql\n );\n envs.registerService(devServerService, new BundlerService());\n graphql.register(() => devServerSchema(bundler, graphql));\n\n return bundler;\n }\n}\n\nBundlerAspect.addRuntime(BundlerMain);\n"],"mappings":";;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,KAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAG,oBAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,mBAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAI,MAAA;EAAA,MAAAJ,IAAA,GAAAC,OAAA;EAAAG,KAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,SAAA;EAAA,MAAAL,IAAA,GAAAC,OAAA;EAAAI,QAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,SAAA;EAAA,MAAAN,IAAA,GAAAC,OAAA;EAAAK,QAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAO,SAAA;EAAA,MA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,CAAC;IACDL,IAAI,CAACiE,eAAe,CAACH,gBAAgB,EAAE,KAAII,0BAAc,EAAC,CAAC,CAAC;IAC5D7D,OAAO,CAACkD,QAAQ,CAAC,MAAM,IAAAY,4BAAe,EAACH,OAAO,EAAE3D,OAAO,CAAC,CAAC;IAEzD,OAAO2D,OAAO;EAChB;AACF;AAACI,OAAA,CAAAxE,WAAA,GAAAA,WAAA;AAAAnB,eAAA,CAxKYmB,WAAW,WAkIP,CACbyE,eAAI,CAACC,QAAQ,CAAiB,CAAC,EAC/BD,eAAI,CAACC,QAAQ,CAA2B,CAAC,EACzCD,eAAI,CAACC,QAAQ,CAA4B,CAAC,CAC3C;AAAA7F,eAAA,CAtIUmB,WAAW,aAwIL2E,kBAAW;AAAA9F,eAAA,CAxIjBmB,WAAW,kBAyIA,CAAC4E,sBAAY,EAAEC,kBAAU,EAAEC,wBAAa,EAAEC,8CAAwB,CAAC;AAAAlG,eAAA,CAzI9EmB,WAAW,mBA2IC;EACrB8B,sBAAsB,EAAE;AAC1B,CAAC;AA6BHE,wBAAa,CAACgD,UAAU,CAAChF,WAAW,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_pubsub","data","require","_cli","_dependencyResolver","_envs","_graphql","_harmony","_bundler","_events","_devServer","_devServer2","_bundler2","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","BundlerMain","constructor","config","pubsub","envs","devService","runtimeSlot","devServerTransformerSlot","onPreDevServerCreatedSlot","graphql","addNewDevServers","newCompsWithoutDevServers","newComponents","filter","component","getComponentServer","length","Promise","all","values","map","subscriberFn","devServer","configureProxy","components","opts","envRuntime","createEnvironment","servers","runOnce","dedicatedEnvDevServers","pub","BundlerAspect","id","NewDevServersCreatedEvent","Date","now","_componentServers","indexByComponent","undefined","envId","getEnvId","server","find","componentServer","context","relatedContexts","includes","computeEntries","slotEntries","browserRuntime","entry","slotPaths","reduce","acc","current","concat","registerTarget","runtime","register","registerDevServerTransformer","devServerTransformer","registerOnPreDevServerCreated","onPreDevServerCreated","provider","dependencyResolver","devServerService","DevServerService","bundler","registerService","BundlerService","devServerSchema","exports","Slot","withType","MainRuntime","PubsubAspect","EnvsAspect","GraphqlAspect","DependencyResolverAspect","addRuntime"],"sources":["bundler.main.runtime.ts"],"sourcesContent":["import type { PubsubMain } from '@teambit/pubsub';\nimport { PubsubAspect } from '@teambit/pubsub';\nimport { MainRuntime } from '@teambit/cli';\nimport type { Component } from '@teambit/component';\nimport type { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { DependencyResolverAspect } from '@teambit/dependency-resolver';\nimport type { EnvsMain } from '@teambit/envs';\nimport { EnvsAspect } from '@teambit/envs';\nimport type { GraphqlMain } from '@teambit/graphql';\nimport { GraphqlAspect } from '@teambit/graphql';\nimport type { SlotRegistry } from '@teambit/harmony';\nimport { Slot } from '@teambit/harmony';\nimport type { BrowserRuntime } from './browser-runtime';\nimport { BundlerAspect } from './bundler.aspect';\nimport type { ComponentServer } from './component-server';\nimport { NewDevServersCreatedEvent } from './events';\nimport type { BundlerContext } from './bundler-context';\nimport { devServerSchema } from './dev-server.graphql';\nimport { DevServerService } from './dev-server.service';\nimport { BundlerService } from './bundler.service';\nimport type { DevServer } from './dev-server';\n\nexport type DevServerTransformer = (devServer: DevServer, { envId }: { envId: string }) => DevServer;\nexport type OnPreDevServerCreated = (newCompsWithoutDevServer: Component[]) => Promise<void>;\nexport type BrowserRuntimeSlot = SlotRegistry<BrowserRuntime>;\nexport type DevServerTransformerSlot = SlotRegistry<DevServerTransformer>;\nexport type OnPreDevServerCreatedSlot = SlotRegistry<OnPreDevServerCreated>;\n\nexport type BundlerConfig = {\n dedicatedEnvDevServers: string[];\n};\n\n/**\n * bundler extension.\n */\nexport class BundlerMain {\n /**\n * component servers.\n */\n private _componentServers: ComponentServer[] = [];\n\n constructor(\n readonly config: BundlerConfig,\n /**\n * Pubsub extension.\n */\n private pubsub: PubsubMain,\n\n /**\n * environments extension.\n */\n private envs: EnvsMain,\n\n /**\n * dev server service.\n */\n private devService: DevServerService,\n\n /**\n * browser runtime slot.\n */\n private runtimeSlot: BrowserRuntimeSlot,\n\n /**\n * dev server transformer slot.\n */\n private devServerTransformerSlot: DevServerTransformerSlot,\n\n /**\n * pre-dev-server operation slot.\n */\n private onPreDevServerCreatedSlot: OnPreDevServerCreatedSlot,\n\n private graphql: GraphqlMain\n ) {}\n\n async addNewDevServers(newCompsWithoutDevServers: Component[]): Promise<ComponentServer[]> {\n const newComponents = newCompsWithoutDevServers.filter((component) => {\n return !this.getComponentServer(component);\n });\n\n if (newComponents.length === 0) {\n return [];\n }\n\n await Promise.all(this.onPreDevServerCreatedSlot.values().map((subscriberFn) => subscriberFn(newComponents)));\n\n return this.devServer(newComponents, { configureProxy: true });\n }\n\n async devServer(components: Component[], opts: { configureProxy?: boolean } = {}): Promise<ComponentServer[]> {\n const envRuntime = await this.envs.createEnvironment(components);\n const servers: ComponentServer[] = await envRuntime.runOnce<ComponentServer>(this.devService, {\n dedicatedEnvDevServers: this.config.dedicatedEnvDevServers,\n });\n if (opts.configureProxy) {\n this.pubsub.pub(BundlerAspect.id, new NewDevServersCreatedEvent(servers, Date.now(), this.graphql, true));\n }\n this._componentServers = servers;\n this.indexByComponent();\n return servers;\n }\n\n /**\n * get a dev server instance containing a component.\n * @param component\n */\n getComponentServer(component: Component): undefined | ComponentServer {\n if (!this._componentServers) return undefined;\n const envId = this.envs.getEnvId(component);\n const server = this._componentServers.find(\n (componentServer) =>\n componentServer.context.relatedContexts.includes(envId) || componentServer.context.id === envId\n );\n return server;\n }\n\n /**\n * compute entry files for bundling components in a given execution context.\n */\n async computeEntries(context: BundlerContext) {\n const slotEntries = await Promise.all(\n this.runtimeSlot.values().map(async (browserRuntime) => browserRuntime.entry(context))\n );\n\n const slotPaths = slotEntries.reduce((acc, current) => {\n acc = acc.concat(current);\n return acc;\n });\n\n return slotPaths;\n }\n\n /**\n * register a new browser runtime environment.\n * @param browserRuntime\n */\n registerTarget(browserRuntime: BrowserRuntime[]) {\n browserRuntime.map((runtime) => {\n return this.runtimeSlot.register(runtime);\n });\n\n return this;\n }\n\n /**\n * register a new dev server transformer.\n * @param devServerTransformer\n */\n registerDevServerTransformer(devServerTransformer: DevServerTransformer) {\n this.devServerTransformerSlot.register(devServerTransformer);\n return this;\n }\n\n /**\n * register a new pre-dev-server compiler.\n * @param onPreDevServerCreated\n */\n registerOnPreDevServerCreated(onPreDevServerCreated: OnPreDevServerCreated) {\n this.onPreDevServerCreatedSlot.register(onPreDevServerCreated);\n return this;\n }\n\n private indexByComponent() {}\n\n static slots = [\n Slot.withType<BrowserRuntime>(),\n Slot.withType<DevServerTransformerSlot>(),\n Slot.withType<OnPreDevServerCreatedSlot>(),\n ];\n\n static runtime = MainRuntime;\n static dependencies = [PubsubAspect, EnvsAspect, GraphqlAspect, DependencyResolverAspect];\n\n static defaultConfig = {\n dedicatedEnvDevServers: [],\n };\n\n static async provider(\n [pubsub, envs, graphql, dependencyResolver]: [PubsubMain, EnvsMain, GraphqlMain, DependencyResolverMain],\n config,\n [runtimeSlot, devServerTransformerSlot, onPreDevServerCreatedSlot]: [\n BrowserRuntimeSlot,\n DevServerTransformerSlot,\n OnPreDevServerCreatedSlot,\n ]\n ) {\n const devServerService = new DevServerService(pubsub, dependencyResolver, runtimeSlot, devServerTransformerSlot);\n const bundler = new BundlerMain(\n config,\n pubsub,\n envs,\n devServerService,\n runtimeSlot,\n devServerTransformerSlot,\n onPreDevServerCreatedSlot,\n graphql\n );\n envs.registerService(devServerService, new BundlerService());\n graphql.register(() => devServerSchema(bundler, graphql));\n\n return bundler;\n }\n}\n\nBundlerAspect.addRuntime(BundlerMain);\n"],"mappings":";;;;;;AACA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,K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AAAlG,eAAA,CAzI9EmB,WAAW,mBA2IC;EACrB8B,sBAAsB,EAAE;AAC1B,CAAC;AA6BHE,wBAAa,CAACgD,UAAU,CAAChF,WAAW,CAAC","ignoreList":[]}
@@ -1,6 +1,6 @@
1
- import { EnvService, Env, EnvContext, ServiceTransformationMap } from '@teambit/envs';
2
- import { Bundler } from './bundler';
3
- import { BundlerContext } from './bundler-context';
1
+ import type { EnvService, Env, EnvContext, ServiceTransformationMap } from '@teambit/envs';
2
+ import type { Bundler } from './bundler';
3
+ import type { BundlerContext } from './bundler-context';
4
4
  type BundlerTransformationMap = ServiceTransformationMap & {
5
5
  getBundler?: (context: BundlerContext) => Promise<Bundler>;
6
6
  };
@@ -1 +1 @@
1
- {"version":3,"names":["BundlerService","constructor","_defineProperty","transform","env","envContext","preview","undefined","getBundler","context","exports"],"sources":["bundler.service.tsx"],"sourcesContent":["import { EnvService, Env, EnvContext, ServiceTransformationMap } from '@teambit/envs';\nimport { Bundler } from './bundler';\nimport { BundlerContext } from './bundler-context';\n\ntype BundlerTransformationMap = ServiceTransformationMap & {\n getBundler?: (context: BundlerContext) => Promise<Bundler>;\n};\nexport class BundlerService implements EnvService<any> {\n name = 'bundler';\n\n transform(env: Env, envContext: EnvContext): BundlerTransformationMap | undefined {\n // Old env\n if (!env?.preview) return undefined;\n const preview = env.preview()(envContext);\n\n return {\n getBundler: (context) => preview.getBundler(context)(envContext),\n };\n }\n}\n"],"mappings":";;;;;;;;;AAOO,MAAMA,cAAc,CAA4B;EAAAC,YAAA;IAAAC,eAAA,eAC9C,SAAS;EAAA;EAEhBC,SAASA,CAACC,GAAQ,EAAEC,UAAsB,EAAwC;IAChF;IACA,IAAI,CAACD,GAAG,EAAEE,OAAO,EAAE,OAAOC,SAAS;IACnC,MAAMD,OAAO,GAAGF,GAAG,CAACE,OAAO,CAAC,CAAC,CAACD,UAAU,CAAC;IAEzC,OAAO;MACLG,UAAU,EAAGC,OAAO,IAAKH,OAAO,CAACE,UAAU,CAACC,OAAO,CAAC,CAACJ,UAAU;IACjE,CAAC;EACH;AACF;AAACK,OAAA,CAAAV,cAAA,GAAAA,cAAA","ignoreList":[]}
1
+ {"version":3,"names":["BundlerService","constructor","_defineProperty","transform","env","envContext","preview","undefined","getBundler","context","exports"],"sources":["bundler.service.tsx"],"sourcesContent":["import type { EnvService, Env, EnvContext, ServiceTransformationMap } from '@teambit/envs';\nimport type { Bundler } from './bundler';\nimport type { BundlerContext } from './bundler-context';\n\ntype BundlerTransformationMap = ServiceTransformationMap & {\n getBundler?: (context: BundlerContext) => Promise<Bundler>;\n};\nexport class BundlerService implements EnvService<any> {\n name = 'bundler';\n\n transform(env: Env, envContext: EnvContext): BundlerTransformationMap | undefined {\n // Old env\n if (!env?.preview) return undefined;\n const preview = env.preview()(envContext);\n\n return {\n getBundler: (context) => preview.getBundler(context)(envContext),\n };\n }\n}\n"],"mappings":";;;;;;;;;AAOO,MAAMA,cAAc,CAA4B;EAAAC,YAAA;IAAAC,eAAA,eAC9C,SAAS;EAAA;EAEhBC,SAASA,CAACC,GAAQ,EAAEC,UAAsB,EAAwC;IAChF;IACA,IAAI,CAACD,GAAG,EAAEE,OAAO,EAAE,OAAOC,SAAS;IACnC,MAAMD,OAAO,GAAGF,GAAG,CAACE,OAAO,CAAC,CAAC,CAACD,UAAU,CAAC;IAEzC,OAAO;MACLG,UAAU,EAAGC,OAAO,IAAKH,OAAO,CAACE,UAAU,CAACC,OAAO,CAAC,CAACJ,UAAU;IACjE,CAAC;EACH;AACF;AAACK,OAAA,CAAAV,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -1,8 +1,8 @@
1
- import { Component } from '@teambit/component';
2
- import { ExecutionContext } from '@teambit/envs';
3
- import { PubsubMain } from '@teambit/pubsub';
4
- import { Server } from 'http';
5
- import { DevServer } from './dev-server';
1
+ import type { Component } from '@teambit/component';
2
+ import type { ExecutionContext } from '@teambit/envs';
3
+ import type { PubsubMain } from '@teambit/pubsub';
4
+ import type { Server } from 'http';
5
+ import type { DevServer } from './dev-server';
6
6
  export declare class ComponentServer {
7
7
  /**
8
8
  * browser runtime slot
@@ -1 +1 @@
1
- {"version":3,"names":["_exceptions","data","require","_events","_bundler","_selectPort","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ComponentServer","constructor","pubsub","context","portRange","devServer","componentsServer","hostname","port","ComponentsServerStartedEvent","Date","now","server","_server","envId","envRuntime","id","hasComponent","component","components","find","contextComponent","equals","_port","listen","specificPort","selectPort","address","getHostname","BindError","pub","BundlerAspect","createComponentsServerStartedEvent","close","Promise","resolve","reject","err","undefined","restart","useNewPort","_isRestarting","error","errors","push","onChange","url","exports"],"sources":["component-server.ts"],"sourcesContent":["import { Component } from '@teambit/component';\nimport { ExecutionContext } from '@teambit/envs';\nimport { PubsubMain } from '@teambit/pubsub';\nimport { AddressInfo } from 'net';\nimport { Server } from 'http';\nimport { DevServer } from './dev-server';\nimport { BindError } from './exceptions';\nimport { ComponentsServerStartedEvent } from './events';\nimport { BundlerAspect } from './bundler.aspect';\nimport { selectPort } from './select-port';\n\nexport class ComponentServer {\n // why is this here\n errors?: Error[];\n constructor(\n /**\n * browser runtime slot\n */\n private pubsub: PubsubMain,\n\n /**\n * components contained in the existing component server.\n */\n readonly context: ExecutionContext,\n\n /**\n * port range of the component server.\n */\n readonly portRange: number[],\n\n /**\n * env dev server.\n */\n readonly devServer: DevServer\n ) {}\n\n hostname: string | undefined;\n private _server?: Server;\n private _isRestarting: boolean = false;\n\n get server() {\n return this._server;\n }\n\n get envId() {\n return this.context.envRuntime.id;\n }\n /**\n * determine whether component server contains a component.\n */\n hasComponent(component: Component) {\n return this.context.components.find((contextComponent) => contextComponent.equals(component));\n }\n\n get port() {\n return this._port;\n }\n\n _port: number;\n\n async listen(specificPort?: number) {\n const port = specificPort || (await selectPort(this.portRange));\n this._port = port;\n this._server = await this.devServer.listen(port);\n const address = this._server.address();\n const hostname = this.getHostname(address);\n if (!address) throw new BindError();\n this.hostname = hostname;\n\n this.pubsub.pub(BundlerAspect.id, this.createComponentsServerStartedEvent(this, this.context, hostname, port));\n }\n\n async close(): Promise<void> {\n if (!this.server) return;\n\n return new Promise<void>((resolve, reject) => {\n this.server?.close((err) => {\n if (err) {\n reject(err);\n } else {\n this._server = undefined;\n this.hostname = undefined;\n resolve();\n }\n });\n });\n }\n\n async restart(useNewPort = false): Promise<void> {\n if (this._isRestarting) {\n // add a logger here once we start using this API\n return;\n }\n this._isRestarting = true;\n try {\n await this.close();\n await this.listen(useNewPort ? undefined : this._port);\n } catch (error) {\n if (!this.errors) this.errors = [];\n this.errors.push(error as Error);\n } finally {\n this._isRestarting = false;\n }\n }\n\n private getHostname(address: string | AddressInfo | null) {\n if (address === null) throw new BindError();\n if (typeof address === 'string') return address;\n\n let hostname = address.address;\n if (hostname === '::') {\n hostname = 'localhost';\n }\n\n return hostname;\n }\n\n private onChange() {}\n\n private createComponentsServerStartedEvent: (\n componentsServer,\n context,\n string,\n number\n ) => ComponentsServerStartedEvent = (componentsServer, context, hostname, port) => {\n return new ComponentsServerStartedEvent(Date.now(), componentsServer, context, hostname, port);\n };\n\n /**\n * get the url of the component server.\n */\n get url() {\n // tailing `/` is required!\n return `/preview/${this.context.envRuntime.id}/`;\n }\n}\n"],"mappings":";;;;;;AAMA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,SAAA;EAAA,MAAAH,IAAA,GAAAC,OAAA;EAAAE,QAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SA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C9B,IAAIpB,QAAQ,KAAK,IAAI,EAAE;MACrBA,QAAQ,GAAG,WAAW;IACxB;IAEA,OAAOA,QAAQ;EACjB;EAEQsC,QAAQA,CAAA,EAAG,CAAC;EAWpB;AACF;AACA;EACE,IAAIC,GAAGA,CAAA,EAAG;IACR;IACA,OAAO,YAAY,IAAI,CAAC3C,OAAO,CAACY,UAAU,CAACC,EAAE,GAAG;EAClD;AACF;AAAC+B,OAAA,CAAA/C,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"names":["_exceptions","data","require","_events","_bundler","_selectPort","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ComponentServer","constructor","pubsub","context","portRange","devServer","componentsServer","hostname","port","ComponentsServerStartedEvent","Date","now","server","_server","envId","envRuntime","id","hasComponent","component","components","find","contextComponent","equals","_port","listen","specificPort","selectPort","address","getHostname","BindError","pub","BundlerAspect","createComponentsServerStartedEvent","close","Promise","resolve","reject","err","undefined","restart","useNewPort","_isRestarting","error","errors","push","onChange","url","exports"],"sources":["component-server.ts"],"sourcesContent":["import type { Component } from '@teambit/component';\nimport type { ExecutionContext } from '@teambit/envs';\nimport type { PubsubMain } from '@teambit/pubsub';\nimport type { AddressInfo } from 'net';\nimport type { Server } from 'http';\nimport type { DevServer } from './dev-server';\nimport { BindError } from './exceptions';\nimport { ComponentsServerStartedEvent } from './events';\nimport { BundlerAspect } from './bundler.aspect';\nimport { selectPort } from './select-port';\n\nexport class ComponentServer {\n // why is this here\n errors?: Error[];\n constructor(\n /**\n * browser runtime slot\n */\n private pubsub: PubsubMain,\n\n /**\n * components contained in the existing component server.\n */\n readonly context: ExecutionContext,\n\n /**\n * port range of the component server.\n */\n readonly portRange: number[],\n\n /**\n * env dev server.\n */\n readonly devServer: DevServer\n ) {}\n\n hostname: string | undefined;\n private _server?: Server;\n private _isRestarting: boolean = false;\n\n get server() {\n return this._server;\n }\n\n get envId() {\n return this.context.envRuntime.id;\n }\n /**\n * determine whether component server contains a component.\n */\n hasComponent(component: Component) {\n return this.context.components.find((contextComponent) => contextComponent.equals(component));\n }\n\n get port() {\n return this._port;\n }\n\n _port: number;\n\n async listen(specificPort?: number) {\n const port = specificPort || (await selectPort(this.portRange));\n this._port = port;\n this._server = await this.devServer.listen(port);\n const address = this._server.address();\n const hostname = this.getHostname(address);\n if (!address) throw new BindError();\n this.hostname = hostname;\n\n this.pubsub.pub(BundlerAspect.id, this.createComponentsServerStartedEvent(this, this.context, hostname, port));\n }\n\n async close(): Promise<void> {\n if (!this.server) return;\n\n return new Promise<void>((resolve, reject) => {\n this.server?.close((err) => {\n if (err) {\n reject(err);\n } else {\n this._server = undefined;\n this.hostname = undefined;\n resolve();\n }\n });\n });\n }\n\n async restart(useNewPort = false): Promise<void> {\n if (this._isRestarting) {\n // add a logger here once we start using this API\n return;\n }\n this._isRestarting = true;\n try {\n await this.close();\n await this.listen(useNewPort ? undefined : this._port);\n } catch (error) {\n if (!this.errors) this.errors = [];\n this.errors.push(error as Error);\n } finally {\n this._isRestarting = false;\n }\n }\n\n private getHostname(address: string | AddressInfo | null) {\n if (address === null) throw new BindError();\n if (typeof address === 'string') return address;\n\n let hostname = address.address;\n if (hostname === '::') {\n hostname = 'localhost';\n }\n\n return hostname;\n }\n\n private onChange() {}\n\n private createComponentsServerStartedEvent: (\n componentsServer,\n context,\n string,\n number\n ) => ComponentsServerStartedEvent = (componentsServer, context, hostname, port) => {\n return new ComponentsServerStartedEvent(Date.now(), componentsServer, context, hostname, port);\n };\n\n /**\n * get the url of the component server.\n */\n get url() {\n // tailing `/` is required!\n return `/preview/${this.context.envRuntime.id}/`;\n }\n}\n"],"mappings":";;;;;;AAMA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,QAAA;EAAA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,GAAG,KAAK;IAC5B;EACF;EAEQb,WAAWA,CAACD,OAAoC,EAAE;IACxD,IAAIA,OAAO,KAAK,IAAI,EAAE,MAAM,KAAIE,uBAAS,EAAC,CAAC;IAC3C,IAAI,OAAOF,OAAO,KAAK,QAAQ,EAAE,OAAOA,OAAO;IAE/C,IAAIpB,QAAQ,GAAGoB,OAAO,CAACA,OAAO;IAC9B,IAAIpB,QAAQ,KAAK,IAAI,EAAE;MACrBA,QAAQ,GAAG,WAAW;IACxB;IAEA,OAAOA,QAAQ;EACjB;EAEQsC,QAAQA,CAAA,EAAG,CAAC;EAWpB;AACF;AACA;EACE,IAAIC,GAAGA,CAAA,EAAG;IACR;IACA,OAAO,YAAY,IAAI,CAAC3C,OAAO,CAACY,UAAU,CAACC,EAAE,GAAG;EAClD;AACF;AAAC+B,OAAA,CAAA/C,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { DependencyResolverMain } from '@teambit/dependency-resolver';
1
+ import type { DependencyResolverMain } from '@teambit/dependency-resolver';
2
2
  import type { ExecutionContext } from '@teambit/envs';
3
3
  type GroupIdContextMap = Record<string, ExecutionContext[]>;
4
4
  /**
@@ -1 +1 @@
1
- {"version":3,"names":["dedupEnvs","contexts","dependencyResolver","dedicatedEnvDevServers","idsGroups","groupByEnvId","hasRootComponents","finalGroups","splitByPeers","groupedEnvs","forEach","context","envId","getEnvId","push","newGroupedEnvs","promises","Object","values","map","peersGroups","groupByPeersHash","assign","Promise","all","dedicatedServers","id","split","includes","env","getDevEnvId","undefined","peerGroups","policy","getComponentEnvPolicyFromEnv","peersHash","byLifecycleType","hashNameVersion","indexPeerGroupsById","result","reduce","acc","firstId"],"sources":["dedup-envs.ts"],"sourcesContent":["import { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport type { ExecutionContext } from '@teambit/envs';\n\ntype GroupIdContextMap = Record<string, ExecutionContext[]>;\n\n/**\n * de-duping dev servers by the amount of type the dev server configuration was overridden by envs.\n * This will split the dev server to groups of dev server that share the same webpack config, and same peer dependencies\n * @param contexts\n * @param dependencyResolver\n * @param dedicatedEnvDevServers\n */\nexport async function dedupEnvs(\n contexts: ExecutionContext[],\n dependencyResolver: DependencyResolverMain,\n dedicatedEnvDevServers?: string[]\n) {\n const idsGroups = groupByEnvId(contexts, dedicatedEnvDevServers);\n const hasRootComponents = dependencyResolver.hasRootComponents();\n // Do not split envs by peers if root components is enabled as it should be already handled by the package manager\n // this will improve the performance of the dev server when root components is enabled\n const finalGroups = hasRootComponents ? idsGroups : await splitByPeers(idsGroups, dependencyResolver);\n return finalGroups;\n}\n\nfunction groupByEnvId(contexts: ExecutionContext[], dedicatedEnvDevServers?: string[]) {\n const groupedEnvs: GroupIdContextMap = {};\n\n contexts.forEach((context) => {\n const envId = getEnvId(context, dedicatedEnvDevServers);\n if (!envId) return;\n if (!(envId in groupedEnvs)) groupedEnvs[envId] = [];\n\n groupedEnvs[envId].push(context);\n });\n\n return groupedEnvs;\n}\n\nasync function splitByPeers(idsGroups: GroupIdContextMap, dependencyResolver: DependencyResolverMain) {\n const newGroupedEnvs: GroupIdContextMap = {};\n const promises = Object.values(idsGroups).map(async (contexts) => {\n const peersGroups = await groupByPeersHash(contexts, dependencyResolver);\n Object.assign(newGroupedEnvs, peersGroups);\n });\n await Promise.all(promises);\n return newGroupedEnvs;\n}\n\nfunction getEnvId(context: ExecutionContext, dedicatedServers?: string[]): string | undefined {\n const id = context.id.split('@')[0];\n\n if (dedicatedServers?.includes(id)) {\n return context.id;\n }\n\n // Happen for envs that are not implementing preview\n if (!context.env?.getDevEnvId) {\n return undefined;\n }\n\n return context.env?.getDevEnvId(context);\n}\n\nasync function groupByPeersHash(contexts: ExecutionContext[], dependencyResolver: DependencyResolverMain) {\n const peerGroups: GroupIdContextMap = {};\n\n await Promise.all(\n contexts.map(async (context) => {\n const env = context.env;\n const policy = await dependencyResolver.getComponentEnvPolicyFromEnv(env, { envId: context.id });\n const peersHash = policy.byLifecycleType('peer').hashNameVersion();\n if (!peerGroups[peersHash]) {\n peerGroups[peersHash] = [];\n }\n peerGroups[peersHash].push(context);\n })\n );\n return indexPeerGroupsById(peerGroups);\n}\n\nfunction indexPeerGroupsById(peerGroups: GroupIdContextMap) {\n const result: GroupIdContextMap = Object.values(peerGroups).reduce((acc, contexts) => {\n const firstId = contexts[0].id;\n acc[firstId] = contexts;\n return acc;\n }, {});\n return result;\n}\n"],"mappings":";;;;;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeA,SAASA,CAC7BC,QAA4B,EAC5BC,kBAA0C,EAC1CC,sBAAiC,EACjC;EACA,MAAMC,SAAS,GAAGC,YAAY,CAACJ,QAAQ,EAAEE,sBAAsB,CAAC;EAChE,MAAMG,iBAAiB,GAAGJ,kBAAkB,CAACI,iBAAiB,CAAC,CAAC;EAChE;EACA;EACA,MAAMC,WAAW,GAAGD,iBAAiB,GAAGF,SAAS,GAAG,MAAMI,YAAY,CAACJ,SAAS,EAAEF,kBAAkB,CAAC;EACrG,OAAOK,WAAW;AACpB;AAEA,SAASF,YAAYA,CAACJ,QAA4B,EAAEE,sBAAiC,EAAE;EACrF,MAAMM,WAA8B,GAAG,CAAC,CAAC;EAEzCR,QAAQ,CAACS,OAAO,CAAEC,OAAO,IAAK;IAC5B,MAAMC,KAAK,GAAGC,QAAQ,CAACF,OAAO,EAAER,sBAAsB,CAAC;IACvD,IAAI,CAACS,KAAK,EAAE;IACZ,IAAI,EAAEA,KAAK,IAAIH,WAAW,CAAC,EAAEA,WAAW,CAACG,KAAK,CAAC,GAAG,EAAE;IAEpDH,WAAW,CAACG,KAAK,CAAC,CAACE,IAAI,CAACH,OAAO,CAAC;EAClC,CAAC,CAAC;EAEF,OAAOF,WAAW;AACpB;AAEA,eAAeD,YAAYA,CAACJ,SAA4B,EAAEF,kBAA0C,EAAE;EACpG,MAAMa,cAAiC,GAAG,CAAC,CAAC;EAC5C,MAAMC,QAAQ,GAAGC,MAAM,CAACC,MAAM,CAACd,SA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B;IACAH,UAAU,CAACG,SAAS,CAAC,CAACrB,IAAI,CAACH,OAAO,CAAC;EACrC,CAAC,CACH,CAAC;EACD,OAAO2B,mBAAmB,CAACN,UAAU,CAAC;AACxC;AAEA,SAASM,mBAAmBA,CAACN,UAA6B,EAAE;EAC1D,MAAMO,MAAyB,GAAGtB,MAAM,CAACC,MAAM,CAACc,UAAU,CAAC,CAACQ,MAAM,CAAC,CAACC,GAAG,EAAExC,QAAQ,KAAK;IACpF,MAAMyC,OAAO,GAAGzC,QAAQ,CAAC,CAAC,CAAC,CAACyB,EAAE;IAC9Be,GAAG,CAACC,OAAO,CAAC,GAAGzC,QAAQ;IACvB,OAAOwC,GAAG;EACZ,CAAC,EAAE,CAAC,CAAC,CAAC;EACN,OAAOF,MAAM;AACf","ignoreList":[]}
1
+ {"version":3,"names":["dedupEnvs","contexts","dependencyResolver","dedicatedEnvDevServers","idsGroups","groupByEnvId","hasRootComponents","finalGroups","splitByPeers","groupedEnvs","forEach","context","envId","getEnvId","push","newGroupedEnvs","promises","Object","values","map","peersGroups","groupByPeersHash","assign","Promise","all","dedicatedServers","id","split","includes","env","getDevEnvId","undefined","peerGroups","policy","getComponentEnvPolicyFromEnv","peersHash","byLifecycleType","hashNameVersion","indexPeerGroupsById","result","reduce","acc","firstId"],"sources":["dedup-envs.ts"],"sourcesContent":["import type { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport type { ExecutionContext } from '@teambit/envs';\n\ntype GroupIdContextMap = Record<string, ExecutionContext[]>;\n\n/**\n * de-duping dev servers by the amount of type the dev server configuration was overridden by envs.\n * This will split the dev server to groups of dev server that share the same webpack config, and same peer dependencies\n * @param contexts\n * @param dependencyResolver\n * @param dedicatedEnvDevServers\n */\nexport async function dedupEnvs(\n contexts: ExecutionContext[],\n dependencyResolver: DependencyResolverMain,\n dedicatedEnvDevServers?: string[]\n) {\n const idsGroups = groupByEnvId(contexts, dedicatedEnvDevServers);\n const hasRootComponents = dependencyResolver.hasRootComponents();\n // Do not split envs by peers if root components is enabled as it should be already handled by the package manager\n // this will improve the performance of the dev server when root components is enabled\n const finalGroups = hasRootComponents ? idsGroups : await splitByPeers(idsGroups, dependencyResolver);\n return finalGroups;\n}\n\nfunction groupByEnvId(contexts: ExecutionContext[], dedicatedEnvDevServers?: string[]) {\n const groupedEnvs: GroupIdContextMap = {};\n\n contexts.forEach((context) => {\n const envId = getEnvId(context, dedicatedEnvDevServers);\n if (!envId) return;\n if (!(envId in groupedEnvs)) groupedEnvs[envId] = [];\n\n groupedEnvs[envId].push(context);\n });\n\n return groupedEnvs;\n}\n\nasync function splitByPeers(idsGroups: GroupIdContextMap, dependencyResolver: DependencyResolverMain) {\n const newGroupedEnvs: GroupIdContextMap = {};\n const promises = Object.values(idsGroups).map(async (contexts) => {\n const peersGroups = await groupByPeersHash(contexts, dependencyResolver);\n Object.assign(newGroupedEnvs, peersGroups);\n });\n await Promise.all(promises);\n return newGroupedEnvs;\n}\n\nfunction getEnvId(context: ExecutionContext, dedicatedServers?: string[]): string | undefined {\n const id = context.id.split('@')[0];\n\n if (dedicatedServers?.includes(id)) {\n return context.id;\n }\n\n // Happen for envs that are not implementing preview\n if (!context.env?.getDevEnvId) {\n return undefined;\n }\n\n return context.env?.getDevEnvId(context);\n}\n\nasync function groupByPeersHash(contexts: ExecutionContext[], dependencyResolver: DependencyResolverMain) {\n const peerGroups: GroupIdContextMap = {};\n\n await Promise.all(\n contexts.map(async (context) => {\n const env = context.env;\n const policy = await dependencyResolver.getComponentEnvPolicyFromEnv(env, { envId: context.id });\n const peersHash = policy.byLifecycleType('peer').hashNameVersion();\n if (!peerGroups[peersHash]) {\n peerGroups[peersHash] = [];\n }\n peerGroups[peersHash].push(context);\n })\n );\n return indexPeerGroupsById(peerGroups);\n}\n\nfunction indexPeerGroupsById(peerGroups: GroupIdContextMap) {\n const result: GroupIdContextMap = Object.values(peerGroups).reduce((acc, contexts) => {\n const firstId = contexts[0].id;\n acc[firstId] = contexts;\n return acc;\n }, {});\n return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AAM,CAAC,CAACC,GAAG,EAAExC,QAAQ,KAAK;IACpF,MAAMyC,OAAO,GAAGzC,QAAQ,CAAC,CAAC,CAAC,CAACyB,EAAE;IAC9Be,GAAG,CAACC,OAAO,CAAC,GAAGzC,QAAQ;IACvB,OAAOwC,GAAG;EACZ,CAAC,EAAE,CAAC,CAAC,CAAC;EACN,OAAOF,MAAM;AACf","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { ExecutionContext } from '@teambit/envs';
1
+ import type { ExecutionContext } from '@teambit/envs';
2
2
  export interface DevServerContext extends ExecutionContext {
3
3
  /**
4
4
  * array of files to include.
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["dev-server-context.ts"],"sourcesContent":["import { ExecutionContext } from '@teambit/envs';\n\nexport interface DevServerContext extends ExecutionContext {\n /**\n * array of files to include.\n */\n entry: string[];\n\n /**\n * public path.\n */\n publicPath: string;\n\n /**\n * root path of the workspace.\n */\n rootPath: string;\n\n /**\n * title of the page.\n */\n title?: string;\n\n /**\n * favicon of the page.\n */\n favicon?: string;\n\n /**\n * A path for the host root dir\n * Host root dir is usually the env root dir\n * This can be used in different bundle options which run require.resolve\n * for example when configuring webpack aliases or webpack expose loader on the peers deps\n */\n hostRootDir?: string;\n\n /**\n * Array of host dependencies, they are used later in case you use one of the following:\n *\n */\n hostDependencies?: string[];\n\n /**\n * Make the hostDependencies externals. externals (from webpack docs):\n * The externals configuration option provides a way of excluding dependencies from the output bundles.\n * Instead, the created bundle relies on that dependency to be present in the consumer's (any end-user application) environment.\n */\n externalizeHostDependencies?: boolean;\n\n /**\n * Make aliases for the hostDependencies.\n * the path of each one will be resolved by [hostRootDir, process.cwd(), __dirname]\n * this will usually replace the instance of import one of the host dependencies by the instance of the env provided it\n */\n aliasHostDependencies?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["dev-server-context.ts"],"sourcesContent":["import type { ExecutionContext } from '@teambit/envs';\n\nexport interface DevServerContext extends ExecutionContext {\n /**\n * array of files to include.\n */\n entry: string[];\n\n /**\n * public path.\n */\n publicPath: string;\n\n /**\n * root path of the workspace.\n */\n rootPath: string;\n\n /**\n * title of the page.\n */\n title?: string;\n\n /**\n * favicon of the page.\n */\n favicon?: string;\n\n /**\n * A path for the host root dir\n * Host root dir is usually the env root dir\n * This can be used in different bundle options which run require.resolve\n * for example when configuring webpack aliases or webpack expose loader on the peers deps\n */\n hostRootDir?: string;\n\n /**\n * Array of host dependencies, they are used later in case you use one of the following:\n *\n */\n hostDependencies?: string[];\n\n /**\n * Make the hostDependencies externals. externals (from webpack docs):\n * The externals configuration option provides a way of excluding dependencies from the output bundles.\n * Instead, the created bundle relies on that dependency to be present in the consumer's (any end-user application) environment.\n */\n externalizeHostDependencies?: boolean;\n\n /**\n * Make aliases for the hostDependencies.\n * the path of each one will be resolved by [hostRootDir, process.cwd(), __dirname]\n * this will usually replace the instance of import one of the host dependencies by the instance of the env provided it\n */\n aliasHostDependencies?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import { Server } from 'http';
1
+ import type { Server } from 'http';
2
2
  /**
3
3
  * interface for implementing dev servers.
4
4
  */
@@ -1,3 +1,3 @@
1
- import { GraphqlMain, Schema } from '@teambit/graphql';
2
- import { BundlerMain } from './bundler.main.runtime';
1
+ import type { GraphqlMain, Schema } from '@teambit/graphql';
2
+ import type { BundlerMain } from './bundler.main.runtime';
3
3
  export declare function devServerSchema(bundler: BundlerMain, graphql: GraphqlMain): Schema;
@@ -1 +1 @@
1
- {"version":3,"names":["_client","data","require","_events","devServerSchema","bundler","graphql","typeDefs","gql","resolvers","Component","server","component","args","context","requestedId","body","variables","id","includes","componentServer","getComponentServer","envRuntime","env","url","Subscription","componentServerStarted","subscribe","pubsub","asyncIterator","ComponentServerStartedEvent","resolve","payload","componentServers"],"sources":["dev-server.graphql.ts"],"sourcesContent":["import { Component } from '@teambit/component';\nimport { GraphqlMain, Schema } from '@teambit/graphql';\nimport { gql } from '@apollo/client';\nimport { BundlerMain } from './bundler.main.runtime';\nimport { ComponentServerStartedEvent } from './events';\n\nexport function devServerSchema(bundler: BundlerMain, graphql: GraphqlMain): Schema {\n return {\n typeDefs: gql`\n extend type Component {\n server: ComponentServer\n }\n\n type ComponentServer {\n id: ID!\n env: String\n url: String\n host: String\n basePath: String\n }\n\n type Subscription {\n componentServerStarted(id: String): [ComponentServer!]!\n }\n `,\n resolvers: {\n Component: {\n server: (component: Component, args, context) => {\n // This is a bit of a hack to get the requested id. it assumes the variable name of\n // the gotHost.get query is \"id\".\n // see it in scopes/component/component/component.graphql.ts\n const requestedId = context?.body?.variables?.id;\n // if we ask for specific id with specific version it means we want to fetch if from scope\n // so don't return the server url\n // see https://github.com/teambit/bit/issues/5328\n if (requestedId && requestedId.includes('@')) {\n return {\n id: 'no-server',\n };\n }\n\n const componentServer = bundler.getComponentServer(component);\n if (!componentServer)\n return {\n id: 'no-server',\n };\n\n return {\n id: `server-${componentServer.context.envRuntime.id}`,\n env: componentServer.context.envRuntime.id,\n url: componentServer.url,\n };\n },\n },\n Subscription: {\n componentServerStarted: {\n subscribe: () => graphql.pubsub.asyncIterator([ComponentServerStartedEvent]),\n resolve: (payload, { id }) => {\n const server = payload.componentServers;\n\n if (!server || (id && server.context.envRuntime.id !== id)) {\n return [];\n }\n\n return [\n {\n id: `server-${server.context.envRuntime.id}`,\n env: server.context.envRuntime.id,\n url: server.url,\n },\n ];\n },\n },\n },\n },\n };\n}\n"],"mappings":";;;;;;AAEA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,SAASG,eAAeA,CAACC,OAAoB,EAAEC,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AAUP,MAAM,CAACG,OAAO,CAACQ,UAAU,CAACJ,EAAE,EAAE;cAC5CK,GAAG,EAAEZ,MAAM,CAACG,OAAO,CAACQ,UAAU,CAACJ,EAAE;cACjCM,GAAG,EAAEb,MAAM,CAACa;YACd,CAAC,CACF;UACH;QACF;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"names":["_client","data","require","_events","devServerSchema","bundler","graphql","typeDefs","gql","resolvers","Component","server","component","args","context","requestedId","body","variables","id","includes","componentServer","getComponentServer","envRuntime","env","url","Subscription","componentServerStarted","subscribe","pubsub","asyncIterator","ComponentServerStartedEvent","resolve","payload","componentServers"],"sources":["dev-server.graphql.ts"],"sourcesContent":["import type { Component } from '@teambit/component';\nimport type { GraphqlMain, Schema } from '@teambit/graphql';\nimport { gql } from '@apollo/client';\nimport type { BundlerMain } from './bundler.main.runtime';\nimport { ComponentServerStartedEvent } from './events';\n\nexport function devServerSchema(bundler: BundlerMain, graphql: GraphqlMain): Schema {\n return {\n typeDefs: gql`\n extend type Component {\n server: ComponentServer\n }\n\n type ComponentServer {\n id: ID!\n env: String\n url: String\n host: String\n basePath: String\n }\n\n type Subscription {\n componentServerStarted(id: String): [ComponentServer!]!\n }\n `,\n resolvers: {\n Component: {\n server: (component: Component, args, context) => {\n // This is a bit of a hack to get the requested id. it assumes the variable name of\n // the gotHost.get query is \"id\".\n // see it in scopes/component/component/component.graphql.ts\n const requestedId = context?.body?.variables?.id;\n // if we ask for specific id with specific version it means we want to fetch if from scope\n // so don't return the server url\n // see https://github.com/teambit/bit/issues/5328\n if (requestedId && requestedId.includes('@')) {\n return {\n id: 'no-server',\n };\n }\n\n const componentServer = bundler.getComponentServer(component);\n if (!componentServer)\n return {\n id: 'no-server',\n };\n\n return {\n id: `server-${componentServer.context.envRuntime.id}`,\n env: componentServer.context.envRuntime.id,\n url: componentServer.url,\n };\n },\n },\n Subscription: {\n componentServerStarted: {\n subscribe: () => graphql.pubsub.asyncIterator([ComponentServerStartedEvent]),\n resolve: (payload, { id }) => {\n const server = payload.componentServers;\n\n if (!server || (id && server.context.envRuntime.id !== id)) {\n return [];\n }\n\n return [\n {\n id: `server-${server.context.envRuntime.id}`,\n env: server.context.envRuntime.id,\n url: server.url,\n },\n ];\n },\n },\n },\n },\n };\n}\n"],"mappings":";;;;;;AAEA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAE,QAAA;EAAA,MAAAF,IAAA,GAAAC,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,SAASG,eAAeA,CAACC,OAAoB,EAAEC,OAAoB,EAAU;EAClF,OAAO;IACLC,QAAQ,EAAE,IAAAC,aAAG;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;IACDC,SAAS,EAAE;MACTC,SAAS,EAAE;QACTC,MAAM,EAAEA,CAACC,SAAoB,EAAEC,IAAI,EAAEC,OAAO,KAAK;UAC/C;UACA;UACA;UACA,MAAMC,WAAW,GAAGD,OAAO,EAAEE,IAAI,EAAEC,SAAS,EAAEC,EAAE;UAChD;UACA;UACA;UACA,IAAIH,WAAW,IAAIA,WAAW,CAACI,QAAQ,CAAC,GAAG,CAAC,EAAE;YAC5C,OAAO;cACLD,EAAE,EAAE;YACN,CAAC;UACH;UAEA,MAAME,eAAe,GAAGf,OAAO,CAACgB,kBAAkB,CAACT,SAAS,CAAC;UAC7D,IAAI,CAACQ,eAAe,EAClB,OAAO;YACLF,EAAE,EAAE;UACN,CAAC;UAEH,OAAO;YACLA,EAAE,EAAE,UAAUE,eAAe,CAACN,OAAO,CAACQ,UAAU,CAACJ,EAAE,EAAE;YACrDK,GAAG,EAAEH,eAAe,CAACN,OAAO,CAACQ,UAAU,CAACJ,EAAE;YAC1CM,GAAG,EAAEJ,eAAe,CAACI;UACvB,CAAC;QACH;MACF,CAAC;MACDC,YAAY,EAAE;QACZC,sBAAsB,EAAE;UACtBC,SAAS,EAAEA,CAAA,KAAMrB,OAAO,CAACsB,MAAM,CAACC,aAAa,CAAC,CAACC,qCAA2B,CAAC,CAAC;UAC5EC,OAAO,EAAEA,CAACC,OAAO,EAAE;YAAEd;UAAG,CAAC,KAAK;YAC5B,MAAMP,MAAM,GAAGqB,OAAO,CAACC,gBAAgB;YAEvC,IAAI,CAACtB,MAAM,IAAKO,EAAE,IAAIP,MAAM,CAACG,OAAO,CAACQ,UAAU,CAACJ,EAAE,KAAKA,EAAG,EAAE;cAC1D,OAAO,EAAE;YACX;YAEA,OAAO,CACL;cACEA,EAAE,EAAE,UAAUP,MAAM,CAACG,OAAO,CAACQ,UAAU,CAACJ,EAAE,EAAE;cAC5CK,GAAG,EAAEZ,MAAM,CAACG,OAAO,CAACQ,UAAU,CAACJ,EAAE;cACjCM,GAAG,EAAEb,MAAM,CAACa;YACd,CAAC,CACF;UACH;QACF;MACF;IACF;EACF,CAAC;AACH","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["dev-server.ts"],"sourcesContent":["import { Server } from 'http';\n\n/**\n * interface for implementing dev servers.\n */\nexport interface DevServer {\n /**\n * attach to given port and start an http server\n */\n listen(port: number): Server | Promise<Server>;\n\n /**\n * display name of the dev server.\n */\n displayName?: string;\n\n /**\n * icon of the dev server.\n */\n icon?: string;\n\n /**\n * serialized config of the dev server.\n */\n displayConfig?(): string;\n\n /**\n * path to the config in the filesystem.\n */\n configPath?: string;\n\n /**\n * id of the dev server.\n */\n id: string;\n\n /**\n * hash of the dev server.\n * This is used in order to determine if we should spin a different dev server.\n */\n hash?(): string;\n\n /**\n * return the dev server version.\n */\n version?(): string;\n\n /**\n * Support dev server configuration properties\n */\n [key: string]: any;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"names":[],"sources":["dev-server.ts"],"sourcesContent":["import type { Server } from 'http';\n\n/**\n * interface for implementing dev servers.\n */\nexport interface DevServer {\n /**\n * attach to given port and start an http server\n */\n listen(port: number): Server | Promise<Server>;\n\n /**\n * display name of the dev server.\n */\n displayName?: string;\n\n /**\n * icon of the dev server.\n */\n icon?: string;\n\n /**\n * serialized config of the dev server.\n */\n displayConfig?(): string;\n\n /**\n * path to the config in the filesystem.\n */\n configPath?: string;\n\n /**\n * id of the dev server.\n */\n id: string;\n\n /**\n * hash of the dev server.\n * This is used in order to determine if we should spin a different dev server.\n */\n hash?(): string;\n\n /**\n * return the dev server version.\n */\n version?(): string;\n\n /**\n * Support dev server configuration properties\n */\n [key: string]: any;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,10 +1,10 @@
1
- import { EnvService, ExecutionContext, EnvDefinition, Env, EnvContext, ServiceTransformationMap } from '@teambit/envs';
2
- import { PubsubMain } from '@teambit/pubsub';
3
- import { DependencyResolverMain } from '@teambit/dependency-resolver';
4
- import { BrowserRuntimeSlot, DevServerTransformerSlot } from './bundler.main.runtime';
1
+ import type { EnvService, ExecutionContext, EnvDefinition, Env, EnvContext, ServiceTransformationMap } from '@teambit/envs';
2
+ import type { PubsubMain } from '@teambit/pubsub';
3
+ import type { DependencyResolverMain } from '@teambit/dependency-resolver';
4
+ import type { BrowserRuntimeSlot, DevServerTransformerSlot } from './bundler.main.runtime';
5
5
  import { ComponentServer } from './component-server';
6
- import { DevServer } from './dev-server';
7
- import { DevServerContext } from './dev-server-context';
6
+ import type { DevServer } from './dev-server';
7
+ import type { DevServerContext } from './dev-server-context';
8
8
  export type DevServerServiceOptions = {
9
9
  dedicatedEnvDevServers?: string[];
10
10
  };
@@ -1 +1 @@
1
- {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_lodash","_cliHighlight","_path","_pMapSeries","_componentServer","_dedupEnvs","_getEntry","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","DevServerService","constructor","pubsub","dependencyResolver","runtimeSlot","devServerTransformerSlot","render","env","context","descriptor","getDescriptor","name","chalk","green","id","displayName","version","configLabel","configObj","config","highlight","language","ignoreIllegals","environment","getDevServer","undefined","mergedContext","buildContext","devServer","icon","displayConfig","transform","envContext","preview","getDevEnvId","runOnce","contexts","dedicatedEnvDevServers","groupedEnvs","dedupEnvs","servers","pMapSeries","entries","contextList","mainContext","find","envDefinition","additionalContexts","filter","devServerContext","envRuntime","transformedDevServer","transformDevServer","envId","ComponentServer","mergeContext","getComponentsFromContexts","flatten","map","components","relatedContexts","ctx","concat","peers","getPreviewHostDependenciesFromEnv","hostRootDir","envAspectDefinition","aspectPath","entry","getEntry","componentDirectoryMap","forEach","component","workspace","toString","componentDir","assign","rootPath","publicPath","sep","hostDependencies","aliasHostDependencies","values","reduce","updatedDevServer","transformFn","exports"],"sources":["dev-server.service.ts"],"sourcesContent":["import { EnvService, ExecutionContext, EnvDefinition, Env, EnvContext, ServiceTransformationMap } from '@teambit/envs';\nimport { PubsubMain } from '@teambit/pubsub';\nimport chalk from 'chalk';\nimport { flatten } from 'lodash';\nimport { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport highlight from 'cli-highlight';\nimport { sep } from 'path';\nimport pMapSeries from 'p-map-series';\nimport { BrowserRuntimeSlot, DevServerTransformerSlot } from './bundler.main.runtime';\nimport { ComponentServer } from './component-server';\nimport { dedupEnvs } from './dedup-envs';\nimport { DevServer } from './dev-server';\nimport { DevServerContext } from './dev-server-context';\nimport { getEntry } from './get-entry';\n\nexport type DevServerServiceOptions = { dedicatedEnvDevServers?: string[] };\n\ntype DevServiceTransformationMap = ServiceTransformationMap & {\n /**\n * Required for `bit start`\n */\n getDevEnvId?: (context?: any) => string;\n\n /**\n * Returns and configures the dev server\n * Required for `bit start`\n */\n getDevServer?: (context: DevServerContext) => DevServer | Promise<DevServer>;\n};\n\nexport type DevServerDescriptor = {\n /**\n * id of the dev server (e.g. webpack)\n */\n id: string;\n\n /**\n * display name of the dev server (e.g. Webpack dev server)\n */\n displayName: string;\n\n /**\n * icon of the configured dev server.\n */\n icon: string;\n\n /**\n * string containing the config for display.\n */\n config: string;\n\n version?: string;\n};\n\nexport class DevServerService implements EnvService<ComponentServer, DevServerDescriptor> {\n name = 'dev server';\n\n constructor(\n private pubsub: PubsubMain,\n\n private dependencyResolver: DependencyResolverMain,\n\n /**\n * browser runtime slot\n */\n private runtimeSlot: BrowserRuntimeSlot,\n\n private devServerTransformerSlot: DevServerTransformerSlot\n ) {}\n\n async render(env: EnvDefinition, context: ExecutionContext[]) {\n const descriptor = await this.getDescriptor(env, context);\n const name = `${chalk.green('configured dev server:')} ${descriptor?.id} (${descriptor?.displayName} @ ${\n descriptor?.version\n })`;\n const configLabel = chalk.green('dev server config:');\n const configObj = descriptor?.config\n ? highlight(descriptor?.config, { language: 'javascript', ignoreIllegals: true })\n : '';\n return `${name}\\n${configLabel}\\n${configObj}`;\n }\n\n async getDescriptor(\n environment: EnvDefinition,\n context?: ExecutionContext[]\n ): Promise<DevServerDescriptor | undefined> {\n if (!environment.env.getDevServer || !context) return undefined;\n const mergedContext = await this.buildContext(context[0], []);\n const devServer: DevServer = environment.env.getDevServer(mergedContext);\n\n return {\n id: devServer.id || '',\n displayName: devServer.displayName || '',\n icon: devServer.icon || '',\n config: devServer.displayConfig ? devServer.displayConfig() : '',\n version: devServer.version ? devServer.version() : '?',\n };\n }\n\n transform(env: Env, envContext: EnvContext): DevServiceTransformationMap | undefined {\n // Old env\n if (!env?.preview) return undefined;\n const preview = env.preview()(envContext);\n\n return {\n getDevEnvId: () => {\n return preview.getDevEnvId();\n },\n getDevServer: (context) => {\n return preview.getDevServer(context)(envContext);\n },\n };\n }\n\n // async run(context: ExecutionContext): Promise<ComponentServer[]> {\n // const devServerContext = await this.buildContext(context);\n // const devServer: DevServer = context.env.getDevServer(devServerContext);\n // const port = await selectPort();\n // // TODO: refactor to replace with a component server instance.\n // return new ComponentServer(this.pubsub, context, port, devServer);\n // }\n\n async runOnce(\n contexts: ExecutionContext[],\n { dedicatedEnvDevServers }: DevServerServiceOptions\n ): Promise<ComponentServer[]> {\n const groupedEnvs = await dedupEnvs(contexts, this.dependencyResolver, dedicatedEnvDevServers);\n\n // TODO: (gilad) - change this back to promise all once we make the preview pre-bundle to run before that loop\n const servers = await pMapSeries(Object.entries(groupedEnvs), async ([id, contextList]) => {\n const mainContext = contextList.find((context) => context.envDefinition.id === id) || contextList[0];\n const additionalContexts = contextList.filter((context) => context.envDefinition.id !== id);\n\n const devServerContext = await this.buildContext(mainContext, additionalContexts);\n const devServer: DevServer = await devServerContext.envRuntime.env.getDevServer(devServerContext);\n const transformedDevServer: DevServer = this.transformDevServer(devServer, { envId: id });\n\n return new ComponentServer(this.pubsub, devServerContext, [3300, 3400], transformedDevServer);\n });\n\n return servers;\n }\n\n mergeContext() {}\n\n private getComponentsFromContexts(contexts: ExecutionContext[]) {\n return flatten(\n contexts.map((context) => {\n return context.components;\n })\n );\n }\n\n /**\n * builds the execution context for the dev server.\n */\n private async buildContext(\n context: ExecutionContext,\n additionalContexts: ExecutionContext[] = []\n ): Promise<DevServerContext> {\n context.relatedContexts = additionalContexts.map((ctx) => ctx.envDefinition.id);\n context.components = context.components.concat(this.getComponentsFromContexts(additionalContexts));\n const peers = await this.dependencyResolver.getPreviewHostDependenciesFromEnv(context.envDefinition.env);\n const hostRootDir = context.envRuntime.envAspectDefinition?.aspectPath;\n const entry = await getEntry(context, this.runtimeSlot);\n const componentDirectoryMap = {};\n context.components.forEach((component) => {\n // @ts-ignore this is usually a workspace component here so it has a workspace\n const workspace = component.workspace;\n if (!workspace) return;\n componentDirectoryMap[component.id.toString()] = workspace.componentDir(component.id);\n });\n\n return Object.assign(context, {\n entry,\n componentDirectoryMap,\n // don't start with a leading \"/\" because it generates errors on Windows\n rootPath: `preview/${context.envRuntime.id}`,\n publicPath: `${sep}public`,\n hostRootDir,\n hostDependencies: peers,\n aliasHostDependencies: true,\n });\n }\n\n private transformDevServer(devServer: DevServer, { envId }: { envId: string }): DevServer {\n return this.devServerTransformerSlot\n .values()\n .reduce((updatedDevServer, transformFn) => transformFn(updatedDevServer, { envId }), devServer);\n }\n}\n"],"mappings":";;;;;;AAEA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,QAAA;EAAA,MAAAH,IAAA,GAAAE,OAAA;EAAAC,OAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAI,cAAA;EAAA,MAAAJ,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAE,aAAA,YAAAA,CAAA;IAAA,OAAAJ,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,MAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,KAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAM,YAAA;EAAA,MAAAN,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAI,WAAA,YAAAA,CAAA;IAAA,OAAAN,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEA,SAAAO,iBAAA;EAAA,MAAAP,IAAA,GAAAE,OAAA;EAAAK,gBAAA,YAAAA,CAAA;IAAA,OAAAP,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAQ,WAAA;EAAA,MAAAR,IAAA,GAAAE,OAAA;EAAAM,UAAA,YAAAA,CAAA;IAAA,OAAAR,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAGA,SAAAS,UAAA;EAAA,MAAAT,IAAA,GAAAE,OAAA;EAAAO,SAAA,YAAAA,CAAA;IAAA,OAAAT,IAAA;EAAA;EAAA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,IAAI,CAACA,SAAS,EAAE;MAChBH,qBAAqB,CAACE,SAAS,CAAC1D,EAAE,CAAC4D,QAAQ,CAAC,CAAC,CAAC,GAAGD,SAAS,CAACE,YAAY,CAACH,SAAS,CAAC1D,EAAE,CAAC;IACvF,CAAC,CAAC;IAEF,OAAO5B,MAAM,CAAC0F,MAAM,CAACpE,OAAO,EAAE;MAC5B4D,KAAK;MACLE,qBAAqB;MACrB;MACAO,QAAQ,EAAE,WAAWrE,OAAO,CAAC0C,UAAU,CAACpC,EAAE,EAAE;MAC5CgE,UAAU,EAAE,GAAGC,WAAG,QAAQ;MAC1Bd,WAAW;MACXe,gBAAgB,EAAEjB,KAAK;MACvBkB,qBAAqB,EAAE;IACzB,CAAC,CAAC;EACJ;EAEQ7B,kBAAkBA,CAACxB,SAAoB,EAAE;IAAEyB;EAAyB,CAAC,EAAa;IACxF,OAAO,IAAI,CAAChD,wBAAwB,CACjC6E,MAAM,CAAC,CAAC,CACRC,MAAM,CAAC,CAACC,gBAAgB,EAAEC,WAAW,KAAKA,WAAW,CAACD,gBAAgB,EAAE;MAAE/B;IAAM,CAAC,CAAC,EAAEzB,SAAS,CAAC;EACnG;AACF;AAAC0D,OAAA,CAAAtF,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_chalk","data","_interopRequireDefault","require","_lodash","_cliHighlight","_path","_pMapSeries","_componentServer","_dedupEnvs","_getEntry","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","DevServerService","constructor","pubsub","dependencyResolver","runtimeSlot","devServerTransformerSlot","render","env","context","descriptor","getDescriptor","name","chalk","green","id","displayName","version","configLabel","configObj","config","highlight","language","ignoreIllegals","environment","getDevServer","undefined","mergedContext","buildContext","devServer","icon","displayConfig","transform","envContext","preview","getDevEnvId","runOnce","contexts","dedicatedEnvDevServers","groupedEnvs","dedupEnvs","servers","pMapSeries","entries","contextList","mainContext","find","envDefinition","additionalContexts","filter","devServerContext","envRuntime","transformedDevServer","transformDevServer","envId","ComponentServer","mergeContext","getComponentsFromContexts","flatten","map","components","relatedContexts","ctx","concat","peers","getPreviewHostDependenciesFromEnv","hostRootDir","envAspectDefinition","aspectPath","entry","getEntry","componentDirectoryMap","forEach","component","workspace","toString","componentDir","assign","rootPath","publicPath","sep","hostDependencies","aliasHostDependencies","values","reduce","updatedDevServer","transformFn","exports"],"sources":["dev-server.service.ts"],"sourcesContent":["import type {\n EnvService,\n ExecutionContext,\n EnvDefinition,\n Env,\n EnvContext,\n ServiceTransformationMap,\n} from '@teambit/envs';\nimport type { PubsubMain } from '@teambit/pubsub';\nimport chalk from 'chalk';\nimport { flatten } from 'lodash';\nimport type { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport highlight from 'cli-highlight';\nimport { sep } from 'path';\nimport pMapSeries from 'p-map-series';\nimport type { BrowserRuntimeSlot, DevServerTransformerSlot } from './bundler.main.runtime';\nimport { ComponentServer } from './component-server';\nimport { dedupEnvs } from './dedup-envs';\nimport type { DevServer } from './dev-server';\nimport type { DevServerContext } from './dev-server-context';\nimport { getEntry } from './get-entry';\n\nexport type DevServerServiceOptions = { dedicatedEnvDevServers?: string[] };\n\ntype DevServiceTransformationMap = ServiceTransformationMap & {\n /**\n * Required for `bit start`\n */\n getDevEnvId?: (context?: any) => string;\n\n /**\n * Returns and configures the dev server\n * Required for `bit start`\n */\n getDevServer?: (context: DevServerContext) => DevServer | Promise<DevServer>;\n};\n\nexport type DevServerDescriptor = {\n /**\n * id of the dev server (e.g. webpack)\n */\n id: string;\n\n /**\n * display name of the dev server (e.g. Webpack dev server)\n */\n displayName: string;\n\n /**\n * icon of the configured dev server.\n */\n icon: string;\n\n /**\n * string containing the config for display.\n */\n config: string;\n\n version?: string;\n};\n\nexport class DevServerService implements EnvService<ComponentServer, DevServerDescriptor> {\n name = 'dev server';\n\n constructor(\n private pubsub: PubsubMain,\n\n private dependencyResolver: DependencyResolverMain,\n\n /**\n * browser runtime slot\n */\n private runtimeSlot: BrowserRuntimeSlot,\n\n private devServerTransformerSlot: DevServerTransformerSlot\n ) {}\n\n async render(env: EnvDefinition, context: ExecutionContext[]) {\n const descriptor = await this.getDescriptor(env, context);\n const name = `${chalk.green('configured dev server:')} ${descriptor?.id} (${descriptor?.displayName} @ ${\n descriptor?.version\n })`;\n const configLabel = chalk.green('dev server config:');\n const configObj = descriptor?.config\n ? highlight(descriptor?.config, { language: 'javascript', ignoreIllegals: true })\n : '';\n return `${name}\\n${configLabel}\\n${configObj}`;\n }\n\n async getDescriptor(\n environment: EnvDefinition,\n context?: ExecutionContext[]\n ): Promise<DevServerDescriptor | undefined> {\n if (!environment.env.getDevServer || !context) return undefined;\n const mergedContext = await this.buildContext(context[0], []);\n const devServer: DevServer = environment.env.getDevServer(mergedContext);\n\n return {\n id: devServer.id || '',\n displayName: devServer.displayName || '',\n icon: devServer.icon || '',\n config: devServer.displayConfig ? devServer.displayConfig() : '',\n version: devServer.version ? devServer.version() : '?',\n };\n }\n\n transform(env: Env, envContext: EnvContext): DevServiceTransformationMap | undefined {\n // Old env\n if (!env?.preview) return undefined;\n const preview = env.preview()(envContext);\n\n return {\n getDevEnvId: () => {\n return preview.getDevEnvId();\n },\n getDevServer: (context) => {\n return preview.getDevServer(context)(envContext);\n },\n };\n }\n\n // async run(context: ExecutionContext): Promise<ComponentServer[]> {\n // const devServerContext = await this.buildContext(context);\n // const devServer: DevServer = context.env.getDevServer(devServerContext);\n // const port = await selectPort();\n // // TODO: refactor to replace with a component server instance.\n // return new ComponentServer(this.pubsub, context, port, devServer);\n // }\n\n async runOnce(\n contexts: ExecutionContext[],\n { dedicatedEnvDevServers }: DevServerServiceOptions\n ): Promise<ComponentServer[]> {\n const groupedEnvs = await dedupEnvs(contexts, this.dependencyResolver, dedicatedEnvDevServers);\n\n // TODO: (gilad) - change this back to promise all once we make the preview pre-bundle to run before that loop\n const servers = await pMapSeries(Object.entries(groupedEnvs), async ([id, contextList]) => {\n const mainContext = contextList.find((context) => context.envDefinition.id === id) || contextList[0];\n const additionalContexts = contextList.filter((context) => context.envDefinition.id !== id);\n\n const devServerContext = await this.buildContext(mainContext, additionalContexts);\n const devServer: DevServer = await devServerContext.envRuntime.env.getDevServer(devServerContext);\n const transformedDevServer: DevServer = this.transformDevServer(devServer, { envId: id });\n\n return new ComponentServer(this.pubsub, devServerContext, [3300, 3400], transformedDevServer);\n });\n\n return servers;\n }\n\n mergeContext() {}\n\n private getComponentsFromContexts(contexts: ExecutionContext[]) {\n return flatten(\n contexts.map((context) => {\n return context.components;\n })\n );\n }\n\n /**\n * builds the execution context for the dev server.\n */\n private async buildContext(\n context: ExecutionContext,\n additionalContexts: ExecutionContext[] = []\n ): Promise<DevServerContext> {\n context.relatedContexts = additionalContexts.map((ctx) => ctx.envDefinition.id);\n context.components = context.components.concat(this.getComponentsFromContexts(additionalContexts));\n const peers = await this.dependencyResolver.getPreviewHostDependenciesFromEnv(context.envDefinition.env);\n const hostRootDir = context.envRuntime.envAspectDefinition?.aspectPath;\n const entry = await getEntry(context, this.runtimeSlot);\n const componentDirectoryMap = {};\n context.components.forEach((component) => {\n // @ts-ignore this is usually a workspace component here so it has a workspace\n const workspace = component.workspace;\n if (!workspace) return;\n componentDirectoryMap[component.id.toString()] = workspace.componentDir(component.id);\n });\n\n return Object.assign(context, {\n entry,\n componentDirectoryMap,\n // don't start with a leading \"/\" because it generates errors on Windows\n rootPath: `preview/${context.envRuntime.id}`,\n publicPath: `${sep}public`,\n hostRootDir,\n hostDependencies: peers,\n aliasHostDependencies: true,\n });\n }\n\n private transformDevServer(devServer: DevServer, { envId }: { envId: string }): DevServer {\n return this.devServerTransformerSlot\n .values()\n .reduce((updatedDevServer, transformFn) => transformFn(updatedDevServer, { envId }), devServer);\n }\n}\n"],"mappings":";;;;;;AASA,SAAAA,OAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,MAAA,YAAAA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rB;MACAO,QAAQ,EAAE,WAAWrE,OAAO,CAAC0C,UAAU,CAACpC,EAAE,EAAE;MAC5CgE,UAAU,EAAE,GAAGC,WAAG,QAAQ;MAC1Bd,WAAW;MACXe,gBAAgB,EAAEjB,KAAK;MACvBkB,qBAAqB,EAAE;IACzB,CAAC,CAAC;EACJ;EAEQ7B,kBAAkBA,CAACxB,SAAoB,EAAE;IAAEyB;EAAyB,CAAC,EAAa;IACxF,OAAO,IAAI,CAAChD,wBAAwB,CACjC6E,MAAM,CAAC,CAAC,CACRC,MAAM,CAAC,CAACC,gBAAgB,EAAEC,WAAW,KAAKA,WAAW,CAACD,gBAAgB,EAAE;MAAE/B;IAAM,CAAC,CAAC,EAAEzB,SAAS,CAAC;EACnG;AACF;AAAC0D,OAAA,CAAAtF,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -1,7 +1,7 @@
1
- import { GraphqlMain } from '@teambit/graphql';
1
+ import type { GraphqlMain } from '@teambit/graphql';
2
2
  import { BitBaseEvent } from '@teambit/pubsub';
3
- import { ComponentServer } from '../component-server';
4
- import { ExecutionContext } from '@teambit/envs';
3
+ import type { ComponentServer } from '../component-server';
4
+ import type { ExecutionContext } from '@teambit/envs';
5
5
  export declare const ComponentServerStartedEvent = "ComponentServerStartedEvent";
6
6
  declare class ComponentsServerStartedEventData {
7
7
  readonly componentsServer: ComponentServer;
@@ -1 +1 @@
1
- {"version":3,"names":["_pubsub","data","require","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ComponentServerStartedEvent","exports","ComponentsServerStartedEventData","constructor","componentsServer","context","hostname","port","ComponentsServerStartedEvent","BitBaseEvent","timestamp","TYPE","NewDevServersCreatedEvent","componentsServers","graphql","restartIfRunning","map","c"],"sources":["components-server-started-event.ts"],"sourcesContent":["/* eslint-disable max-classes-per-file */\n\nimport { GraphqlMain } from '@teambit/graphql';\nimport { BitBaseEvent } from '@teambit/pubsub';\nimport { ComponentServer } from '../component-server';\nimport { ExecutionContext } from '@teambit/envs';\n\nexport const ComponentServerStartedEvent = 'ComponentServerStartedEvent';\n\nclass ComponentsServerStartedEventData {\n constructor(\n readonly componentsServer: ComponentServer,\n readonly context: ExecutionContext,\n readonly hostname?: string,\n readonly port?: number\n ) {}\n}\n\nexport class ComponentsServerStartedEvent extends BitBaseEvent<ComponentsServerStartedEventData> {\n static readonly TYPE = 'components-server-started';\n\n constructor(\n readonly timestamp: number,\n readonly componentsServer: ComponentServer,\n readonly context: ExecutionContext,\n readonly hostname?: string,\n readonly port?: number\n ) {\n super(\n ComponentsServerStartedEvent.TYPE,\n '0.0.1',\n timestamp,\n new ComponentsServerStartedEventData(componentsServer, context, hostname, port)\n );\n }\n}\n\nexport class NewDevServersCreatedEvent extends BitBaseEvent<ComponentsServerStartedEventData[]> {\n static readonly TYPE = 'new-dev-servers-created';\n\n constructor(\n readonly componentsServers: ComponentServer[],\n readonly timestamp: number,\n readonly graphql: GraphqlMain,\n readonly restartIfRunning: boolean = false\n ) {\n super(\n NewDevServersCreatedEvent.TYPE,\n '0.0.1',\n timestamp,\n componentsServers.map((c) => new ComponentsServerStartedEventData(c, c.context, c.hostname, c.port))\n );\n }\n}\n"],"mappings":";;;;;;AAGA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA+C,SAAAE,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAD,CAAA,GAAAI,MAAA,CAAAC,cAAA,CAAAL,CAAA,EAAAC,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAT,CAAA,CAAAC,CAAA,IAAAC,CAAA,EAAAF,CAAA;AAAA,SAAAG,eAAAD,CAAA,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4BAAA;AAAA3B,eAAA,CAjBY2B,4BAA4B,UAChB,2BAA2B;AAkB7C,MAAMI,yBAAyB,SAASH,sBAAY,CAAqC;EAG9FN,WAAWA,CACAU,iBAAoC,EACpCH,SAAiB,EACjBI,OAAoB,EACpBC,gBAAyB,GAAG,KAAK,EAC1C;IACA,KAAK,CACHH,yBAAyB,CAACD,IAAI,EAC9B,OAAO,EACPD,SAAS,EACTG,iBAAiB,CAACG,GAAG,CAAEC,CAAC,IAAK,IAAIf,gCAAgC,CAACe,CAAC,EAAEA,CAAC,CAACZ,OAAO,EAAEY,CAAC,CAACX,QAAQ,EAAEW,CAAC,CAACV,IAAI,CAAC,CACrG,CAAC;IAAC,KAVOM,iBAAoC,GAApCA,iBAAoC;IAAA,KACpCH,SAAiB,GAAjBA,SAAiB;IAAA,KACjBI,OAAoB,GAApBA,OAAoB;IAAA,KACpBC,gBAAyB,GAAzBA,gBAAyB;EAQpC;AACF;AAACd,OAAA,CAAAW,yBAAA,GAAAA,yBAAA;AAAA/B,eAAA,CAhBY+B,yBAAyB,UACb,yBAAyB","ignoreList":[]}
1
+ {"version":3,"names":["_pubsub","data","require","_defineProperty","e","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","ComponentServerStartedEvent","exports","ComponentsServerStartedEventData","constructor","componentsServer","context","hostname","port","ComponentsServerStartedEvent","BitBaseEvent","timestamp","TYPE","NewDevServersCreatedEvent","componentsServers","graphql","restartIfRunning","map","c"],"sources":["components-server-started-event.ts"],"sourcesContent":["/* eslint-disable max-classes-per-file */\n\nimport type { GraphqlMain } from '@teambit/graphql';\nimport { BitBaseEvent } from '@teambit/pubsub';\nimport type { ComponentServer } from '../component-server';\nimport type { ExecutionContext } from '@teambit/envs';\n\nexport const ComponentServerStartedEvent = 'ComponentServerStartedEvent';\n\nclass ComponentsServerStartedEventData {\n constructor(\n readonly componentsServer: ComponentServer,\n readonly context: ExecutionContext,\n readonly hostname?: string,\n readonly port?: number\n ) {}\n}\n\nexport class ComponentsServerStartedEvent extends BitBaseEvent<ComponentsServerStartedEventData> {\n static readonly TYPE = 'components-server-started';\n\n constructor(\n readonly timestamp: number,\n readonly componentsServer: ComponentServer,\n readonly context: ExecutionContext,\n readonly hostname?: string,\n readonly port?: number\n ) {\n super(\n ComponentsServerStartedEvent.TYPE,\n '0.0.1',\n timestamp,\n new ComponentsServerStartedEventData(componentsServer, context, hostname, port)\n );\n }\n}\n\nexport class NewDevServersCreatedEvent extends BitBaseEvent<ComponentsServerStartedEventData[]> {\n static readonly TYPE = 'new-dev-servers-created';\n\n constructor(\n readonly componentsServers: ComponentServer[],\n readonly timestamp: number,\n readonly graphql: GraphqlMain,\n readonly restartIfRunning: boolean = false\n ) {\n super(\n NewDevServersCreatedEvent.TYPE,\n '0.0.1',\n timestamp,\n componentsServers.map((c) => new ComponentsServerStartedEventData(c, c.context, c.hostname, c.port))\n );\n }\n}\n"],"mappings":";;;;;;AAGA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAA+C,SAAAE,gBAAAC,CAAA,EAAAC,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAD,CAAA,GAAAI,MAAA,CAAAC,cAAA,CAAAL,CAAA,EAAAC,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAT,CAAA,CAAAC,CAAA,IAAAC,CAAA,EAAAF,CAAA;AAAA,SAAAG,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAF,CAAA,GA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KAAK,EAC1C;IACA,KAAK,CACHH,yBAAyB,CAACD,IAAI,EAC9B,OAAO,EACPD,SAAS,EACTG,iBAAiB,CAACG,GAAG,CAAEC,CAAC,IAAK,IAAIf,gCAAgC,CAACe,CAAC,EAAEA,CAAC,CAACZ,OAAO,EAAEY,CAAC,CAACX,QAAQ,EAAEW,CAAC,CAACV,IAAI,CAAC,CACrG,CAAC;IAAC,KAVOM,iBAAoC,GAApCA,iBAAoC;IAAA,KACpCH,SAAiB,GAAjBA,SAAiB;IAAA,KACjBI,OAAoB,GAApBA,OAAoB;IAAA,KACpBC,gBAAyB,GAAzBA,gBAAyB;EAQpC;AACF;AAACd,OAAA,CAAAW,yBAAA,GAAAA,yBAAA;AAAA/B,eAAA,CAhBY+B,yBAAyB,UACb,yBAAyB","ignoreList":[]}
@@ -1,8 +1,8 @@
1
- import { ComponentID } from '@teambit/component';
2
- import { ExecutionContext } from '@teambit/envs';
3
- import { GetBitMapComponentOptions } from '@teambit/legacy.bit-map';
4
- import { PathOsBased } from '@teambit/toolbox.path.path';
5
- import { BrowserRuntimeSlot } from './bundler.main.runtime';
1
+ import type { ComponentID } from '@teambit/component';
2
+ import type { ExecutionContext } from '@teambit/envs';
3
+ import type { GetBitMapComponentOptions } from '@teambit/legacy.bit-map';
4
+ import type { PathOsBased } from '@teambit/toolbox.path.path';
5
+ import type { BrowserRuntimeSlot } from './bundler.main.runtime';
6
6
  export type ComponentDir = {
7
7
  componentDir?: (componentId: ComponentID, bitMapOptions?: GetBitMapComponentOptions, options?: {
8
8
  relative: boolean;
@@ -1 +1 @@
1
- {"version":3,"names":["getEntry","context","runtimeSlot","slotEntries","Promise","all","values","map","browserRuntime","entry","slotPaths","reduce","acc","current","concat"],"sources":["get-entry.ts"],"sourcesContent":["import { ComponentID } from '@teambit/component';\nimport { ExecutionContext } from '@teambit/envs';\nimport { GetBitMapComponentOptions } from '@teambit/legacy.bit-map';\nimport { PathOsBased } from '@teambit/toolbox.path.path';\n\nimport { BrowserRuntimeSlot } from './bundler.main.runtime';\n\nexport type ComponentDir = {\n componentDir?: (\n componentId: ComponentID,\n bitMapOptions?: GetBitMapComponentOptions,\n options?: { relative: boolean }\n ) => PathOsBased | undefined;\n};\n\n/**\n * computes the bundler entry.\n */\nexport async function getEntry(context: ExecutionContext, runtimeSlot: BrowserRuntimeSlot): Promise<string[]> {\n // TODO: refactor this away from here and use computePaths instead\n const slotEntries = await Promise.all(\n runtimeSlot.values().map(async (browserRuntime) => browserRuntime.entry(context))\n );\n\n const slotPaths = slotEntries.reduce((acc, current) => {\n acc = acc.concat(current);\n return acc;\n });\n\n return slotPaths;\n}\n"],"mappings":";;;;;;AAeA;AACA;AACA;AACO,eAAeA,QAAQA,CAACC,OAAyB,EAAEC,WAA+B,EAAqB;EAC5G;EACA,MAAMC,WAAW,GAAG,MAAMC,OAAO,CAACC,GAAG,CACnCH,WAAW,CAACI,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,MAAOC,cAAc,IAAKA,cAAc,CAACC,KAAK,CAACR,OAAO,CAAC,CAClF,CAAC;EAED,MAAMS,SAAS,GAAGP,WAAW,CAACQ,MAAM,CAAC,CAACC,GAAG,EAAEC,OAAO,KAAK;IACrDD,GAAG,GAAGA,GAAG,CAACE,MAAM,CAACD,OAAO,CAAC;IACzB,OAAOD,GAAG;EACZ,CAAC,CAAC;EAEF,OAAOF,SAAS;AAClB","ignoreList":[]}
1
+ {"version":3,"names":["getEntry","context","runtimeSlot","slotEntries","Promise","all","values","map","browserRuntime","entry","slotPaths","reduce","acc","current","concat"],"sources":["get-entry.ts"],"sourcesContent":["import type { ComponentID } from '@teambit/component';\nimport type { ExecutionContext } from '@teambit/envs';\nimport type { GetBitMapComponentOptions } from '@teambit/legacy.bit-map';\nimport type { PathOsBased } from '@teambit/toolbox.path.path';\n\nimport type { BrowserRuntimeSlot } from './bundler.main.runtime';\n\nexport type ComponentDir = {\n componentDir?: (\n componentId: ComponentID,\n bitMapOptions?: GetBitMapComponentOptions,\n options?: { relative: boolean }\n ) => PathOsBased | undefined;\n};\n\n/**\n * computes the bundler entry.\n */\nexport async function getEntry(context: ExecutionContext, runtimeSlot: BrowserRuntimeSlot): Promise<string[]> {\n // TODO: refactor this away from here and use computePaths instead\n const slotEntries = await Promise.all(\n runtimeSlot.values().map(async (browserRuntime) => browserRuntime.entry(context))\n );\n\n const slotPaths = slotEntries.reduce((acc, current) => {\n acc = acc.concat(current);\n return acc;\n });\n\n return slotPaths;\n}\n"],"mappings":";;;;;;AAeA;AACA;AACA;AACO,eAAeA,QAAQA,CAACC,OAAyB,EAAEC,WAA+B,EAAqB;EAC5G;EACA,MAAMC,WAAW,GAAG,MAAMC,OAAO,CAACC,GAAG,CACnCH,WAAW,CAACI,MAAM,CAAC,CAAC,CAACC,GAAG,CAAC,MAAOC,cAAc,IAAKA,cAAc,CAACC,KAAK,CAACR,OAAO,CAAC,CAClF,CAAC;EAED,MAAMS,SAAS,GAAGP,WAAW,CAACQ,MAAM,CAAC,CAACC,GAAG,EAAEC,OAAO,KAAK;IACrDD,GAAG,GAAGA,GAAG,CAACE,MAAM,CAACD,OAAO,CAAC;IACzB,OAAOD,GAAG;EACZ,CAAC,CAAC;EAEF,OAAOF,SAAS;AAClB","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.compilation_bundler@1.0.666/dist/bundler.composition.js';
2
- import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.compilation_bundler@1.0.666/dist/bundler.docs.mdx';
1
+ import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.compilation_bundler@1.0.668/dist/bundler.composition.js';
2
+ import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad/teambit.compilation_bundler@1.0.668/dist/bundler.docs.mdx';
3
3
 
4
4
  export const compositions = [compositions_0];
5
5
  export const overview = [overview_0];
@@ -1,9 +1,9 @@
1
1
  /* eslint-disable max-classes-per-file */
2
2
 
3
- import { GraphqlMain } from '@teambit/graphql';
3
+ import type { GraphqlMain } from '@teambit/graphql';
4
4
  import { BitBaseEvent } from '@teambit/pubsub';
5
- import { ComponentServer } from '../component-server';
6
- import { ExecutionContext } from '@teambit/envs';
5
+ import type { ComponentServer } from '../component-server';
6
+ import type { ExecutionContext } from '@teambit/envs';
7
7
 
8
8
  export const ComponentServerStartedEvent = 'ComponentServerStartedEvent';
9
9
 
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/bundler",
3
- "version": "1.0.666",
3
+ "version": "1.0.668",
4
4
  "homepage": "https://bit.cloud/teambit/compilation/bundler",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.compilation",
8
8
  "name": "bundler",
9
- "version": "1.0.666"
9
+ "version": "1.0.668"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "4.1.2",
@@ -14,16 +14,16 @@
14
14
  "lodash": "4.17.21",
15
15
  "p-map-series": "2.1.0",
16
16
  "@teambit/harmony": "0.4.7",
17
- "@teambit/legacy.bit-map": "0.0.114",
18
17
  "@teambit/toolbox.path.path": "0.0.8",
19
18
  "@teambit/toolbox.network.get-port": "1.0.10",
20
- "@teambit/envs": "1.0.666",
21
- "@teambit/builder": "1.0.666",
22
- "@teambit/component": "1.0.666",
23
- "@teambit/cli": "0.0.1243",
24
- "@teambit/dependency-resolver": "1.0.666",
25
- "@teambit/graphql": "1.0.666",
26
- "@teambit/pubsub": "1.0.666"
19
+ "@teambit/envs": "1.0.668",
20
+ "@teambit/builder": "1.0.668",
21
+ "@teambit/component": "1.0.668",
22
+ "@teambit/cli": "0.0.1245",
23
+ "@teambit/dependency-resolver": "1.0.668",
24
+ "@teambit/graphql": "1.0.668",
25
+ "@teambit/pubsub": "1.0.668",
26
+ "@teambit/legacy.bit-map": "0.0.115"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/lodash": "4.14.165",