@teambit/react 0.0.553 → 0.0.557

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 (98) hide show
  1. package/dist/mount.d.ts +5 -0
  2. package/dist/react-app-options.d.ts +25 -0
  3. package/dist/react.env.d.ts +87 -1
  4. package/dist/react.main.runtime.d.ts +89 -1
  5. package/package.json +51 -43
  6. package/tsconfig.json +1 -2
  7. package/compositions-app.tsx +0 -31
  8. package/eslint/eslintrc.js +0 -12
  9. package/highlighter-widget.tsx +0 -19
  10. package/index.ts +0 -9
  11. package/jest/css-transform.js +0 -12
  12. package/jest/file-transform.js +0 -38
  13. package/jest/jest.config.js +0 -30
  14. package/jest/setupTests.js +0 -7
  15. package/jest/transformer.js +0 -41
  16. package/mount.tsx +0 -17
  17. package/package-tar/teambit-react-0.0.553.tgz +0 -0
  18. package/prettier/prettier.config.js +0 -5
  19. package/react-app-options.ts +0 -45
  20. package/react.app-type.ts +0 -19
  21. package/react.application.ts +0 -96
  22. package/react.aspect.ts +0 -5
  23. package/react.composition.tsx +0 -7
  24. package/react.docs.mdx +0 -8
  25. package/react.env.ts +0 -363
  26. package/react.graphql.ts +0 -52
  27. package/react.main.runtime.ts +0 -437
  28. package/react.preview.runtime.ts +0 -44
  29. package/react.templates.ts +0 -29
  30. package/react.ui.runtime.tsx +0 -35
  31. package/templates/react-app/files/app-root.ts +0 -10
  32. package/templates/react-app/files/app.ts +0 -30
  33. package/templates/react-app/files/aspect.ts +0 -10
  34. package/templates/react-app/files/compositions.ts +0 -11
  35. package/templates/react-app/files/doc.ts +0 -29
  36. package/templates/react-app/files/index.ts +0 -10
  37. package/templates/react-app/files/main.runtime.ts +0 -22
  38. package/templates/react-app/index.ts +0 -47
  39. package/templates/react-component/files/component.ts +0 -25
  40. package/templates/react-component/files/composition.ts +0 -16
  41. package/templates/react-component/files/docs.ts +0 -32
  42. package/templates/react-component/files/test.ts +0 -19
  43. package/templates/react-component/index.ts +0 -40
  44. package/templates/react-component-js/files/component.ts +0 -18
  45. package/templates/react-component-js/files/composition.ts +0 -16
  46. package/templates/react-component-js/files/docs.ts +0 -32
  47. package/templates/react-component-js/files/test.ts +0 -21
  48. package/templates/react-component-js/index.ts +0 -38
  49. package/templates/react-context/files/composition.ts +0 -27
  50. package/templates/react-context/files/context-provider.ts +0 -27
  51. package/templates/react-context/files/context.ts +0 -21
  52. package/templates/react-context/files/docs.ts +0 -51
  53. package/templates/react-context/files/test.ts +0 -18
  54. package/templates/react-context/index.ts +0 -32
  55. package/templates/react-env/files/aspect.ts +0 -10
  56. package/templates/react-env/files/doc.ts +0 -163
  57. package/templates/react-env/files/index.ts +0 -10
  58. package/templates/react-env/files/jest.config.ts +0 -21
  59. package/templates/react-env/files/main.runtime.ts +0 -84
  60. package/templates/react-env/files/preview.runtime.ts +0 -27
  61. package/templates/react-env/files/typescript.config.ts +0 -21
  62. package/templates/react-env/files/webpack.config.ts +0 -48
  63. package/templates/react-env/index.ts +0 -51
  64. package/templates/react-hook/files/component.ts +0 -16
  65. package/templates/react-hook/files/composition.ts +0 -23
  66. package/templates/react-hook/files/docs.ts +0 -33
  67. package/templates/react-hook/files/test.ts +0 -20
  68. package/templates/react-hook/index.ts +0 -21
  69. package/templates/react-workspace/index.ts +0 -27
  70. package/templates/react-workspace-app/index.ts +0 -20
  71. package/templates/react-workspace-deprecated/index.ts +0 -28
  72. package/templates/react-workspace-lib/index.ts +0 -21
  73. package/templates/workspace-common/files/eslint-config.ts +0 -6
  74. package/templates/workspace-common/files/git-ignore.ts +0 -113
  75. package/templates/workspace-common/files/prettier-config.ts +0 -5
  76. package/templates/workspace-common/files/readme-file.ts +0 -36
  77. package/templates/workspace-common/files/ts-config.ts +0 -7
  78. package/templates/workspace-common/files/types/asset.ts +0 -28
  79. package/templates/workspace-common/files/types/style.ts +0 -43
  80. package/templates/workspace-common/files/workspace-config.ts +0 -58
  81. package/templates/workspace-common/generate-files.ts +0 -51
  82. package/templates/workspace-common/index.ts +0 -1
  83. package/types/asset.d.ts +0 -29
  84. package/types/style.d.ts +0 -42
  85. package/typescript/asset.d.ts +0 -29
  86. package/typescript/style.d.ts +0 -42
  87. package/typescript/tsconfig.build.json +0 -22
  88. package/typescript/tsconfig.json +0 -18
  89. package/webpack/format-webpack-messages.js +0 -102
  90. package/webpack/launch-editor-endpoint.js +0 -8
  91. package/webpack/postcss.config.ts +0 -21
  92. package/webpack/react-hot-dev-client.js +0 -274
  93. package/webpack/refresh.js +0 -16
  94. package/webpack/webpack.config.base.prod.ts +0 -123
  95. package/webpack/webpack.config.base.ts +0 -365
  96. package/webpack/webpack.config.component.dev.ts +0 -104
  97. package/webpack/webpack.config.component.prod.ts +0 -39
  98. package/webpack/webpack.config.env.dev.ts +0 -21
