@teambit/react 0.0.805 → 0.0.808
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/apps/web/compute-results.ts +3 -1
- package/apps/web/react-app-options.ts +5 -0
- package/apps/web/react-build-result.ts +1 -0
- package/apps/web/react.app-type.ts +1 -0
- package/apps/web/react.application.ts +61 -83
- package/apps/web/webpack/mutators.ts +68 -0
- package/apps/web/webpack/webpack.app.ssr.config.ts +24 -0
- package/artifacts/__bit_junit.xml +2 -2
- package/artifacts/env-template/public/{750.2bbe0002ca73603de518.js → 548.ae6b13e3e1fea0f4647a.js} +2 -2
- package/artifacts/env-template/public/assets-manifest.json +12 -12
- package/artifacts/env-template/public/{compositions.853254f720441442d37a.js → compositions.3bf1e8427f9666aecb0d.js} +1 -1
- package/artifacts/env-template/public/compositions.html +1 -1
- package/artifacts/env-template/public/{overview.0ca27c1c75ca340b6722.js → overview.cdae065ea48dd28a71dd.js} +1 -1
- package/artifacts/env-template/public/overview.html +1 -1
- package/artifacts/env-template/public/{peers.283551d5f03dbfad5477.js → peers.ef67914ba54787974ada.js} +1 -1
- package/artifacts/env-template/public/{preview-root.b859b02336387c766d60.js → preview-root.5dd264c670f6b6a39b15.js} +1 -1
- package/artifacts/env-template/public/static/css/{750.f6840c3e.css → 548.f6840c3e.css} +0 -0
- package/artifacts/preview/teambit_react_react-preview.js +1 -1
- package/{compositions-1659456045857.js → compositions-1659670139925.js} +0 -0
- package/dist/apps/web/compute-results.d.ts +2 -1
- package/dist/apps/web/compute-results.js +3 -1
- package/dist/apps/web/compute-results.js.map +1 -1
- package/dist/apps/web/react-app-options.d.ts +4 -0
- package/dist/apps/web/react-app-options.js.map +1 -1
- package/dist/apps/web/react-build-result.d.ts +1 -0
- package/dist/apps/web/react-build-result.js.map +1 -1
- package/dist/apps/web/react.app-type.js +1 -1
- package/dist/apps/web/react.app-type.js.map +1 -1
- package/dist/apps/web/react.application.d.ts +7 -3
- package/dist/apps/web/react.application.js +62 -95
- package/dist/apps/web/react.application.js.map +1 -1
- package/dist/apps/web/webpack/mutators.d.ts +3 -0
- package/dist/apps/web/webpack/mutators.js +90 -0
- package/dist/apps/web/webpack/mutators.js.map +1 -1
- package/dist/apps/web/webpack/webpack.app.ssr.config.d.ts +6 -0
- package/dist/apps/web/webpack/webpack.app.ssr.config.js +29 -0
- package/dist/apps/web/webpack/webpack.app.ssr.config.js.map +1 -1
- package/dist/webpack/webpack.config.base.js +15 -1
- package/dist/webpack/webpack.config.base.js.map +1 -1
- package/{overview-1659456045857.js → overview-1659670139925.js} +0 -0
- package/package-tar/teambit-react-0.0.808.tgz +0 -0
- package/package.json +32 -30
- package/{preview-1659456045857.js → preview-1659670139925.js} +2 -2
- package/webpack/webpack.config.base.ts +2 -1
- package/package-tar/teambit-react-0.0.805.tgz +0 -0
|
@@ -42,7 +42,7 @@ function _toolboxNetwork() {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
function _lodash() {
|
|
45
|
-
const data = require("lodash");
|
|
45
|
+
const data = _interopRequireDefault(require("lodash.compact"));
|
|
46
46
|
|
|
47
47
|
_lodash = function () {
|
|
48
48
|
return data;
|
|
@@ -51,16 +51,6 @@ function _lodash() {
|
|
|
51
51
|
return data;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
function _terserWebpackPlugin() {
|
|
55
|
-
const data = _interopRequireDefault(require("terser-webpack-plugin"));
|
|
56
|
-
|
|
57
|
-
_terserWebpackPlugin = function () {
|
|
58
|
-
return data;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
return data;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
54
|
function _bitError() {
|
|
65
55
|
const data = require("@teambit/bit-error");
|
|
66
56
|
|
|
@@ -136,7 +126,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
136
126
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
137
127
|
|
|
138
128
|
class ReactApp {
|
|
139
|
-
constructor(name, entry, ssr, portRange, reactEnv, prerender, bundler, devServer, transformers = [], deploy, favicon, logger) {
|
|
129
|
+
constructor(name, entry, ssr, portRange, reactEnv, prerender, bundler, ssrBundler, devServer, transformers = [], deploy, favicon, logger) {
|
|
140
130
|
this.name = name;
|
|
141
131
|
this.entry = entry;
|
|
142
132
|
this.ssr = ssr;
|
|
@@ -144,6 +134,7 @@ class ReactApp {
|
|
|
144
134
|
this.reactEnv = reactEnv;
|
|
145
135
|
this.prerender = prerender;
|
|
146
136
|
this.bundler = bundler;
|
|
137
|
+
this.ssrBundler = ssrBundler;
|
|
147
138
|
this.devServer = devServer;
|
|
148
139
|
this.transformers = transformers;
|
|
149
140
|
this.deploy = deploy;
|
|
@@ -151,58 +142,7 @@ class ReactApp {
|
|
|
151
142
|
this.logger = logger;
|
|
152
143
|
(0, _defineProperty2().default)(this, "applicationType", 'react-common-js');
|
|
153
144
|
(0, _defineProperty2().default)(this, "dir", 'public');
|
|
154
|
-
(0, _defineProperty2().default)(this, "
|
|
155
|
-
// We don't want to use esbuild in case of prerendering since the headless browser puppeteer doesn't support
|
|
156
|
-
// the output of esbuild
|
|
157
|
-
if (isPrerendering) {
|
|
158
|
-
return new (_terserWebpackPlugin().default)({
|
|
159
|
-
extractComments: false,
|
|
160
|
-
terserOptions: {
|
|
161
|
-
parse: {
|
|
162
|
-
// We want terser to parse ecma 8 code. However, we don't want it
|
|
163
|
-
// to apply any minification steps that turns valid ecma 5 code
|
|
164
|
-
// into invalid ecma 5 code. This is why the 'compress' and 'output'
|
|
165
|
-
// sections only apply transformations that are ecma 5 safe
|
|
166
|
-
// https://github.com/facebook/create-react-app/pull/4234
|
|
167
|
-
ecma: 8
|
|
168
|
-
},
|
|
169
|
-
compress: {
|
|
170
|
-
ecma: 5,
|
|
171
|
-
warnings: false,
|
|
172
|
-
// Disabled because of an issue with Uglify breaking seemingly valid code:
|
|
173
|
-
// https://github.com/facebook/create-react-app/issues/2376
|
|
174
|
-
// Pending further investigation:
|
|
175
|
-
// https://github.com/mishoo/UglifyJS2/issues/2011
|
|
176
|
-
comparisons: false,
|
|
177
|
-
// Disabled because of an issue with Terser breaking valid code:
|
|
178
|
-
// https://github.com/facebook/create-react-app/issues/5250
|
|
179
|
-
// Pending further investigation:
|
|
180
|
-
// https://github.com/terser-js/terser/issues/120
|
|
181
|
-
inline: 2
|
|
182
|
-
},
|
|
183
|
-
mangle: {
|
|
184
|
-
safari10: true
|
|
185
|
-
},
|
|
186
|
-
output: {
|
|
187
|
-
ecma: 5,
|
|
188
|
-
comments: false,
|
|
189
|
-
// Turned on because emoji and regex is not minified properly using default
|
|
190
|
-
// https://github.com/facebook/create-react-app/issues/2488
|
|
191
|
-
ascii_only: true
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
return new (_terserWebpackPlugin().default)({
|
|
198
|
-
minify: _terserWebpackPlugin().default.esbuildMinify,
|
|
199
|
-
// `terserOptions` options will be passed to `esbuild`
|
|
200
|
-
// Link to options - https://esbuild.github.io/api/#minify
|
|
201
|
-
terserOptions: {
|
|
202
|
-
minify: true
|
|
203
|
-
}
|
|
204
|
-
});
|
|
205
|
-
});
|
|
145
|
+
(0, _defineProperty2().default)(this, "ssrDir", 'ssr');
|
|
206
146
|
}
|
|
207
147
|
|
|
208
148
|
async run(context) {
|
|
@@ -312,8 +252,15 @@ class ReactApp {
|
|
|
312
252
|
});
|
|
313
253
|
const bundler = await this.getBundler(context);
|
|
314
254
|
const bundleResult = await bundler.run();
|
|
255
|
+
|
|
256
|
+
if (this.ssr) {
|
|
257
|
+
const bunlder = await this.getSsrBundler(context);
|
|
258
|
+
await bunlder.run();
|
|
259
|
+
}
|
|
260
|
+
|
|
315
261
|
return (0, _computeResults().computeResults)(bundleResult, {
|
|
316
|
-
publicDir: `${this.getPublicDir(context.artifactsDir)}/${this.dir}
|
|
262
|
+
publicDir: `${this.getPublicDir(context.artifactsDir)}/${this.dir}`,
|
|
263
|
+
ssrPublicDir: this.ssr ? `${this.getPublicDir(context.artifactsDir)}/${this.ssrDir}` : undefined
|
|
317
264
|
});
|
|
318
265
|
}
|
|
319
266
|
|
|
@@ -322,19 +269,64 @@ class ReactApp {
|
|
|
322
269
|
return this.getDefaultBundler(context);
|
|
323
270
|
}
|
|
324
271
|
|
|
272
|
+
getSsrBundler(context) {
|
|
273
|
+
if (this.ssrBundler) return this.ssrBundler;
|
|
274
|
+
return this.getDefaultSsrBundler(context);
|
|
275
|
+
}
|
|
276
|
+
|
|
325
277
|
async getDefaultBundler(context) {
|
|
326
278
|
const {
|
|
327
279
|
capsule
|
|
328
280
|
} = context;
|
|
281
|
+
const publicDir = this.getPublicDir(context.artifactsDir);
|
|
282
|
+
const outputPath = (0, _path().join)(capsule.path, publicDir);
|
|
283
|
+
const bundlerContext = await this.getBuildContext(context, {
|
|
284
|
+
outputPath
|
|
285
|
+
});
|
|
286
|
+
const transformers = (0, _lodash().default)([configMutator => configMutator.merge((0, _webpackAppSsr().buildConfig)({
|
|
287
|
+
outputPath: (0, _path().join)(outputPath, this.dir)
|
|
288
|
+
})), config => {
|
|
289
|
+
if (this.prerender) config.addPlugin((0, _plugins().prerenderPlugin)(this.prerender));
|
|
290
|
+
return config;
|
|
291
|
+
}, (0, _mutators().replaceTerserPlugin)({
|
|
292
|
+
prerender: !!this.prerender
|
|
293
|
+
}), ...this.transformers]);
|
|
329
294
|
const reactEnv = context.env;
|
|
295
|
+
const bundler = await reactEnv.getBundler(bundlerContext, transformers);
|
|
296
|
+
return bundler;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
async getDefaultSsrBundler(context) {
|
|
300
|
+
const {
|
|
301
|
+
capsule
|
|
302
|
+
} = context;
|
|
330
303
|
const publicDir = this.getPublicDir(context.artifactsDir);
|
|
331
304
|
const outputPath = (0, _path().join)(capsule.path, publicDir);
|
|
305
|
+
const bundlerContext = await this.getBuildContext(context, {
|
|
306
|
+
outputPath
|
|
307
|
+
});
|
|
308
|
+
const transformers = (0, _lodash().default)([configMutator => configMutator.merge((0, _webpackAppSsr().ssrBuildConfig)({
|
|
309
|
+
outputPath: (0, _path().join)(outputPath, this.ssrDir)
|
|
310
|
+
})), (0, _mutators().replaceTerserPlugin)({
|
|
311
|
+
prerender: !!this.prerender
|
|
312
|
+
}), ...this.transformers]);
|
|
313
|
+
const reactEnv = context.env;
|
|
314
|
+
const bundler = await reactEnv.getBundler(bundlerContext, transformers);
|
|
315
|
+
return bundler;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
async getBuildContext(context, {
|
|
319
|
+
outputPath
|
|
320
|
+
}) {
|
|
321
|
+
const {
|
|
322
|
+
capsule
|
|
323
|
+
} = context;
|
|
324
|
+
const reactEnv = context.env;
|
|
332
325
|
const {
|
|
333
326
|
distDir
|
|
334
327
|
} = reactEnv.getCompiler();
|
|
335
|
-
const targetEntries =
|
|
328
|
+
const targetEntries = await this.getEntries(`${capsule.path}/${distDir}`);
|
|
336
329
|
const entries = targetEntries.map(entry => require.resolve(`${capsule.path}/${distDir}/${(0, _path().basename)(entry)}`));
|
|
337
|
-
const staticDir = (0, _path().join)(outputPath, this.dir);
|
|
338
330
|
const bundlerContext = Object.assign(context, {
|
|
339
331
|
targets: [{
|
|
340
332
|
components: [capsule === null || capsule === void 0 ? void 0 : capsule.component],
|
|
@@ -351,41 +343,16 @@ class ReactApp {
|
|
|
351
343
|
envId: context.id
|
|
352
344
|
}
|
|
353
345
|
});
|
|
354
|
-
|
|
355
|
-
const defaultTransformer = configMutator => {
|
|
356
|
-
var _config$raw$optimizat;
|
|
357
|
-
|
|
358
|
-
const config = configMutator.addTopLevel('output', {
|
|
359
|
-
path: staticDir,
|
|
360
|
-
publicPath: `/`,
|
|
361
|
-
filename: '[name].[chunkhash].js'
|
|
362
|
-
});
|
|
363
|
-
if (this.prerender) config.addPlugin((0, _plugins().prerenderPlugin)(this.prerender));
|
|
364
|
-
|
|
365
|
-
if ((_config$raw$optimizat = config.raw.optimization) !== null && _config$raw$optimizat !== void 0 && _config$raw$optimizat.minimizer) {
|
|
366
|
-
var _config$raw$optimizat2, _config$raw$optimizat3;
|
|
367
|
-
|
|
368
|
-
(0, _lodash().remove)((_config$raw$optimizat2 = config.raw.optimization) === null || _config$raw$optimizat2 === void 0 ? void 0 : _config$raw$optimizat2.minimizer, minimizer => {
|
|
369
|
-
return minimizer.constructor.name === 'TerserPlugin';
|
|
370
|
-
});
|
|
371
|
-
(_config$raw$optimizat3 = config.raw.optimization) === null || _config$raw$optimizat3 === void 0 ? void 0 : _config$raw$optimizat3.minimizer.push(this.getESBuildConfig());
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
return config;
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
const transformers = [defaultTransformer, ...this.transformers];
|
|
378
|
-
const bundler = await reactEnv.getBundler(bundlerContext, transformers);
|
|
379
|
-
return bundler;
|
|
346
|
+
return bundlerContext;
|
|
380
347
|
}
|
|
381
348
|
|
|
382
349
|
getPublicDir(artifactsDir) {
|
|
383
350
|
return (0, _path().join)(artifactsDir, this.applicationType, this.name);
|
|
384
351
|
}
|
|
385
352
|
|
|
386
|
-
async getEntries() {
|
|
353
|
+
async getEntries(path) {
|
|
387
354
|
if (Array.isArray(this.entry)) return this.entry;
|
|
388
|
-
return this.entry();
|
|
355
|
+
return this.entry(path);
|
|
389
356
|
}
|
|
390
357
|
|
|
391
358
|
async getSsrEntries() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ReactApp","constructor","name","entry","ssr","portRange","reactEnv","prerender","bundler","devServer","transformers","deploy","favicon","logger","isPrerendering","TerserPlugin","extractComments","terserOptions","parse","ecma","compress","warnings","comparisons","inline","mangle","safari10","output","comments","ascii_only","minify","esbuildMinify","run","context","from","to","port","Port","getPort","listen","devServerContext","getDevServerContext","getDevServer","addDevServer","setOutput","runSsr","clientBundle","buildClient","errors","length","info","serverBundle","buildSsr","app","loadSsrApp","workdir","appName","expressApp","createExpressSsr","assets","parseAssets","htmlConfig","title","templateContent","html","ctx","Object","assign","create","targets","entries","getEntries","components","appComponent","outputPath","resolve","calcOutputPath","hostDependencies","getPeers","aliasHostDependencies","capsuleNetwork","undefined","previousTasksResults","getBundler","config","merge","clientConfig","bundleResult","getSsrEntries","ssrConfig","build","computeResults","publicDir","getPublicDir","artifactsDir","dir","getDefaultBundler","capsule","env","join","path","distDir","getCompiler","targetEntries","Array","isArray","map","require","basename","staticDir","bundlerContext","component","hostRootDir","rootPath","metaData","initiator","envId","id","defaultTransformer","configMutator","addTopLevel","publicPath","filename","addPlugin","prerenderPlugin","raw","optimization","minimizer","remove","push","getESBuildConfig","applicationType","BitError","getPeerDependenciesList"],"sources":["react.application.ts"],"sourcesContent":["import { join, resolve, basename } from 'path';\nimport { Application, AppContext, AppBuildContext, AppResult } from '@teambit/application';\nimport type { Bundler, DevServer, BundlerContext, DevServerContext, BundlerHtmlConfig } from '@teambit/bundler';\nimport { Port } from '@teambit/toolbox.network.get-port';\nimport type { Logger } from '@teambit/logger';\nimport { remove } from 'lodash';\nimport TerserPlugin from 'terser-webpack-plugin';\nimport { WebpackConfigTransformer } from '@teambit/webpack';\nimport { BitError } from '@teambit/bit-error';\nimport { ReactEnv } from '../../react.env';\nimport { prerenderPlugin } from './plugins';\nimport { ReactAppBuildResult } from './react-build-result';\nimport { ReactAppPrerenderOptions } from './react-app-options';\nimport { html } from '../../webpack';\nimport { ReactDeployContext } from '.';\nimport { computeResults } from './compute-results';\nimport { clientConfig, ssrConfig, calcOutputPath } from './webpack/webpack.app.ssr.config';\nimport { addDevServer, setOutput } from './webpack/mutators';\nimport { createExpressSsr, loadSsrApp, parseAssets } from './ssr/ssr-express';\n\nexport class ReactApp implements Application {\n constructor(\n readonly name: string,\n readonly entry: string[] | ((path?: string) => Promise<string[]>),\n readonly ssr: string | (() => Promise<string>) | undefined,\n readonly portRange: [number, number],\n private reactEnv: ReactEnv,\n readonly prerender?: ReactAppPrerenderOptions,\n readonly bundler?: Bundler,\n readonly devServer?: DevServer,\n readonly transformers: WebpackConfigTransformer[] = [],\n readonly deploy?: (context: ReactDeployContext) => Promise<void>,\n readonly favicon?: string,\n private logger?: Logger\n ) {}\n readonly applicationType = 'react-common-js';\n readonly dir = 'public';\n\n async run(context: AppContext): Promise<number> {\n const [from, to] = this.portRange;\n const port = await Port.getPort(from, to);\n\n if (this.devServer) {\n await this.devServer.listen(port);\n return port;\n }\n\n const devServerContext = await this.getDevServerContext(context);\n const devServer = this.reactEnv.getDevServer(devServerContext, [addDevServer, setOutput, ...this.transformers]);\n await devServer.listen(port);\n return port;\n }\n\n async runSsr(context: AppContext): Promise<AppResult> {\n const [from, to] = this.portRange;\n const port = await Port.getPort(from, to);\n\n // bundle client\n const clientBundle = await this.buildClient(context);\n if (clientBundle.errors.length > 0) return { errors: clientBundle.errors };\n this.logger?.info('[react.application] [ssr] client bundle - complete');\n\n // bundle server\n const serverBundle = await this.buildSsr(context);\n if (serverBundle.errors.length > 0) return { errors: serverBundle.errors };\n this.logger?.info('[react.application] [ssr] server bundle - complete');\n\n // load server-side runtime\n const app = await loadSsrApp(context.workdir, context.appName);\n this.logger?.info('[react.application] [ssr] bundle code - loaded');\n\n const expressApp = createExpressSsr({\n name: context.appName,\n workdir: context.workdir,\n port,\n app,\n assets: parseAssets(clientBundle.assets),\n logger: this.logger,\n });\n\n expressApp.listen(port);\n return { port };\n }\n\n private async buildClient(context: AppContext) {\n const htmlConfig: BundlerHtmlConfig[] = [\n {\n title: context.appName,\n templateContent: html(context.appName),\n minify: false,\n favicon: this.favicon,\n },\n ];\n\n // extend, including prototype methods\n const ctx: BundlerContext = Object.assign(Object.create(context), {\n html: htmlConfig,\n targets: [\n {\n entries: await this.getEntries(),\n components: [context.appComponent],\n outputPath: resolve(context.workdir, calcOutputPath(context.appName, 'browser')),\n hostDependencies: await this.getPeers(),\n aliasHostDependencies: true,\n },\n ],\n\n // @ts-ignore\n capsuleNetwork: undefined,\n previousTasksResults: [],\n });\n\n const bundler = await this.reactEnv.getBundler(ctx, [\n (config) => config.merge([clientConfig()]),\n ...this.transformers,\n ]);\n\n const bundleResult = await bundler.run();\n return bundleResult[0];\n }\n\n private async buildSsr(context: AppContext) {\n // extend, including prototype methods\n const ctx: BundlerContext = Object.assign(Object.create(context), {\n ...context,\n targets: [\n {\n entries: await this.getSsrEntries(),\n components: [context.appComponent],\n outputPath: resolve(context.workdir, calcOutputPath(context.appName, 'ssr')),\n hostDependencies: await this.getPeers(),\n aliasHostDependencies: true,\n },\n ],\n\n // @ts-ignore\n capsuleNetwork: undefined,\n previousTasksResults: [],\n });\n\n const bundler = await this.reactEnv.getBundler(ctx, [\n (config) => config.merge([ssrConfig()]),\n ...this.transformers,\n ]);\n\n const bundleResult = await bundler.run();\n return bundleResult[0];\n }\n\n async build(context: AppBuildContext): Promise<ReactAppBuildResult> {\n const htmlConfig: BundlerHtmlConfig[] = [\n {\n title: context.name,\n templateContent: html(context.name),\n minify: false,\n favicon: this.favicon,\n // filename: ''.html`,\n },\n ];\n Object.assign(context, {\n html: htmlConfig,\n });\n const bundler = await this.getBundler(context);\n const bundleResult = await bundler.run();\n\n return computeResults(bundleResult, { publicDir: `${this.getPublicDir(context.artifactsDir)}/${this.dir}` });\n }\n\n private getBundler(context: AppBuildContext) {\n if (this.bundler) return this.bundler;\n return this.getDefaultBundler(context);\n }\n \n private async getDefaultBundler(context: AppBuildContext) {\n const { capsule } = context;\n const reactEnv: ReactEnv = context.env as ReactEnv;\n const publicDir = this.getPublicDir(context.artifactsDir);\n const outputPath = join(capsule.path, publicDir);\n const { distDir } = reactEnv.getCompiler();\n const targetEntries = Array.isArray(this.entry) ? this.entry : await this.entry(`${capsule.path}/${distDir}`);\n const entries = targetEntries.map((entry) => require.resolve(`${capsule.path}/${distDir}/${basename(entry)}`));\n const staticDir = join(outputPath, this.dir);\n\n const bundlerContext: BundlerContext = Object.assign(context, {\n targets: [\n {\n components: [capsule?.component],\n entries,\n outputPath,\n hostRootDir: capsule?.path,\n hostDependencies: await this.getPeers(),\n aliasHostDependencies: true,\n },\n ],\n entry: [],\n rootPath: '/',\n metaData: {\n initiator: `building app: ${context.name}`,\n envId: context.id,\n },\n });\n\n const defaultTransformer: WebpackConfigTransformer = (configMutator) => {\n const config = configMutator.addTopLevel('output', {\n path: staticDir,\n publicPath: `/`,\n filename: '[name].[chunkhash].js',\n });\n if (this.prerender) config.addPlugin(prerenderPlugin(this.prerender));\n if (config.raw.optimization?.minimizer) {\n remove(config.raw.optimization?.minimizer, (minimizer) => {\n return minimizer.constructor.name === 'TerserPlugin';\n });\n\n config.raw.optimization?.minimizer.push(this.getESBuildConfig());\n }\n\n return config;\n };\n const transformers = [defaultTransformer, ...this.transformers];\n const bundler: Bundler = await reactEnv.getBundler(bundlerContext, transformers);\n return bundler;\n }\n private getESBuildConfig = (isPrerendering = this.prerender) => {\n // We don't want to use esbuild in case of prerendering since the headless browser puppeteer doesn't support\n // the output of esbuild\n\n if (isPrerendering) {\n return new TerserPlugin({\n extractComments: false,\n terserOptions: {\n parse: {\n // We want terser to parse ecma 8 code. However, we don't want it\n // to apply any minification steps that turns valid ecma 5 code\n // into invalid ecma 5 code. This is why the 'compress' and 'output'\n // sections only apply transformations that are ecma 5 safe\n // https://github.com/facebook/create-react-app/pull/4234\n ecma: 8,\n },\n compress: {\n ecma: 5,\n warnings: false,\n // Disabled because of an issue with Uglify breaking seemingly valid code:\n // https://github.com/facebook/create-react-app/issues/2376\n // Pending further investigation:\n // https://github.com/mishoo/UglifyJS2/issues/2011\n comparisons: false,\n // Disabled because of an issue with Terser breaking valid code:\n // https://github.com/facebook/create-react-app/issues/5250\n // Pending further investigation:\n // https://github.com/terser-js/terser/issues/120\n inline: 2,\n },\n mangle: {\n safari10: true,\n },\n output: {\n ecma: 5,\n comments: false,\n // Turned on because emoji and regex is not minified properly using default\n // https://github.com/facebook/create-react-app/issues/2488\n ascii_only: true,\n },\n },\n });\n }\n return new TerserPlugin({\n minify: TerserPlugin.esbuildMinify,\n // `terserOptions` options will be passed to `esbuild`\n // Link to options - https://esbuild.github.io/api/#minify\n terserOptions: {\n minify: true,\n },\n });\n };\n\n private getPublicDir(artifactsDir: string) {\n return join(artifactsDir, this.applicationType, this.name);\n }\n\n async getEntries(): Promise<string[]> {\n if (Array.isArray(this.entry)) return this.entry;\n return this.entry();\n }\n\n async getSsrEntries(): Promise<string[]> {\n if (!this.ssr) throw new BitError('tried to build ssr without ssr entries');\n if (typeof this.ssr === 'string') return [this.ssr];\n return [await this.ssr()];\n }\n\n private async getDevServerContext(context: AppContext): Promise<DevServerContext> {\n const entries = await this.getEntries();\n return Object.assign(context, {\n entry: entries,\n rootPath: '',\n publicPath: `public/${this.name}`,\n title: this.name,\n favicon: this.favicon,\n hostDependencies: await this.getPeers(),\n aliasHostDependencies: true,\n });\n }\n\n private getPeers(): Promise<string[]> {\n return this.reactEnv.getPeerDependenciesList();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAA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,MAAVoE,UAAU,GAAsB;IACpC,IAAIiC,KAAK,CAACC,OAAN,CAAc,KAAKrG,KAAnB,CAAJ,EAA+B,OAAO,KAAKA,KAAZ;IAC/B,OAAO,KAAKA,KAAL,EAAP;EACD;;EAEkB,MAAboF,aAAa,GAAsB;IACvC,IAAI,CAAC,KAAKnF,GAAV,EAAe,MAAM,KAAI+H,oBAAJ,EAAa,wCAAb,CAAN;IACf,IAAI,OAAO,KAAK/H,GAAZ,KAAoB,QAAxB,EAAkC,OAAO,CAAC,KAAKA,GAAN,CAAP;IAClC,OAAO,CAAC,MAAM,KAAKA,GAAL,EAAP,CAAP;EACD;;EAEgC,MAAnBoC,mBAAmB,CAACR,OAAD,EAAiD;IAChF,MAAMqC,OAAO,GAAG,MAAM,KAAKC,UAAL,EAAtB;IACA,OAAOL,MAAM,CAACC,MAAP,CAAclC,OAAd,EAAuB;MAC5B7B,KAAK,EAAEkE,OADqB;MAE5B2C,QAAQ,EAAE,EAFkB;MAG5BQ,UAAU,EAAG,UAAS,KAAKtH,IAAK,EAHJ;MAI5B2D,KAAK,EAAE,KAAK3D,IAJgB;MAK5BU,OAAO,EAAE,KAAKA,OALc;MAM5BgE,gBAAgB,EAAE,MAAM,KAAKC,QAAL,EANI;MAO5BC,qBAAqB,EAAE;IAPK,CAAvB,CAAP;EASD;;EAEOD,QAAQ,GAAsB;IACpC,OAAO,KAAKvE,QAAL,CAAc8H,uBAAd,EAAP;EACD;;AA9R0C"}
|
|
1
|
+
{"version":3,"names":["ReactApp","constructor","name","entry","ssr","portRange","reactEnv","prerender","bundler","ssrBundler","devServer","transformers","deploy","favicon","logger","run","context","from","to","port","Port","getPort","listen","devServerContext","getDevServerContext","getDevServer","addDevServer","setOutput","runSsr","clientBundle","buildClient","errors","length","info","serverBundle","buildSsr","app","loadSsrApp","workdir","appName","expressApp","createExpressSsr","assets","parseAssets","htmlConfig","title","templateContent","html","minify","ctx","Object","assign","create","targets","entries","getEntries","components","appComponent","outputPath","resolve","calcOutputPath","hostDependencies","getPeers","aliasHostDependencies","capsuleNetwork","undefined","previousTasksResults","getBundler","config","merge","clientConfig","bundleResult","getSsrEntries","ssrConfig","build","bunlder","getSsrBundler","computeResults","publicDir","getPublicDir","artifactsDir","dir","ssrPublicDir","ssrDir","getDefaultBundler","getDefaultSsrBundler","capsule","join","path","bundlerContext","getBuildContext","compact","configMutator","buildConfig","addPlugin","prerenderPlugin","replaceTerserPlugin","env","ssrBuildConfig","distDir","getCompiler","targetEntries","map","require","basename","component","hostRootDir","rootPath","metaData","initiator","envId","id","applicationType","Array","isArray","BitError","publicPath","getPeerDependenciesList"],"sources":["react.application.ts"],"sourcesContent":["import { join, resolve, basename } from 'path';\nimport { Application, AppContext, AppBuildContext, AppResult } from '@teambit/application';\nimport type { Bundler, DevServer, BundlerContext, DevServerContext, BundlerHtmlConfig } from '@teambit/bundler';\nimport { Port } from '@teambit/toolbox.network.get-port';\nimport type { Logger } from '@teambit/logger';\nimport compact from 'lodash.compact';\nimport { WebpackConfigTransformer } from '@teambit/webpack';\nimport { BitError } from '@teambit/bit-error';\nimport { ReactEnv } from '../../react.env';\nimport { prerenderPlugin } from './plugins';\nimport { ReactAppBuildResult } from './react-build-result';\nimport { ReactAppPrerenderOptions } from './react-app-options';\nimport { html } from '../../webpack';\nimport { ReactDeployContext } from '.';\nimport { computeResults } from './compute-results';\nimport { clientConfig, ssrConfig, calcOutputPath, ssrBuildConfig, buildConfig } from './webpack/webpack.app.ssr.config';\nimport { addDevServer, setOutput, replaceTerserPlugin } from './webpack/mutators';\nimport { createExpressSsr, loadSsrApp, parseAssets } from './ssr/ssr-express';\n\nexport class ReactApp implements Application {\n constructor(\n readonly name: string,\n readonly entry: string[] | ((path?: string) => Promise<string[]>),\n readonly ssr: string | (() => Promise<string>) | undefined,\n readonly portRange: [number, number],\n private reactEnv: ReactEnv,\n readonly prerender?: ReactAppPrerenderOptions,\n readonly bundler?: Bundler,\n readonly ssrBundler?: Bundler,\n readonly devServer?: DevServer,\n readonly transformers: WebpackConfigTransformer[] = [],\n readonly deploy?: (context: ReactDeployContext) => Promise<void>,\n readonly favicon?: string,\n private logger?: Logger\n ) {}\n readonly applicationType = 'react-common-js';\n readonly dir = 'public';\n readonly ssrDir = 'ssr';\n\n async run(context: AppContext): Promise<number> {\n const [from, to] = this.portRange;\n const port = await Port.getPort(from, to);\n\n if (this.devServer) {\n await this.devServer.listen(port);\n return port;\n }\n\n const devServerContext = await this.getDevServerContext(context);\n const devServer = this.reactEnv.getDevServer(devServerContext, [addDevServer, setOutput, ...this.transformers]);\n await devServer.listen(port);\n return port;\n }\n\n async runSsr(context: AppContext): Promise<AppResult> {\n const [from, to] = this.portRange;\n const port = await Port.getPort(from, to);\n\n // bundle client\n const clientBundle = await this.buildClient(context);\n if (clientBundle.errors.length > 0) return { errors: clientBundle.errors };\n this.logger?.info('[react.application] [ssr] client bundle - complete');\n\n // bundle server\n const serverBundle = await this.buildSsr(context);\n if (serverBundle.errors.length > 0) return { errors: serverBundle.errors };\n this.logger?.info('[react.application] [ssr] server bundle - complete');\n\n // load server-side runtime\n const app = await loadSsrApp(context.workdir, context.appName);\n this.logger?.info('[react.application] [ssr] bundle code - loaded');\n\n const expressApp = createExpressSsr({\n name: context.appName,\n workdir: context.workdir,\n port,\n app,\n assets: parseAssets(clientBundle.assets),\n logger: this.logger,\n });\n\n expressApp.listen(port);\n return { port };\n }\n\n private async buildClient(context: AppContext) {\n const htmlConfig: BundlerHtmlConfig[] = [\n {\n title: context.appName,\n templateContent: html(context.appName),\n minify: false,\n favicon: this.favicon,\n },\n ];\n\n // extend, including prototype methods\n const ctx: BundlerContext = Object.assign(Object.create(context), {\n html: htmlConfig,\n targets: [\n {\n entries: await this.getEntries(),\n components: [context.appComponent],\n outputPath: resolve(context.workdir, calcOutputPath(context.appName, 'browser')),\n hostDependencies: await this.getPeers(),\n aliasHostDependencies: true,\n },\n ],\n\n // @ts-ignore\n capsuleNetwork: undefined,\n previousTasksResults: [],\n });\n\n const bundler = await this.reactEnv.getBundler(ctx, [\n (config) => config.merge([clientConfig()]),\n ...this.transformers,\n ]);\n\n const bundleResult = await bundler.run();\n return bundleResult[0];\n }\n\n private async buildSsr(context: AppContext) {\n // extend, including prototype methods\n const ctx: BundlerContext = Object.assign(Object.create(context), {\n ...context,\n targets: [\n {\n entries: await this.getSsrEntries(),\n components: [context.appComponent],\n outputPath: resolve(context.workdir, calcOutputPath(context.appName, 'ssr')),\n hostDependencies: await this.getPeers(),\n aliasHostDependencies: true,\n },\n ],\n\n // @ts-ignore\n capsuleNetwork: undefined,\n previousTasksResults: [],\n });\n\n const bundler = await this.reactEnv.getBundler(ctx, [\n (config) => config.merge([ssrConfig()]),\n ...this.transformers,\n ]);\n\n const bundleResult = await bundler.run();\n return bundleResult[0];\n }\n\n async build(context: AppBuildContext): Promise<ReactAppBuildResult> {\n const htmlConfig: BundlerHtmlConfig[] = [\n {\n title: context.name,\n templateContent: html(context.name),\n minify: false,\n favicon: this.favicon,\n // filename: ''.html`,\n },\n ];\n Object.assign(context, {\n html: htmlConfig,\n });\n const bundler = await this.getBundler(context);\n const bundleResult = await bundler.run();\n\n if (this.ssr) {\n const bunlder = await this.getSsrBundler(context);\n await bunlder.run();\n }\n\n return computeResults(bundleResult, {\n publicDir: `${this.getPublicDir(context.artifactsDir)}/${this.dir}`,\n ssrPublicDir: this.ssr ? `${this.getPublicDir(context.artifactsDir)}/${this.ssrDir}` : undefined,\n });\n }\n\n private getBundler(context: AppBuildContext) {\n if (this.bundler) return this.bundler;\n return this.getDefaultBundler(context);\n }\n\n private getSsrBundler(context: AppBuildContext) {\n if (this.ssrBundler) return this.ssrBundler;\n return this.getDefaultSsrBundler(context);\n }\n\n private async getDefaultBundler(context: AppBuildContext) {\n const { capsule } = context;\n const publicDir = this.getPublicDir(context.artifactsDir);\n const outputPath = join(capsule.path, publicDir);\n\n const bundlerContext = await this.getBuildContext(context, { outputPath });\n const transformers: WebpackConfigTransformer[] = compact([\n (configMutator) => configMutator.merge(buildConfig({ outputPath: join(outputPath, this.dir) })),\n (config) => {\n if (this.prerender) config.addPlugin(prerenderPlugin(this.prerender));\n return config;\n },\n replaceTerserPlugin({ prerender: !!this.prerender }),\n ...this.transformers,\n ]);\n\n const reactEnv = context.env as ReactEnv;\n const bundler: Bundler = await reactEnv.getBundler(bundlerContext, transformers);\n return bundler;\n }\n\n private async getDefaultSsrBundler(context: AppBuildContext) {\n const { capsule } = context;\n const publicDir = this.getPublicDir(context.artifactsDir);\n const outputPath = join(capsule.path, publicDir);\n\n const bundlerContext = await this.getBuildContext(context, { outputPath });\n const transformers: WebpackConfigTransformer[] = compact([\n (configMutator) => configMutator.merge(ssrBuildConfig({ outputPath: join(outputPath, this.ssrDir) })),\n replaceTerserPlugin({ prerender: !!this.prerender }),\n ...this.transformers,\n ]);\n\n const reactEnv = context.env as ReactEnv;\n const bundler: Bundler = await reactEnv.getBundler(bundlerContext, transformers);\n return bundler;\n }\n\n private async getBuildContext(context: AppBuildContext, { outputPath }: { outputPath: string }) {\n const { capsule } = context;\n const reactEnv = context.env as ReactEnv;\n const { distDir } = reactEnv.getCompiler();\n const targetEntries = await this.getEntries(`${capsule.path}/${distDir}`);\n const entries = targetEntries.map((entry) => require.resolve(`${capsule.path}/${distDir}/${basename(entry)}`));\n\n const bundlerContext: BundlerContext = Object.assign(context, {\n targets: [\n {\n components: [capsule?.component],\n entries,\n outputPath,\n hostRootDir: capsule?.path,\n hostDependencies: await this.getPeers(),\n aliasHostDependencies: true,\n },\n ],\n entry: [],\n rootPath: '/',\n metaData: {\n initiator: `building app: ${context.name}`,\n envId: context.id,\n },\n });\n\n return bundlerContext;\n }\n\n private getPublicDir(artifactsDir: string) {\n return join(artifactsDir, this.applicationType, this.name);\n }\n\n async getEntries(path?: string): Promise<string[]> {\n if (Array.isArray(this.entry)) return this.entry;\n return this.entry(path);\n }\n\n async getSsrEntries(): Promise<string[]> {\n if (!this.ssr) throw new BitError('tried to build ssr without ssr entries');\n if (typeof this.ssr === 'string') return [this.ssr];\n return [await this.ssr()];\n }\n\n private async getDevServerContext(context: AppContext): Promise<DevServerContext> {\n const entries = await this.getEntries();\n return Object.assign(context, {\n entry: entries,\n rootPath: '',\n publicPath: `public/${this.name}`,\n title: this.name,\n favicon: this.favicon,\n hostDependencies: await this.getPeers(),\n aliasHostDependencies: true,\n });\n }\n\n private getPeers(): Promise<string[]> {\n return this.reactEnv.getPeerDependenciesList();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;AAEO,MAAMA,QAAN,CAAsC;EAC3CC,WAAW,CACAC,IADA,EAEAC,KAFA,EAGAC,GAHA,EAIAC,SAJA,EAKDC,QALC,EAMAC,SANA,EAOAC,OAPA,EAQAC,UARA,EASAC,SATA,EAUAC,YAAwC,GAAG,EAV3C,EAWAC,MAXA,EAYAC,OAZA,EAaDC,MAbC,EAcT;IAAA,KAbSZ,IAaT,GAbSA,IAaT;IAAA,KAZSC,KAYT,GAZSA,KAYT;IAAA,KAXSC,GAWT,GAXSA,GAWT;IAAA,KAVSC,SAUT,GAVSA,SAUT;IAAA,KATQC,QASR,GATQA,QASR;IAAA,KARSC,SAQT,GARSA,SAQT;IAAA,KAPSC,OAOT,GAPSA,OAOT;IAAA,KANSC,UAMT,GAN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GAAsB;IACvC,IAAI,CAAC,KAAKpE,GAAV,EAAe,MAAM,KAAI+G,oBAAJ,EAAa,wCAAb,CAAN;IACf,IAAI,OAAO,KAAK/G,GAAZ,KAAoB,QAAxB,EAAkC,OAAO,CAAC,KAAKA,GAAN,CAAP;IAClC,OAAO,CAAC,MAAM,KAAKA,GAAL,EAAP,CAAP;EACD;;EAEgC,MAAnBoB,mBAAmB,CAACR,OAAD,EAAiD;IAChF,MAAMsC,OAAO,GAAG,MAAM,KAAKC,UAAL,EAAtB;IACA,OAAOL,MAAM,CAACC,MAAP,CAAcnC,OAAd,EAAuB;MAC5Bb,KAAK,EAAEmD,OADqB;MAE5BqD,QAAQ,EAAE,EAFkB;MAG5BS,UAAU,EAAG,UAAS,KAAKlH,IAAK,EAHJ;MAI5B2C,KAAK,EAAE,KAAK3C,IAJgB;MAK5BW,OAAO,EAAE,KAAKA,OALc;MAM5BgD,gBAAgB,EAAE,MAAM,KAAKC,QAAL,EANI;MAO5BC,qBAAqB,EAAE;IAPK,CAAvB,CAAP;EASD;;EAEOD,QAAQ,GAAsB;IACpC,OAAO,KAAKxD,QAAL,CAAc+G,uBAAd,EAAP;EACD;;AAzQ0C"}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { WebpackConfigMutator } from '@teambit/webpack';
|
|
2
2
|
export declare function addDevServer(configMutator: WebpackConfigMutator): WebpackConfigMutator;
|
|
3
3
|
export declare function setOutput(configMutator: WebpackConfigMutator): WebpackConfigMutator;
|
|
4
|
+
export declare function replaceTerserPlugin({ prerender }: {
|
|
5
|
+
prerender: boolean;
|
|
6
|
+
}): (configMutator: WebpackConfigMutator) => WebpackConfigMutator;
|
|
@@ -1,11 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.addDevServer = addDevServer;
|
|
9
|
+
exports.replaceTerserPlugin = replaceTerserPlugin;
|
|
7
10
|
exports.setOutput = setOutput;
|
|
8
11
|
|
|
12
|
+
function _lodash() {
|
|
13
|
+
const data = require("lodash");
|
|
14
|
+
|
|
15
|
+
_lodash = function () {
|
|
16
|
+
return data;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function _terserWebpackPlugin() {
|
|
23
|
+
const data = _interopRequireDefault(require("terser-webpack-plugin"));
|
|
24
|
+
|
|
25
|
+
_terserWebpackPlugin = function () {
|
|
26
|
+
return data;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
|
|
9
32
|
function addDevServer(configMutator) {
|
|
10
33
|
return configMutator.addTopLevel('devServer', {
|
|
11
34
|
allowedHosts: 'all',
|
|
@@ -25,4 +48,71 @@ function setOutput(configMutator) {
|
|
|
25
48
|
return configMutator;
|
|
26
49
|
}
|
|
27
50
|
|
|
51
|
+
function replaceTerserPlugin({
|
|
52
|
+
prerender = false
|
|
53
|
+
}) {
|
|
54
|
+
return configMutator => {
|
|
55
|
+
var _configMutator$raw$op, _configMutator$raw$op2, _configMutator$raw$op3;
|
|
56
|
+
|
|
57
|
+
if (!((_configMutator$raw$op = configMutator.raw.optimization) !== null && _configMutator$raw$op !== void 0 && _configMutator$raw$op.minimizer)) return configMutator;
|
|
58
|
+
(0, _lodash().remove)((_configMutator$raw$op2 = configMutator.raw.optimization) === null || _configMutator$raw$op2 === void 0 ? void 0 : _configMutator$raw$op2.minimizer, minimizer => {
|
|
59
|
+
return minimizer.constructor.name === 'TerserPlugin';
|
|
60
|
+
});
|
|
61
|
+
const terserer = prerender ? CreateTerserPluginForPrerender() : CreateTerserPlugin();
|
|
62
|
+
(_configMutator$raw$op3 = configMutator.raw.optimization) === null || _configMutator$raw$op3 === void 0 ? void 0 : _configMutator$raw$op3.minimizer.push(terserer);
|
|
63
|
+
return configMutator;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function CreateTerserPlugin() {
|
|
68
|
+
return new (_terserWebpackPlugin().default)({
|
|
69
|
+
minify: _terserWebpackPlugin().default.esbuildMinify,
|
|
70
|
+
// `terserOptions` options will be passed to `esbuild`
|
|
71
|
+
// Link to options - https://esbuild.github.io/api/#minify
|
|
72
|
+
terserOptions: {
|
|
73
|
+
minify: true
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function CreateTerserPluginForPrerender() {
|
|
79
|
+
return new (_terserWebpackPlugin().default)({
|
|
80
|
+
extractComments: false,
|
|
81
|
+
terserOptions: {
|
|
82
|
+
parse: {
|
|
83
|
+
// We want terser to parse ecma 8 code. However, we don't want it
|
|
84
|
+
// to apply any minification steps that turns valid ecma 5 code
|
|
85
|
+
// into invalid ecma 5 code. This is why the 'compress' and 'output'
|
|
86
|
+
// sections only apply transformations that are ecma 5 safe
|
|
87
|
+
// https://github.com/facebook/create-react-app/pull/4234
|
|
88
|
+
ecma: 8
|
|
89
|
+
},
|
|
90
|
+
compress: {
|
|
91
|
+
ecma: 5,
|
|
92
|
+
warnings: false,
|
|
93
|
+
// Disabled because of an issue with Uglify breaking seemingly valid code:
|
|
94
|
+
// https://github.com/facebook/create-react-app/issues/2376
|
|
95
|
+
// Pending further investigation:
|
|
96
|
+
// https://github.com/mishoo/UglifyJS2/issues/2011
|
|
97
|
+
comparisons: false,
|
|
98
|
+
// Disabled because of an issue with Terser breaking valid code:
|
|
99
|
+
// https://github.com/facebook/create-react-app/issues/5250
|
|
100
|
+
// Pending further investigation:
|
|
101
|
+
// https://github.com/terser-js/terser/issues/120
|
|
102
|
+
inline: 2
|
|
103
|
+
},
|
|
104
|
+
mangle: {
|
|
105
|
+
safari10: true
|
|
106
|
+
},
|
|
107
|
+
output: {
|
|
108
|
+
ecma: 5,
|
|
109
|
+
comments: false,
|
|
110
|
+
// Turned on because emoji and regex is not minified properly using default
|
|
111
|
+
// https://github.com/facebook/create-react-app/issues/2488
|
|
112
|
+
ascii_only: true
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
28
118
|
//# sourceMappingURL=mutators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["addDevServer","configMutator","addTopLevel","allowedHosts","historyApiFallback","index","disableDotRule","headers","setOutput","raw","output","publicPath"],"sources":["mutators.ts"],"sourcesContent":["import { WebpackConfigMutator } from '@teambit/webpack';\n\nexport function addDevServer(configMutator: WebpackConfigMutator) {\n return configMutator.addTopLevel('devServer', {\n allowedHosts: 'all',\n historyApiFallback: {\n index: '/index.html',\n disableDotRule: true,\n },\n headers: {\n 'Access-Control-Allow-Origin': '*',\n },\n });\n}\n\nexport function setOutput(configMutator: WebpackConfigMutator) {\n if (!configMutator.raw.output) configMutator.raw.output = {};\n configMutator.raw.output.publicPath = '/';\n\n return configMutator;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["addDevServer","configMutator","addTopLevel","allowedHosts","historyApiFallback","index","disableDotRule","headers","setOutput","raw","output","publicPath","replaceTerserPlugin","prerender","optimization","minimizer","remove","constructor","name","terserer","CreateTerserPluginForPrerender","CreateTerserPlugin","push","TerserPlugin","minify","esbuildMinify","terserOptions","extractComments","parse","ecma","compress","warnings","comparisons","inline","mangle","safari10","comments","ascii_only"],"sources":["mutators.ts"],"sourcesContent":["import { WebpackConfigMutator } from '@teambit/webpack';\nimport { remove } from 'lodash';\nimport TerserPlugin from 'terser-webpack-plugin';\n\nexport function addDevServer(configMutator: WebpackConfigMutator) {\n return configMutator.addTopLevel('devServer', {\n allowedHosts: 'all',\n historyApiFallback: {\n index: '/index.html',\n disableDotRule: true,\n },\n headers: {\n 'Access-Control-Allow-Origin': '*',\n },\n });\n}\n\nexport function setOutput(configMutator: WebpackConfigMutator) {\n if (!configMutator.raw.output) configMutator.raw.output = {};\n configMutator.raw.output.publicPath = '/';\n\n return configMutator;\n}\n\nexport function replaceTerserPlugin({ prerender = false }: { prerender: boolean }) {\n return (configMutator: WebpackConfigMutator) => {\n if (!configMutator.raw.optimization?.minimizer) return configMutator;\n\n remove(configMutator.raw.optimization?.minimizer, (minimizer) => {\n return minimizer.constructor.name === 'TerserPlugin';\n });\n\n const terserer = prerender ? CreateTerserPluginForPrerender() : CreateTerserPlugin();\n configMutator.raw.optimization?.minimizer.push(terserer);\n\n return configMutator;\n };\n}\n\nfunction CreateTerserPlugin() {\n return new TerserPlugin({\n minify: TerserPlugin.esbuildMinify,\n // `terserOptions` options will be passed to `esbuild`\n // Link to options - https://esbuild.github.io/api/#minify\n terserOptions: {\n minify: true,\n },\n });\n}\n\nfunction CreateTerserPluginForPrerender() {\n return new TerserPlugin({\n extractComments: false,\n terserOptions: {\n parse: {\n // We want terser to parse ecma 8 code. However, we don't want it\n // to apply any minification steps that turns valid ecma 5 code\n // into invalid ecma 5 code. This is why the 'compress' and 'output'\n // sections only apply transformations that are ecma 5 safe\n // https://github.com/facebook/create-react-app/pull/4234\n ecma: 8,\n },\n compress: {\n ecma: 5,\n warnings: false,\n // Disabled because of an issue with Uglify breaking seemingly valid code:\n // https://github.com/facebook/create-react-app/issues/2376\n // Pending further investigation:\n // https://github.com/mishoo/UglifyJS2/issues/2011\n comparisons: false,\n // Disabled because of an issue with Terser breaking valid code:\n // https://github.com/facebook/create-react-app/issues/5250\n // Pending further investigation:\n // https://github.com/terser-js/terser/issues/120\n inline: 2,\n },\n mangle: {\n safari10: true,\n },\n output: {\n ecma: 5,\n comments: false,\n // Turned on because emoji and regex is not minified properly using default\n // https://github.com/facebook/create-react-app/issues/2488\n ascii_only: true,\n },\n },\n });\n}\n"],"mappings":";;;;;;;;;;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEO,SAASA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,aAAa,EAAE;MACbF,MAAM,EAAE;IADK;EAJO,CAAjB,CAAP;AAQD;;AAED,SAASJ,8BAAT,GAA0C;EACxC,OAAO,KAAIG,8BAAJ,EAAiB;IACtBI,eAAe,EAAE,KADK;IAEtBD,aAAa,EAAE;MACbE,KAAK,EAAE;QACL;QACA;QACA;QACA;QACA;QACAC,IAAI,EAAE;MAND,CADM;MASbC,QAAQ,EAAE;QACRD,IAAI,EAAE,CADE;QAERE,QAAQ,EAAE,KAFF;QAGR;QACA;QACA;QACA;QACAC,WAAW,EAAE,KAPL;QAQR;QACA;QACA;QACA;QACAC,MAAM,EAAE;MAZA,CATG;MAuBbC,MAAM,EAAE;QACNC,QAAQ,EAAE;MADJ,CAvBK;MA0BbzB,MAAM,EAAE;QACNmB,IAAI,EAAE,CADA;QAENO,QAAQ,EAAE,KAFJ;QAGN;QACA;QACAC,UAAU,EAAE;MALN;IA1BK;EAFO,CAAjB,CAAP;AAqCD"}
|
|
@@ -12,4 +12,10 @@ declare enum Targets {
|
|
|
12
12
|
export declare function calcOutputPath(appName: string, target: Targets | keyof typeof Targets): string;
|
|
13
13
|
export declare function clientConfig(): Configuration;
|
|
14
14
|
export declare function ssrConfig(): Configuration;
|
|
15
|
+
export declare function buildConfig({ outputPath }: {
|
|
16
|
+
outputPath: string;
|
|
17
|
+
}): Configuration;
|
|
18
|
+
export declare function ssrBuildConfig({ outputPath }: {
|
|
19
|
+
outputPath: string;
|
|
20
|
+
}): Configuration;
|
|
15
21
|
export {};
|
|
@@ -4,8 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SSR_ENTRY_FILE = exports.PUBLIC_PATH = void 0;
|
|
7
|
+
exports.buildConfig = buildConfig;
|
|
7
8
|
exports.calcOutputPath = calcOutputPath;
|
|
8
9
|
exports.clientConfig = clientConfig;
|
|
10
|
+
exports.ssrBuildConfig = ssrBuildConfig;
|
|
9
11
|
exports.ssrConfig = ssrConfig;
|
|
10
12
|
|
|
11
13
|
function _path() {
|
|
@@ -59,4 +61,31 @@ function ssrConfig() {
|
|
|
59
61
|
};
|
|
60
62
|
}
|
|
61
63
|
|
|
64
|
+
function buildConfig({
|
|
65
|
+
outputPath
|
|
66
|
+
}) {
|
|
67
|
+
return {
|
|
68
|
+
output: {
|
|
69
|
+
path: outputPath,
|
|
70
|
+
publicPath: `/`,
|
|
71
|
+
filename: '[name].[chunkhash].js'
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function ssrBuildConfig({
|
|
77
|
+
outputPath
|
|
78
|
+
}) {
|
|
79
|
+
return {
|
|
80
|
+
target: 'node',
|
|
81
|
+
devtool: 'eval-cheap-source-map',
|
|
82
|
+
output: {
|
|
83
|
+
path: outputPath,
|
|
84
|
+
publicPath: `/`,
|
|
85
|
+
libraryTarget: 'commonjs',
|
|
86
|
+
filename: 'index.js'
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
62
91
|
//# sourceMappingURL=webpack.app.ssr.config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["OUTPUT_FOLDER","SSR_ENTRY_FILE","PUBLIC_PATH","Targets","calcOutputPath","appName","target","join","clientConfig","output","publicPath","filename","ssrConfig","devtool","libraryTarget"],"sources":["webpack.app.ssr.config.ts"],"sourcesContent":["import { join } from 'path';\nimport type { Configuration } from 'webpack';\n\nconst OUTPUT_FOLDER = 'public/bit-apps';\nexport const SSR_ENTRY_FILE = 'index.js';\n/** _external_ base url for static files. (is not a folder)\n * @example\n * \"http://localhost:3000/public/main.88a88d47d86aaabc0230.js\"\n */\nexport const PUBLIC_PATH = '/public';\n\nenum Targets {\n ssr = 'ssr',\n browser = 'browser',\n}\n\nexport function calcOutputPath(appName: string, target: Targets | keyof typeof Targets) {\n return join(OUTPUT_FOLDER, appName, target);\n}\n\nexport function clientConfig(): Configuration {\n return {\n output: { publicPath: PUBLIC_PATH, filename: '[name].[chunkhash].js' },\n };\n}\n\nexport function ssrConfig(): Configuration {\n return {\n target: 'node',\n devtool: 'eval-cheap-source-map',\n\n output: {\n libraryTarget: 'commonjs',\n filename: SSR_ENTRY_FILE,\n },\n };\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["OUTPUT_FOLDER","SSR_ENTRY_FILE","PUBLIC_PATH","Targets","calcOutputPath","appName","target","join","clientConfig","output","publicPath","filename","ssrConfig","devtool","libraryTarget","buildConfig","outputPath","path","ssrBuildConfig"],"sources":["webpack.app.ssr.config.ts"],"sourcesContent":["import { join } from 'path';\nimport type { Configuration } from 'webpack';\n\nconst OUTPUT_FOLDER = 'public/bit-apps';\nexport const SSR_ENTRY_FILE = 'index.js';\n/** _external_ base url for static files. (is not a folder)\n * @example\n * \"http://localhost:3000/public/main.88a88d47d86aaabc0230.js\"\n */\nexport const PUBLIC_PATH = '/public';\n\nenum Targets {\n ssr = 'ssr',\n browser = 'browser',\n}\n\nexport function calcOutputPath(appName: string, target: Targets | keyof typeof Targets) {\n return join(OUTPUT_FOLDER, appName, target);\n}\n\nexport function clientConfig(): Configuration {\n return {\n output: { publicPath: PUBLIC_PATH, filename: '[name].[chunkhash].js' },\n };\n}\n\nexport function ssrConfig(): Configuration {\n return {\n target: 'node',\n devtool: 'eval-cheap-source-map',\n\n output: {\n libraryTarget: 'commonjs',\n filename: SSR_ENTRY_FILE,\n },\n };\n}\n\nexport function buildConfig({ outputPath }: { outputPath: string }): Configuration {\n return {\n output: {\n path: outputPath,\n publicPath: `/`,\n filename: '[name].[chunkhash].js',\n },\n };\n}\n\nexport function ssrBuildConfig({ outputPath }: { outputPath: string }): Configuration {\n return {\n target: 'node',\n devtool: 'eval-cheap-source-map',\n\n output: {\n path: outputPath,\n publicPath: `/`,\n libraryTarget: 'commonjs',\n filename: 'index.js',\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA,MAAMA,aAAa,GAAG,iBAAtB;AACO,MAAMC,cAAc,GAAG,UAAvB;AACP;AACA;AACA;AACA;;;AACO,MAAMC,WAAW,GAAG,SAApB;;IAEFC,O;;WAAAA,O;EAAAA,O;EAAAA,O;GAAAA,O,KAAAA,O;;AAKE,SAASC,cAAT,CAAwBC,OAAxB,EAAyCC,MAAzC,EAAiF;EACtF,OAAO,IAAAC,YAAA,EAAKP,aAAL,EAAoBK,OAApB,EAA6BC,MAA7B,CAAP;AACD;;AAEM,SAASE,YAAT,GAAuC;EAC5C,OAAO;IACLC,MAAM,EAAE;MAAEC,UAAU,EAAER,WAAd;MAA2BS,QAAQ,EAAE;IAArC;EADH,CAAP;AAGD;;AAEM,SAASC,SAAT,GAAoC;EACzC,OAAO;IACLN,MAAM,EAAE,MADH;IAELO,OAAO,EAAE,uBAFJ;IAILJ,MAAM,EAAE;MACNK,aAAa,EAAE,UADT;MAENH,QAAQ,EAAEV;IAFJ;EAJH,CAAP;AASD;;AAEM,SAASc,WAAT,CAAqB;EAAEC;AAAF,CAArB,EAA4E;EACjF,OAAO;IACLP,MAAM,EAAE;MACNQ,IAAI,EAAED,UADA;MAENN,UAAU,EAAG,GAFP;MAGNC,QAAQ,EAAE;IAHJ;EADH,CAAP;AAOD;;AAEM,SAASO,cAAT,CAAwB;EAAEF;AAAF,CAAxB,EAA+E;EACpF,OAAO;IACLV,MAAM,EAAE,MADH;IAELO,OAAO,EAAE,uBAFJ;IAILJ,MAAM,EAAE;MACNQ,IAAI,EAAED,UADA;MAENN,UAAU,EAAG,GAFP;MAGNI,aAAa,EAAE,UAHT;MAINH,QAAQ,EAAE;IAJJ;EAJH,CAAP;AAWD"}
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
+
require("core-js/modules/es.regexp.constructor.js");
|
|
6
|
+
|
|
7
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
8
|
+
|
|
5
9
|
Object.defineProperty(exports, "__esModule", {
|
|
6
10
|
value: true
|
|
7
11
|
});
|
|
@@ -27,6 +31,16 @@ function _lodash() {
|
|
|
27
31
|
return data;
|
|
28
32
|
}
|
|
29
33
|
|
|
34
|
+
function _path() {
|
|
35
|
+
const data = require("path");
|
|
36
|
+
|
|
37
|
+
_path = function () {
|
|
38
|
+
return data;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
|
|
30
44
|
require("style-loader");
|
|
31
45
|
|
|
32
46
|
function _miniCssExtractPlugin() {
|
|
@@ -392,7 +406,7 @@ function _default(isEnvProduction = false) {
|
|
|
392
406
|
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
|
|
393
407
|
// You can remove this if you don't use Moment.js:
|
|
394
408
|
new (_webpack().IgnorePlugin)({
|
|
395
|
-
resourceRegExp:
|
|
409
|
+
resourceRegExp: new RegExp(`^\\.${_path().sep}locale$`),
|
|
396
410
|
contextRegExp: /moment$/
|
|
397
411
|
})].filter(Boolean),
|
|
398
412
|
// Turn off performance processing because we utilize
|