@teambit/react 0.0.621 → 0.0.629

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.
Files changed (90) hide show
  1. package/__compositions-1642994756471.js +7 -0
  2. package/__overview-1642994756471.js +7 -0
  3. package/__preview-1642994756471.js +2 -0
  4. package/apps/web/deploy-context.ts +4 -0
  5. package/apps/web/index.ts +3 -0
  6. package/apps/web/react-app-options.ts +3 -3
  7. package/apps/web/react-build-result.ts +9 -0
  8. package/apps/web/react.application.ts +32 -34
  9. package/artifacts/env-template/public/141.js +1 -0
  10. package/artifacts/env-template/public/181.js +1 -0
  11. package/artifacts/env-template/public/283.js +1 -0
  12. package/artifacts/env-template/public/664.js +128 -0
  13. package/artifacts/env-template/public/743.js +1 -0
  14. package/artifacts/env-template/public/848.js +1 -0
  15. package/artifacts/env-template/public/assets-manifest.json +74 -0
  16. package/artifacts/env-template/public/compositions.68fc39172cbc486d5064.js +1 -0
  17. package/artifacts/env-template/public/compositions.html +2 -0
  18. package/artifacts/env-template/public/overview.8ab165bb03610b2e8c5b.js +1 -0
  19. package/artifacts/env-template/public/overview.html +2 -0
  20. package/artifacts/env-template/public/peers.23d97726152f744ec115.js +1 -0
  21. package/artifacts/env-template/public/preview-root.b33a2fef3cb8fc3d6479.js +1 -0
  22. package/artifacts/env-template/public/runtime.js +1 -0
  23. package/artifacts/env-template/public/service-worker.js +1 -0
  24. package/artifacts/env-template/public/static/css/664.50460623.css +1 -0
  25. package/artifacts/env-template/public/static/css/compositions.cd8be53f.css +1 -0
  26. package/artifacts/env-template/public/static/css/overview.71e25e30.css +1 -0
  27. package/artifacts/env-template/public/static/css/previewRoot.5ad41161.css +1 -0
  28. package/artifacts/env-template/public/workbox-ca45de73.js +1 -0
  29. package/artifacts/preview/teambit_react_react-preview.js +1 -0
  30. package/dist/apps/web/deploy-context.d.ts +3 -0
  31. package/dist/apps/web/deploy-context.js +3 -0
  32. package/dist/apps/web/deploy-context.js.map +1 -0
  33. package/dist/apps/web/index.d.ts +3 -0
  34. package/dist/apps/web/index.js +23 -0
  35. package/dist/apps/web/index.js.map +1 -0
  36. package/dist/apps/web/react-app-options.d.ts +2 -3
  37. package/dist/apps/web/react-app-options.js +0 -10
  38. package/dist/apps/web/react-app-options.js.map +1 -1
  39. package/dist/apps/web/react-build-result.d.ts +8 -0
  40. package/dist/apps/web/react-build-result.js +3 -0
  41. package/dist/apps/web/react-build-result.js.map +1 -0
  42. package/dist/apps/web/react.application.d.ts +7 -7
  43. package/dist/apps/web/react.application.js +41 -29
  44. package/dist/apps/web/react.application.js.map +1 -1
  45. package/dist/index.d.ts +1 -1
  46. package/dist/index.js.map +1 -1
  47. package/dist/react.env.d.ts +10 -1
  48. package/dist/react.env.js +60 -8
  49. package/dist/react.env.js.map +1 -1
  50. package/dist/react.main.runtime.js +11 -11
  51. package/dist/react.main.runtime.js.map +1 -1
  52. package/dist/templates/react-app/files/app-root.js +7 -1
  53. package/dist/templates/react-app/files/app-root.js.map +1 -1
  54. package/dist/templates/react-app/files/compositions.js +1 -1
  55. package/dist/templates/react-app/files/compositions.js.map +1 -1
  56. package/dist/templates/workspace-common/files/workspace-config.js +1 -1
  57. package/dist/templates/workspace-common/files/workspace-config.js.map +1 -1
  58. package/dist/webpack/get-exposed-rules.d.ts +2 -0
  59. package/dist/webpack/get-exposed-rules.js +50 -0
  60. package/dist/webpack/get-exposed-rules.js.map +1 -0
  61. package/dist/webpack/get-externals.d.ts +1 -0
  62. package/dist/webpack/get-externals.js +42 -0
  63. package/dist/webpack/get-externals.js.map +1 -0
  64. package/dist/webpack/html.d.ts +2 -0
  65. package/dist/webpack/html.js +31 -0
  66. package/dist/webpack/html.js.map +1 -0
  67. package/dist/webpack/index.d.ts +1 -0
  68. package/dist/webpack/index.js +23 -0
  69. package/dist/webpack/index.js.map +1 -0
  70. package/dist/webpack/transformers.d.ts +2 -0
  71. package/dist/webpack/transformers.js +19 -0
  72. package/dist/webpack/transformers.js.map +1 -0
  73. package/dist/webpack/webpack.config.base.js +3 -5
  74. package/dist/webpack/webpack.config.base.js.map +1 -1
  75. package/dist/webpack/webpack.config.base.prod.d.ts +1 -1
  76. package/dist/webpack/webpack.config.base.prod.js +101 -80
  77. package/dist/webpack/webpack.config.base.prod.js.map +1 -1
  78. package/package-tar/teambit-react-0.0.629.tgz +0 -0
  79. package/package.json +38 -36
  80. package/templates/react-app/files/app-root.ts +7 -1
  81. package/templates/react-app/files/compositions.ts +1 -1
  82. package/templates/workspace-common/files/workspace-config.ts +1 -1
  83. package/webpack/get-exposed-rules.ts +12 -0
  84. package/webpack/get-externals.ts +8 -0
  85. package/webpack/html.ts +22 -0
  86. package/webpack/index.ts +1 -0
  87. package/webpack/transformers.ts +12 -0
  88. package/webpack/webpack.config.base.prod.ts +99 -81
  89. package/webpack/webpack.config.base.ts +3 -5
  90. package/package-tar/teambit-react-0.0.621.tgz +0 -0
