@teambit/bundler 0.0.736 → 0.0.739

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.
@@ -3,6 +3,7 @@ import { PubsubMain } from '@teambit/pubsub';
3
3
  import { flatten } from 'lodash';
4
4
  import React from 'react';
5
5
  import { Text, Newline } from 'ink';
6
+ import { DependencyResolverMain } from '@teambit/dependency-resolver';
6
7
  import highlight from 'cli-highlight';
7
8
  import { sep } from 'path';
8
9
  import { BrowserRuntimeSlot } from './bundler.main.runtime';
@@ -47,6 +48,8 @@ export class DevServerService implements EnvService<ComponentServer, DevServerDe
47
48
  */
48
49
  private pubsub: PubsubMain,
49
50
 
51
+ private dependencyResolver: DependencyResolverMain,
52
+
50
53
  /**
51
54
  * browser runtime slot
52
55
  */
@@ -140,12 +143,15 @@ export class DevServerService implements EnvService<ComponentServer, DevServerDe
140
143
  ): Promise<DevServerContext> {
141
144
  context.relatedContexts = additionalContexts.map((ctx) => ctx.envDefinition.id);
142
145
  context.components = context.components.concat(this.getComponentsFromContexts(additionalContexts));
146
+ const peers = await this.dependencyResolver.getPeerDependenciesListFromEnv(context.env);
143
147
 
144
148
  return Object.assign(context, {
145
149
  entry: await getEntry(context, this.runtimeSlot),
146
150
  // don't start with a leading "/" because it generates errors on Windows
147
151
  rootPath: `preview/${context.envRuntime.id}`,
148
152
  publicPath: `${sep}public`,
153
+ hostDependencies: peers,
154
+ aliasHostDependencies: true,
149
155
  });
150
156
  }