@@ -1,437 +0,0 @@
1
- import mergeDeepLeft from 'ramda/src/mergeDeepLeft';
2
- import { omit } from 'lodash';
3
- import { MainRuntime } from '@teambit/cli';
4
- import type { CompilerMain } from '@teambit/compiler';
5
- import { CompilerAspect, Compiler } from '@teambit/compiler';
6
- import { BuildTask } from '@teambit/builder';
7
- import { Component } from '@teambit/component';
8
- import { EnvsAspect, EnvsMain, EnvTransformer, Environment } from '@teambit/envs';
9
- import type { GraphqlMain } from '@teambit/graphql';
10
- import { GraphqlAspect } from '@teambit/graphql';
11
- import type { JestMain } from '@teambit/jest';
12
- import { JestAspect } from '@teambit/jest';
13
- import type { PkgMain, PackageJsonProps } from '@teambit/pkg';
14
- import { PkgAspect } from '@teambit/pkg';
15
- import type { TesterMain } from '@teambit/tester';
16
- import { TesterAspect } from '@teambit/tester';
17
- import type { TypescriptMain, TsCompilerOptionsWithoutTsConfig, TsConfigTransformer } from '@teambit/typescript';
18
- import { TypescriptAspect } from '@teambit/typescript';
19
- import type { WebpackMain, Configuration, WebpackConfigTransformer } from '@teambit/webpack';
20
- import { WebpackAspect } from '@teambit/webpack';
21
- import { GeneratorAspect, GeneratorMain } from '@teambit/generator';
22
- import { Workspace, WorkspaceAspect } from '@teambit/workspace';
23
- import { DevServerContext, BundlerContext } from '@teambit/bundler';
24
- import { VariantPolicyConfigObject } from '@teambit/dependency-resolver';
25
- import ts from 'typescript';
26
- import { ApplicationAspect, ApplicationMain } from '@teambit/application';
27
- import { FormatterContext } from '@teambit/formatter';
28
- import { LinterContext } from '@teambit/linter';
29
- import { ESLintMain, ESLintAspect, EslintConfigTransformer } from '@teambit/eslint';
30
- import { PrettierMain, PrettierAspect, PrettierConfigTransformer } from '@teambit/prettier';
31
- import { ReactAspect } from './react.aspect';
32
- import { ReactEnv } from './react.env';
33
- import { ReactAppType } from './react.app-type';
34
- import { reactSchema } from './react.graphql';
35
- import { ReactAppOptions } from './react-app-options';
36
- import { ReactApp } from './react.application';
37
- import { componentTemplates, workspaceTemplates } from './react.templates';
38
-
39
- type ReactDeps = [
40
- EnvsMain,
41
- JestMain,
42
- TypescriptMain,
43
- CompilerMain,
44
- WebpackMain,
45
- Workspace,
46
- GraphqlMain,
47
- PkgMain,
48
- TesterMain,
49
- ESLintMain,
50
- PrettierMain,
51
- ApplicationMain,
52
- GeneratorMain
53
- ];
54
-
55
- export type ReactMainConfig = {
56
- /**
57
- * configure the react env compiler.
58
- * can be configured to either TypeScript ('ts') or Babel ('babel').
59
- */
60
- compiler: 'babel' | 'ts';
61
-
62
- /**
63
- * configure the component tester.
64
- * can be either Jest ('jest') or Mocha ('mocha')
65
- */
66
- tester: 'jest' | 'mocha';
67
-
68
- /**
69
- * version of React to configure.
70
- */
71
- reactVersion: string;
72
- };
73
-
74
- export type UseWebpackModifiers = {
75
- previewConfig?: WebpackConfigTransformer[];
76
- devServerConfig?: WebpackConfigTransformer[];
77
- };
78
-
79
- export type UseTypescriptModifiers = {
80
- buildConfig?: TsConfigTransformer[];
81
- devConfig?: TsConfigTransformer[];
82
- };
83
-
84
- export type UseEslintModifiers = {
85
- transformers: EslintConfigTransformer[];
86
- };
87
- export type UsePrettierModifiers = {
88
- transformers: PrettierConfigTransformer[];
89
- };
90
-
91
- export class ReactMain {
92
- constructor(
93
- /**
94
- * an instance of the React env.
95
- */
96
- readonly reactEnv: ReactEnv,
97
-
98
- private envs: EnvsMain,
99
-
100
- private application: ApplicationMain,
101
-
102
- private workspace: Workspace
103
- ) {}
104
-
105
- readonly env = this.reactEnv;
106
-
107
- /**
108
- * override the env's typescript config for both dev and build time.
109
- * Replaces both overrideTsConfig (devConfig) and overrideBuildTsConfig (buildConfig)
110
- */
111
- useTypescript(modifiers?: UseTypescriptModifiers, tsModule: any = ts) {
112
- const overrides: any = {};
113
- const devTransformers = modifiers?.devConfig;
114
- if (devTransformers) {
115
- overrides.getCompiler = () => this.reactEnv.getCompiler(devTransformers, tsModule);
116
- }
117
- const buildTransformers = modifiers?.buildConfig;
118
- if (buildTransformers) {
119
- const buildPipeModifiers = {
120
- tsModifier: {
121
- transformers: buildTransformers,
122
- module: tsModule,
123
- },
124
- };
125
- overrides.getBuildPipe = () => this.reactEnv.getBuildPipe(buildPipeModifiers);
126
- }
127
- return this.envs.override(overrides);
128
- }
129
-
130
- /**
131
- * @deprecated use useTypescript()
132
- * override the TS config of the React environment.
133
- * @param tsModule typeof `ts` module instance.
134
- */
135
- overrideTsConfig(
136
- tsconfig: Record<string, any> = {},
137
- compilerOptions: Partial<TsCompilerOptionsWithoutTsConfig> = {},
138
- tsModule: any = ts
139
- ) {
140
- const transformer: TsConfigTransformer = (configMutator) => {
141
- configMutator.mergeTsConfig(tsconfig);
142
- configMutator.raw.compileJs = compilerOptions.compileJs ?? configMutator.raw.compileJs;
143
- configMutator.raw.compileJsx = compilerOptions.compileJsx ?? configMutator.raw.compileJsx;
144
- if (compilerOptions.types) {
145
- configMutator.addTypes(compilerOptions.types);
146
- }
147
- const genericCompilerOptions = omit(compilerOptions, ['types', 'compileJs', 'compileJsx']);
148
- configMutator.raw = Object.assign(configMutator.raw, genericCompilerOptions);
149
- return configMutator;
150
- };
151
- // return this.envs.override({
152
- // getCompiler: () => this.reactEnv.getCompiler([transformer], tsModule),
153
- // });
154
- return this.useTypescript({ devConfig: [transformer] }, tsModule);
155
- }
156
-
157
- /**
158
- * Override the Bit documentation link. See docs: https://bit.dev/docs/docs/doc-templates
159
- */
160
- overrideDocsTemplate(templatePath: string) {
161
- return this.envs.override({
162
- getDocsTemplate: () => templatePath,
163
- });
164
- }
165
-
166
- /**
167
- * @deprecated use useTypescript()
168
- * override the build tsconfig.
169
- */
170
- overrideBuildTsConfig(
171
- tsconfig: Record<string, any> = {},
172
- compilerOptions: Partial<TsCompilerOptionsWithoutTsConfig> = {},
173
- tsModule: any = ts
174
- ) {
175
- const transformer: TsConfigTransformer = (configMutator) => {
176
- configMutator.mergeTsConfig(tsconfig);
177
- configMutator.raw.compileJs = compilerOptions.compileJs ?? configMutator.raw.compileJs;
178
- configMutator.raw.compileJsx = compilerOptions.compileJsx ?? configMutator.raw.compileJsx;
179
- if (compilerOptions.types) {
180
- configMutator.addTypes(compilerOptions.types);
181
- }
182
- const genericCompilerOptions = omit(compilerOptions, ['types', 'compileJs', 'compileJsx']);
183
- configMutator.raw = Object.assign(configMutator.raw, genericCompilerOptions);
184
- return configMutator;
185
- };
186
- // return this.envs.override({
187
- // getBuildPipe: () => this.reactEnv.getBuildPipe([transformer], tsModule),
188
- // });
189
- return this.useTypescript({ buildConfig: [transformer] }, tsModule);
190
- }
191
-
192
- /**
193
- * register a new React application.
194
- */
195
- registerReactApp(options: ReactAppOptions) {
196
- this.application.registerApp(
197
- new ReactApp(options.name, options.entry, options.portRange || [3000, 4000], this.reactEnv, options.deploy)
198
- );
199
-
200
- return this;
201
- }
202
-
203
- /**
204
- * override the env's dev server and preview webpack configurations.
205
- * Replaces both overrideDevServerConfig and overridePreviewConfig
206
- */
207
- useWebpack(modifiers?: UseWebpackModifiers): EnvTransformer {
208
- const overrides: any = {};
209
- const devServerTransformers = modifiers?.devServerConfig;
210
- if (devServerTransformers) {
211
- overrides.getDevServer = (context: DevServerContext) =>
212
- this.reactEnv.getDevServer(context, devServerTransformers);
213
- overrides.getDevEnvId = (context: DevServerContext) => this.reactEnv.getDevEnvId(context.envDefinition.id);
214
- }
215
- const previewTransformers = modifiers?.previewConfig;
216
- if (previewTransformers) {
217
- overrides.getBundler = (context: BundlerContext) => this.reactEnv.getBundler(context, previewTransformers);
218
- }
219
- return this.envs.override(overrides);
220
- }
221
-
222
- /**
223
- * An API to mutate the prettier config
224
- * @param modifiers
225
- * @returns
226
- */
227
- useEslint(modifiers?: UseEslintModifiers): EnvTransformer {
228
- const transformers = modifiers?.transformers || [];
229
- return this.envs.override({
230
- getLinter: (context: LinterContext) => this.reactEnv.getLinter(context, transformers),
231
- });
232
- }
233
-
234
- /**
235
- * An API to mutate the prettier config
236
- * @param modifiers
237
- * @returns
238
- */
239
- usePrettier(modifiers?: UsePrettierModifiers): EnvTransformer {
240
- const transformers = modifiers?.transformers || [];
241
- return this.envs.override({
242
- getFormatter: (context: FormatterContext) => this.reactEnv.getFormatter(context, transformers),
243
- });
244
- }
245
-
246
- /**
247
- * @deprecated use useWebpack()
248
- * override the dev server webpack config.
249
- */
250
- overrideDevServerConfig(config: Configuration) {
251
- const transformer: WebpackConfigTransformer = (configMutator) => {
252
- return configMutator.merge([config]);
253
- };
254
-
255
- return this.envs.override({
256
- getDevServer: (context: DevServerContext) => this.reactEnv.getDevServer(context, [transformer]),
257
- getDevEnvId: (context: DevServerContext) => this.reactEnv.getDevEnvId(context.envDefinition.id),
258
- });
259
- }
260
-
261
- /**
262
- * @deprecated use useWebpack()
263
- * override the preview webpack config.
264
- */
265
- overridePreviewConfig(config: Configuration) {
266
- const transformer: WebpackConfigTransformer = (configMutator) => {
267
- return configMutator.merge([config]);
268
- };
269
- return this.envs.override({
270
- getBundler: (context: BundlerContext) => this.reactEnv.getBundler(context, [transformer]),
271
- });
272
- }
273
-
274
- overrideMounter(mounterPath: string) {
275
- return this.envs.override({
276
- getMounter: () => {
277
- return mounterPath;
278
- },
279
- });
280
- }
281
-
282
- /**
283
- * create a new composition of the react environment.
284
- */
285
- compose(transformers: EnvTransformer[], targetEnv: Environment = {}) {
286
- return this.envs.compose(this.envs.merge(targetEnv, this.reactEnv), transformers);
287
- }
288
-
289
- /**
290
- * override the jest configuration.
291
- * @param jestConfigPath {typeof jest} absolute path to jest.config.json.
292
- * @param jestModulePath absolute path to jest
293
- */
294
- overrideJestConfig(jestConfigPath: string, jestModulePath?: string) {
295
- return this.envs.override({
296
- getTester: () => this.reactEnv.getTester(jestConfigPath, jestModulePath),
297
- });
298
- }
299
-
300
- /**
301
- * override the build pipeline of the component environment.
302
- */
303
- overrideBuildPipe(tasks: BuildTask[]) {
304
- return this.envs.override({
305
- getBuildPipe: () => tasks,
306
- });
307
- }
308
-
309
- /**
310
- * override the compiler tasks inside the build pipeline of the component environment.
311
- */
312
- overrideCompilerTasks(tasks: BuildTask[]) {
313
- const pipeWithoutCompiler = this.reactEnv.getBuildPipe().filter((task) => task.aspectId !== CompilerAspect.id);
314
-
315
- return this.envs.override({
316
- getBuildPipe: () => [...tasks, ...pipeWithoutCompiler],
317
- });
318
- }
319
-
320
- /**
321
- * override the dependency configuration of the component environment.
322
- */
323
- overrideDependencies(dependencyPolicy: VariantPolicyConfigObject) {
324
- return this.envs.override({
325
- getDependencies: async () => {
326
- const reactDeps = await this.reactEnv.getDependencies();
327
- return mergeDeepLeft(dependencyPolicy, reactDeps);
328
- },
329
- });
330
- }
331
-
332
- /**
333
- * override the workspace compiler.
334
- */
335
- overrideCompiler(compiler: Compiler) {
336
- return this.envs.override({
337
- getCompiler: () => {
338
- return compiler;
339
- },
340
- });
341
- }
342
-
343
- /**
344
- * TODO: @gilad we need to implement this.
345
- */
346
- overrideEslintConfig() {}
347
-
348
- /**
349
- * override the package json props of the component environment.
350
- */
351
- overridePackageJsonProps(props: PackageJsonProps) {
352
- return this.envs.override({
353
- getPackageJsonProps: () => {
354
- return {
355
- ...props,
356
- ...this.reactEnv.getPackageJsonProps(),
357
- };
358
- },
359
- });
360
- }
361
-
362
- /**
363
- * returns doc adjusted specifically for react components.
364
- */
365
- getDocs(component: Component) {
366
- const docsArray = component.state._consumer.docs;
367
- if (!docsArray || !docsArray[0]) {
368
- return null;
369
- }
370
-
371
- const docs = docsArray[0];
372
-
373
- return {
374
- abstract: docs.description,
375
- filePath: docs.filePath,
376
- properties: docs.properties,
377
- };
378
- }
379
-
380
- static runtime = MainRuntime;
381
- static dependencies = [
382
- EnvsAspect,
383
- JestAspect,
384
- TypescriptAspect,
385
- CompilerAspect,
386
- WebpackAspect,
387
- WorkspaceAspect,
388
- GraphqlAspect,
389
- PkgAspect,
390
- TesterAspect,
391
- ESLintAspect,
392
- PrettierAspect,
393
- ApplicationAspect,
394
- GeneratorAspect,
395
- ];
396
-
397
- static async provider(
398
- [
399
- envs,
400
- jestAspect,
401
- tsAspect,
402
- compiler,
403
- webpack,
404
- workspace,
405
- graphql,
406
- pkg,
407
- tester,
408
- eslint,
409
- prettier,
410
- application,
411
- generator,
412
- ]: ReactDeps,
413
- config: ReactMainConfig
414
- ) {
415
- const reactEnv = new ReactEnv(
416
- jestAspect,
417
- tsAspect,
418
- compiler,
419
- webpack,
420
- workspace,
421
- pkg,
422
- tester,
423
- config,
424
- eslint,
425
- prettier
426
- );
427
- const react = new ReactMain(reactEnv, envs, application, workspace);
428
- graphql.register(reactSchema(react));
429
- envs.registerEnv(reactEnv);
430
- generator.registerComponentTemplate(componentTemplates);
431
- generator.registerWorkspaceTemplate(workspaceTemplates);
432
- application.registerAppType(new ReactAppType('react-app', reactEnv));
433
- return react;
434
- }
435
- }
436
-
437
- ReactAspect.addRuntime(ReactMain);
@@ -1,44 +0,0 @@
1
- import { ComponentType } from 'react';
2
- import flatten from 'lodash.flatten';
3
- import { SlotRegistry, Slot } from '@teambit/harmony';
4
- import PreviewAspect, { PreviewPreview, PreviewRuntime } from '@teambit/preview';
5
- import { HighlighterProvider } from '@teambit/react.ui.highlighter-provider';
6
- import { ReactAspect } from './react.aspect';
7
-
8
- export type Provider = ComponentType<{}>;
9
- export type ProviderSlot = SlotRegistry<Provider[]>;
10
-
11
- export class ReactPreview {
12
- constructor(private preview: PreviewPreview, private providerSlot: ProviderSlot) {}
13
-
14
- registerProvider(provider: Provider[]) {
15
- this.providerSlot.register(provider);
16
- }
17
-
18
- getRenderingContext() {
19
- return {
20
- providers: flatten(this.providerSlot.values()),
21
- };
22
- }
23
-
24
- static runtime = PreviewRuntime;
25
-
26
- static slots = [Slot.withType<Provider>()];
27
-
28
- static dependencies = [PreviewAspect];
29
-
30
- static async provider([preview]: [PreviewPreview], config, [providerSlot]: [ProviderSlot]) {
31
- const reactPreview = new ReactPreview(preview, providerSlot);
32
-
33
- reactPreview.registerProvider([HighlighterProvider]);
34
-
35
- preview.registerRenderContext(() => {
36
- return reactPreview.getRenderingContext();
37
- });
38
- return reactPreview;
39
- }
40
- }
41
-
42
- ReactAspect.addRuntime(ReactPreview);
43
-
44
- export default ReactPreview;
@@ -1,29 +0,0 @@
1
- import { ComponentTemplate, WorkspaceTemplate } from '@teambit/generator';
2
- import { reactComponent, deprecatedReactComponent } from './templates/react-component';
3
- import { reactComponentJS, deprecatedReactComponentJS } from './templates/react-component-js';
4
- import { reactEnvTemplate } from './templates/react-env';
5
- import { deprecatedReactWorkspaceTemplate } from './templates/react-workspace-deprecated';
6
- import { reactHook } from './templates/react-hook';
7
- import { reactContext } from './templates/react-context';
8
- import { reactAppTemplate } from './templates/react-app';
9
- import { reactWorkspaceTemplate } from './templates/react-workspace';
10
- import { reactWorkspaceAppTemplate } from './templates/react-workspace-app';
11
- import { reactWorkspaceLibTemplate } from './templates/react-workspace-lib';
12
-
13
- export const componentTemplates: ComponentTemplate[] = [
14
- reactComponent,
15
- reactContext,
16
- reactHook,
17
- reactComponentJS,
18
- reactEnvTemplate,
19
- reactAppTemplate,
20
- deprecatedReactComponent,
21
- deprecatedReactComponentJS,
22
- ];
23
-
24
- export const workspaceTemplates: WorkspaceTemplate[] = [
25
- reactWorkspaceTemplate,
26
- reactWorkspaceAppTemplate,
27
- reactWorkspaceLibTemplate,
28
- deprecatedReactWorkspaceTemplate,
29
- ];
@@ -1,35 +0,0 @@
1
- import React from 'react';
2
- import { CompositionsAspect, CompositionsUI } from '@teambit/compositions';
3
- import { UIRuntime } from '@teambit/ui';
4
- import { TesterAspect, TesterUI } from '@teambit/tester';
5
- import { AddingTests } from '@teambit/react.instructions.react.adding-tests';
6
- import { AddingCompositions } from '@teambit/react.instructions.react.adding-compositions';
7
- import { ReactAspect } from './react.aspect';
8
- import { HighlighterWidget } from './highlighter-widget';
9
-
10
- export class ReactUI {
11
- static runtime = UIRuntime;
12
- static slots = [];
13
- static dependencies = [CompositionsAspect, TesterAspect];
14
-
15
- static async provider([compositionsUI, testerUi]: [CompositionsUI, TesterUI]) {
16
- const reactUI = new ReactUI();
17
- testerUi.registerEmptyState(() => {
18
- return <AddingTests />;
19
- });
20
- compositionsUI.registerEmptyState(() => {
21
- return <AddingCompositions />;
22
- });
23
-
24
- compositionsUI.registerMenuWidget({
25
- location: 'start',
26
- content: <HighlighterWidget />,
27
- });
28
-
29
- return reactUI;
30
- }
31
- }
32
-
33
- ReactAspect.addRuntime(ReactUI);
34
-
35
- export default ReactUI;
@@ -1,10 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function appRootFile({ namePascalCase: Name }: ComponentContext) {
4
- return `import React from 'react';
5
- import ReactDOM from 'react-dom';
6
- import { ${Name}App } from './app';
7
-
8
- ReactDOM.render(<${Name}App />, document.getElementById('root'));
9
- `;
10
- }
@@ -1,30 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function appFile({ namePascalCase: Name }: ComponentContext) {
4
- return `import React from 'react';
5
- import { BrowserRouter, Switch, Route } from 'react-router-dom';
6
-
7
- export function ${Name}App() {
8
- return (
9
- <BrowserRouter>
10
-
11
- {/* header component */}
12
-
13
- <Switch>
14
- <Route path="/">
15
- {/* home page component */}
16
- </Route>
17
-
18
- <Route path="/about">
19
- {/* about page component */}
20
- </Route>
21
-
22
- </Switch>
23
-
24
- {/* footer component */}
25
-
26
- </BrowserRouter>
27
- );
28
- }
29
- `;
30
- }
@@ -1,10 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function aspectFile({ name, namePascalCase: Name }: ComponentContext) {
4
- return `import { Aspect } from '@teambit/harmony';
5
-
6
- export const ${Name}Aspect = Aspect.create({
7
- id: 'YourOrgName.YourScopeName/namespace?/${name}'
8
- });
9
- `;
10
- }
@@ -1,11 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function compositionsFile({ namePascalCase: Name }: ComponentContext) {
4
- return `import React from 'react';
5
- import { ${Name}App } from './app';
6
-
7
- export const ${Name}Basic = () => {
8
- return <${Name}App></${Name}App>;
9
- };
10
- `;
11
- }
@@ -1,29 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function docFile({ name }: ComponentContext) {
4
- return `---
5
- description: Application.
6
- labels: ['env', 'app']
7
- ---
8
-
9
- ## Application component
10
-
11
- - The app file contains components from react router dom so you can add here all routes for your app and include all your page components.
12
- - The main runtime file contains what is needed to build your application as a React app.
13
- - The app root file renders your app to the DOM.
14
- - The compositions file renders your app so it can be seen in the compositions tab.
15
- - The aspect file contains the id of the aspect. You will need to modify this with your own org name, scope name and namespace if any, and then add it to your \`workspace.json\` file at root level like:
16
-
17
- \`\`\`json
18
- "org-name.scope-name/namespace/name": {},
19
- \`\`\`
20
-
21
- ### Run the application
22
-
23
- You can run your application on a separate port to see it outside of the Bit workspace
24
-
25
- \`\`\`bash
26
- bit run ${name}
27
- \`\`\`
28
- `;
29
- }
@@ -1,10 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function indexFile({ name, namePascalCase: Name }: ComponentContext) {
4
- return `import { ${Name}Aspect } from './${name}.aspect';
5
-
6
- export type { ${Name}Main } from './${name}.main.runtime';
7
- export default ${Name}Aspect;
8
- export { ${Name}Aspect };
9
- `;
10
- }
@@ -1,22 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function mainRuntimeFile({ name, namePascalCase: Name }: ComponentContext) {
4
- return `import { MainRuntime } from '@teambit/cli';
5
- import { ReactAspect, ReactMain } from '@teambit/react';
6
- import { ${Name}Aspect } from './${name}.aspect';
7
-
8
- export class ${Name}Main {
9
- static slots = [];
10
- static dependencies = [ReactAspect];
11
- static runtime = MainRuntime;
12
- static async provider([react]: [ReactMain]) {
13
- react.registerReactApp({
14
- name: '${name}',
15
- entry: ['dist/${name}.app-root']
16
- });
17
- return new ${Name}Main();
18
- }
19
- }
20
- ${Name}Aspect.addRuntime(${Name}Main);
21
- `;
22
- }