@teambit/react 0.0.554 → 0.0.555

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/mount.d.ts CHANGED
@@ -1,4 +1,9 @@
1
1
  import React from 'react';
2
2
  import { RenderingContext } from '@teambit/preview';
3
3
  declare const _default: (Composition: React.ComponentType, previewContext: RenderingContext) => void;
4
+ /**
5
+ * this mounts compositions into the DOM in the component preview.
6
+ * this function can be overridden through ReactAspect.overrideCompositionsMounter() API
7
+ * to apply custom logic for component DOM mounting.
8
+ */
4
9
  export default _default;
@@ -1,12 +1,37 @@
1
1
  import { Bundler, DevServer } from '@teambit/bundler';
2
2
  import { DeployContext } from '@teambit/application';
3
3
  export declare type ReactAppOptions = {
4
+ /**
5
+ * name of the application.
6
+ */
4
7
  name: string;
8
+ /**
9
+ * path to entry files of the application.
10
+ */
5
11
  entry: string[];
12
+ /**
13
+ * use server-side rendering for the app.
14
+ */
6
15
  ssr?: boolean;
16
+ /**
17
+ * instance of bundler to use.
18
+ */
7
19
  bundler?: Bundler;
20
+ /**
21
+ * instance of dev server to use.
22
+ */
8
23
  devServer?: DevServer;
24
+ /**
25
+ * deploy function.
26
+ */
9
27
  deploy?: (context: DeployContext) => Promise<void>;
28
+ /**
29
+ * prerender routes of application (will create static file for the route)
30
+ * e.g ['/plugins', '/learn', '/docs/quick-start]
31
+ */
10
32
  prerenderRoutes?: string[];
33
+ /**
34
+ * ranges of ports to use to run the app server.
35
+ */
11
36
  portRange?: number[];
12
37
  };
@@ -19,38 +19,121 @@ export declare const AspectEnvType = "react";
19
19
  declare type GetBuildPipeModifiers = PipeServiceModifiersMap & {
20
20
  tsModifier?: PipeServiceModifier;
21
21
  };