151
157
  }
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
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":""}
@@ -1 +1 @@
1
- {"version":3,"sources":["bundle.ts"],"names":["Bundle","constructor","errors"],"mappings":";;;;;;;AAAO,MAAMA,MAAN,CAAa;AAClBC,EAAAA,WAAW,CAAUC,MAAV,EAAyB;AAAA,SAAfA,MAAe,GAAfA,MAAe;AAAE;;AADpB","sourcesContent":["export class Bundle {\n constructor(readonly errors: Error) {}\n}\n"]}
1
+ {"version":3,"names":["Bundle","constructor","errors"],"sources":["bundle.ts"],"sourcesContent":["export class Bundle {\n constructor(readonly errors: Error) {}\n}\n"],"mappings":";;;;;;;AAAO,MAAMA,MAAN,CAAa;EAClBC,WAAW,CAAUC,MAAV,EAAyB;IAAA,KAAfA,MAAe,GAAfA,MAAe;EAAE;;AADpB"}
@@ -49,10 +49,6 @@ export declare type Target = {
49
49
  * This option determines the name of non-initial chunk files
50
50
  */
51
51
  chunkFilename?: string;
52
- /**
53
- * Make the peer dependencies externals.
54
- */
55
- externalizePeer?: boolean;
56
52
  /**
57
53
  * Whether to run compression by the bundler
58
54
  */
@@ -84,6 +80,30 @@ export declare type Target = {
84
80
  * for example when configuring webpack aliases or webpack expose loader on the peers deps
85
81
  */
86
82
  hostRootDir?: string;
83
+ /**
84
+ * Array of host dependencies, they are used later in case you use one of the following:
85
+ *
86
+ */
87
+ hostDependencies?: string[];
88
+ /**
89
+ * Make the hostDependencies externals. externals (from webpack docs):
90
+ * The externals configuration option provides a way of excluding dependencies from the output bundles.
91
+ * Instead, the created bundle relies on that dependency to be present in the consumer's (any end-user application) environment.
92
+ */
93
+ externalizeHostDependencies?: boolean;
94
+ /**
95
+ * Make aliases for the hostDependencies.
96
+ * the path of each one will be resolved by [hostRootDir, process.cwd(), __dirname]
97
+ * this will usually replace the instance of import one of the host dependencies by the instance of the env provided it
98
+ */
99
+ aliasHostDependencies?: boolean;
100
+ /**
101
+ * Expose the hostDependencies on the global (window) object.
102
+ * the path of each one will be resolved by [hostRootDir, process.cwd(), __dirname]
103
+ * from the webpack plugin docs:
104
+ * The expose-loader loader allows to expose a module (in whole or in part) to global object (self, window and global).
105
+ */
106
+ exposeHostDependencies?: boolean;
87
107
  };
88
108
  export declare type ModuleTarget = {
89
109
  /**
@@ -160,10 +180,6 @@ export interface BundlerContext extends BuildContext {
160
180
  * root path
161
181
  */
162
182
  rootPath?: string;
163
- /**
164
- * Make the peer dependencies externals for all targets
165
- */
166
- externalizePeer?: boolean;
167
183
  /**
168
184
  * Whether to run compression by the bundler
169
185
  */
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
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 /**\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 /**\n * Expose the hostDependencies on the global (window) object.\n * the path of each one will be resolved by [hostRootDir, process.cwd(), __dirname]\n * from the webpack plugin docs:\n * The expose-loader loader allows to expose a module (in whole or in part) to global object (self, window and global).\n */\n exposeHostDependencies?: 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 * 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};\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":""}
@@ -1 +1 @@
1
- {"version":3,"sources":["bundler.aspect.ts"],"names":["BundlerAspect","Aspect","create","id"],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,aAAa,GAAGC,kBAAOC,MAAP,CAAc;AACzCC,EAAAA,EAAE,EAAE;AADqC,CAAd,CAAtB","sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const BundlerAspect = Aspect.create({\n id: 'teambit.compilation/bundler',\n});\n"]}
1
+ {"version":3,"names":["BundlerAspect","Aspect","create","id"],"sources":["bundler.aspect.ts"],"sourcesContent":["import { Aspect } from '@teambit/harmony';\n\nexport const BundlerAspect = Aspect.create({\n id: 'teambit.compilation/bundler',\n});\n"],"mappings":";;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,aAAa,GAAGC,iBAAA,CAAOC,MAAP,CAAc;EACzCC,EAAE,EAAE;AADqC,CAAd,CAAtB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["bundler.composition.tsx"],"names":["Logo","height","display","justifyContent","width"],"mappings":";;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,IAAI,GAAG,mBAClB;AAAK,EAAA,KAAK,EAAE;AAAEC,IAAAA,MAAM,EAAE,MAAV;AAAkBC,IAAAA,OAAO,EAAE,MAA3B;AAAmCC,IAAAA,cAAc,EAAE;AAAnD;AAAZ,gBACE;AAAK,EAAA,KAAK,EAAE;AAAEC,IAAAA,KAAK,EAAE;AAAT,GAAZ;AAA2B,EAAA,GAAG,EAAC;AAA/B,EADF,CADK","sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/extensions-icons/bundler.svg\" />\n </div>\n);\n"]}
1
+ {"version":3,"names":["Logo","height","display","justifyContent","width"],"sources":["bundler.composition.tsx"],"sourcesContent":["import React from 'react';\n\nexport const Logo = () => (\n <div style={{ height: '100%', display: 'flex', justifyContent: 'center' }}>\n <img style={{ width: 70 }} src=\"https://static.bit.dev/extensions-icons/bundler.svg\" />\n </div>\n);\n"],"mappings":";;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,IAAI,GAAG,mBAClB;EAAK,KAAK,EAAE;IAAEC,MAAM,EAAE,MAAV;IAAkBC,OAAO,EAAE,MAA3B;IAAmCC,cAAc,EAAE;EAAnD;AAAZ,gBACE;EAAK,KAAK,EAAE;IAAEC,KAAK,EAAE;EAAT,CAAZ;EAA2B,GAAG,EAAC;AAA/B,EADF,CADK"}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
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":""}
@@ -2,6 +2,7 @@ import { PubsubMain } from '@teambit/pubsub';
2
2
  import { Component } from '@teambit/component';
3
3
  import { EnvsMain } from '@teambit/envs';
4
4
  import { GraphqlMain } from '@teambit/graphql';
5
+ import { DependencyResolverMain } from '@teambit/dependency-resolver';
5
6
  import { SlotRegistry } from '@teambit/harmony';
6
7
  import { BrowserRuntime } from './browser-runtime';
7
8
  import { ComponentServer } from './component-server';
@@ -79,5 +80,5 @@ export declare class BundlerMain {
79
80
  static defaultConfig: {
80
81
  dedicatedEnvDevServers: never[];
81
82
  };
82
- static provider([pubsub, envs, graphql]: [PubsubMain, EnvsMain, GraphqlMain], config: any, [runtimeSlot]: [BrowserRuntimeSlot]): Promise<BundlerMain>;
83
+ static provider([pubsub, envs, graphql, dependencyResolver]: [PubsubMain, EnvsMain, GraphqlMain, DependencyResolverMain], config: any, [runtimeSlot]: [BrowserRuntimeSlot]): Promise<BundlerMain>;
83
84
  }
@@ -71,6 +71,16 @@ function _graphql() {
71
71
  return data;
72
72
  }
73
73
 
74
+ function _dependencyResolver() {
75
+ const data = require("@teambit/dependency-resolver");
76
+
77
+ _dependencyResolver = function () {
78
+ return data;
79
+ };
80
+
81
+ return data;
82
+ }
83
+
74
84
  function _harmony() {
75
85
  const data = require("@teambit/harmony");
76
86
 
@@ -201,8 +211,8 @@ class BundlerMain {
201
211
 
202
212
  indexByComponent() {}
203
213
 
204
- static async provider([pubsub, envs, graphql], config, [runtimeSlot]) {
205
- const devServerService = new (_devServer2().DevServerService)(pubsub, runtimeSlot);
214
+ static async provider([pubsub, envs, graphql, dependencyResolver], config, [runtimeSlot]) {
215
+ const devServerService = new (_devServer2().DevServerService)(pubsub, dependencyResolver, runtimeSlot);
206
216
  const bundler = new BundlerMain(config, pubsub, envs, devServerService, runtimeSlot);
207
217
  envs.registerService(devServerService);
208
218
  graphql.register((0, _devServer().devServerSchema)(bundler));
@@ -214,7 +224,7 @@ class BundlerMain {
214
224
  exports.BundlerMain = BundlerMain;
215
225
  (0, _defineProperty2().default)(BundlerMain, "slots", [_harmony().Slot.withType()]);
216
226
  (0, _defineProperty2().default)(BundlerMain, "runtime", _cli().MainRuntime);
217
- (0, _defineProperty2().default)(BundlerMain, "dependencies", [_pubsub().default, _envs().EnvsAspect, _graphql().GraphqlAspect, _component().ComponentAspect]);
227
+ (0, _defineProperty2().default)(BundlerMain, "dependencies", [_pubsub().default, _envs().EnvsAspect, _graphql().GraphqlAspect, _dependencyResolver().DependencyResolverAspect, _component().ComponentAspect]);
218
228
  (0, _defineProperty2().default)(BundlerMain, "defaultConfig", {
219
229
  dedicatedEnvDevServers: []
220
230
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["bundler.main.runtime.ts"],"names":["BundlerMain","constructor","config","pubsub","envs","devService","runtimeSlot","devServer","components","envRuntime","createEnvironment","servers","runOnce","dedicatedEnvDevServers","_componentServers","indexByComponent","getComponentServer","component","undefined","envId","getEnvId","server","find","componentServer","context","relatedContexts","includes","id","computeEntries","slotEntries","Promise","all","values","map","browserRuntime","entry","slotPaths","reduce","acc","current","concat","registerTarget","runtime","register","provider","graphql","devServerService","DevServerService","bundler","registerService","Slot","withType","MainRuntime","PubsubAspect","EnvsAspect","GraphqlAspect","ComponentAsp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,OAAf,CADmB,EAEnB3C,MAFmB,EAGnB,CAACI,WAAD,CAHmB,EAInB;AACA,UAAMwC,gBAAgB,GAAG,KAAIC,8BAAJ,EAAqB5C,MAArB,EAA6BG,WAA7B,CAAzB;AACA,UAAM0C,OAAO,GAAG,IAAIhD,WAAJ,CAAgBE,MAAhB,EAAwBC,MAAxB,EAAgCC,IAAhC,EAAsC0C,gBAAtC,EAAwDxC,WAAxD,CAAhB;AACAF,IAAAA,IAAI,CAAC6C,eAAL,CAAqBH,gBAArB;AAEAD,IAAAA,OAAO,CAACF,QAAR,CAAiB,kCAAgBK,OAAhB,CAAjB;AAEA,WAAOA,OAAP;AACD;;AAhHsB;;;gCAAZhD,W,WA2FI,CAACkD,gBAAKC,QAAL,EAAD,C;gCA3FJnD,W,aA6FMoD,kB;gCA7FNpD,W,kBA8FW,CAACqD,iBAAD,EAAeC,kBAAf,EAA2BC,wBAA3B,EAA0CC,4BAA1C,C;gCA9FXxD,W,mBAgGY;AACrBa,EAAAA,sBAAsB,EAAE;AADH,C;;AAmBzB4C,yBAAcC,UAAd,CAAyB1D,WAAzB","sourcesContent":["import PubsubAspect, { PubsubMain } from '@teambit/pubsub';\nimport { MainRuntime } from '@teambit/cli';\nimport { Component, ComponentAspect } from '@teambit/component';\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 { BundlerContext } from './bundler-context';\nimport { devServerSchema } from './dev-server.graphql';\nimport { DevServerService } from './dev-server.service';\n\nexport type BrowserRuntimeSlot = SlotRegistry<BrowserRuntime>;\n\nexport type BundlerConfig = {\n dedicatedEnvDevServers: string[];\n};\n\n/**\n * bundler extension.\n */\nexport class BundlerMain {\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 /**\n * load all given components in corresponding dev servers.\n * @param components defaults to all components in the workspace.\n */\n async devServer(components: Component[]): Promise<ComponentServer[]> {\n const envRuntime = await this.envs.createEnvironment(components);\n // TODO: this must be refactored away from here. this logic should be in the Preview.\n const servers: ComponentServer[] = await envRuntime.runOnce<ComponentServer[]>(this.devService, {\n dedicatedEnvDevServers: this.config.dedicatedEnvDevServers,\n });\n this._componentServers = servers;\n\n this.indexByComponent();\n\n return this._componentServers;\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\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 * component servers.\n */\n private _componentServers: null | ComponentServer[];\n\n private indexByComponent() {}\n\n static slots = [Slot.withType<BrowserRuntime>()];\n\n static runtime = MainRuntime;\n static dependencies = [PubsubAspect, EnvsAspect, GraphqlAspect, ComponentAspect];\n\n static defaultConfig = {\n dedicatedEnvDevServers: [],\n };\n\n static async provider(\n [pubsub, envs, graphql]: [PubsubMain, EnvsMain, GraphqlMain],\n config,\n [runtimeSlot]: [BrowserRuntimeSlot]\n ) {\n const devServerService = new DevServerService(pubsub, runtimeSlot);\n const bundler = new BundlerMain(config, pubsub, envs, devServerService, runtimeSlot);\n envs.registerService(devServerService);\n\n graphql.register(devServerSchema(bundler));\n\n return bundler;\n }\n}\n\nBundlerAspect.addRuntime(BundlerMain);\n"]}
1
+ {"version":3,"names":["BundlerMain","constructor","config","pubsub","envs","devService","runtimeSlot","devServer","components","envRuntime","createEnvironment","servers","runOnce","dedicatedEnvDevServers","_componentServers","indexByComponent","getComponentServer","component","undefined","envId","getEnvId","server","find","componentServer","context","relatedContexts","includes","id","computeEntries","slotEntries","Promise","all","values","map","browserRuntime","entry","slotPaths","reduce","acc","current","concat","registerTarget","runtime","register","provider","graphql","dependencyResolver","devServerService","DevServerService","bundler","registerService","devServerSchema","Slot","withType","MainRuntime","PubsubAspect","EnvsAspect","GraphqlAspect","DependencyResolverAspect","ComponentAspect","BundlerAspect","addRuntime"],"sources":["bundler.main.runtime.ts"],"sourcesContent":["import PubsubAspect, { PubsubMain } from '@teambit/pubsub';\nimport { MainRuntime } from '@teambit/cli';\nimport { Component, ComponentAspect } from '@teambit/component';\nimport { EnvsAspect, EnvsMain } from '@teambit/envs';\nimport { GraphqlAspect, GraphqlMain } from '@teambit/graphql';\nimport { DependencyResolverAspect, DependencyResolverMain } from '@teambit/dependency-resolver';\nimport { Slot, SlotRegistry } from '@teambit/harmony';\nimport { BrowserRuntime } from './browser-runtime';\nimport { BundlerAspect } from './bundler.aspect';\nimport { ComponentServer } from './component-server';\nimport { BundlerContext } from './bundler-context';\nimport { devServerSchema } from './dev-server.graphql';\nimport { DevServerService } from './dev-server.service';\n\nexport type BrowserRuntimeSlot = SlotRegistry<BrowserRuntime>;\n\nexport type BundlerConfig = {\n dedicatedEnvDevServers: string[];\n};\n\n/**\n * bundler extension.\n */\nexport class BundlerMain {\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 /**\n * load all given components in corresponding dev servers.\n * @param components defaults to all components in the workspace.\n */\n async devServer(components: Component[]): Promise<ComponentServer[]> {\n const envRuntime = await this.envs.createEnvironment(components);\n // TODO: this must be refactored away from here. this logic should be in the Preview.\n const servers: ComponentServer[] = await envRuntime.runOnce<ComponentServer[]>(this.devService, {\n dedicatedEnvDevServers: this.config.dedicatedEnvDevServers,\n });\n this._componentServers = servers;\n\n this.indexByComponent();\n\n return this._componentServers;\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\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 * component servers.\n */\n private _componentServers: null | ComponentServer[];\n\n private indexByComponent() {}\n\n static slots = [Slot.withType<BrowserRuntime>()];\n\n static runtime = MainRuntime;\n static dependencies = [PubsubAspect, EnvsAspect, GraphqlAspect, DependencyResolverAspect, ComponentAspect];\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]: [BrowserRuntimeSlot]\n ) {\n const devServerService = new DevServerService(pubsub, dependencyResolver, runtimeSlot);\n const bundler = new BundlerMain(config, pubsub, envs, devServerService, runtimeSlot);\n envs.registerService(devServerService);\n\n graphql.register(devServerSchema(bundler));\n\n return bundler;\n }\n}\n\nBundlerAspect.addRuntime(BundlerMain);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAQA;AACA;AACA;AACO,MAAMA,WAAN,CAAkB;EACvBC,WAAW,CACAC,MADA;EAET;AACJ;AACA;EACYC,MALC;EAOT;AACJ;AACA;EACYC,IAVC;EAYT;AACJ;AACA;EACYC,UAfC;EAiBT;AACJ;AACA;EACYC,WApBC,EAqBT;IAAA,KApBSJ,MAoBT,GApBSA,MAoBT;IAAA,KAhBQC,MAgBR,GAhBQA,MAgBR;IAAA,KAXQC,IAWR,GAXQA,IAWR;IAAA,KANQC,UAMR,GANQA,UAMR;IAAA,KADQC,WACR,GADQA,WACR;IAAA;EAAE;EAEJ;AACF;AACA;AACA;;;EACiB,MAATC,SAAS,CAACC,UAAD,EAAsD;IACnE,MAAMC,UAAU,GAAG,MAAM,KAAKL,IAAL,CAAUM,iBAAV,CAA4BF,UAA5B,CAAzB,CADmE,CAEnE;;IAC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C,QAAjB,CAA0BD,OAA1B,CAAP;IACD,CAFD;IAIA,OAAO,IAAP;EACD;EAED;AACF;AACA;;;EAGU3B,gBAAgB,GAAG,CAAE;;EAWR,aAAR6B,QAAQ,CACnB,CAACzC,MAAD,EAASC,IAAT,EAAeyC,OAAf,EAAwBC,kBAAxB,CADmB,EAEnB5C,MAFmB,EAGnB,CAACI,WAAD,CAHmB,EAInB;IACA,MAAMyC,gBAAgB,GAAG,KAAIC,8BAAJ,EAAqB7C,MAArB,EAA6B2C,kBAA7B,EAAiDxC,WAAjD,CAAzB;IACA,MAAM2C,OAAO,GAAG,IAAIjD,WAAJ,CAAgBE,MAAhB,EAAwBC,MAAxB,EAAgCC,IAAhC,EAAsC2C,gBAAtC,EAAwDzC,WAAxD,CAAhB;IACAF,IAAI,CAAC8C,eAAL,CAAqBH,gBAArB;IAEAF,OAAO,CAACF,QAAR,CAAiB,IAAAQ,4BAAA,EAAgBF,OAAhB,CAAjB;IAEA,OAAOA,OAAP;EACD;;AAhHsB;;;gCAAZjD,W,WA2FI,CAACoD,eAAA,CAAKC,QAAL,EAAD,C;gCA3FJrD,W,aA6FMsD,kB;gCA7FNtD,W,kBA8FW,CAACuD,iBAAD,EAAeC,kBAAf,EAA2BC,wBAA3B,EAA0CC,8CAA1C,EAAoEC,4BAApE,C;gCA9FX3D,W,mBAgGY;EACrBa,sBAAsB,EAAE;AADH,C;;AAmBzB+C,wBAAA,CAAcC,UAAd,CAAyB7D,WAAzB"}
@@ -1 +1 @@
1
- {"version":3,"sources":["component-server.ts"],"names":["ComponentServer","constructor","pubsub","context","portRange","devServer","componentsServer","hostname","port","ComponentsServerStartedEvent","Date","now","hasComponent","component","components","find","contextComponent","equals","_port","listen","server","address","getHostname","BindError","pub","BundlerAspect","id","createComponentsServerStartedEvent","onChange","url","envRuntime"],"mappings":";;;;;;;;;;;;;;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAKA;AAAA;;AAAA;AAAA;AAA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OAAO,GAAGD,MAAM,CAACC,OAAP,EAAhB;AACA,UAAMd,QAAQ,GAAG,KAAKe,WAAL,CAAiBD,OAAjB,CAAjB;AACA,QAAI,CAACA,OAAL,EAAc,MAAM,KAAIE,uBAAJ,GAAN;AACd,SAAKhB,QAAL,GAAgBA,QAAhB;AAEA,SAAKL,MAAL,CAAYsB,GAAZ,CAAgBC,yBAAcC,EAA9B,EAAkC,KAAKC,kCAAL,CAAwCP,MAAxC,EAAgD,KAAKjB,OAArD,EAA8DI,QAA9D,EAAwEC,IAAxE,CAAlC;AACD;;AAEOc,EAAAA,WAAW,CAACD,OAAD,EAAuC;AACxD,QAAIA,OAAO,KAAK,IAAhB,EAAsB,MAAM,KAAIE,uBAAJ,GAAN;AACtB,QAAI,OAAOF,OAAP,KAAmB,QAAvB,EAAiC,OAAOA,OAAP;AAEjC,QAAId,QAAQ,GAAGc,OAAO,CAACA,OAAvB;;AACA,QAAId,QAAQ,KAAK,IAAjB,EAAuB;AACrBA,MAAAA,QAAQ,GAAG,WAAX;AACD;;AAED,WAAOA,QAAP;AACD;;AAEOqB,EAAAA,QAAQ,GAAG,CAAE;;AAWrB;AACF;AACA;AACS,MAAHC,GAAG,GAAG;AACR;AACA,WAAQ,YAAW,KAAK1B,OAAL,CAAa2B,UAAb,CAAwBJ,EAAG,GAA9C;AACD;;AAhF0B","sourcesContent":["import { Component } from '@teambit/component';\nimport { ExecutionContext } from '@teambit/envs';\nimport { PubsubMain } from '@teambit/pubsub';\n\nimport { AddressInfo } from 'net';\n\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\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 async listen() {\n const port = await selectPort(this.portRange);\n this._port = port;\n const server = await this.devServer.listen(port);\n const address = 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(server, this.context, hostname, port));\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 DevServer,\n ExecutionContext,\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"]}
1
+ {"version":3,"names":["ComponentServer","constructor","pubsub","context","portRange","devServer","componentsServer","hostname","port","ComponentsServerStartedEvent","Date","now","hasComponent","component","components","find","contextComponent","equals","_port","listen","selectPort","server","address","getHostname","BindError","pub","BundlerAspect","id","createComponentsServerStartedEvent","onChange","url","envRuntime"],"sources":["component-server.ts"],"sourcesContent":["import { Component } from '@teambit/component';\nimport { ExecutionContext } from '@teambit/envs';\nimport { PubsubMain } from '@teambit/pubsub';\n\nimport { AddressInfo } from 'net';\n\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\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 async listen() {\n const port = await selectPort(this.portRange);\n this._port = port;\n const server = await this.devServer.listen(port);\n const address = 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(server, this.context, hostname, port));\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 DevServer,\n ExecutionContext,\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":";;;;;;;;;;;;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAKA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,MAAMA,eAAN,CAAsB;EAC3B;EAEAC,WAAW;EACT;AACJ;AACA;EACYC,MAJC;EAMT;AACJ;AACA;EACaC,OATA;EA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9D,EAAwEC,IAAxE,CAAlC;EACD;;EAEOe,WAAW,CAACD,OAAD,EAAuC;IACxD,IAAIA,OAAO,KAAK,IAAhB,EAAsB,MAAM,KAAIE,uBAAJ,GAAN;IACtB,IAAI,OAAOF,OAAP,KAAmB,QAAvB,EAAiC,OAAOA,OAAP;IAEjC,IAAIf,QAAQ,GAAGe,OAAO,CAACA,OAAvB;;IACA,IAAIf,QAAQ,KAAK,IAAjB,EAAuB;MACrBA,QAAQ,GAAG,WAAX;IACD;;IAED,OAAOA,QAAP;EACD;;EAEOsB,QAAQ,GAAG,CAAE;;EAWrB;AACF;AACA;EACS,IAAHC,GAAG,GAAG;IACR;IACA,OAAQ,YAAW,KAAK3B,OAAL,CAAa4B,UAAb,CAAwBJ,EAAG,GAA9C;EACD;;AAhF0B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["dedup-envs.ts"],"names":["dedupEnvs","contexts","dedicatedEnvDevServers","groupedEnvs","forEach","context","envId","getEnvId","push","dedicatedServers","id","split","includes","env","getDevEnvId"],"mappings":";;;;;;;;;AAEA;AACO,SAASA,SAAT,CAAmBC,QAAnB,EAAiDC,sBAAjD,EAAoF;AACzF,QAAMC,WAA+C,GAAG,EAAxD;AAEAF,EAAAA,QAAQ,CAACG,OAAT,CAAkBC,OAAD,IAAa;AAC5B,UAAMC,KAAK,GAAGC,QAAQ,CAACF,OAAD,EAAUH,sBAAV,CAAtB;AACA,QAAI,CAACI,KAAL,EAAY;AACZ,QAAI,EAAEA,KAAK,IAAIH,WAAX,CAAJ,EAA6BA,WAAW,CAACG,KAAD,CAAX,GAAqB,EAArB;AAE7BH,IAAAA,WAAW,CAACG,KAAD,CAAX,CAAmBE,IAAnB,CAAwBH,OAAxB;AACD,GAND;AAQA,SAAOF,WAAP;AACD;;AAED,SAASI,QAAT,CAAkBF,OAAlB,EAA6CI,gBAA7C,EAA8F;AAAA;;AAC5F,QAAMC,EAAE,GAAGL,OAAO,CAACK,EAAR,CAAWC,KAAX,CAAiB,GAAjB,EAAsB,CAAtB,CAAX;;AAEA,MAAIF,gBAAJ,aAAIA,gBAAJ,eAAIA,gBAAgB,CAAEG,QAAlB,CAA2BF,EAA3B,CAAJ,EAAoC;AAClC,WAAOL,OAAO,CAACK,EAAf;AACD;;AAED,yBAAOL,OAAO,CAACQ,GAAf,iDAAO,aAAaC,WAAb,CAAyBT,OAAzB,CAAP;AACD","sourcesContent":["import type { ExecutionContext } from '@teambit/envs';\n\n// de-duping dev servers by the amount of type the dev server configuration was overridden by envs.\nexport function dedupEnvs(contexts: ExecutionContext[], dedicatedEnvDevServers?: string[]) {\n const groupedEnvs: Record<string, ExecutionContext[]> = {};\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\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 return context.env?.getDevEnvId(context);\n}\n"]}
1
+ {"version":3,"names":["dedupEnvs","contexts","dedicatedEnvDevServers","groupedEnvs","forEach","context","envId","getEnvId","push","dedicatedServers","id","split","includes","env","getDevEnvId"],"sources":["dedup-envs.ts"],"sourcesContent":["import type { ExecutionContext } from '@teambit/envs';\n\n// de-duping dev servers by the amount of type the dev server configuration was overridden by envs.\nexport function dedupEnvs(contexts: ExecutionContext[], dedicatedEnvDevServers?: string[]) {\n const groupedEnvs: Record<string, ExecutionContext[]> = {};\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\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 return context.env?.getDevEnvId(context);\n}\n"],"mappings":";;;;;;;;;AAEA;AACO,SAASA,SAAT,CAAmBC,QAAnB,EAAiDC,sBAAjD,EAAoF;EACzF,MAAMC,WAA+C,GAAG,EAAxD;EAEAF,QAAQ,CAACG,OAAT,CAAkBC,OAAD,IAAa;IAC5B,MAAMC,KAAK,GAAGC,QAAQ,CAACF,OAAD,EAAUH,sBAAV,CAAtB;IACA,IAAI,CAACI,KAAL,EAAY;IACZ,IAAI,EAAEA,KAAK,IAAIH,WAAX,CAAJ,EAA6BA,WAAW,CAACG,KAAD,CAAX,GAAqB,EAArB;IAE7BH,WAAW,CAACG,KAAD,CAAX,CAAmBE,IAAnB,CAAwBH,OAAxB;EACD,CAND;EAQA,OAAOF,WAAP;AACD;;AAED,SAASI,QAAT,CAAkBF,OAAlB,EAA6CI,gBAA7C,EAA8F;EAAA;;EAC5F,MAAMC,EAAE,GAAGL,OAAO,CAACK,EAAR,CAAWC,KAAX,CAAiB,GAAjB,EAAsB,CAAtB,CAAX;;EAEA,IAAIF,gBAAJ,aAAIA,gBAAJ,eAAIA,gBAAgB,CAAEG,QAAlB,CAA2BF,EAA3B,CAAJ,EAAoC;IAClC,OAAOL,OAAO,CAACK,EAAf;EACD;;EAED,uBAAOL,OAAO,CAACQ,GAAf,iDAAO,aAAaC,WAAb,CAAyBT,OAAzB,CAAP;AACD"}
@@ -20,4 +20,35 @@ export interface DevServerContext extends ExecutionContext {
20
20
  * favicon of the page.
21
21
  */
22
22
  favicon?: string;
23
+ /**
24
+ * A path for the host root dir
25
+ * Host root dir is usually the env root dir
26
+ * This can be used in different bundle options which run require.resolve
27
+ * for example when configuring webpack aliases or webpack expose loader on the peers deps
28
+ */
29
+ hostRootDir?: string;
30
+ /**
31
+ * Array of host dependencies, they are used later in case you use one of the following:
32
+ *
33
+ */
34
+ hostDependencies?: string[];
35
+ /**
36
+ * Make the hostDependencies externals. externals (from webpack docs):
37
+ * The externals configuration option provides a way of excluding dependencies from the output bundles.
38
+ * Instead, the created bundle relies on that dependency to be present in the consumer's (any end-user application) environment.
39
+ */
40
+ externalizeHostDependencies?: boolean;
41
+ /**
42
+ * Make aliases for the hostDependencies.
43
+ * the path of each one will be resolved by [hostRootDir, process.cwd(), __dirname]
44
+ * this will usually replace the instance of import one of the host dependencies by the instance of the env provided it
45
+ */
46
+ aliasHostDependencies?: boolean;
47
+ /**
48
+ * Expose the hostDependencies on the global (window) object.
49
+ * the path of each one will be resolved by [hostRootDir, process.cwd(), __dirname]
50
+ * from the webpack plugin docs:
51
+ * The expose-loader loader allows to expose a module (in whole or in part) to global object (self, window and global).
52
+ */
53
+ exposeHostDependencies?: boolean;
23
54
  }
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
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 /**\n * Expose the hostDependencies on the global (window) object.\n * the path of each one will be resolved by [hostRootDir, process.cwd(), __dirname]\n * from the webpack plugin docs:\n * The expose-loader loader allows to expose a module (in whole or in part) to global object (self, window and global).\n */\n exposeHostDependencies?: boolean;\n}\n"],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"sources":["dev-server.graphql.ts"],"names":["devServerSchema","bundler","typeDefs","resolvers","Component","server","component","args","context","requestedId","body","variables","id","includes","componentServer","getComponentServer","env","envRuntime","url"],"mappings":";;;;;;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIA;AACO,SAASA,eAAT,CAAyBC,OAAzB,EAAuD;AAC5D,SAAO;AACLC,IAAAA,QAAQ,EAAE,kBAAI;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAVS;AAWLC,IAAAA,SAAS,EAAE;AACTC,MAAAA,SAAS,EAAE;AACTC,QAAAA,MAAM,EAAE,CAACC,SAAD,EAAuBC,IAAvB,EAA6BC,OAA7B,KAAyC;AAC/C;AACA;AACA;AACA,gBAAMC,WAAW,GAAGD,OAAO,CAACE,IAAR,CAAaC,SAAb,CAAuBC,EAA3C,CAJ+C,CAK/C;AACA;AACA;;AACA,cAAIH,WAAW,IAAIA,WAAW,CAACI,QAAZ,CAAqB,GAArB,CAAnB,EAA8C;AAC5C,mBAAO,EAAP;AACD;;AACD,gBAAMC,eAAe,GAAGb,OAAO,CAACc,kBAAR,CAA2BT,SAA3B,CAAxB;AACA,cAAI,CAACQ,eAAL,EAAsB,OAAO,EAAP;AAEtB,iBAAO;AACLE,YAAAA,GAAG,EAAEF,eAAe,CAACN,OAAhB,CAAwBS,UAAxB,CAAmCL,EADnC;AAELM,YAAAA,GAAG,EAAEJ,eAAe,CAACI;AAFhB,WAAP;AAID;AAnBQ;AADF;AAXN,GAAP;AAmCD","sourcesContent":["import { Component } from '@teambit/component';\nimport { Schema } from '@teambit/graphql';\nimport { gql } from '@apollo/client';\n\nimport { BundlerMain } from './bundler.main.runtime';\n\n// TODO: this has to be refactored to the Preview aspect. with the entire preview logic here.\nexport function devServerSchema(bundler: BundlerMain): Schema {\n return {\n typeDefs: gql`\n extend type Component {\n server: ComponentServer\n }\n\n type ComponentServer {\n env: String\n url: String\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 }\n const componentServer = bundler.getComponentServer(component);\n if (!componentServer) return {};\n\n return {\n env: componentServer.context.envRuntime.id,\n url: componentServer.url,\n };\n },\n },\n },\n };\n}\n"]}
1
+ {"version":3,"names":["devServerSchema","bundler","typeDefs","gql","resolvers","Component","server","component","args","context","requestedId","body","variables","id","includes","componentServer","getComponentServer","env","envRuntime","url"],"sources":["dev-server.graphql.ts"],"sourcesContent":["import { Component } from '@teambit/component';\nimport { Schema } from '@teambit/graphql';\nimport { gql } from '@apollo/client';\n\nimport { BundlerMain } from './bundler.main.runtime';\n\n// TODO: this has to be refactored to the Preview aspect. with the entire preview logic here.\nexport function devServerSchema(bundler: BundlerMain): Schema {\n return {\n typeDefs: gql`\n extend type Component {\n server: ComponentServer\n }\n\n type ComponentServer {\n env: String\n url: String\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 }\n const componentServer = bundler.getComponentServer(component);\n if (!componentServer) return {};\n\n return {\n env: componentServer.context.envRuntime.id,\n url: componentServer.url,\n };\n },\n },\n },\n };\n}\n"],"mappings":";;;;;;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAIA;AACO,SAASA,eAAT,CAAyBC,OAAzB,EAAuD;EAC5D,OAAO;IACLC,QAAQ,EAAE,IAAAC,aAAA,CAAI;AAClB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAVS;IAWLC,SAAS,EAAE;MACTC,SAAS,EAAE;QACTC,MAAM,EAAE,CAACC,SAAD,EAAuBC,IAAvB,EAA6BC,OAA7B,KAAyC;UAC/C;UACA;UACA;UACA,MAAMC,WAAW,GAAGD,OAAO,CAACE,IAAR,CAAaC,SAAb,CAAuBC,EAA3C,CAJ+C,CAK/C;UACA;UACA;;UACA,IAAIH,WAAW,IAAIA,WAAW,CAACI,QAAZ,CAAqB,GAArB,CAAnB,EAA8C;YAC5C,OAAO,EAAP;UACD;;UACD,MAAMC,eAAe,GAAGd,OAAO,CAACe,kBAAR,CAA2BT,SAA3B,CAAxB;UACA,IAAI,CAACQ,eAAL,EAAsB,OAAO,EAAP;UAEtB,OAAO;YACLE,GAAG,EAAEF,eAAe,CAACN,OAAhB,CAAwBS,UAAxB,CAAmCL,EADnC;YAELM,GAAG,EAAEJ,eAAe,CAACI;UAFhB,CAAP;QAID;MAnBQ;IADF;EAXN,CAAP;AAmCD"}
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}
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 tester.\n */\n displayName?: string;\n\n /**\n * icon of the tester.\n */\n icon?: string;\n\n /**\n * serialized config of the tester.\n */\n displayConfig?(): string;\n\n /**\n * path to the config in the filesystem.\n */\n configPath?: string;\n\n /**\n * id of the tester.\n */\n id: string;\n\n /**\n * return the tester version.\n */\n version?(): string;\n}\n"],"mappings":""}
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { EnvService, ExecutionContext, EnvDefinition } from '@teambit/envs';
3
3
  import { PubsubMain } from '@teambit/pubsub';
4
+ import { DependencyResolverMain } from '@teambit/dependency-resolver';
4
5
  import { BrowserRuntimeSlot } from './bundler.main.runtime';
5
6
  import { ComponentServer } from './component-server';
6
7
  export declare type DevServerServiceOptions = {
@@ -30,6 +31,7 @@ export declare class DevServerService implements EnvService<ComponentServer, Dev
30
31
  * browser runtime slot
31
32
  */
32
33
  private pubsub;
34
+ private dependencyResolver;
33
35
  /**
34
36
  * browser runtime slot
35
37
  */
@@ -39,7 +41,7 @@ export declare class DevServerService implements EnvService<ComponentServer, Dev
39
41
  /**
40
42
  * browser runtime slot
41
43
  */
42
- pubsub: PubsubMain,
44
+ pubsub: PubsubMain, dependencyResolver: DependencyResolverMain,
43
45
  /**
44
46
  * browser runtime slot
45
47
  */
@@ -106,12 +106,13 @@ class DevServerService {
106
106
  /**
107
107
  * browser runtime slot
108
108
  */
109
- pubsub,
109
+ pubsub, dependencyResolver,
110
110
  /**
111
111
  * browser runtime slot
112
112
  */
113
113
  runtimeSlot) {
114
114
  this.pubsub = pubsub;
115
+ this.dependencyResolver = dependencyResolver;
115
116
  this.runtimeSlot = runtimeSlot;
116
117
  (0, _defineProperty2().default)(this, "name", 'dev server');
117
118
  }
@@ -180,11 +181,14 @@ class DevServerService {
180
181
  async buildContext(context, additionalContexts = []) {
181
182
  context.relatedContexts = additionalContexts.map(ctx => ctx.envDefinition.id);
182
183
  context.components = context.components.concat(this.getComponentsFromContexts(additionalContexts));
184
+ const peers = await this.dependencyResolver.getPeerDependenciesListFromEnv(context.env);
183
185
  return Object.assign(context, {
184
186
  entry: await (0, _getEntry().getEntry)(context, this.runtimeSlot),
185
187
  // don't start with a leading "/" because it generates errors on Windows
186
188
  rootPath: `preview/${context.envRuntime.id}`,
187
- publicPath: `${_path().sep}public`
189
+ publicPath: `${_path().sep}public`,
190
+ hostDependencies: peers,
191
+ aliasHostDependencies: true
188
192
  });
189
193
  }
190
194
 
@@ -1 +1 @@
1
- {"version":3,"sources":["dev-server.service.tsx"],"names":["DevServerService","constructor","pubsub","runtimeSlot","render","env","context","descriptor","getDescriptor","id","displayName","version","config","language","ignoreIllegals","environment","getDevServer","undefined","mergedContext","buildContext","devServer","icon","displayConfig","runOnce","contexts","dedicatedEnvDevServers","groupedEnvs","servers","Promise","all","Object","entries","map","contextList","mainContext","find","envDefinition","additionalContexts","filter","devServerContext","envRuntime","ComponentServer","mergeContext","getComponentsFromContexts","components","relatedContexts","ctx","concat","assign","entry","rootPath","publicPath","sep"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AA4BO,MAAMA,gBAAN,CAAmF;AAGxFC,EAAAA,WAAW;AACT;AACJ;AACA;AACYC,EAAAA,MAJC;AAMT;AACJ;AACA;AACYC,EAAAA,WATC,EAUT;AAAA,SANQD,MAMR,GANQA,MAMR;AAAA,SADQC,WACR,GADQA,WACR;AAAA,kDAZK,YAYL;AAAE;;AAEQ,QAANC,MAAM,CAACC,GAAD,EAAqBC,OAArB,EAAkD;AAC5D,UAAMC,UAAU,GAAG,MAAM,KAAKC,aAAL,CAAmBH,GAAnB,EAAwBC,OAAxB,CAAzB;AACA,wBACE,+BAAC,WAAD;AAAM,MAAA,GAAG,EAAEC,UAAF,aAAEA,UAAF,uBAAEA,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,CAACQ,GAAT,CAAc1B,OAAD,IAAa;AACxB,aAAOA,OAAO,CAACsC,UAAf;AACD,KAFD,CADK,CAAP;AAKD;AAED;AACF;AACA;;;AAC4B,QAAZzB,YAAY,CACxBb,OADwB,EAExB+B,kBAAsC,GAAG,EAFjB,EAGG;AAC3B/B,IAAAA,OAAO,CAACuC,eAAR,GAA0BR,kBAAkB,CAACL,GAAnB,CAAwBc,GAAD,IAASA,GAAG,CAACV,aAAJ,CAAkB3B,EAAlD,CAA1B;AACAH,IAAAA,OAAO,CAACsC,UAAR,GAAqBtC,OAAO,CAACsC,UAAR,CAAmBG,MAAnB,CAA0B,KAAKJ,yBAAL,CAA+BN,kBAA/B,CAA1B,CAArB;AAEA,WAAOP,MAAM,CAACkB,MAAP,CAAc1C,OAAd,EAAuB;AAC5B2C,MAAAA,KAAK,EAAE,MAAM,0BAAS3C,OAAT,EAAkB,KAAKH,WAAvB,CADe;AAE5B;AACA+C,MAAAA,QAAQ,EAAG,WAAU5C,OAAO,CAACkC,UAAR,CAAmB/B,EAAG,EAHf;AAI5B0C,MAAAA,UAAU,EAAG,GAAEC,WAAI;AAJS,KAAvB,CAAP;AAMD;;AA7GuF","sourcesContent":["import { EnvService, ExecutionContext, EnvDefinition } from '@teambit/envs';\nimport { PubsubMain } from '@teambit/pubsub';\nimport { flatten } from 'lodash';\nimport React from 'react';\nimport { Text, Newline } from 'ink';\nimport highlight from 'cli-highlight';\nimport { sep } from 'path';\nimport { BrowserRuntimeSlot } 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\nexport type DevServerDescriptor = {\n /**\n * id of the dev server (e.g. jest/mocha)\n */\n id: string;\n\n /**\n * display name of the dev server (e.g. Jest / Mocha)\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 /**\n * browser runtime slot\n */\n private pubsub: PubsubMain,\n\n /**\n * browser runtime slot\n */\n private runtimeSlot: BrowserRuntimeSlot\n ) {}\n\n async render(env: EnvDefinition, context: ExecutionContext[]) {\n const descriptor = await this.getDescriptor(env, context);\n return (\n <Text key={descriptor?.id}>\n <Text color=\"cyan\">configured dev server: </Text>\n <Text>\n {descriptor?.id} ({descriptor?.displayName} @ {descriptor?.version})\n </Text>\n <Newline />\n <Text underline color=\"cyan\">\n dev server config:\n </Text>\n <Newline />\n <Text>\n {/* refactor a separate component which highlights for cli */}\n {highlight(descriptor?.config || '', { language: 'javascript', ignoreIllegals: true })}\n </Text>\n <Newline />\n </Text>\n );\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 // 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 = dedupEnvs(contexts, dedicatedEnvDevServers);\n\n const servers = await Promise.all(\n Object.entries(groupedEnvs).map(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\n return new ComponentServer(this.pubsub, devServerContext, [3300, 3400], devServer);\n })\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\n return Object.assign(context, {\n entry: await getEntry(context, this.runtimeSlot),\n // don't start with a leading \"/\" because it generates errors on Windows\n rootPath: `preview/${context.envRuntime.id}`,\n publicPath: `${sep}public`,\n });\n }\n}\n"]}
1
+ {"version":3,"names":["DevServerService","constructor","pubsub","dependencyResolver","runtimeSlot","render","env","context","descriptor","getDescriptor","id","displayName","version","highlight","config","language","ignoreIllegals","environment","getDevServer","undefined","mergedContext","buildContext","devServer","icon","displayConfig","runOnce","contexts","dedicatedEnvDevServers","groupedEnvs","dedupEnvs","servers","Promise","all","Object","entries","map","contextList","mainContext","find","envDefinition","additionalContexts","filter","devServerContext","envRuntime","ComponentServer","mergeContext","getComponentsFromContexts","flatten","components","relatedContexts","ctx","concat","peers","getPeerDependenciesListFromEnv","assign","entry","getEntry","rootPath","publicPath","sep","hostDependencies","aliasHostDependencies"],"sources":["dev-server.service.tsx"],"sourcesContent":["import { EnvService, ExecutionContext, EnvDefinition } from '@teambit/envs';\nimport { PubsubMain } from '@teambit/pubsub';\nimport { flatten } from 'lodash';\nimport React from 'react';\nimport { Text, Newline } from 'ink';\nimport { DependencyResolverMain } from '@teambit/dependency-resolver';\nimport highlight from 'cli-highlight';\nimport { sep } from 'path';\nimport { BrowserRuntimeSlot } 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\nexport type DevServerDescriptor = {\n /**\n * id of the dev server (e.g. jest/mocha)\n */\n id: string;\n\n /**\n * display name of the dev server (e.g. Jest / Mocha)\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 /**\n * browser runtime slot\n */\n private pubsub: PubsubMain,\n\n private dependencyResolver: DependencyResolverMain,\n\n /**\n * browser runtime slot\n */\n private runtimeSlot: BrowserRuntimeSlot\n ) {}\n\n async render(env: EnvDefinition, context: ExecutionContext[]) {\n const descriptor = await this.getDescriptor(env, context);\n return (\n <Text key={descriptor?.id}>\n <Text color=\"cyan\">configured dev server: </Text>\n <Text>\n {descriptor?.id} ({descriptor?.displayName} @ {descriptor?.version})\n </Text>\n <Newline />\n <Text underline color=\"cyan\">\n dev server config:\n </Text>\n <Newline />\n <Text>\n {/* refactor a separate component which highlights for cli */}\n {highlight(descriptor?.config || '', { language: 'javascript', ignoreIllegals: true })}\n </Text>\n <Newline />\n </Text>\n );\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 // 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 = dedupEnvs(contexts, dedicatedEnvDevServers);\n\n const servers = await Promise.all(\n Object.entries(groupedEnvs).map(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\n return new ComponentServer(this.pubsub, devServerContext, [3300, 3400], devServer);\n })\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.getPeerDependenciesListFromEnv(context.env);\n\n return Object.assign(context, {\n entry: await getEntry(context, this.runtimeSlot),\n // don't start with a leading \"/\" because it generates errors on Windows\n rootPath: `preview/${context.envRuntime.id}`,\n publicPath: `${sep}public`,\n hostDependencies: peers,\n aliasHostDependencies: true,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAA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ASjD,OAAT,EAAkB,KAAKH,WAAvB,CADe;MAE5B;MACAqD,QAAQ,EAAG,WAAUlD,OAAO,CAACoC,UAAR,CAAmBjC,EAAG,EAHf;MAI5BgD,UAAU,EAAG,GAAEC,WAAI,QAJS;MAK5BC,gBAAgB,EAAER,KALU;MAM5BS,qBAAqB,EAAE;IANK,CAAvB,CAAP;EAQD;;AAlHuF"}
@@ -1 +1 @@
1
- {"version":3,"sources":["components-server-started-event.ts"],"names":["ComponentsServerStartedEventData","constructor","componentsServer","context","hostname","port","ComponentsServerStartedEvent","BitBaseEvent","timestamp","TYPE"],"mappings":";;;;;;;;;;;;;;;;;;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAFA;AAIA,MAAMA,gCAAN,CAAuC;AACrCC,EAAAA,WAAW,CAAUC,gBAAV,EAAqCC,OAArC,EAAuDC,QAAvD,EAA0EC,IAA1E,EAAgF;AAAA,SAAtEH,gBAAsE,GAAtEA,gBAAsE;AAAA,SAA3CC,OAA2C,GAA3CA,OAA2C;AAAA,SAAzBC,QAAyB,GAAzBA,QAAyB;AAAA,SAANC,IAAM,GAANA,IAAM;AAAE;;AADxD;;AAIhC,MAAMC,4BAAN,SAA2CC,sBAA3C,CAA0F;AAG/FN,EAAAA,WAAW,CAAUO,SAAV,EAA8BN,gBAA9B,EAAyDC,OAAzD,EAA2EC,QAA3E,EAA8FC,IAA9F,EAAoG;AAC7G,UACEC,4BAA4B,CAACG,IAD/B,EAEE,OAFF,EAGED,SAHF,EAIE,IAAIR,gCAAJ,CAAqCE,gBAArC,EAAuDC,OAAvD,EAAgEC,QAAhE,EAA0EC,IAA1E,CAJF;AAD6G,SAA1FG,SAA0F,GAA1FA,SAA0F;AAAA,SAAtEN,gBAAsE,GAAtEA,gBAAsE;AAAA,SAA3CC,OAA2C,GAA3CA,OAA2C;AAAA,SAAzBC,QAAyB,GAAzBA,QAAyB;AAAA,SAANC,IAAM,GAANA,IAAM;AAO9G;;AAV8F;;;gCAApFC,4B,UACY,2B","sourcesContent":["/* eslint-disable max-classes-per-file */\n\nimport { BitBaseEvent } from '@teambit/pubsub';\n\nclass ComponentsServerStartedEventData {\n constructor(readonly componentsServer, readonly context, readonly hostname, readonly port) {}\n}\n\nexport class ComponentsServerStartedEvent extends BitBaseEvent<ComponentsServerStartedEventData> {\n static readonly TYPE = 'components-server-started';\n\n constructor(readonly timestamp, readonly componentsServer, readonly context, readonly hostname, readonly port) {\n super(\n ComponentsServerStartedEvent.TYPE,\n '0.0.1',\n timestamp,\n new ComponentsServerStartedEventData(componentsServer, context, hostname, port)\n );\n }\n}\n"]}
1
+ {"version":3,"names":["ComponentsServerStartedEventData","constructor","componentsServer","context","hostname","port","ComponentsServerStartedEvent","BitBaseEvent","timestamp","TYPE"],"sources":["components-server-started-event.ts"],"sourcesContent":["/* eslint-disable max-classes-per-file */\n\nimport { BitBaseEvent } from '@teambit/pubsub';\n\nclass ComponentsServerStartedEventData {\n constructor(readonly componentsServer, readonly context, readonly hostname, readonly port) {}\n}\n\nexport class ComponentsServerStartedEvent extends BitBaseEvent<ComponentsServerStartedEventData> {\n static readonly TYPE = 'components-server-started';\n\n constructor(readonly timestamp, readonly componentsServer, readonly context, readonly hostname, readonly port) {\n super(\n ComponentsServerStartedEvent.TYPE,\n '0.0.1',\n timestamp,\n new ComponentsServerStartedEventData(componentsServer, context, hostname, port)\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAFA;AAIA,MAAMA,gCAAN,CAAuC;EACrCC,WAAW,CAAUC,gBAAV,EAAqCC,OAArC,EAAuDC,QAAvD,EAA0EC,IAA1E,EAAgF;IAAA,KAAtEH,gBAAsE,GAAtEA,gBAAsE;IAAA,KAA3CC,OAA2C,GAA3CA,OAA2C;IAAA,KAAzBC,QAAyB,GAAzBA,QAAyB;IAAA,KAANC,IAAM,GAANA,IAAM;EAAE;;AADxD;;AAIhC,MAAMC,4BAAN,SAA2CC,sBAA3C,CAA0F;EAG/FN,WAAW,CAAUO,SAAV,EAA8BN,gBAA9B,EAAyDC,OAAzD,EAA2EC,QAA3E,EAA8FC,IAA9F,EAAoG;IAC7G,MACEC,4BAA4B,CAACG,IAD/B,EAEE,OAFF,EAGED,SAHF,EAIE,IAAIR,gCAAJ,CAAqCE,gBAArC,EAAuDC,OAAvD,EAAgEC,QAAhE,EAA0EC,IAA1E,CAJF;IAD6G,KAA1FG,SAA0F,GAA1FA,SAA0F;IAAA,KAAtEN,gBAAsE,GAAtEA,gBAAsE;IAAA,KAA3CC,OAA2C,GAA3CA,OAA2C;IAAA,KAAzBC,QAAyB,GAAzBA,QAAyB;IAAA,KAANC,IAAM,GAANA,IAAM;EAO9G;;AAV8F;;;gCAApFC,4B,UACY,2B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export * from './components-server-started-event';\n"]}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './components-server-started-event';\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["bind-error.ts"],"names":["BindError","Error"],"mappings":";;;;;;;AAAO,MAAMA,SAAN,SAAwBC,KAAxB,CAA8B","sourcesContent":["export class BindError extends Error {}\n"]}
1
+ {"version":3,"names":["BindError","Error"],"sources":["bind-error.ts"],"sourcesContent":["export class BindError extends Error {}\n"],"mappings":";;;;;;;AAAO,MAAMA,SAAN,SAAwBC,KAAxB,CAA8B"}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA","sourcesContent":["export { BindError } from './bind-error';\n"]}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { BindError } from './bind-error';\n"],"mappings":";;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["get-entry.ts"],"names":["getEntry","context","runtimeSlot","slotEntries","Promise","all","values","map","browserRuntime","entry","slotPaths","reduce","acc","current","concat"],"mappings":";;;;;;;;;;;AAeA;AACA;AACA;AACO,eAAeA,QAAf,CAAwBC,OAAxB,EAAmDC,WAAnD,EAAuG;AAC5G;AACA,QAAMC,WAAW,GAAG,MAAMC,OAAO,CAACC,GAAR,CACxBH,WAAW,CAACI,MAAZ,GAAqBC,GAArB,CAAyB,MAAOC,cAAP,IAA0BA,cAAc,CAACC,KAAf,CAAqBR,OAArB,CAAnD,CADwB,CAA1B;AAIA,QAAMS,SAAS,GAAGP,WAAW,CAACQ,MAAZ,CAAmB,CAACC,GAAD,EAAMC,OAAN,KAAkB;AACrDD,IAAAA,GAAG,GAAGA,GAAG,CAACE,MAAJ,CAAWD,OAAX,CAAN;AACA,WAAOD,GAAP;AACD,GAHiB,CAAlB;AAKA,SAAOF,SAAP;AACD","sourcesContent":["import { ComponentID } from '@teambit/component';\nimport { ExecutionContext } from '@teambit/envs';\nimport { GetBitMapComponentOptions } from '@teambit/legacy/dist/consumer/bit-map/bit-map';\nimport { PathOsBased } from '@teambit/legacy/dist/utils/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"]}
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/dist/consumer/bit-map/bit-map';\nimport { PathOsBased } from '@teambit/legacy/dist/utils/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,QAAf,CAAwBC,OAAxB,EAAmDC,WAAnD,EAAuG;EAC5G;EACA,MAAMC,WAAW,GAAG,MAAMC,OAAO,CAACC,GAAR,CACxBH,WAAW,CAACI,MAAZ,GAAqBC,GAArB,CAAyB,MAAOC,cAAP,IAA0BA,cAAc,CAACC,KAAf,CAAqBR,OAArB,CAAnD,CADwB,CAA1B;EAIA,MAAMS,SAAS,GAAGP,WAAW,CAACQ,MAAZ,CAAmB,CAACC,GAAD,EAAMC,OAAN,KAAkB;IACrDD,GAAG,GAAGA,GAAG,CAACE,MAAJ,CAAWD,OAAX,CAAN;IACA,OAAOD,GAAP;EACD,CAHiB,CAAlB;EAKA,OAAOF,SAAP;AACD"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AASA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export { DevServer } from './dev-server';\nexport { DevServerContext } from './dev-server-context';\nexport {\n BundlerContext,\n Target,\n ModuleTarget,\n HtmlConfig as BundlerHtmlConfig,\n EntryMap as BundlerEntryMap,\n Entry as BundlerEntry,\n MetaData as BundlerContextMetaData,\n} from './bundler-context';\nexport { Bundler, BundlerResult, BundlerMode, Asset, ChunksAssetsMap, EntriesAssetsMap, EntryAssets } from './bundler';\nexport type { BundlerMain } from './bundler.main.runtime';\nexport { BundlerAspect } from './bundler.aspect';\nexport { ComponentDir } from './get-entry';\nexport { ComponentServer } from './component-server';\nexport * from './events';\n"]}
1
+ {"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export { DevServer } from './dev-server';\nexport { DevServerContext } from './dev-server-context';\nexport {\n BundlerContext,\n Target,\n ModuleTarget,\n HtmlConfig as BundlerHtmlConfig,\n EntryMap as BundlerEntryMap,\n Entry as BundlerEntry,\n MetaData as BundlerContextMetaData,\n} from './bundler-context';\nexport { Bundler, BundlerResult, BundlerMode, Asset, ChunksAssetsMap, EntriesAssetsMap, EntryAssets } from './bundler';\nexport type { BundlerMain } from './bundler.main.runtime';\nexport { BundlerAspect } from './bundler.aspect';\nexport { ComponentDir } from './get-entry';\nexport { ComponentServer } from './component-server';\nexport * from './events';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AASA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"sources":["select-port.ts"],"names":["selectPort","range","Port","getPortFromRange"],"mappings":";;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEA;AACA;AACA;AACO,eAAeA,UAAf,CAA0BC,KAA1B,EAAqE;AAC1E,SAAOC,uBAAKC,gBAAL,CAAsBF,KAAtB,CAAP;AACD","sourcesContent":["import { Port } from '@teambit/toolbox.network.get-port';\n\n/**\n * get an available port between range 3000 to 3200 or from port range\n */\nexport async function selectPort(range: number[] | number): Promise<number> {\n return Port.getPortFromRange(range);\n}\n"]}
1
+ {"version":3,"names":["selectPort","range","Port","getPortFromRange"],"sources":["select-port.ts"],"sourcesContent":["import { Port } from '@teambit/toolbox.network.get-port';\n\n/**\n * get an available port between range 3000 to 3200 or from port range\n */\nexport async function selectPort(range: number[] | number): Promise<number> {\n return Port.getPortFromRange(range);\n}\n"],"mappings":";;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;AACA;AACA;AACO,eAAeA,UAAf,CAA0BC,KAA1B,EAAqE;EAC1E,OAAOC,sBAAA,CAAKC,gBAAL,CAAsBF,KAAtB,CAAP;AACD"}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/bundler",
3
- "version": "0.0.736",
3
+ "version": "0.0.739",
4
4
  "homepage": "https://bit.dev/teambit/compilation/bundler",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.compilation",
8
8
  "name": "bundler",
9
- "version": "0.0.736"
9
+ "version": "0.0.739"
10
10
  },
11
11
  "dependencies": {
12
12
  "cli-highlight": "2.1.9",
@@ -15,12 +15,13 @@
15
15
  "@babel/runtime": "7.12.18",
16
16
  "core-js": "^3.0.0",
17
17
  "@teambit/harmony": "0.3.3",
18
- "@teambit/envs": "0.0.736",
19
- "@teambit/builder": "0.0.736",
20
- "@teambit/component": "0.0.736",
18
+ "@teambit/envs": "0.0.739",
19
+ "@teambit/builder": "0.0.739",
20
+ "@teambit/component": "0.0.739",
21
21
  "@teambit/cli": "0.0.491",
22
- "@teambit/graphql": "0.0.736",
23
- "@teambit/pubsub": "0.0.736",
22
+ "@teambit/dependency-resolver": "0.0.739",
23
+ "@teambit/graphql": "0.0.739",
24
+ "@teambit/pubsub": "0.0.739",
24
25
  "@teambit/toolbox.network.get-port": "0.0.113"
25
26
  },
26
27
  "devDependencies": {
@@ -1,2 +1,2 @@
1
- export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compilation_bundler@0.0.736/dist/bundler.composition.js')]
2
- export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compilation_bundler@0.0.736/dist/bundler.docs.mdx')]
1
+ export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compilation_bundler@0.0.739/dist/bundler.composition.js')]
2
+ export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.compilation_bundler@0.0.739/dist/bundler.docs.mdx')]
package/tsconfig.json CHANGED
@@ -15,13 +15,13 @@
15
15
  "declaration": true,
16
16
  "sourceMap": true,
17
17
  "skipLibCheck": true,
18
+ "experimentalDecorators": true,
18
19
  "outDir": "dist",
19
20
  "moduleResolution": "node",
20
21
  "esModuleInterop": true,
21
22
  "rootDir": ".",
22
23
  "resolveJsonModule": true,
23
24
  "emitDeclarationOnly": true,
24
- "experimentalDecorators": true,
25
25
  "emitDecoratorMetadata": true,
26
26
  "allowSyntheticDefaultImports": true,
27
27
  "strictPropertyInitialization": false,