@teambit/ui 0.0.527 → 0.0.531
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/start-plugin.d.ts +1 -1
- package/dist/ui-server.d.ts +1 -1
- package/dist/ui-server.js +21 -13
- package/dist/ui-server.js.map +1 -1
- package/dist/webpack/webpack.dev.config.d.ts +2 -1
- package/dist/webpack/webpack.dev.config.js +117 -39
- package/dist/webpack/webpack.dev.config.js.map +1 -1
- package/package-tar/teambit-ui-0.0.531.tgz +0 -0
- package/package.json +23 -23
- package/start-plugin.ts +1 -1
- package/ui-server.ts +17 -10
- package/webpack/webpack.dev.config.ts +15 -22
- package/package-tar/teambit-ui-0.0.527.tgz +0 -0
package/dist/start-plugin.d.ts
CHANGED
package/dist/ui-server.d.ts
CHANGED
|
@@ -38,7 +38,7 @@ export declare class UIServer {
|
|
|
38
38
|
ssr?: boolean | undefined;
|
|
39
39
|
launchBrowserOnStart?: boolean | undefined;
|
|
40
40
|
} | undefined;
|
|
41
|
-
getDevConfig(): Promise<
|
|
41
|
+
getDevConfig(): Promise<import("@teambit/webpack").WebpackConfigWithDevServer>;
|
|
42
42
|
private setReady;
|
|
43
43
|
private startPromise;
|
|
44
44
|
get whenReady(): Promise<void[]>;
|
package/dist/ui-server.js
CHANGED
|
@@ -121,14 +121,20 @@ function _ui() {
|
|
|
121
121
|
return data;
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
+
function _webpackDev() {
|
|
125
|
+
const data = require("./webpack/webpack.dev.config");
|
|
126
|
+
|
|
127
|
+
_webpackDev = function () {
|
|
128
|
+
return data;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
return data;
|
|
132
|
+
}
|
|
133
|
+
|
|
124
134
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
125
135
|
|
|
126
136
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
127
137
|
|
|
128
|
-
const {
|
|
129
|
-
devConfig
|
|
130
|
-
} = require('./webpack/webpack.dev.config');
|
|
131
|
-
|
|
132
138
|
class UIServer {
|
|
133
139
|
constructor(graphql, expressExtension, ui, uiRoot, uiRootExtension, logger, publicDir, plugins) {
|
|
134
140
|
this.graphql = graphql;
|
|
@@ -176,7 +182,7 @@ class UIServer {
|
|
|
176
182
|
async getDevConfig() {
|
|
177
183
|
const aspects = await this.uiRoot.resolveAspects(_ui().UIRuntime.name);
|
|
178
184
|
const aspectsPaths = aspects.map(aspect => aspect.aspectPath);
|
|
179
|
-
return devConfig(this.uiRoot.path, [await this.ui.generateRoot(aspects, this.uiRootExtension)], this.uiRoot.name, aspectsPaths);
|
|
185
|
+
return (0, _webpackDev().devConfig)(this.uiRoot.path, [await this.ui.generateRoot(aspects, this.uiRootExtension)], this.uiRoot.name, aspectsPaths);
|
|
180
186
|
}
|
|
181
187
|
|
|
182
188
|
get whenReady() {
|
|
@@ -281,17 +287,18 @@ class UIServer {
|
|
|
281
287
|
async dev({
|
|
282
288
|
portRange
|
|
283
289
|
} = {}) {
|
|
284
|
-
const
|
|
290
|
+
const devServerPort = await this.selectPort(portRange);
|
|
285
291
|
await this.start({
|
|
286
292
|
portRange: [4100, 4200]
|
|
287
293
|
});
|
|
294
|
+
const expressAppPort = this._port;
|
|
288
295
|
const config = await this.getDevConfig();
|
|
289
296
|
const compiler = (0, _webpack().default)(config);
|
|
290
|
-
const devServerConfig = await this.getDevServerConfig(
|
|
297
|
+
const devServerConfig = await this.getDevServerConfig(devServerPort, expressAppPort, config.devServer); // @ts-ignore in the capsules it throws an error about compatibilities issues between webpack.compiler and webpackDevServer/webpack/compiler
|
|
291
298
|
|
|
292
|
-
const devServer = new (_webpackDevServer().default)(
|
|
293
|
-
devServer.
|
|
294
|
-
this._port =
|
|
299
|
+
const devServer = new (_webpackDevServer().default)(devServerConfig, compiler);
|
|
300
|
+
await devServer.start();
|
|
301
|
+
this._port = devServerPort;
|
|
295
302
|
return devServer;
|
|
296
303
|
}
|
|
297
304
|
|
|
@@ -320,11 +327,12 @@ class UIServer {
|
|
|
320
327
|
return gqlProxies.concat(proxyEntries);
|
|
321
328
|
}
|
|
322
329
|
|
|
323
|
-
async getDevServerConfig(
|
|
324
|
-
const proxy = await this.getProxy(
|
|
330
|
+
async getDevServerConfig(appPort, gqlPort, config) {
|
|
331
|
+
const proxy = await this.getProxy(gqlPort);
|
|
325
332
|
|
|
326
333
|
const devServerConf = _objectSpread(_objectSpread({}, config), {}, {
|
|
327
|
-
proxy
|
|
334
|
+
proxy,
|
|
335
|
+
port: appPort
|
|
328
336
|
});
|
|
329
337
|
|
|
330
338
|
return devServerConf;
|
package/dist/ui-server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["ui-server.ts"],"names":["devConfig","require","UIServer","constructor","graphql","expressExtension","ui","uiRoot","uiRootExtension","logger","publicDir","plugins","Promise","resolve","setReady","getName","name","port","_port","host","fullUrl","buildOptions","getDevConfig","aspects","resolveAspects","UIRuntime","aspectsPaths","map","aspect","aspectPath","path","generateRoot","whenReady","all","startPromise","x","start","portRange","app","createApp","root","server","createServer","configureProxy","use","express","static","index","Port","getPortFromRange","setupServerSideRendering","listen","info","getPluginsComponents","plugin","render","ssr","ssrMiddleware","title","warn","get","debug","proxServer","httpProxy","createProxyServer","on","e","error","message","proxyEntries","getProxyFromPlugins","req","socket","head","entry","find","proxy","context","some","item","url","ws","target","forEach","route","res","web","originalUrl","dev","selectedPort","selectPort","config","compiler","devServerConfig","getDevServerConfig","devServer","WebpackDevServer","proxiesByPlugin","getProxy","gqlProxies","changeOrigin","concat","devServerConf","create","props","startPlugins"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIA;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;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;AAGA,MAAM;AAAEA,EAAAA;AAAF,IAAgBC,OAAO,CAAC,8BAAD,CAA7B;;AAoBO,MAAMC,QAAN,CAAe;AACpBC,EAAAA,WAAW,CACDC,OADC,EAEDC,gBAFC,EAGDC,EAHC,EAIDC,MAJC,EAKDC,eALC,EAMDC,MANC,EAODC,SAPC,EAQDC,OARC,EAST;AAAA,SARQP,OAQR,GARQA,OAQR;AAAA,SAPQC,gBAOR,GAPQA,gBAOR;AAAA,SANQC,EAMR,GANQA,EAMR;AAAA,SALQC,MAKR,GALQA,MAKR;AAAA,SAJQC,eAIR,GAJQA,eAIR;AAAA,SAHQC,MAGR,GAHQA,MAGR;AAAA,SAFQC,SAER,GAFQA,SAER;AAAA,SADQC,OACR,GADQA,OACR;AAAA,mDAMc,CANd;AAAA;AAAA,0DA2CqB,IAAIC,OAAJ,CAAmBC,OAAD,IAAc,KAAKC,QAAL,GAAgBD,OAAhD,CA3C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AKLiG,KAAK,CAAChG,eALD,EAMLgG,KAAK,CAAC/F,MAND,EAOL+F,KAAK,CAAC9F,SAPD,EAQL8F,KAAK,CAACC,YARD,CAAP;AAUD;;AA1MmB","sourcesContent":["import { flatten } from 'lodash';\nimport { ExpressMain } from '@teambit/express';\nimport { GraphqlMain } from '@teambit/graphql';\nimport { Logger } from '@teambit/logger';\nimport express, { Express } from 'express';\nimport fallback from 'express-history-api-fallback';\nimport { Port } from '@teambit/toolbox.network.get-port';\nimport { Server } from 'http';\nimport httpProxy from 'http-proxy';\nimport { join } from 'path';\nimport webpack from 'webpack';\nimport WebpackDevServer, { Configuration as WdsConfiguration } from 'webpack-dev-server';\nimport { createSsrMiddleware } from './ssr/render-middleware';\nimport { StartPlugin } from './start-plugin';\nimport { ProxyEntry, UIRoot } from './ui-root';\nimport { UIRuntime } from './ui.aspect';\nimport { UiMain } from './ui.main.runtime';\n\nconst { devConfig } = require('./webpack/webpack.dev.config');\n\nexport type UIServerProps = {\n graphql: GraphqlMain;\n express: ExpressMain;\n ui: UiMain;\n uiRoot: UIRoot;\n uiRootExtension: string;\n logger: Logger;\n publicDir: string;\n startPlugins: StartPlugin[];\n};\n\nexport type StartOptions = {\n /**\n * port range for the UI server to bind. default is a port range of 4000-4200.\n */\n portRange?: number[] | number;\n};\n\nexport class UIServer {\n constructor(\n private graphql: GraphqlMain,\n private expressExtension: ExpressMain,\n private ui: UiMain,\n private uiRoot: UIRoot,\n private uiRootExtension: string,\n private logger: Logger,\n private publicDir: string,\n private plugins: StartPlugin[]\n ) {}\n\n getName() {\n return this.uiRoot.name;\n }\n\n private _port = 0;\n\n get port() {\n return this._port;\n }\n\n /** the hostname for the server to listen at. Currently statically 'localhost' */\n get host() {\n return 'localhost';\n }\n\n /** the server listens at this url */\n get fullUrl() {\n const port = this.port !== 80 ? `:${this.port}` : '';\n return `http://${this.host}${port}`;\n }\n\n get buildOptions() {\n return this.uiRoot.buildOptions;\n }\n\n /**\n * get the webpack configuration of the UI server.\n */\n async getDevConfig(): Promise<any> {\n const aspects = await this.uiRoot.resolveAspects(UIRuntime.name);\n const aspectsPaths = aspects.map((aspect) => aspect.aspectPath);\n\n return devConfig(\n this.uiRoot.path,\n [await this.ui.generateRoot(aspects, this.uiRootExtension)],\n this.uiRoot.name,\n aspectsPaths\n );\n }\n\n private setReady: () => void;\n private startPromise = new Promise<void>((resolve) => (this.setReady = resolve));\n get whenReady() {\n return Promise.all([this.startPromise, ...this.plugins.map((x) => x?.whenReady)]);\n }\n\n /**\n * start a UI server.\n */\n async start({ portRange }: StartOptions = {}) {\n const app = this.expressExtension.createApp();\n const publicDir = `/${this.publicDir}`;\n const root = join(this.uiRoot.path, publicDir);\n const server = await this.graphql.createServer({ app });\n\n // set up proxy, for things like preview, e.g. '/preview/teambit.react/react'\n await this.configureProxy(app, server);\n\n // pass through files from public /folder:\n // setting `index: false` so index.html will be served by the fallback() middleware\n app.use(express.static(root, { index: false }));\n\n const port = await Port.getPortFromRange(portRange || [3100, 3200]);\n\n await this.setupServerSideRendering({ root, port, app });\n\n // in any and all other cases, serve index.html.\n // No any other endpoints past this will execute\n app.use(fallback('index.html', { root }));\n\n server.listen(port);\n this._port = port;\n\n // important: we use the string of the following message for the http.e2e.ts. if you change the message,\n // please make sure you change the `HTTP_SERVER_READY_MSG` const.\n this.logger.info(`UI server of ${this.uiRootExtension} is listening to port ${port}`);\n\n this.setReady();\n }\n\n getPluginsComponents() {\n return this.plugins.map((plugin) => plugin.render);\n }\n\n private async setupServerSideRendering({ root, port, app }: { root: string; port: number; app: Express }) {\n if (!this.buildOptions?.ssr) return;\n\n const ssrMiddleware = await createSsrMiddleware({\n root,\n port,\n title: this.uiRoot.name,\n logger: this.logger,\n });\n\n if (!ssrMiddleware) {\n this.logger.warn('[ssr] middleware failed setup');\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n app.get('*', ssrMiddleware);\n this.logger.debug('[ssr] serving for \"*\"');\n }\n\n private async configureProxy(app: Express, server: Server) {\n const proxServer = httpProxy.createProxyServer();\n proxServer.on('error', (e) => this.logger.error(e.message));\n const proxyEntries = await this.getProxyFromPlugins();\n server.on('upgrade', function (req, socket, head) {\n const entry = proxyEntries.find((proxy) => proxy.context.some((item) => item === req.url));\n if (!entry) return;\n proxServer.ws(req, socket, head, {\n target: entry.target,\n });\n });\n\n proxyEntries.forEach((entry) => {\n entry.context.forEach((route) => {\n app.use(`${route}/*`, (req, res) => {\n proxServer.web(req, res, { ...entry, target: `${entry.target}/${req.originalUrl}` });\n });\n });\n });\n }\n\n /**\n * start a UI dev server.\n */\n async dev({ portRange }: StartOptions = {}) {\n const selectedPort = await this.selectPort(portRange);\n await this.start({ portRange: [4100, 4200] });\n const config = await this.getDevConfig();\n const compiler = webpack(config);\n const devServerConfig = await this.getDevServerConfig(this._port, config.devServer);\n // @ts-ignore in the capsules it throws an error about compatibilities issues between webpack.compiler and webpackDevServer/webpack/compiler\n const devServer = new WebpackDevServer(compiler, devServerConfig);\n devServer.listen(selectedPort);\n this._port = selectedPort;\n return devServer;\n }\n\n private async selectPort(portRange?: number[] | number) {\n return Port.getPortFromRange(portRange || [3100, 3200]);\n }\n\n private async getProxyFromPlugins(): Promise<ProxyEntry[]> {\n const proxiesByPlugin = this.plugins.map((plugin) => {\n return plugin.getProxy ? plugin.getProxy() : [];\n });\n\n return flatten(await Promise.all(proxiesByPlugin));\n }\n\n private async getProxy(port = 4000) {\n const proxyEntries = await this.getProxyFromPlugins();\n\n const gqlProxies: ProxyEntry[] = [\n {\n context: ['/graphql', '/api'],\n target: `http://${this.host}:${port}`,\n changeOrigin: true,\n },\n {\n context: ['/subscriptions'],\n target: `ws://${this.host}:${port}`,\n ws: true,\n },\n ];\n\n return gqlProxies.concat(proxyEntries);\n }\n\n private async getDevServerConfig(port: number, config?: WdsConfiguration): Promise<WdsConfiguration> {\n const proxy = await this.getProxy(port);\n const devServerConf = { ...config, proxy };\n\n return devServerConf;\n }\n\n static create(props: UIServerProps) {\n return new UIServer(\n props.graphql,\n props.express,\n props.ui,\n props.uiRoot,\n props.uiRootExtension,\n props.logger,\n props.publicDir,\n props.startPlugins\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["ui-server.ts"],"names":["UIServer","constructor","graphql","expressExtension","ui","uiRoot","uiRootExtension","logger","publicDir","plugins","Promise","resolve","setReady","getName","name","port","_port","host","fullUrl","buildOptions","getDevConfig","aspects","resolveAspects","UIRuntime","aspectsPaths","map","aspect","aspectPath","path","generateRoot","whenReady","all","startPromise","x","start","portRange","app","createApp","root","server","createServer","configureProxy","use","express","static","index","Port","getPortFromRange","setupServerSideRendering","listen","info","getPluginsComponents","plugin","render","ssr","ssrMiddleware","title","warn","get","debug","proxServer","httpProxy","createProxyServer","on","e","error","message","proxyEntries","getProxyFromPlugins","req","socket","head","entry","find","proxy","context","some","item","url","ws","target","forEach","route","res","web","originalUrl","dev","devServerPort","selectPort","expressAppPort","config","compiler","devServerConfig","getDevServerConfig","devServer","WebpackDevServer","proxiesByPlugin","getProxy","gqlProxies","changeOrigin","concat","appPort","gqlPort","devServerConf","create","props","startPlugins"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAIA;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;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;AAoBO,M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IAAK,IAAGF,IAAK,EAFpC;AAGEgE,MAAAA,EAAE,EAAE;AAHN,KAN+B,CAAjC;AAaA,WAAOmB,UAAU,CAACE,MAAX,CAAkBjC,YAAlB,CAAP;AACD;;AAE+B,QAAlB0B,kBAAkB,CAC9BQ,OAD8B,EAE9BC,OAF8B,EAG9BZ,MAH8B,EAIH;AAC3B,UAAMhB,KAAK,GAAG,MAAM,KAAKuB,QAAL,CAAcK,OAAd,CAApB;;AACA,UAAMC,aAAa,mCAAQb,MAAR;AAAgBhB,MAAAA,KAAhB;AAAuB3D,MAAAA,IAAI,EAAEsF;AAA7B,MAAnB;;AAEA,WAAOE,aAAP;AACD;;AAEY,SAANC,MAAM,CAACC,KAAD,EAAuB;AAClC,WAAO,IAAIzG,QAAJ,CACLyG,KAAK,CAACvG,OADD,EAELuG,KAAK,CAAC9D,OAFD,EAGL8D,KAAK,CAACrG,EAHD,EAILqG,KAAK,CAACpG,MAJD,EAKLoG,KAAK,CAACnG,eALD,EAMLmG,KAAK,CAAClG,MAND,EAOLkG,KAAK,CAACjG,SAPD,EAQLiG,KAAK,CAACC,YARD,CAAP;AAUD;;AAjNmB","sourcesContent":["import { flatten } from 'lodash';\nimport { ExpressMain } from '@teambit/express';\nimport { GraphqlMain } from '@teambit/graphql';\nimport { Logger } from '@teambit/logger';\nimport express, { Express } from 'express';\nimport fallback from 'express-history-api-fallback';\nimport { Port } from '@teambit/toolbox.network.get-port';\nimport { Server } from 'http';\nimport httpProxy from 'http-proxy';\nimport { join } from 'path';\nimport webpack from 'webpack';\nimport WebpackDevServer, { Configuration as WdsConfiguration } from 'webpack-dev-server';\nimport { createSsrMiddleware } from './ssr/render-middleware';\nimport { StartPlugin } from './start-plugin';\nimport { ProxyEntry, UIRoot } from './ui-root';\nimport { UIRuntime } from './ui.aspect';\nimport { UiMain } from './ui.main.runtime';\n\nimport { devConfig } from './webpack/webpack.dev.config';\n\nexport type UIServerProps = {\n graphql: GraphqlMain;\n express: ExpressMain;\n ui: UiMain;\n uiRoot: UIRoot;\n uiRootExtension: string;\n logger: Logger;\n publicDir: string;\n startPlugins: StartPlugin[];\n};\n\nexport type StartOptions = {\n /**\n * port range for the UI server to bind. default is a port range of 4000-4200.\n */\n portRange?: number[] | number;\n};\n\nexport class UIServer {\n constructor(\n private graphql: GraphqlMain,\n private expressExtension: ExpressMain,\n private ui: UiMain,\n private uiRoot: UIRoot,\n private uiRootExtension: string,\n private logger: Logger,\n private publicDir: string,\n private plugins: StartPlugin[]\n ) {}\n\n getName() {\n return this.uiRoot.name;\n }\n\n private _port = 0;\n\n get port() {\n return this._port;\n }\n\n /** the hostname for the server to listen at. Currently statically 'localhost' */\n get host() {\n return 'localhost';\n }\n\n /** the server listens at this url */\n get fullUrl() {\n const port = this.port !== 80 ? `:${this.port}` : '';\n return `http://${this.host}${port}`;\n }\n\n get buildOptions() {\n return this.uiRoot.buildOptions;\n }\n\n /**\n * get the webpack configuration of the UI server.\n */\n async getDevConfig() {\n const aspects = await this.uiRoot.resolveAspects(UIRuntime.name);\n const aspectsPaths = aspects.map((aspect) => aspect.aspectPath);\n\n return devConfig(\n this.uiRoot.path,\n [await this.ui.generateRoot(aspects, this.uiRootExtension)],\n this.uiRoot.name,\n aspectsPaths\n );\n }\n\n private setReady: () => void;\n private startPromise = new Promise<void>((resolve) => (this.setReady = resolve));\n get whenReady() {\n return Promise.all([this.startPromise, ...this.plugins.map((x) => x?.whenReady)]);\n }\n\n /**\n * start a UI server.\n */\n async start({ portRange }: StartOptions = {}) {\n const app = this.expressExtension.createApp();\n const publicDir = `/${this.publicDir}`;\n const root = join(this.uiRoot.path, publicDir);\n const server = await this.graphql.createServer({ app });\n\n // set up proxy, for things like preview, e.g. '/preview/teambit.react/react'\n await this.configureProxy(app, server);\n\n // pass through files from public /folder:\n // setting `index: false` so index.html will be served by the fallback() middleware\n app.use(express.static(root, { index: false }));\n\n const port = await Port.getPortFromRange(portRange || [3100, 3200]);\n\n await this.setupServerSideRendering({ root, port, app });\n\n // in any and all other cases, serve index.html.\n // No any other endpoints past this will execute\n app.use(fallback('index.html', { root }));\n\n server.listen(port);\n this._port = port;\n\n // important: we use the string of the following message for the http.e2e.ts. if you change the message,\n // please make sure you change the `HTTP_SERVER_READY_MSG` const.\n this.logger.info(`UI server of ${this.uiRootExtension} is listening to port ${port}`);\n\n this.setReady();\n }\n\n getPluginsComponents() {\n return this.plugins.map((plugin) => plugin.render);\n }\n\n private async setupServerSideRendering({ root, port, app }: { root: string; port: number; app: Express }) {\n if (!this.buildOptions?.ssr) return;\n\n const ssrMiddleware = await createSsrMiddleware({\n root,\n port,\n title: this.uiRoot.name,\n logger: this.logger,\n });\n\n if (!ssrMiddleware) {\n this.logger.warn('[ssr] middleware failed setup');\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n app.get('*', ssrMiddleware);\n this.logger.debug('[ssr] serving for \"*\"');\n }\n\n private async configureProxy(app: Express, server: Server) {\n const proxServer = httpProxy.createProxyServer();\n proxServer.on('error', (e) => this.logger.error(e.message));\n const proxyEntries = await this.getProxyFromPlugins();\n server.on('upgrade', function (req, socket, head) {\n const entry = proxyEntries.find((proxy) => proxy.context.some((item) => item === req.url));\n if (!entry) return;\n proxServer.ws(req, socket, head, {\n target: entry.target,\n });\n });\n\n proxyEntries.forEach((entry) => {\n entry.context.forEach((route) => {\n app.use(`${route}/*`, (req, res) => {\n proxServer.web(req, res, { ...entry, target: `${entry.target}/${req.originalUrl}` });\n });\n });\n });\n }\n\n /**\n * start a UI dev server.\n */\n async dev({ portRange }: StartOptions = {}) {\n const devServerPort = await this.selectPort(portRange);\n await this.start({ portRange: [4100, 4200] });\n const expressAppPort = this._port;\n\n const config = await this.getDevConfig();\n const compiler = webpack(config);\n const devServerConfig = await this.getDevServerConfig(devServerPort, expressAppPort, config.devServer);\n // @ts-ignore in the capsules it throws an error about compatibilities issues between webpack.compiler and webpackDevServer/webpack/compiler\n const devServer = new WebpackDevServer(devServerConfig, compiler);\n \n await devServer.start();\n this._port = devServerPort;\n return devServer;\n }\n\n private async selectPort(portRange?: number[] | number) {\n return Port.getPortFromRange(portRange || [3100, 3200]);\n }\n\n private async getProxyFromPlugins(): Promise<ProxyEntry[]> {\n const proxiesByPlugin = this.plugins.map((plugin) => {\n return plugin.getProxy ? plugin.getProxy() : [];\n });\n\n return flatten(await Promise.all(proxiesByPlugin));\n }\n\n private async getProxy(port = 4000) {\n const proxyEntries = await this.getProxyFromPlugins();\n\n const gqlProxies: ProxyEntry[] = [\n {\n context: ['/graphql', '/api'],\n target: `http://${this.host}:${port}`,\n changeOrigin: true,\n },\n {\n context: ['/subscriptions'],\n target: `ws://${this.host}:${port}`,\n ws: true,\n },\n ];\n\n return gqlProxies.concat(proxyEntries);\n }\n\n private async getDevServerConfig(\n appPort: number,\n gqlPort: number,\n config?: WdsConfiguration\n ): Promise<WdsConfiguration> {\n const proxy = await this.getProxy(gqlPort);\n const devServerConf = { ...config, proxy, port: appPort };\n\n return devServerConf;\n }\n\n static create(props: UIServerProps) {\n return new UIServer(\n props.graphql,\n props.express,\n props.ui,\n props.uiRoot,\n props.uiRootExtension,\n props.logger,\n props.publicDir,\n props.startPlugins\n );\n }\n}\n"]}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { WebpackConfigWithDevServer } from '@teambit/webpack';
|
|
2
|
+
export declare function devConfig(workspaceDir: any, entryFiles: any, title: any, aspectPaths: any): WebpackConfigWithDevServer;
|
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.devConfig = devConfig;
|
|
9
|
+
|
|
10
|
+
function _webpack() {
|
|
11
|
+
const data = require("webpack");
|
|
12
|
+
|
|
13
|
+
_webpack = function () {
|
|
14
|
+
return data;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return data;
|
|
18
|
+
}
|
|
19
|
+
|
|
3
20
|
function stylesRegexps() {
|
|
4
21
|
const data = _interopRequireWildcard(require("@teambit/webpack.modules.style-regexps"));
|
|
5
22
|
|
|
@@ -20,35 +37,104 @@ function _utils() {
|
|
|
20
37
|
return data;
|
|
21
38
|
}
|
|
22
39
|
|
|
23
|
-
function
|
|
40
|
+
function _htmlWebpackPlugin() {
|
|
41
|
+
const data = _interopRequireDefault(require("html-webpack-plugin"));
|
|
24
42
|
|
|
25
|
-
|
|
43
|
+
_htmlWebpackPlugin = function () {
|
|
44
|
+
return data;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function _reactRefreshWebpackPlugin() {
|
|
51
|
+
const data = _interopRequireDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
|
|
52
|
+
|
|
53
|
+
_reactRefreshWebpackPlugin = function () {
|
|
54
|
+
return data;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return data;
|
|
58
|
+
}
|
|
26
59
|
|
|
27
|
-
|
|
60
|
+
function _errorOverlayMiddleware() {
|
|
61
|
+
const data = _interopRequireDefault(require("react-dev-utils/errorOverlayMiddleware"));
|
|
28
62
|
|
|
29
|
-
|
|
63
|
+
_errorOverlayMiddleware = function () {
|
|
64
|
+
return data;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
return data;
|
|
68
|
+
}
|
|
30
69
|
|
|
31
|
-
|
|
70
|
+
function _evalSourceMapMiddleware() {
|
|
71
|
+
const data = _interopRequireDefault(require("react-dev-utils/evalSourceMapMiddleware"));
|
|
32
72
|
|
|
33
|
-
|
|
73
|
+
_evalSourceMapMiddleware = function () {
|
|
74
|
+
return data;
|
|
75
|
+
};
|
|
34
76
|
|
|
35
|
-
|
|
77
|
+
return data;
|
|
78
|
+
}
|
|
36
79
|
|
|
37
|
-
|
|
80
|
+
function _noopServiceWorkerMiddleware() {
|
|
81
|
+
const data = _interopRequireDefault(require("react-dev-utils/noopServiceWorkerMiddleware"));
|
|
38
82
|
|
|
39
|
-
|
|
83
|
+
_noopServiceWorkerMiddleware = function () {
|
|
84
|
+
return data;
|
|
85
|
+
};
|
|
40
86
|
|
|
41
|
-
|
|
87
|
+
return data;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function _redirectServedPathMiddleware() {
|
|
91
|
+
const data = _interopRequireDefault(require("react-dev-utils/redirectServedPathMiddleware"));
|
|
92
|
+
|
|
93
|
+
_redirectServedPathMiddleware = function () {
|
|
94
|
+
return data;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
return data;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function _getPublicUrlOrPath() {
|
|
101
|
+
const data = _interopRequireDefault(require("react-dev-utils/getPublicUrlOrPath"));
|
|
102
|
+
|
|
103
|
+
_getPublicUrlOrPath = function () {
|
|
104
|
+
return data;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
return data;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function _path() {
|
|
111
|
+
const data = _interopRequireDefault(require("path"));
|
|
112
|
+
|
|
113
|
+
_path = function () {
|
|
114
|
+
return data;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
return data;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function _html() {
|
|
121
|
+
const data = require("./html");
|
|
122
|
+
|
|
123
|
+
_html = function () {
|
|
124
|
+
return data;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
return data;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
131
|
+
|
|
132
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
42
133
|
|
|
43
|
-
const {
|
|
44
|
-
html
|
|
45
|
-
} = require('./html');
|
|
46
134
|
/*
|
|
47
135
|
* Webpack config for the bit ui
|
|
48
136
|
* i.e. `bit start --dev`,
|
|
49
137
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
138
|
const clientHost = process.env.WDS_SOCKET_HOST;
|
|
53
139
|
const clientPath = process.env.WDS_SOCKET_PATH; // default is '/sockjs-node';
|
|
54
140
|
|
|
@@ -57,15 +143,11 @@ const port = process.env.WDS_SOCKET_PORT; // const reactRefreshRuntimeEntry = re
|
|
|
57
143
|
// '@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils'
|
|
58
144
|
// );
|
|
59
145
|
|
|
60
|
-
const publicUrlOrPath =
|
|
146
|
+
const publicUrlOrPath = (0, _getPublicUrlOrPath().default)(process.env.NODE_ENV === 'development', '/', '/public');
|
|
61
147
|
const moduleFileExtensions = ['web.mjs', 'mjs', 'web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx'];
|
|
62
|
-
module.exports = {
|
|
63
|
-
createWebpackConfig,
|
|
64
|
-
devConfig: createWebpackConfig
|
|
65
|
-
};
|
|
66
148
|
|
|
67
|
-
function
|
|
68
|
-
const resolveWorkspacePath = relativePath =>
|
|
149
|
+
function devConfig(workspaceDir, entryFiles, title, aspectPaths) {
|
|
150
|
+
const resolveWorkspacePath = relativePath => _path().default.resolve(workspaceDir, relativePath); // Host
|
|
69
151
|
|
|
70
152
|
|
|
71
153
|
const host = process.env.HOST || 'localhost'; // Required for babel-preset-react-app
|
|
@@ -74,15 +156,14 @@ function createWebpackConfig(workspaceDir, entryFiles, title, aspectPaths) {
|
|
|
74
156
|
return {
|
|
75
157
|
// Environment mode
|
|
76
158
|
mode: 'development',
|
|
77
|
-
// improves HMR
|
|
159
|
+
// improves HMR - assume node_modules might change
|
|
78
160
|
snapshot: {
|
|
79
161
|
managedPaths: []
|
|
80
162
|
},
|
|
81
163
|
devtool: 'inline-source-map',
|
|
82
164
|
// Entry point of app
|
|
83
165
|
entry: {
|
|
84
|
-
main: entryFiles
|
|
85
|
-
|
|
166
|
+
main: entryFiles
|
|
86
167
|
},
|
|
87
168
|
output: {
|
|
88
169
|
// Development filename output
|
|
@@ -92,7 +173,7 @@ function createWebpackConfig(workspaceDir, entryFiles, title, aspectPaths) {
|
|
|
92
173
|
publicPath: publicUrlOrPath,
|
|
93
174
|
chunkFilename: 'static/js/[name].chunk.js',
|
|
94
175
|
// point sourcemap entries to original disk locations (format as URL on windows)
|
|
95
|
-
devtoolModuleFilenameTemplate: info => (0, _utils().pathNormalizeToLinux)(
|
|
176
|
+
devtoolModuleFilenameTemplate: info => (0, _utils().pathNormalizeToLinux)(_path().default.resolve(info.absoluteResourcePath)) // this defaults to 'window', but by setting it to 'this' then
|
|
96
177
|
// module chunks which are built will work in web workers as well.
|
|
97
178
|
// Commented out to use the default (self) as according to tobias with webpack5 self is working with workers as well
|
|
98
179
|
// globalObject: 'this',
|
|
@@ -142,22 +223,22 @@ function createWebpackConfig(workspaceDir, entryFiles, title, aspectPaths) {
|
|
|
142
223
|
// Keep `evalSourceMapMiddleware` and `errorOverlayMiddleware`
|
|
143
224
|
// middlewares before `redirectServedPath` otherwise will not have any effect
|
|
144
225
|
// This lets us fetch source contents from webpack for the error overlay
|
|
145
|
-
app.use(
|
|
226
|
+
app.use((0, _evalSourceMapMiddleware().default)(server)); // This lets us open files from the runtime error overlay.
|
|
146
227
|
|
|
147
|
-
app.use(
|
|
228
|
+
app.use((0, _errorOverlayMiddleware().default)());
|
|
148
229
|
},
|
|
149
230
|
|
|
150
231
|
onAfterSetupMiddleware({
|
|
151
232
|
app
|
|
152
233
|
}) {
|
|
153
234
|
// Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match
|
|
154
|
-
app.use(
|
|
235
|
+
app.use((0, _redirectServedPathMiddleware().default)(publicUrlOrPath)); // This service worker file is effectively a 'no-op' that will reset any
|
|
155
236
|
// previous service worker registered for the same host:port combination.
|
|
156
237
|
// We do this in development to avoid hitting the production cache if
|
|
157
238
|
// it used the same host and port.
|
|
158
239
|
// https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
|
|
159
240
|
|
|
160
|
-
app.use(
|
|
241
|
+
app.use((0, _noopServiceWorkerMiddleware().default)(publicUrlOrPath));
|
|
161
242
|
},
|
|
162
243
|
|
|
163
244
|
devMiddleware: {
|
|
@@ -282,7 +363,7 @@ function createWebpackConfig(workspaceDir, entryFiles, title, aspectPaths) {
|
|
|
282
363
|
use: [require.resolve('style-loader'), require.resolve('css-loader')]
|
|
283
364
|
}]
|
|
284
365
|
},
|
|
285
|
-
plugins: [new
|
|
366
|
+
plugins: [new (_reactRefreshWebpackPlugin().default)({
|
|
286
367
|
include: aspectPaths,
|
|
287
368
|
// original default value was /\.([cm]js|[jt]sx?|flow)$/i
|
|
288
369
|
// replaces the default value of `/node_modules/`
|
|
@@ -292,17 +373,14 @@ function createWebpackConfig(workspaceDir, entryFiles, title, aspectPaths) {
|
|
|
292
373
|
}), // Re-generate index.html with injected script tag.
|
|
293
374
|
// The injected script tag contains a src value of the
|
|
294
375
|
// filename output defined above.
|
|
295
|
-
new
|
|
376
|
+
new (_htmlWebpackPlugin().default)({
|
|
296
377
|
inject: true,
|
|
297
|
-
templateContent: html(title || 'My component workspace'),
|
|
378
|
+
templateContent: (0, _html().html)(title || 'My component workspace'),
|
|
298
379
|
chunks: ['main'],
|
|
299
380
|
filename: 'index.html'
|
|
300
|
-
})
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
// filename: 'preview.html'
|
|
304
|
-
// })
|
|
305
|
-
]
|
|
381
|
+
}), new (_webpack().ProvidePlugin)({
|
|
382
|
+
process: require.resolve('process/browser')
|
|
383
|
+
})]
|
|
306
384
|
};
|
|
307
385
|
}
|
|
308
386
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack.dev.config.ts"],"names":["HtmlWebpackPlugin","require","ReactRefreshWebpackPlugin","errorOverlayMiddleware","evalSourceMapMiddleware","noopServiceWorkerMiddleware","redirectServedPath","getPublicUrlOrPath","path","html","clientHost","process","env","WDS_SOCKET_HOST","clientPath","WDS_SOCKET_PATH","port","WDS_SOCKET_PORT","publicUrlOrPath","NODE_ENV","moduleFileExtensions","module","exports","createWebpackConfig","devConfig","workspaceDir","entryFiles","title","aspectPaths","resolveWorkspacePath","relativePath","resolve","host","HOST","mode","snapshot","managedPaths","devtool","entry","main","output","filename","pathinfo","publicPath","chunkFilename","devtoolModuleFilenameTemplate","info","absoluteResourcePath","infrastructureLogging","level","stats","devServer","allowedHosts","static","directory","staticOptions","serveIndex","watch","compress","hot","historyApiFallback","disableDotRule","index","client","webSocketURL","hostname","pathname","onBeforeSetupMiddleware","app","server","use","onAfterSetupMiddleware","devMiddleware","slice","extensions","map","ext","alias","react","fallback","fs","stream","unsafeCache","rules","test","fullySpecified","enforce","include","descriptionData","componentId","value","exclude","loader","options","configFile","babelrc","presets","plugins","stylesRegexps","sassModuleRegex","modules","localIdentName","sourceMap","sassNoModuleRegex","lessModuleRegex","lessNoModuleRegex","cssModuleRegex","cssNoModulesRegex","inject","templateContent","chunks"],"mappings":";;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA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,CAA8B;AAC5BqF,MAAAA,OAAO,EAAE3D,WADmB;AACN;AACtB;AACA+D,MAAAA,OAAO,EAAE,CACP,+BADO,EAEP;AACA;AACA,gDAJO;AAHmB,KAA9B,CADO,EAWP;AACA;AACA;AACA,QAAI3F,iBAAJ,CAAsB;AACpB4G,MAAAA,MAAM,EAAE,IADY;AAEpBC,MAAAA,eAAe,EAAEpG,IAAI,CAACkB,KAAK,IAAI,wBAAV,CAFD;AAGpBmF,MAAAA,MAAM,EAAE,CAAC,MAAD,CAHY;AAIpBrE,MAAAA,QAAQ,EAAE;AAJU,KAAtB,CAdO,CAoBP;AACA;AACA;AACA;AACA;AAxBO;AAjQJ,GAAP;AA4RD","sourcesContent":["import * as stylesRegexps from '@teambit/webpack.modules.style-regexps';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport { WebpackConfigWithDevServer } from '@teambit/webpack';\n\nconst HtmlWebpackPlugin = require('html-webpack-plugin');\nconst ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');\nconst errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware');\nconst evalSourceMapMiddleware = require('react-dev-utils/evalSourceMapMiddleware');\nconst noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');\nconst redirectServedPath = require('react-dev-utils/redirectServedPathMiddleware');\nconst getPublicUrlOrPath = require('react-dev-utils/getPublicUrlOrPath');\nconst path = require('path');\nconst { html } = require('./html');\n\n/*\n * Webpack config for the bit ui\n * i.e. `bit start --dev`,\n */\n\nconst clientHost = process.env.WDS_SOCKET_HOST;\nconst clientPath = process.env.WDS_SOCKET_PATH; // default is '/sockjs-node';\nconst port = process.env.WDS_SOCKET_PORT;\n\n// const reactRefreshRuntimeEntry = require.resolve('react-refresh/runtime');\n// const reactRefreshWebpackPluginRuntimeEntry = require.resolve(\n// '@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils'\n// );\n\nconst publicUrlOrPath = getPublicUrlOrPath(process.env.NODE_ENV === 'development', '/', '/public');\n\nconst moduleFileExtensions = [\n 'web.mjs',\n 'mjs',\n 'web.js',\n 'js',\n 'web.ts',\n 'ts',\n 'web.tsx',\n 'tsx',\n 'json',\n 'web.jsx',\n 'jsx',\n];\n\nmodule.exports = {\n createWebpackConfig,\n devConfig: createWebpackConfig,\n};\n\nfunction createWebpackConfig(workspaceDir, entryFiles, title, aspectPaths): WebpackConfigWithDevServer {\n const resolveWorkspacePath = (relativePath) => path.resolve(workspaceDir, relativePath);\n\n // Host\n const host = process.env.HOST || 'localhost';\n\n // Required for babel-preset-react-app\n process.env.NODE_ENV = 'development';\n\n return {\n // Environment mode\n mode: 'development',\n // improves HMR\n snapshot: { managedPaths: [] },\n\n devtool: 'inline-source-map',\n\n // Entry point of app\n entry: {\n main: entryFiles,\n // preview: entryFiles.map(filePath => resolveWorkspacePath(filePath))\n },\n\n output: {\n // Development filename output\n filename: 'static/js/[name].bundle.js',\n\n pathinfo: true,\n\n path: resolveWorkspacePath('/'),\n\n publicPath: publicUrlOrPath,\n\n chunkFilename: 'static/js/[name].chunk.js',\n\n // point sourcemap entries to original disk locations (format as URL on windows)\n devtoolModuleFilenameTemplate: (info) => pathNormalizeToLinux(path.resolve(info.absoluteResourcePath)),\n\n // this defaults to 'window', but by setting it to 'this' then\n // module chunks which are built will work in web workers as well.\n // Commented out to use the default (self) as according to tobias with webpack5 self is working with workers as well\n // globalObject: 'this',\n },\n\n infrastructureLogging: {\n level: 'error',\n },\n\n stats: 'errors-only',\n\n devServer: {\n allowedHosts: 'all',\n\n static: [\n {\n directory: resolveWorkspacePath(publicUrlOrPath),\n staticOptions: {},\n // Don't be confused with `dev.publicPath`, it is `publicPath` for static directory\n // Can be:\n // publicPath: ['/static-public-path-one/', '/static-public-path-two/'],\n publicPath: publicUrlOrPath,\n // Can be:\n // serveIndex: {} (options for the `serveIndex` option you can find https://github.com/expressjs/serve-index)\n serveIndex: true,\n // Can be:\n // watch: {} (options for the `watch` option you can find https://github.com/paulmillr/chokidar)\n watch: true,\n },\n ],\n\n // Enable compression\n compress: true,\n\n // Enable hot reloading\n hot: true,\n\n host,\n\n historyApiFallback: {\n disableDotRule: true,\n index: publicUrlOrPath,\n },\n\n client: {\n webSocketURL: {\n hostname: clientHost,\n pathname: clientPath,\n port,\n },\n },\n\n onBeforeSetupMiddleware({ app, server }) {\n // Keep `evalSourceMapMiddleware` and `errorOverlayMiddleware`\n // middlewares before `redirectServedPath` otherwise will not have any effect\n // This lets us fetch source contents from webpack for the error overlay\n app.use(evalSourceMapMiddleware(server));\n // This lets us open files from the runtime error overlay.\n app.use(errorOverlayMiddleware());\n },\n\n onAfterSetupMiddleware({ app }) {\n // Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match\n app.use(redirectServedPath(publicUrlOrPath));\n\n // This service worker file is effectively a 'no-op' that will reset any\n // previous service worker registered for the same host:port combination.\n // We do this in development to avoid hitting the production cache if\n // it used the same host and port.\n // https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432\n app.use(noopServiceWorkerMiddleware(publicUrlOrPath));\n },\n\n devMiddleware: {\n // forward static files\n publicPath: publicUrlOrPath.slice(0, -1),\n },\n },\n\n resolve: {\n // These are the reasonable defaults supported by the Node ecosystem.\n // We also include JSX as a common component filename extension to support\n // some tools, although we do not recommend using it, see:\n // https://github.com/facebook/create-react-app/issues/290\n // `web` extension prefixes have been added for better support\n // for React Native Web.\n extensions: moduleFileExtensions.map((ext) => `.${ext}`),\n alias: {\n react: require.resolve('react'),\n 'react-dom/server': require.resolve('react-dom/server'),\n 'react-dom': require.resolve('react-dom'),\n // 'react-refresh/runtime': require.resolve('react-refresh/runtime'),\n },\n fallback: {\n fs: false,\n path: require.resolve('path-browserify'),\n stream: false,\n process: false,\n },\n },\n\n module: {\n // Webpack by default includes node_modules under its managed paths which cause the whole directory to be cached\n // Watch mode requires us to turn off unsafeCache as well\n // this de-optimizes the dev build but ensures hmr works when writing/linking into node modules.\n // However we do not lose the caching entirely like cache: false\n unsafeCache: false,\n rules: [\n {\n test: /\\.m?js/,\n resolve: {\n fullySpecified: false,\n },\n },\n {\n test: /\\.js$/,\n enforce: 'pre',\n include: /node_modules/,\n // only apply to packages with componentId in their package.json (ie. bit components)\n descriptionData: { componentId: (value) => !!value },\n use: [require.resolve('source-map-loader')],\n },\n {\n test: /\\.(js|jsx|tsx|ts)$/,\n exclude: /node_modules/,\n include: workspaceDir,\n loader: require.resolve('babel-loader'),\n options: {\n configFile: false,\n babelrc: false,\n presets: [\n // Preset includes JSX, TypeScript, and some ESnext features\n require.resolve('babel-preset-react-app'),\n ],\n plugins: [require.resolve('react-refresh/babel')],\n },\n },\n {\n test: stylesRegexps.sassModuleRegex,\n use: [\n require.resolve('style-loader'),\n {\n loader: require.resolve('css-loader'),\n options: {\n modules: {\n localIdentName: '[name]__[local]--[hash:base64:5]',\n },\n sourceMap: true,\n },\n },\n {\n loader: require.resolve('sass-loader'),\n options: {\n sourceMap: true,\n },\n },\n ],\n },\n {\n test: stylesRegexps.sassNoModuleRegex,\n use: [\n require.resolve('style-loader'),\n require.resolve('css-loader'),\n {\n loader: require.resolve('sass-loader'),\n options: {\n sourceMap: true,\n },\n },\n ],\n },\n {\n test: stylesRegexps.lessModuleRegex,\n use: [\n require.resolve('style-loader'),\n {\n loader: require.resolve('css-loader'),\n options: {\n modules: {\n localIdentName: '[name]__[local]--[hash:base64:5]',\n },\n sourceMap: true,\n },\n },\n {\n loader: require.resolve('less-loader'),\n options: {\n sourceMap: true,\n },\n },\n ],\n },\n {\n test: stylesRegexps.lessNoModuleRegex,\n use: [\n require.resolve('style-loader'),\n require.resolve('css-loader'),\n {\n loader: require.resolve('less-loader'),\n options: {\n sourceMap: true,\n },\n },\n ],\n },\n {\n test: stylesRegexps.cssModuleRegex,\n use: [\n require.resolve('style-loader'),\n {\n loader: require.resolve('css-loader'),\n options: {\n modules: {\n localIdentName: '[name]__[local]--[hash:base64:5]',\n },\n sourceMap: true,\n },\n },\n ],\n },\n {\n test: stylesRegexps.cssNoModulesRegex,\n use: [require.resolve('style-loader'), require.resolve('css-loader')],\n },\n ],\n },\n\n plugins: [\n new ReactRefreshWebpackPlugin({\n include: aspectPaths, // original default value was /\\.([cm]js|[jt]sx?|flow)$/i\n // replaces the default value of `/node_modules/`\n exclude: [\n /react-refresh-webpack-plugin/i,\n // file type filtering was done by `include`, so need to negative-filter them out here\n // A lookbehind assertion (`?<!`) has to be fixed width\n /(?<!\\.jsx)(?<!\\.js)(?<!\\.tsx)(?<!\\.ts)$/i,\n ],\n }),\n // Re-generate index.html with injected script tag.\n // The injected script tag contains a src value of the\n // filename output defined above.\n new HtmlWebpackPlugin({\n inject: true,\n templateContent: html(title || 'My component workspace'),\n chunks: ['main'],\n filename: 'index.html',\n }),\n // new HtmlWebpackPlugin({\n // templateContent: html('Component preview'),\n // chunks: ['preview'],\n // filename: 'preview.html'\n // })\n ],\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["webpack.dev.config.ts"],"names":["clientHost","process","env","WDS_SOCKET_HOST","clientPath","WDS_SOCKET_PATH","port","WDS_SOCKET_PORT","publicUrlOrPath","NODE_ENV","moduleFileExtensions","devConfig","workspaceDir","entryFiles","title","aspectPaths","resolveWorkspacePath","relativePath","path","resolve","host","HOST","mode","snapshot","managedPaths","devtool","entry","main","output","filename","pathinfo","publicPath","chunkFilename","devtoolModuleFilenameTemplate","info","absoluteResourcePath","infrastructureLogging","level","stats","devServer","allowedHosts","static","directory","staticOptions","serveIndex","watch","compress","hot","historyApiFallback","disableDotRule","index","client","webSocketURL","hostname","pathname","onBeforeSetupMiddleware","app","server","use","onAfterSetupMiddleware","devMiddleware","slice","extensions","map","ext","alias","react","require","fallback","fs","stream","module","unsafeCache","rules","test","fullySpecified","enforce","include","descriptionData","componentId","value","exclude","loader","options","configFile","babelrc","presets","plugins","stylesRegexps","sassModuleRegex","modules","localIdentName","sourceMap","sassNoModuleRegex","lessModuleRegex","lessNoModuleRegex","cssModuleRegex","cssNoMod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O;AAHmB,KAA9B,CADO,EAWP;AACA;AACA;AACA,SAAIkB,4BAAJ,EAAsB;AACpBC,MAAAA,MAAM,EAAE,IADY;AAEpBC,MAAAA,eAAe,EAAE,kBAAKvF,KAAK,IAAI,wBAAd,CAFG;AAGpBwF,MAAAA,MAAM,EAAE,CAAC,MAAD,CAHY;AAIpBzE,MAAAA,QAAQ,EAAE;AAJU,KAAtB,CAdO,EAoBP,KAAI0E,wBAAJ,EAAkB;AAChBtG,MAAAA,OAAO,EAAEkE,OAAO,CAAChD,OAAR,CAAgB,iBAAhB;AADO,KAAlB,CApBO;AAhQJ,GAAP;AAyRD","sourcesContent":["import { ProvidePlugin } from 'webpack';\nimport * as stylesRegexps from '@teambit/webpack.modules.style-regexps';\nimport { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';\nimport { WebpackConfigWithDevServer } from '@teambit/webpack';\n\nimport HtmlWebpackPlugin from 'html-webpack-plugin';\nimport ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';\nimport errorOverlayMiddleware from 'react-dev-utils/errorOverlayMiddleware';\nimport evalSourceMapMiddleware from 'react-dev-utils/evalSourceMapMiddleware';\nimport noopServiceWorkerMiddleware from 'react-dev-utils/noopServiceWorkerMiddleware';\nimport redirectServedPath from 'react-dev-utils/redirectServedPathMiddleware';\nimport getPublicUrlOrPath from 'react-dev-utils/getPublicUrlOrPath';\nimport path from 'path';\nimport { html } from './html';\n\n/*\n * Webpack config for the bit ui\n * i.e. `bit start --dev`,\n */\n\nconst clientHost = process.env.WDS_SOCKET_HOST;\nconst clientPath = process.env.WDS_SOCKET_PATH; // default is '/sockjs-node';\nconst port = process.env.WDS_SOCKET_PORT;\n\n// const reactRefreshRuntimeEntry = require.resolve('react-refresh/runtime');\n// const reactRefreshWebpackPluginRuntimeEntry = require.resolve(\n// '@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils'\n// );\n\nconst publicUrlOrPath = getPublicUrlOrPath(process.env.NODE_ENV === 'development', '/', '/public');\n\nconst moduleFileExtensions = [\n 'web.mjs',\n 'mjs',\n 'web.js',\n 'js',\n 'web.ts',\n 'ts',\n 'web.tsx',\n 'tsx',\n 'json',\n 'web.jsx',\n 'jsx',\n];\n\nexport function devConfig(workspaceDir, entryFiles, title, aspectPaths): WebpackConfigWithDevServer {\n const resolveWorkspacePath = (relativePath) => path.resolve(workspaceDir, relativePath);\n\n // Host\n const host = process.env.HOST || 'localhost';\n\n // Required for babel-preset-react-app\n process.env.NODE_ENV = 'development';\n\n return {\n // Environment mode\n mode: 'development',\n // improves HMR - assume node_modules might change\n snapshot: { managedPaths: [] },\n\n devtool: 'inline-source-map',\n\n // Entry point of app\n entry: {\n main: entryFiles,\n },\n\n output: {\n // Development filename output\n filename: 'static/js/[name].bundle.js',\n\n pathinfo: true,\n\n path: resolveWorkspacePath('/'),\n\n publicPath: publicUrlOrPath,\n\n chunkFilename: 'static/js/[name].chunk.js',\n\n // point sourcemap entries to original disk locations (format as URL on windows)\n devtoolModuleFilenameTemplate: (info) => pathNormalizeToLinux(path.resolve(info.absoluteResourcePath)),\n\n // this defaults to 'window', but by setting it to 'this' then\n // module chunks which are built will work in web workers as well.\n // Commented out to use the default (self) as according to tobias with webpack5 self is working with workers as well\n // globalObject: 'this',\n },\n\n infrastructureLogging: {\n level: 'error',\n },\n\n stats: 'errors-only',\n\n devServer: {\n allowedHosts: 'all',\n\n static: [\n {\n directory: resolveWorkspacePath(publicUrlOrPath),\n staticOptions: {},\n // Don't be confused with `dev.publicPath`, it is `publicPath` for static directory\n // Can be:\n // publicPath: ['/static-public-path-one/', '/static-public-path-two/'],\n publicPath: publicUrlOrPath,\n // Can be:\n // serveIndex: {} (options for the `serveIndex` option you can find https://github.com/expressjs/serve-index)\n serveIndex: true,\n // Can be:\n // watch: {} (options for the `watch` option you can find https://github.com/paulmillr/chokidar)\n watch: true,\n },\n ],\n\n // Enable compression\n compress: true,\n\n // Enable hot reloading\n hot: true,\n\n host,\n\n historyApiFallback: {\n disableDotRule: true,\n index: publicUrlOrPath,\n },\n\n client: {\n webSocketURL: {\n hostname: clientHost,\n pathname: clientPath,\n port,\n },\n },\n\n onBeforeSetupMiddleware({ app, server }) {\n // Keep `evalSourceMapMiddleware` and `errorOverlayMiddleware`\n // middlewares before `redirectServedPath` otherwise will not have any effect\n // This lets us fetch source contents from webpack for the error overlay\n app.use(evalSourceMapMiddleware(server));\n // This lets us open files from the runtime error overlay.\n app.use(errorOverlayMiddleware());\n },\n\n onAfterSetupMiddleware({ app }) {\n // Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match\n app.use(redirectServedPath(publicUrlOrPath));\n\n // This service worker file is effectively a 'no-op' that will reset any\n // previous service worker registered for the same host:port combination.\n // We do this in development to avoid hitting the production cache if\n // it used the same host and port.\n // https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432\n app.use(noopServiceWorkerMiddleware(publicUrlOrPath));\n },\n\n devMiddleware: {\n // forward static files\n publicPath: publicUrlOrPath.slice(0, -1),\n },\n },\n\n resolve: {\n // These are the reasonable defaults supported by the Node ecosystem.\n // We also include JSX as a common component filename extension to support\n // some tools, although we do not recommend using it, see:\n // https://github.com/facebook/create-react-app/issues/290\n // `web` extension prefixes have been added for better support\n // for React Native Web.\n extensions: moduleFileExtensions.map((ext) => `.${ext}`),\n alias: {\n react: require.resolve('react'),\n 'react-dom/server': require.resolve('react-dom/server'),\n 'react-dom': require.resolve('react-dom'),\n // 'react-refresh/runtime': require.resolve('react-refresh/runtime'),\n },\n fallback: {\n fs: false,\n path: require.resolve('path-browserify'),\n stream: false,\n process: false,\n },\n },\n\n module: {\n // Webpack by default includes node_modules under its managed paths which cause the whole directory to be cached\n // Watch mode requires us to turn off unsafeCache as well\n // this de-optimizes the dev build but ensures hmr works when writing/linking into node modules.\n // However we do not lose the caching entirely like cache: false\n unsafeCache: false,\n rules: [\n {\n test: /\\.m?js/,\n resolve: {\n fullySpecified: false,\n },\n },\n {\n test: /\\.js$/,\n enforce: 'pre',\n include: /node_modules/,\n // only apply to packages with componentId in their package.json (ie. bit components)\n descriptionData: { componentId: (value) => !!value },\n use: [require.resolve('source-map-loader')],\n },\n {\n test: /\\.(js|jsx|tsx|ts)$/,\n exclude: /node_modules/,\n include: workspaceDir,\n loader: require.resolve('babel-loader'),\n options: {\n configFile: false,\n babelrc: false,\n presets: [\n // Preset includes JSX, TypeScript, and some ESnext features\n require.resolve('babel-preset-react-app'),\n ],\n plugins: [require.resolve('react-refresh/babel')],\n },\n },\n {\n test: stylesRegexps.sassModuleRegex,\n use: [\n require.resolve('style-loader'),\n {\n loader: require.resolve('css-loader'),\n options: {\n modules: {\n localIdentName: '[name]__[local]--[hash:base64:5]',\n },\n sourceMap: true,\n },\n },\n {\n loader: require.resolve('sass-loader'),\n options: {\n sourceMap: true,\n },\n },\n ],\n },\n {\n test: stylesRegexps.sassNoModuleRegex,\n use: [\n require.resolve('style-loader'),\n require.resolve('css-loader'),\n {\n loader: require.resolve('sass-loader'),\n options: {\n sourceMap: true,\n },\n },\n ],\n },\n {\n test: stylesRegexps.lessModuleRegex,\n use: [\n require.resolve('style-loader'),\n {\n loader: require.resolve('css-loader'),\n options: {\n modules: {\n localIdentName: '[name]__[local]--[hash:base64:5]',\n },\n sourceMap: true,\n },\n },\n {\n loader: require.resolve('less-loader'),\n options: {\n sourceMap: true,\n },\n },\n ],\n },\n {\n test: stylesRegexps.lessNoModuleRegex,\n use: [\n require.resolve('style-loader'),\n require.resolve('css-loader'),\n {\n loader: require.resolve('less-loader'),\n options: {\n sourceMap: true,\n },\n },\n ],\n },\n {\n test: stylesRegexps.cssModuleRegex,\n use: [\n require.resolve('style-loader'),\n {\n loader: require.resolve('css-loader'),\n options: {\n modules: {\n localIdentName: '[name]__[local]--[hash:base64:5]',\n },\n sourceMap: true,\n },\n },\n ],\n },\n {\n test: stylesRegexps.cssNoModulesRegex,\n use: [require.resolve('style-loader'), require.resolve('css-loader')],\n },\n ],\n },\n\n plugins: [\n new ReactRefreshWebpackPlugin({\n include: aspectPaths, // original default value was /\\.([cm]js|[jt]sx?|flow)$/i\n // replaces the default value of `/node_modules/`\n exclude: [\n /react-refresh-webpack-plugin/i,\n // file type filtering was done by `include`, so need to negative-filter them out here\n // A lookbehind assertion (`?<!`) has to be fixed width\n /(?<!\\.jsx)(?<!\\.js)(?<!\\.tsx)(?<!\\.ts)$/i,\n ],\n }),\n // Re-generate index.html with injected script tag.\n // The injected script tag contains a src value of the\n // filename output defined above.\n new HtmlWebpackPlugin({\n inject: true,\n templateContent: html(title || 'My component workspace'),\n chunks: ['main'],\n filename: 'index.html',\n }),\n new ProvidePlugin({\n process: require.resolve('process/browser'),\n }),\n ],\n };\n}\n"]}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.531",
|
|
4
4
|
"homepage": "https://bit.dev/teambit/ui-foundation/ui",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.ui-foundation",
|
|
8
8
|
"name": "ui",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.531"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"lodash": "4.17.21",
|
|
@@ -53,28 +53,28 @@
|
|
|
53
53
|
"@teambit/base-ui.loaders.loader-ribbon": "1.0.0",
|
|
54
54
|
"@teambit/base-ui.theme.fonts.roboto": "1.0.0",
|
|
55
55
|
"@teambit/base-ui.theme.theme-provider": "1.0.1",
|
|
56
|
-
"@teambit/aspect-loader": "0.0.
|
|
57
|
-
"@teambit/toolbox.path.to-windows-compatible-path": "0.0.
|
|
58
|
-
"@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.
|
|
59
|
-
"@teambit/logger": "0.0.
|
|
56
|
+
"@teambit/aspect-loader": "0.0.531",
|
|
57
|
+
"@teambit/toolbox.path.to-windows-compatible-path": "0.0.446",
|
|
58
|
+
"@teambit/ui-foundation.ui.hooks.use-data-query": "0.0.450",
|
|
59
|
+
"@teambit/logger": "0.0.455",
|
|
60
60
|
"@teambit/cli": "0.0.380",
|
|
61
|
-
"@teambit/ui-foundation.cli.ui-server-console": "0.0.
|
|
62
|
-
"@teambit/bundler": "0.0.
|
|
63
|
-
"@teambit/component": "0.0.
|
|
64
|
-
"@teambit/express": "0.0.
|
|
65
|
-
"@teambit/graphql": "0.0.
|
|
66
|
-
"@teambit/toolbox.network.get-port": "0.0.
|
|
67
|
-
"@teambit/aspect": "0.0.
|
|
68
|
-
"@teambit/cache": "0.0.
|
|
69
|
-
"@teambit/pubsub": "0.0.
|
|
70
|
-
"@teambit/react-router": "0.0.
|
|
71
|
-
"@teambit/ui-foundation.ui.rendering.html": "0.0.
|
|
61
|
+
"@teambit/ui-foundation.cli.ui-server-console": "0.0.451",
|
|
62
|
+
"@teambit/bundler": "0.0.531",
|
|
63
|
+
"@teambit/component": "0.0.531",
|
|
64
|
+
"@teambit/express": "0.0.459",
|
|
65
|
+
"@teambit/graphql": "0.0.531",
|
|
66
|
+
"@teambit/toolbox.network.get-port": "0.0.76",
|
|
67
|
+
"@teambit/aspect": "0.0.531",
|
|
68
|
+
"@teambit/cache": "0.0.455",
|
|
69
|
+
"@teambit/pubsub": "0.0.531",
|
|
70
|
+
"@teambit/react-router": "0.0.531",
|
|
71
|
+
"@teambit/ui-foundation.ui.rendering.html": "0.0.32",
|
|
72
72
|
"@teambit/design.theme.icons-font": "1.0.2",
|
|
73
73
|
"@teambit/design.ui.tooltip": "0.0.352",
|
|
74
|
-
"@teambit/ui-foundation.ui.global-loader": "0.0.
|
|
75
|
-
"@teambit/webpack.modules.generate-style-loaders": "0.0.
|
|
76
|
-
"@teambit/webpack.modules.style-regexps": "0.0.
|
|
77
|
-
"@teambit/webpack": "0.0.
|
|
74
|
+
"@teambit/ui-foundation.ui.global-loader": "0.0.449",
|
|
75
|
+
"@teambit/webpack.modules.generate-style-loaders": "0.0.66",
|
|
76
|
+
"@teambit/webpack.modules.style-regexps": "0.0.95",
|
|
77
|
+
"@teambit/webpack": "0.0.531"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@types/react": "^17.0.8",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
},
|
|
97
97
|
"peerDependencies": {
|
|
98
98
|
"@apollo/client": "^3.0.0",
|
|
99
|
-
"@teambit/legacy": "1.0.
|
|
99
|
+
"@teambit/legacy": "1.0.163",
|
|
100
100
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
101
101
|
"react": "^16.8.0 || ^17.0.0"
|
|
102
102
|
},
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
"react": "-"
|
|
142
142
|
},
|
|
143
143
|
"peerDependencies": {
|
|
144
|
-
"@teambit/legacy": "1.0.
|
|
144
|
+
"@teambit/legacy": "1.0.163",
|
|
145
145
|
"react-dom": "^16.8.0 || ^17.0.0",
|
|
146
146
|
"react": "^16.8.0 || ^17.0.0"
|
|
147
147
|
}
|
package/start-plugin.ts
CHANGED
package/ui-server.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { ProxyEntry, UIRoot } from './ui-root';
|
|
|
16
16
|
import { UIRuntime } from './ui.aspect';
|
|
17
17
|
import { UiMain } from './ui.main.runtime';
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
import { devConfig } from './webpack/webpack.dev.config';
|
|
20
20
|
|
|
21
21
|
export type UIServerProps = {
|
|
22
22
|
graphql: GraphqlMain;
|
|
@@ -76,7 +76,7 @@ export class UIServer {
|
|
|
76
76
|
/**
|
|
77
77
|
* get the webpack configuration of the UI server.
|
|
78
78
|
*/
|
|
79
|
-
async getDevConfig()
|
|
79
|
+
async getDevConfig() {
|
|
80
80
|
const aspects = await this.uiRoot.resolveAspects(UIRuntime.name);
|
|
81
81
|
const aspectsPaths = aspects.map((aspect) => aspect.aspectPath);
|
|
82
82
|
|
|
@@ -177,15 +177,18 @@ export class UIServer {
|
|
|
177
177
|
* start a UI dev server.
|
|
178
178
|
*/
|
|
179
179
|
async dev({ portRange }: StartOptions = {}) {
|
|
180
|
-
const
|
|
180
|
+
const devServerPort = await this.selectPort(portRange);
|
|
181
181
|
await this.start({ portRange: [4100, 4200] });
|
|
182
|
+
const expressAppPort = this._port;
|
|
183
|
+
|
|
182
184
|
const config = await this.getDevConfig();
|
|
183
185
|
const compiler = webpack(config);
|
|
184
|
-
const devServerConfig = await this.getDevServerConfig(
|
|
186
|
+
const devServerConfig = await this.getDevServerConfig(devServerPort, expressAppPort, config.devServer);
|
|
185
187
|
// @ts-ignore in the capsules it throws an error about compatibilities issues between webpack.compiler and webpackDevServer/webpack/compiler
|
|
186
|
-
const devServer = new WebpackDevServer(
|
|
187
|
-
|
|
188
|
-
|
|
188
|
+
const devServer = new WebpackDevServer(devServerConfig, compiler);
|
|
189
|
+
|
|
190
|
+
await devServer.start();
|
|
191
|
+
this._port = devServerPort;
|
|
189
192
|
return devServer;
|
|
190
193
|
}
|
|
191
194
|
|
|
@@ -220,9 +223,13 @@ export class UIServer {
|
|
|
220
223
|
return gqlProxies.concat(proxyEntries);
|
|
221
224
|
}
|
|
222
225
|
|
|
223
|
-
private async getDevServerConfig(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
+
private async getDevServerConfig(
|
|
227
|
+
appPort: number,
|
|
228
|
+
gqlPort: number,
|
|
229
|
+
config?: WdsConfiguration
|
|
230
|
+
): Promise<WdsConfiguration> {
|
|
231
|
+
const proxy = await this.getProxy(gqlPort);
|
|
232
|
+
const devServerConf = { ...config, proxy, port: appPort };
|
|
226
233
|
|
|
227
234
|
return devServerConf;
|
|
228
235
|
}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
+
import { ProvidePlugin } from 'webpack';
|
|
1
2
|
import * as stylesRegexps from '@teambit/webpack.modules.style-regexps';
|
|
2
3
|
import { pathNormalizeToLinux } from '@teambit/legacy/dist/utils';
|
|
3
4
|
import { WebpackConfigWithDevServer } from '@teambit/webpack';
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
7
|
+
import ReactRefreshWebpackPlugin from '@pmmmwh/react-refresh-webpack-plugin';
|
|
8
|
+
import errorOverlayMiddleware from 'react-dev-utils/errorOverlayMiddleware';
|
|
9
|
+
import evalSourceMapMiddleware from 'react-dev-utils/evalSourceMapMiddleware';
|
|
10
|
+
import noopServiceWorkerMiddleware from 'react-dev-utils/noopServiceWorkerMiddleware';
|
|
11
|
+
import redirectServedPath from 'react-dev-utils/redirectServedPathMiddleware';
|
|
12
|
+
import getPublicUrlOrPath from 'react-dev-utils/getPublicUrlOrPath';
|
|
13
|
+
import path from 'path';
|
|
14
|
+
import { html } from './html';
|
|
14
15
|
|
|
15
16
|
/*
|
|
16
17
|
* Webpack config for the bit ui
|
|
@@ -42,12 +43,7 @@ const moduleFileExtensions = [
|
|
|
42
43
|
'jsx',
|
|
43
44
|
];
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
createWebpackConfig,
|
|
47
|
-
devConfig: createWebpackConfig,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
function createWebpackConfig(workspaceDir, entryFiles, title, aspectPaths): WebpackConfigWithDevServer {
|
|
46
|
+
export function devConfig(workspaceDir, entryFiles, title, aspectPaths): WebpackConfigWithDevServer {
|
|
51
47
|
const resolveWorkspacePath = (relativePath) => path.resolve(workspaceDir, relativePath);
|
|
52
48
|
|
|
53
49
|
// Host
|
|
@@ -59,7 +55,7 @@ function createWebpackConfig(workspaceDir, entryFiles, title, aspectPaths): Webp
|
|
|
59
55
|
return {
|
|
60
56
|
// Environment mode
|
|
61
57
|
mode: 'development',
|
|
62
|
-
// improves HMR
|
|
58
|
+
// improves HMR - assume node_modules might change
|
|
63
59
|
snapshot: { managedPaths: [] },
|
|
64
60
|
|
|
65
61
|
devtool: 'inline-source-map',
|
|
@@ -67,7 +63,6 @@ function createWebpackConfig(workspaceDir, entryFiles, title, aspectPaths): Webp
|
|
|
67
63
|
// Entry point of app
|
|
68
64
|
entry: {
|
|
69
65
|
main: entryFiles,
|
|
70
|
-
// preview: entryFiles.map(filePath => resolveWorkspacePath(filePath))
|
|
71
66
|
},
|
|
72
67
|
|
|
73
68
|
output: {
|
|
@@ -333,11 +328,9 @@ function createWebpackConfig(workspaceDir, entryFiles, title, aspectPaths): Webp
|
|
|
333
328
|
chunks: ['main'],
|
|
334
329
|
filename: 'index.html',
|
|
335
330
|
}),
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
// filename: 'preview.html'
|
|
340
|
-
// })
|
|
331
|
+
new ProvidePlugin({
|
|
332
|
+
process: require.resolve('process/browser'),
|
|
333
|
+
}),
|
|
341
334
|
],
|
|
342
335
|
};
|
|
343
336
|
}
|
|
Binary file
|