@@ -0,0 +1,7 @@
1
+
2
+ import { linkModules } from '/home/circleci/bit/bit/node_modules/@teambit/preview/dist/preview.preview.runtime.js';
3
+ import harmony from '/home/circleci/bit/bit/node_modules/@teambit/harmony/dist/index.js';
4
+ const defaultModule = require('/home/circleci/bit/bit/node_modules/@teambit/react/dist/mount.js');
5
+ linkModules('compositions', defaultModule, true, {
6
+
7
+ });
@@ -0,0 +1,7 @@
1
+
2
+ import { linkModules } from '/home/circleci/bit/bit/node_modules/@teambit/preview/dist/preview.preview.runtime.js';
3
+ import harmony from '/home/circleci/bit/bit/node_modules/@teambit/harmony/dist/index.js';
4
+ const defaultModule = require('/home/circleci/bit/bit/node_modules/@teambit/react.ui.docs-app/dist/index.js');
5
+ linkModules('overview', defaultModule, true, {
6
+
7
+ });
@@ -0,0 +1,2 @@
1
+ export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.react_react@0.0.629/dist/react.composition.js')]
2
+ export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.react_react@0.0.629/dist/react.docs.mdx')]
@@ -0,0 +1,4 @@
1
+ import { AppDeployContext } from '@teambit/application';
2
+ import { ReactAppBuildResult } from './react-build-result';
3
+
4
+ export type ReactDeployContext = ReactAppBuildResult & AppDeployContext;
@@ -0,0 +1,3 @@
1
+ export { ReactAppType } from './react.app-type';
2
+ export type { ReactDeployContext } from './deploy-context';
3
+ export type { ReactAppOptions } from './react-app-options';
@@ -1,8 +1,8 @@
1
1
  import { Bundler, DevServer } from '@teambit/bundler';
2
- import { DeployContext } from '@teambit/application';
3
- import { Capsule } from '@teambit/isolator';
4
2
  import { WebpackConfigTransformer } from '@teambit/webpack';
5
3
 
4
+ import { ReactDeployContext } from './deploy-context';
5
+
6
6
  export type ReactAppOptions = {
7
7
  /**
8
8
  * name of the application.
@@ -45,7 +45,7 @@ export type ReactAppOptions = {
45
45
  /**
46
46
  * deploy function.
47
47
  */
48
- deploy?: (context: DeployContext, Capsule: Capsule) => Promise<void>;
48
+ deploy?: (context: ReactDeployContext) => Promise<void>;
49
49
 
50
50
  /**
51
51
  * ranges of ports to use to run the app server.
@@ -0,0 +1,9 @@
1
+ import { AppBuildResult } from '@teambit/application';
2
+
3
+ export type ReactAppBuildResult = {
4
+ /**
5
+ * the directory which includes the built application public assets.
6
+ * when using ssr, public dir is undefined.
7
+ */
8
+ publicDir?: string;
9
+ } & AppBuildResult;
@@ -1,12 +1,13 @@
1
1
  import { join, basename } from 'path';
2
- import { Capsule } from '@teambit/isolator';
3
- import { Application, AppContext, AppBuildResult, DeployContext } from '@teambit/application';
4
- import { ArtifactDefinition, BuildContext } from '@teambit/builder';
5
- import { Bundler, DevServer, BundlerResult, BundlerContext, DevServerContext } from '@teambit/bundler';
2
+ import { Application, AppContext, AppBuildContext } from '@teambit/application';
3
+ import { Bundler, DevServer, BundlerContext, DevServerContext, BundlerHtmlConfig } from '@teambit/bundler';
6
4
  import { Port } from '@teambit/toolbox.network.get-port';
7
5
  import { WebpackConfigTransformer } from '@teambit/webpack';