22
+ /**
23
+ * a component environment built for [React](https://reactjs.org) .
24
+ */
22
25
  export declare class ReactEnv implements TesterEnv, CompilerEnv, LinterEnv, DevEnv, BuilderEnv, DependenciesEnv, PackageEnv, FormatterEnv {
26
+ /**
27
+ * jest extension
28
+ */
23
29
  private jestAspect;
30
+ /**
31
+ * typescript extension.
32
+ */
24
33
  private tsAspect;
34
+ /**
35
+ * compiler extension.
36
+ */
25
37
  private compiler;
38
+ /**
39
+ * webpack extension.
40
+ */
26
41
  private webpack;
42
+ /**
43
+ * workspace extension.
44
+ */
27
45
  private workspace;
46
+ /**
47
+ * pkg extension.
48
+ */
28
49
  private pkg;
50
+ /**
51
+ * tester extension
52
+ */
29
53
  private tester;
30
54
  private config;
31
55
  private eslint;
32
56
  private prettier;
33
- constructor(jestAspect: JestMain, tsAspect: TypescriptMain, compiler: CompilerMain, webpack: WebpackMain, workspace: Workspace, pkg: PkgMain, tester: TesterMain, config: ReactMainConfig, eslint: ESLintMain, prettier: PrettierMain);
57
+ constructor(
58
+ /**
59
+ * jest extension
60
+ */
61
+ jestAspect: JestMain,
62
+ /**
63
+ * typescript extension.
64
+ */
65
+ tsAspect: TypescriptMain,
66
+ /**
67
+ * compiler extension.
68
+ */
69
+ compiler: CompilerMain,
70
+ /**
71
+ * webpack extension.
72
+ */
73
+ webpack: WebpackMain,
74
+ /**
75
+ * workspace extension.
76
+ */
77
+ workspace: Workspace,
78
+ /**
79
+ * pkg extension.
80
+ */
81
+ pkg: PkgMain,
82
+ /**
83
+ * tester extension
84
+ */
85
+ tester: TesterMain, config: ReactMainConfig, eslint: ESLintMain, prettier: PrettierMain);
34
86
  getTsConfig(targetTsConfig?: TsConfigSourceFile): TsConfigSourceFile;
35
87
  getBuildTsConfig(targetTsConfig?: TsConfigSourceFile): TsConfigSourceFile;
88
+ /**
89
+ * returns a component tester.
90
+ */
36
91
  getTester(jestConfigPath: string, jestModulePath?: string): Tester;
37
92
  private getTsCompilerOptions;
38
93
  private getTsCompiler;
39
94
  getCompiler(transformers?: TsConfigTransformer[], tsModule?: typeof ts): import("@teambit/compiler").Compiler;
95
+ /**
96
+ * returns and configures the component linter.
97
+ */
40
98
  getLinter(context: LinterContext, transformers?: EslintConfigTransformer[]): Linter;
99
+ /**
100
+ * returns and configures the component formatter.
101
+ */
41
102
  getFormatter(context: FormatterContext, transformers?: PrettierConfigTransformer[]): Formatter;
42
103
  private getFileMap;
43
104
  private writeFileMap;
105
+ /**
106
+ * required for `bit start`
107
+ */
44
108
  getDevEnvId(id?: string): string;
109
+ /**
110
+ * get a schema generator instance configured with the correct tsconfig.
111
+ */
45
112
  getSchemaExtractor(tsconfig: TsConfigSourceFile): SchemaExtractor;
113
+ /**
114
+ * returns and configures the React component dev server.
115
+ * required for `bit start`
116
+ */
46
117
  getDevServer(context: DevServerContext, transformers?: WebpackConfigTransformer[]): DevServer;
47
118
  getBundler(context: BundlerContext, transformers?: WebpackConfigTransformer[]): Promise<Bundler>;
48
119
  private getComponentsModulesDirectories;
49
120
  private getEntriesFromWebpackConfig;
121
+ /**
122
+ * returns a path to a docs template.
123
+ */
50
124
  getDocsTemplate(): string;
51
125
  icon: string;
126
+ /**
127
+ * returns a paths to a function which mounts a given component to DOM
128
+ */
52
129
  getMounter(): string;
130
+ /**
131
+ * define the package json properties to add to each component.
132
+ */
53
133
  getPackageJsonProps(): import("@teambit/pkg").PackageJsonProps;
134
+ /**
135
+ * adds dependencies to all configured components.
136
+ */
54
137
  getDependencies(): {
55
138
  dependencies: {
56
139
  react: string;
@@ -73,6 +156,9 @@ export declare class ReactEnv implements TesterEnv, CompilerEnv, LinterEnv, DevE
73
156
  'react-dom': string;
74
157
  };
75
158
  };
159
+ /**
160
+ * returns the component build pipeline.
161
+ */
76
162
  getBuildPipe(modifiers?: GetBuildPipeModifiers): BuildTask[];
77
163
  private getCompilerTask;
78
164
  __getDescriptor(): Promise<{
@@ -33,8 +33,19 @@ declare type ReactDeps = [
33
33
  GeneratorMain
34
34
  ];
35
35
  export declare type ReactMainConfig = {
36
+ /**
37
+ * configure the react env compiler.
38
+ * can be configured to either TypeScript ('ts') or Babel ('babel').
39
+ */
36
40
  compiler: 'babel' | 'ts';
41
+ /**
42
+ * configure the component tester.
43
+ * can be either Jest ('jest') or Mocha ('mocha')
44
+ */
37
45
  tester: 'jest' | 'mocha';
46
+ /**
47
+ * version of React to configure.
48
+ */
38
49
  reactVersion: string;
39
50
  };
40
51
  export declare type UseWebpackModifiers = {
@@ -52,31 +63,108 @@ export declare type UsePrettierModifiers = {
52
63
  transformers: PrettierConfigTransformer[];
53
64
  };
54
65
  export declare class ReactMain {
66
+ /**
67
+ * an instance of the React env.
68
+ */
55
69
  readonly reactEnv: ReactEnv;
56
70
  private envs;
57
71
  private application;
58
72
  private workspace;
59
- constructor(reactEnv: ReactEnv, envs: EnvsMain, application: ApplicationMain, workspace: Workspace);
73
+ constructor(
74
+ /**
75
+ * an instance of the React env.
76
+ */
77
+ reactEnv: ReactEnv, envs: EnvsMain, application: ApplicationMain, workspace: Workspace);
60
78
  readonly env: ReactEnv;
79
+ /**
80
+ * override the env's typescript config for both dev and build time.
81
+ * Replaces both overrideTsConfig (devConfig) and overrideBuildTsConfig (buildConfig)
82
+ */
61
83
  useTypescript(modifiers?: UseTypescriptModifiers, tsModule?: any): EnvTransformer;
84
+ /**
85
+ * @deprecated use useTypescript()
86
+ * override the TS config of the React environment.
87
+ * @param tsModule typeof `ts` module instance.
88
+ */
62
89
  overrideTsConfig(tsconfig?: Record<string, any>, compilerOptions?: Partial<TsCompilerOptionsWithoutTsConfig>, tsModule?: any): EnvTransformer;
90
+ /**
91
+ * Override the Bit documentation link. See docs: https://bit.dev/docs/docs/doc-templates
92
+ */
63
93
  overrideDocsTemplate(templatePath: string): EnvTransformer;
94
+ /**
95
+ * @deprecated use useTypescript()
96
+ * override the build tsconfig.
97
+ */
64
98
  overrideBuildTsConfig(tsconfig?: Record<string, any>, compilerOptions?: Partial<TsCompilerOptionsWithoutTsConfig>, tsModule?: any): EnvTransformer;
99
+ /**
100
+ * register a new React application.
101
+ */
65
102
  registerReactApp(options: ReactAppOptions): this;
103
+ /**
104
+ * override the env's dev server and preview webpack configurations.
105
+ * Replaces both overrideDevServerConfig and overridePreviewConfig
106
+ */
66
107
  useWebpack(modifiers?: UseWebpackModifiers): EnvTransformer;
108
+ /**
109
+ * An API to mutate the prettier config
110
+ * @param modifiers
111
+ * @returns
112
+ */
67
113
  useEslint(modifiers?: UseEslintModifiers): EnvTransformer;
114
+ /**
115
+ * An API to mutate the prettier config
116
+ * @param modifiers
117
+ * @returns
118
+ */
68
119
  usePrettier(modifiers?: UsePrettierModifiers): EnvTransformer;
120
+ /**
121
+ * @deprecated use useWebpack()
122
+ * override the dev server webpack config.
123
+ */
69
124
  overrideDevServerConfig(config: Configuration): EnvTransformer;
125
+ /**
126
+ * @deprecated use useWebpack()
127
+ * override the preview webpack config.
128
+ */
70
129
  overridePreviewConfig(config: Configuration): EnvTransformer;
71
130
  overrideMounter(mounterPath: string): EnvTransformer;
131
+ /**
132
+ * create a new composition of the react environment.
133
+ */
72
134
  compose(transformers: EnvTransformer[], targetEnv?: Environment): Environment;
135
+ /**
136
+ * override the jest configuration.
137
+ * @param jestConfigPath {typeof jest} absolute path to jest.config.json.
138
+ * @param jestModulePath absolute path to jest
139
+ */
73
140
  overrideJestConfig(jestConfigPath: string, jestModulePath?: string): EnvTransformer;
141
+ /**
142
+ * override the build pipeline of the component environment.
143
+ */
74
144
  overrideBuildPipe(tasks: BuildTask[]): EnvTransformer;
145
+ /**
146
+ * override the compiler tasks inside the build pipeline of the component environment.
147
+ */
75
148
  overrideCompilerTasks(tasks: BuildTask[]): EnvTransformer;
149
+ /**
150
+ * override the dependency configuration of the component environment.
151
+ */
76
152
  overrideDependencies(dependencyPolicy: VariantPolicyConfigObject): EnvTransformer;
153
+ /**
154
+ * override the workspace compiler.
155
+ */
77
156
  overrideCompiler(compiler: Compiler): EnvTransformer;
157
+ /**
158
+ * TODO: @gilad we need to implement this.
159
+ */
78
160
  overrideEslintConfig(): void;
161
+ /**
162
+ * override the package json props of the component environment.
163
+ */
79
164
  overridePackageJsonProps(props: PackageJsonProps): EnvTransformer;
165
+ /**
166
+ * returns doc adjusted specifically for react components.
167
+ */
80
168
  getDocs(component: Component): {
81
169
  abstract: any;
82
170
  filePath: any;
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/react",
3
- "version": "0.0.554",
3
+ "version": "0.0.555",
4
4
  "homepage": "https://bit.dev/teambit/react/react",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.react",
8
8
  "name": "react",
9
- "version": "0.0.554"
9
+ "version": "0.0.555"
10
10
  },
11
11
  "dependencies": {
12
12
  "react-error-boundary": "^3.0.0",
@@ -79,46 +79,46 @@
79
79
  "@teambit/react.instructions.react.adding-compositions": "0.0.6",
80
80
  "@teambit/react.instructions.react.adding-tests": "0.0.6",
81
81
  "@teambit/design.ui.pages.standalone-not-found-page": "0.0.354",
82
- "@teambit/preview": "0.0.554",
83
- "@teambit/react.ui.error-fallback": "0.0.86",
84
- "@teambit/react.ui.loader-fallback": "0.0.64",
85
- "@teambit/compositions.ui.hooks.use-composition": "0.0.139",
82
+ "@teambit/preview": "0.0.555",
83
+ "@teambit/react.ui.error-fallback": "0.0.87",
84
+ "@teambit/react.ui.loader-fallback": "0.0.65",
85
+ "@teambit/compositions.ui.hooks.use-composition": "0.0.140",
86
86
  "@teambit/design.ui.input.option-button": "0.0.26",
87
87
  "@teambit/design.ui.tooltip": "0.0.352",
88
- "@teambit/application": "0.0.196",
89
- "@teambit/bundler": "0.0.554",
90
- "@teambit/builder": "0.0.554",
91
- "@teambit/isolator": "0.0.554",
92
- "@teambit/toolbox.network.get-port": "0.0.89",
93
- "@teambit/compiler": "0.0.554",
94
- "@teambit/component.modules.component-url": "0.0.96",
95
- "@teambit/component": "0.0.554",
96
- "@teambit/envs": "0.0.554",
97
- "@teambit/eslint": "0.0.554",
98
- "@teambit/formatter": "0.0.105",
99
- "@teambit/jest": "0.0.554",
100
- "@teambit/linter": "0.0.554",
101
- "@teambit/pkg": "0.0.554",
102
- "@teambit/prettier": "0.0.105",
103
- "@teambit/react.babel.bit-react-transformer": "0.0.469",
104
- "@teambit/schema": "0.0.554",
105
- "@teambit/tester": "0.0.554",
106
- "@teambit/typescript": "0.0.554",
107
- "@teambit/webpack": "0.0.554",
108
- "@teambit/workspace": "0.0.554",
109
- "@teambit/cli": "0.0.385",
110
- "@teambit/dependency-resolver": "0.0.554",
111
- "@teambit/generator": "0.0.554",
112
- "@teambit/graphql": "0.0.554",
113
- "@teambit/react.ui.highlighter-provider": "0.0.149",
114
- "@teambit/compositions": "0.0.554",
115
- "@teambit/ui": "0.0.554",
116
- "@teambit/react.eslint-config-bit-react": "0.0.462",
117
- "@teambit/mdx.modules.mdx-loader": "0.0.463",
118
- "@teambit/webpack.modules.generate-style-loaders": "0.0.79",
119
- "@teambit/webpack.modules.style-regexps": "0.0.108",
120
- "@teambit/component-id": "0.0.375",
121
- "@teambit/config": "0.0.396"
88
+ "@teambit/application": "0.0.197",
89
+ "@teambit/bundler": "0.0.555",
90
+ "@teambit/builder": "0.0.555",
91
+ "@teambit/isolator": "0.0.555",
92
+ "@teambit/toolbox.network.get-port": "0.0.90",
93
+ "@teambit/compiler": "0.0.555",
94
+ "@teambit/component.modules.component-url": "0.0.97",
95
+ "@teambit/component": "0.0.555",
96
+ "@teambit/envs": "0.0.555",
97
+ "@teambit/eslint": "0.0.555",
98
+ "@teambit/formatter": "0.0.106",
99
+ "@teambit/jest": "0.0.555",
100
+ "@teambit/linter": "0.0.555",
101
+ "@teambit/pkg": "0.0.555",
102
+ "@teambit/prettier": "0.0.106",
103
+ "@teambit/react.babel.bit-react-transformer": "0.0.470",
104
+ "@teambit/schema": "0.0.555",
105
+ "@teambit/tester": "0.0.555",
106
+ "@teambit/typescript": "0.0.555",
107
+ "@teambit/webpack": "0.0.555",
108
+ "@teambit/workspace": "0.0.555",
109
+ "@teambit/cli": "0.0.386",
110
+ "@teambit/dependency-resolver": "0.0.555",
111
+ "@teambit/generator": "0.0.555",
112
+ "@teambit/graphql": "0.0.555",
113
+ "@teambit/react.ui.highlighter-provider": "0.0.150",
114
+ "@teambit/compositions": "0.0.555",
115
+ "@teambit/ui": "0.0.555",
116
+ "@teambit/react.eslint-config-bit-react": "0.0.463",
117
+ "@teambit/mdx.modules.mdx-loader": "0.0.464",
118
+ "@teambit/webpack.modules.generate-style-loaders": "0.0.80",
119
+ "@teambit/webpack.modules.style-regexps": "0.0.109",
120
+ "@teambit/component-id": "0.0.376",
121
+ "@teambit/config": "0.0.397"
122
122
  },
123
123
  "devDependencies": {
124
124
  "@types/react": "^17.0.8",
@@ -133,10 +133,10 @@
133
133
  "@types/mocha": "5.2.7",
134
134
  "@types/testing-library__jest-dom": "5.9.5",
135
135
  "@types/jest": "^26.0.0",
136
- "@teambit/react.aspect-docs.react": "0.0.104"
136
+ "@teambit/react.aspect-docs.react": "0.0.105"
137
137
  },
138
138
  "peerDependencies": {
139
- "@teambit/legacy": "1.0.171",
139
+ "@teambit/legacy": "1.0.172",
140
140
  "react-dom": "^16.8.0 || ^17.0.0",
141
141
  "react": "^16.8.0 || ^17.0.0"
142
142
  },
@@ -198,7 +198,7 @@
198
198
  "@types/jest": "^26.0.0"
199
199
  },
200
200
  "peerDependencies": {
201
- "@teambit/legacy": "1.0.171",
201
+ "@teambit/legacy": "1.0.172",
202
202
  "react-dom": "^16.8.0 || ^17.0.0",
203
203
  "react": "^16.8.0 || ^17.0.0"
204
204
  }
package/tsconfig.json CHANGED
@@ -25,7 +25,6 @@
25
25
  "strict": true,
26
26
  "noImplicitAny": false,
27
27
  "rootDir": ".",
28
- "removeComments": true,
29
28
  "preserveConstEnums": true,
30
29
  "resolveJsonModule": true
31
30
  },