8
6
  import { ReactEnv } from '../../react.env';
9
7
  import { prerenderSPAPlugin } from './plugins';
8
+ import { ReactAppBuildResult } from './react-build-result';
9
+ import { html } from '../../webpack';
10
+ import { ReactDeployContext } from '.';
10
11
 
11
12
  export class ReactApp implements Application {
12
13
  constructor(
@@ -18,10 +19,11 @@ export class ReactApp implements Application {
18
19
  readonly bundler?: Bundler,
19
20
  readonly devServer?: DevServer,
20
21
  readonly transformers?: WebpackConfigTransformer[],
21
- readonly deploy?: (context: DeployContext, capsule: Capsule) => Promise<void>
22
+ readonly deploy?: (context: ReactDeployContext) => Promise<void>
22
23
  ) {}
23
24
 
24
25
  readonly applicationType = 'react-common-js';
26
+ readonly dir = 'public';
25
27
  async run(context: AppContext): Promise<number> {
26
28
  const [from, to] = this.portRange;
27
29
  const port = await Port.getPort(from, to);
@@ -49,36 +51,33 @@ export class ReactApp implements Application {
49
51
  return port;
50
52
  }
51
53
 
52
- async build(context: BuildContext, capsule: Capsule): Promise<AppBuildResult> {
53
- const bundler = await this.getBundler(context, capsule);
54
- const bundlerResult = await bundler.run();
55
- const artifacts: ArtifactDefinition[] = this.getBlobPatterns(bundlerResult);
56
- const deployContext: AppBuildResult = Object.assign(context, { artifacts });
57
- return deployContext;
58
- }
59
-
60
- private getBlobPatterns(bundlerResults: BundlerResult[]) {
61
- const _globs = bundlerResults.map((result) => {
62
- if (!result.outputPath) return undefined;
63
- return {
64
- name: 'CommonJS',
65
- globPatterns: [`${this.getPublicDir()}/**`],
66
- };
67
- });
68
- return _globs.filter((glob) => !!glob) as ArtifactDefinition[];
54
+ async build(context: AppBuildContext): Promise<ReactAppBuildResult> {
55
+ const htmlConfig: BundlerHtmlConfig[] = [
56
+ {
57
+ title: context.name,
58
+ templateContent: html(context.name),
59
+ minify: false,
60
+ // filename: ''.html`,
61
+ },
62
+ ];
63
+ Object.assign(context, { html: htmlConfig });
64
+ const bundler = await this.getBundler(context);
65
+ await bundler.run();
66
+ return { publicDir: `${this.getPublicDir()}/${this.dir}` };
69
67
  }
70
68
 
71
- private getBundler(context: BuildContext, capsule: Capsule) {
69
+ private getBundler(context: AppBuildContext) {
72
70
  if (this.bundler) return this.bundler;
73
- return this.getDefaultBundler(context, capsule);
71
+ return this.getDefaultBundler(context);
74
72
  }
75
- private async getDefaultBundler(context: BuildContext, capsule: Capsule) {
73
+ private async getDefaultBundler(context: AppBuildContext) {
74
+ const { capsule } = context;
76
75
  const reactEnv: ReactEnv = context.env;
77
76
  const publicDir = this.getPublicDir();
78
77
  const outputPath = join(capsule.path, publicDir);
79
78
  const { distDir } = reactEnv.getCompiler();
80
79
  const entries = this.entry.map((entry) => require.resolve(`${capsule.path}/${distDir}/${basename(entry)}`));
81
- const staticDir = join(outputPath, 'public');
80
+ const staticDir = join(outputPath, this.dir);
82
81
 
83
82
  const bundlerContext: BundlerContext = Object.assign(context, {
84
83
  targets: [
@@ -92,14 +91,13 @@ export class ReactApp implements Application {
92
91
  rootPath: '/',
93
92
  });
94
93
 
95
- const bundler: Bundler = await reactEnv.getBundler(bundlerContext, [
96
- (configMutator) => {
97
- if (this.transformers?.length) configMutator.addPlugin(this.transformers);
98
- configMutator.addTopLevel('output', { path: staticDir, publicPath: `/` });
99
- if (this.prerenderRoutes) configMutator.addPlugin(prerenderSPAPlugin(this.prerenderRoutes, staticDir));
100
- return configMutator;
101
- },
102
- ]);
94
+ const defaultTransformer: WebpackConfigTransformer = (configMutator) => {
95
+ const config = configMutator.addTopLevel('output', { path: staticDir, publicPath: `/` });
96
+ if (this.prerenderRoutes) config.addPlugin(prerenderSPAPlugin(this.prerenderRoutes, staticDir));
97
+ return config;
98
+ };
99
+ const transformers = [defaultTransformer, ...(this.transformers ?? [])];
100
+ const bundler: Bundler = await reactEnv.getBundler(bundlerContext, transformers);
103
101
  return bundler;
104
102
  }
105
103