@teambit/react 1.0.41 → 1.0.43
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/artifacts/env-template/public/{29.aabccd461805a58cd99a.js → 29.4f04dfbd91dbb8c799d1.js} +20 -20
- package/artifacts/env-template/public/{238.64be32cc6d4bc396b35e.js → 293.4bce474b96c9eb955917.js} +4 -4
- package/artifacts/env-template/public/assets-manifest.json +14 -14
- package/artifacts/env-template/public/{compositions.b6446d022ddef607b2fb.js → compositions.41e4853de81dfc859051.js} +1 -1
- package/artifacts/env-template/public/compositions.html +1 -1
- package/artifacts/env-template/public/{overview.536d77e3d6f68d0ddf21.js → overview.94f37bd549c676ac5677.js} +1 -1
- package/artifacts/env-template/public/overview.html +1 -1
- package/artifacts/env-template/public/{peers.777d86ba769cf02b788f.js → peers.24438ad67cb125c83d75.js} +1 -1
- package/artifacts/env-template/public/{preview-root.983463c786334e1fbaf1.js → preview-root.3b62d04b3a7f234bd8ca.js} +1 -1
- package/artifacts/env-template/public/static/css/{29.1c2448c7.css → 29.a178b2ff.css} +1 -1
- package/dist/apps/web/ssr/ssr-express.js +2 -2
- package/dist/apps/web/ssr/ssr-express.js.map +1 -1
- package/dist/apps/web/webpack/webpack.app.ssr.config.js +2 -4
- package/dist/apps/web/webpack/webpack.app.ssr.config.js.map +1 -1
- package/dist/{preview-1698981534427.js → preview-1699369416537.js} +2 -2
- package/dist/react.aspect.js +2 -4
- package/dist/react.aspect.js.map +1 -1
- package/dist/react.env.js +2 -3
- package/dist/react.env.js.map +1 -1
- package/dist/react.main.runtime.d.ts +5 -2
- package/dist/react.main.runtime.js +18 -3
- package/dist/react.main.runtime.js.map +1 -1
- package/dist/react.preview.runtime.js +3 -4
- package/dist/react.preview.runtime.js.map +1 -1
- package/dist/react.templates.d.ts +2 -1
- package/dist/react.templates.js +21 -36
- package/dist/react.templates.js.map +1 -1
- package/dist/react.ui.runtime.js +1 -2
- package/dist/react.ui.runtime.js.map +1 -1
- package/dist/webpack/postcss.config.js +1 -2
- package/dist/webpack/postcss.config.js.map +1 -1
- package/dist/webpack/webpack.config.base.js +2 -2
- package/dist/webpack/webpack.config.base.js.map +1 -1
- package/package.json +46 -44
- package/dist/templates/react-app/files/app-plugin.d.ts +0 -2
- package/dist/templates/react-app/files/app-plugin.js +0 -17
- package/dist/templates/react-app/files/app-plugin.js.map +0 -1
- package/dist/templates/react-app/files/app-root.d.ts +0 -2
- package/dist/templates/react-app/files/app-root.js +0 -24
- package/dist/templates/react-app/files/app-root.js.map +0 -1
- package/dist/templates/react-app/files/app.d.ts +0 -2
- package/dist/templates/react-app/files/app.js +0 -34
- package/dist/templates/react-app/files/app.js.map +0 -1
- package/dist/templates/react-app/files/compositions.d.ts +0 -2
- package/dist/templates/react-app/files/compositions.js +0 -24
- package/dist/templates/react-app/files/compositions.js.map +0 -1
- package/dist/templates/react-app/files/doc.d.ts +0 -2
- package/dist/templates/react-app/files/doc.js +0 -33
- package/dist/templates/react-app/files/doc.js.map +0 -1
- package/dist/templates/react-app/files/index.d.ts +0 -2
- package/dist/templates/react-app/files/index.js +0 -13
- package/dist/templates/react-app/files/index.js.map +0 -1
- package/dist/templates/react-app/index.d.ts +0 -2
- package/dist/templates/react-app/index.js +0 -84
- package/dist/templates/react-app/index.js.map +0 -1
- package/dist/templates/react-component/files/component.d.ts +0 -5
- package/dist/templates/react-component/files/component.js +0 -35
- package/dist/templates/react-component/files/component.js.map +0 -1
- package/dist/templates/react-component/files/composition.d.ts +0 -5
- package/dist/templates/react-component/files/composition.js +0 -27
- package/dist/templates/react-component/files/composition.js.map +0 -1
- package/dist/templates/react-component/files/docs.d.ts +0 -5
- package/dist/templates/react-component/files/docs.js +0 -37
- package/dist/templates/react-component/files/docs.js.map +0 -1
- package/dist/templates/react-component/files/index-file.d.ts +0 -5
- package/dist/templates/react-component/files/index-file.js +0 -21
- package/dist/templates/react-component/files/index-file.js.map +0 -1
- package/dist/templates/react-component/files/test.d.ts +0 -5
- package/dist/templates/react-component/files/test.js +0 -28
- package/dist/templates/react-component/files/test.js.map +0 -1
- package/dist/templates/react-component/index.d.ts +0 -3
- package/dist/templates/react-component/index.js +0 -68
- package/dist/templates/react-component/index.js.map +0 -1
- package/dist/templates/react-component-js/files/component.d.ts +0 -5
- package/dist/templates/react-component-js/files/component.js +0 -28
- package/dist/templates/react-component-js/files/component.js.map +0 -1
- package/dist/templates/react-component-js/files/composition.d.ts +0 -5
- package/dist/templates/react-component-js/files/composition.js +0 -25
- package/dist/templates/react-component-js/files/composition.js.map +0 -1
- package/dist/templates/react-component-js/files/docs.d.ts +0 -5
- package/dist/templates/react-component-js/files/docs.js +0 -41
- package/dist/templates/react-component-js/files/docs.js.map +0 -1
- package/dist/templates/react-component-js/files/test.d.ts +0 -5
- package/dist/templates/react-component-js/files/test.js +0 -30
- package/dist/templates/react-component-js/files/test.js.map +0 -1
- package/dist/templates/react-component-js/index.d.ts +0 -3
- package/dist/templates/react-component-js/index.js +0 -70
- package/dist/templates/react-component-js/index.js.map +0 -1
- package/dist/templates/react-context/files/composition.d.ts +0 -5
- package/dist/templates/react-context/files/composition.js +0 -36
- package/dist/templates/react-context/files/composition.js.map +0 -1
- package/dist/templates/react-context/files/context-provider.d.ts +0 -5
- package/dist/templates/react-context/files/context-provider.js +0 -37
- package/dist/templates/react-context/files/context-provider.js.map +0 -1
- package/dist/templates/react-context/files/context.d.ts +0 -5
- package/dist/templates/react-context/files/context.js +0 -31
- package/dist/templates/react-context/files/context.js.map +0 -1
- package/dist/templates/react-context/files/docs.d.ts +0 -5
- package/dist/templates/react-context/files/docs.js +0 -60
- package/dist/templates/react-context/files/docs.js.map +0 -1
- package/dist/templates/react-context/files/index-file.d.ts +0 -5
- package/dist/templates/react-context/files/index-file.js +0 -23
- package/dist/templates/react-context/files/index-file.js.map +0 -1
- package/dist/templates/react-context/files/test.d.ts +0 -5
- package/dist/templates/react-context/files/test.js +0 -26
- package/dist/templates/react-context/files/test.js.map +0 -1
- package/dist/templates/react-context/index.d.ts +0 -2
- package/dist/templates/react-context/index.js +0 -65
- package/dist/templates/react-context/index.js.map +0 -1
- package/dist/templates/react-env/files/aspect.d.ts +0 -2
- package/dist/templates/react-env/files/aspect.js +0 -19
- package/dist/templates/react-env/files/aspect.js.map +0 -1
- package/dist/templates/react-env/files/doc.d.ts +0 -2
- package/dist/templates/react-env/files/doc.js +0 -186
- package/dist/templates/react-env/files/doc.js.map +0 -1
- package/dist/templates/react-env/files/index.d.ts +0 -2
- package/dist/templates/react-env/files/index.js +0 -19
- package/dist/templates/react-env/files/index.js.map +0 -1
- package/dist/templates/react-env/files/jest.config.d.ts +0 -1
- package/dist/templates/react-env/files/jest.config.js +0 -29
- package/dist/templates/react-env/files/jest.config.js.map +0 -1
- package/dist/templates/react-env/files/main.runtime.d.ts +0 -2
- package/dist/templates/react-env/files/main.runtime.js +0 -103
- package/dist/templates/react-env/files/main.runtime.js.map +0 -1
- package/dist/templates/react-env/files/preview.runtime.d.ts +0 -2
- package/dist/templates/react-env/files/preview.runtime.js +0 -37
- package/dist/templates/react-env/files/preview.runtime.js.map +0 -1
- package/dist/templates/react-env/files/typescript/styles.d.ts +0 -1
- package/dist/templates/react-env/files/typescript/styles.js +0 -15
- package/dist/templates/react-env/files/typescript/styles.js.map +0 -1
- package/dist/templates/react-env/files/typescript/ts-transformer.d.ts +0 -1
- package/dist/templates/react-env/files/typescript/ts-transformer.js +0 -58
- package/dist/templates/react-env/files/typescript/ts-transformer.js.map +0 -1
- package/dist/templates/react-env/files/typescript/typescript.config.d.ts +0 -1
- package/dist/templates/react-env/files/typescript/typescript.config.js +0 -29
- package/dist/templates/react-env/files/typescript/typescript.config.js.map +0 -1
- package/dist/templates/react-env/files/webpack.config.d.ts +0 -1
- package/dist/templates/react-env/files/webpack.config.js +0 -56
- package/dist/templates/react-env/files/webpack.config.js.map +0 -1
- package/dist/templates/react-env/index.d.ts +0 -2
- package/dist/templates/react-env/index.js +0 -124
- package/dist/templates/react-env/index.js.map +0 -1
- package/dist/templates/react-hook/files/component.d.ts +0 -5
- package/dist/templates/react-hook/files/component.js +0 -26
- package/dist/templates/react-hook/files/component.js.map +0 -1
- package/dist/templates/react-hook/files/composition.d.ts +0 -5
- package/dist/templates/react-hook/files/composition.js +0 -32
- package/dist/templates/react-hook/files/composition.js.map +0 -1
- package/dist/templates/react-hook/files/docs.d.ts +0 -5
- package/dist/templates/react-hook/files/docs.js +0 -42
- package/dist/templates/react-hook/files/docs.js.map +0 -1
- package/dist/templates/react-hook/files/index-file.d.ts +0 -5
- package/dist/templates/react-hook/files/index-file.js +0 -20
- package/dist/templates/react-hook/files/index-file.js.map +0 -1
- package/dist/templates/react-hook/files/index-file.spec.d.ts +0 -1
- package/dist/templates/react-hook/files/index-file.spec.js +0 -36
- package/dist/templates/react-hook/files/index-file.spec.js.map +0 -1
- package/dist/templates/react-hook/files/test.d.ts +0 -5
- package/dist/templates/react-hook/files/test.js +0 -29
- package/dist/templates/react-hook/files/test.js.map +0 -1
- package/dist/templates/react-hook/index.d.ts +0 -2
- package/dist/templates/react-hook/index.js +0 -58
- package/dist/templates/react-hook/index.js.map +0 -1
- package/templates/react-app/files/app-plugin.ts +0 -9
- package/templates/react-app/files/app-root.ts +0 -16
- package/templates/react-app/files/app.ts +0 -26
- package/templates/react-app/files/compositions.ts +0 -16
- package/templates/react-app/files/doc.ts +0 -23
- package/templates/react-app/files/index.ts +0 -5
- package/templates/react-app/index.ts +0 -48
- package/templates/react-component/files/component.ts +0 -25
- package/templates/react-component/files/composition.ts +0 -18
- package/templates/react-component/files/docs.ts +0 -28
- package/templates/react-component/files/index-file.ts +0 -12
- package/templates/react-component/files/test.ts +0 -19
- package/templates/react-component/index.ts +0 -27
- package/templates/react-component-js/files/component.ts +0 -18
- package/templates/react-component-js/files/composition.ts +0 -16
- package/templates/react-component-js/files/docs.ts +0 -32
- package/templates/react-component-js/files/test.ts +0 -21
- package/templates/react-component-js/index.ts +0 -32
- package/templates/react-context/files/composition.ts +0 -27
- package/templates/react-context/files/context-provider.ts +0 -27
- package/templates/react-context/files/context.ts +0 -21
- package/templates/react-context/files/docs.ts +0 -51
- package/templates/react-context/files/index-file.ts +0 -14
- package/templates/react-context/files/test.ts +0 -18
- package/templates/react-context/index.ts +0 -29
- package/templates/react-env/files/aspect.ts +0 -10
- package/templates/react-env/files/doc.ts +0 -177
- package/templates/react-env/files/index.ts +0 -10
- package/templates/react-env/files/jest.config.ts +0 -21
- package/templates/react-env/files/main.runtime.ts +0 -94
- package/templates/react-env/files/preview.runtime.ts +0 -27
- package/templates/react-env/files/typescript/styles.ts +0 -7
- package/templates/react-env/files/typescript/ts-transformer.ts +0 -50
- package/templates/react-env/files/typescript/typescript.config.ts +0 -21
- package/templates/react-env/files/webpack.config.ts +0 -48
- package/templates/react-env/index.ts +0 -68
- package/templates/react-hook/files/component.ts +0 -16
- package/templates/react-hook/files/composition.ts +0 -23
- package/templates/react-hook/files/docs.ts +0 -33
- package/templates/react-hook/files/index-file.spec.ts +0 -24
- package/templates/react-hook/files/index-file.ts +0 -11
- package/templates/react-hook/files/test.ts +0 -20
- package/templates/react-hook/index.ts +0 -21
- /package/{compositions-1698981534427.js → compositions-1699369416537.js} +0 -0
- /package/{overview-1698981534427.js → overview-1699369416537.js} +0 -0
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export function mainRuntimeFile({ namePascalCase: Name, name }: ComponentContext) {
|
|
4
|
-
return `import { MainRuntime } from '@teambit/cli';
|
|
5
|
-
import { ReactAspect, ReactMain, UseTypescriptModifiers } from '@teambit/react';
|
|
6
|
-
import { EnvsAspect, EnvsMain } from '@teambit/envs';
|
|
7
|
-
import { ${Name}Aspect } from './${name}.aspect';
|
|
8
|
-
//import {
|
|
9
|
-
// previewConfigTransformer,
|
|
10
|
-
// devServerConfigTransformer
|
|
11
|
-
//} from './webpack/webpack-transformers';
|
|
12
|
-
//import {
|
|
13
|
-
// devConfigTransformer,
|
|
14
|
-
// buildConfigTransformer,
|
|
15
|
-
//} from "./typescript/ts-transformer";
|
|
16
|
-
|
|
17
|
-
export class ${Name}Main {
|
|
18
|
-
static slots = [];
|
|
19
|
-
|
|
20
|
-
static dependencies = [ReactAspect, EnvsAspect];
|
|
21
|
-
|
|
22
|
-
static runtime = MainRuntime;
|
|
23
|
-
|
|
24
|
-
static async provider([react, envs]: [ReactMain, EnvsMain]) {
|
|
25
|
-
|
|
26
|
-
//const webpackModifiers: UseWebpackModifiers = {
|
|
27
|
-
// previewConfig: [previewConfigTransformer],
|
|
28
|
-
// devServerConfig: [devServerConfigTransformer],
|
|
29
|
-
//};
|
|
30
|
-
|
|
31
|
-
//const tsModifiers: UseTypescriptModifiers = {
|
|
32
|
-
// devConfig: [devConfigTransformer],
|
|
33
|
-
// buildConfig: [buildConfigTransformer],
|
|
34
|
-
//};
|
|
35
|
-
|
|
36
|
-
const ${Name}Env = react.compose([
|
|
37
|
-
/**
|
|
38
|
-
* Uncomment to override the config files for TypeScript, Webpack or Jest
|
|
39
|
-
* Your config gets merged with the defaults
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
// react.useTypescript(tsModifiers), // note: this cannot be used in conjunction with react.overrideCompiler
|
|
43
|
-
// react.useWebpack(webpackModifiers),
|
|
44
|
-
// react.overrideJestConfig(require.resolve('./jest/jest.config')),
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* override the ESLint default config here then check your files for lint errors
|
|
48
|
-
* @example
|
|
49
|
-
* bit lint
|
|
50
|
-
* bit lint --fix
|
|
51
|
-
*/
|
|
52
|
-
//react.useEslint({
|
|
53
|
-
// transformers: [
|
|
54
|
-
// (config) => {
|
|
55
|
-
// config.setRule('no-console', ['error']);
|
|
56
|
-
// return config;
|
|
57
|
-
// }
|
|
58
|
-
// ]
|
|
59
|
-
//}),
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* override the Prettier default config here the check your formatting
|
|
63
|
-
* @example
|
|
64
|
-
* bit format --check
|
|
65
|
-
* bit format
|
|
66
|
-
*/
|
|
67
|
-
//react.usePrettier({
|
|
68
|
-
// transformers: [
|
|
69
|
-
// (config) => {
|
|
70
|
-
// config.setKey('tabWidth', 2);
|
|
71
|
-
// return config;
|
|
72
|
-
// }
|
|
73
|
-
// ]
|
|
74
|
-
//}),
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* override dependencies here
|
|
78
|
-
* @example
|
|
79
|
-
* Uncomment types to include version 17.0.3 of the types package
|
|
80
|
-
*/
|
|
81
|
-
react.overrideDependencies({
|
|
82
|
-
devDependencies: {
|
|
83
|
-
// '@types/react': '17.0.3'
|
|
84
|
-
}
|
|
85
|
-
})
|
|
86
|
-
]);
|
|
87
|
-
envs.registerEnv(${Name}Env);
|
|
88
|
-
return new ${Name}Main();
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
${Name}Aspect.addRuntime(${Name}Main);
|
|
93
|
-
`;
|
|
94
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export function previewRuntimeFile({ namePascalCase: Name, nameCamelCase: nameCamel, name }: ComponentContext) {
|
|
4
|
-
return `import { PreviewRuntime } from '@teambit/preview';
|
|
5
|
-
import { ReactAspect, ReactPreview } from '@teambit/react';
|
|
6
|
-
// uncomment the line below and install the theme if you want to use our theme or create your own and import it here
|
|
7
|
-
// import { ThemeCompositions } from '@teambit/documenter.theme.theme-compositions';
|
|
8
|
-
|
|
9
|
-
import { ${Name}Aspect } from './${name}.aspect';
|
|
10
|
-
|
|
11
|
-
export class ${Name}PreviewMain {
|
|
12
|
-
static runtime = PreviewRuntime;
|
|
13
|
-
|
|
14
|
-
static dependencies = [ReactAspect];
|
|
15
|
-
|
|
16
|
-
static async provider([react]: [ReactPreview]) {
|
|
17
|
-
const ${nameCamel}PreviewMain = new ${Name}PreviewMain();
|
|
18
|
-
// uncomment the line below to register a new provider to wrap all compositions using this environment with a custom theme.
|
|
19
|
-
// react.registerProvider([ThemeCompositions]);
|
|
20
|
-
|
|
21
|
-
return ${nameCamel}PreviewMain;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
${Name}Aspect.addRuntime(${Name}PreviewMain);
|
|
26
|
-
`;
|
|
27
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
export function tsTransformerFile() {
|
|
2
|
-
return `
|
|
3
|
-
import * as path from 'path';
|
|
4
|
-
import {
|
|
5
|
-
TsConfigTransformer,
|
|
6
|
-
TypescriptConfigMutator,
|
|
7
|
-
} from "@teambit/typescript";
|
|
8
|
-
|
|
9
|
-
const tsConfig = require('./tsconfig.json');
|
|
10
|
-
|
|
11
|
-
export const commonTransformer: TsConfigTransformer = (
|
|
12
|
-
config: TypescriptConfigMutator
|
|
13
|
-
) => {
|
|
14
|
-
const newConfig = config.addTypes([path.join(__dirname, 'styles.d.ts')])
|
|
15
|
-
newConfig.mergeTsConfig(tsConfig);
|
|
16
|
-
// Some examples of other built in mutator functions:
|
|
17
|
-
//newConfig.addExclude(['someExclude']);
|
|
18
|
-
//newConfig.setCompileJs(true)
|
|
19
|
-
return newConfig;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Transformation for the dev config only
|
|
24
|
-
* @param config
|
|
25
|
-
* @param context
|
|
26
|
-
* @returns
|
|
27
|
-
*/
|
|
28
|
-
export const devConfigTransformer: TsConfigTransformer = (
|
|
29
|
-
config: TypescriptConfigMutator,
|
|
30
|
-
) => {
|
|
31
|
-
const newConfig = commonTransformer(config, {});
|
|
32
|
-
return newConfig;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Transformation for the build only
|
|
37
|
-
* @param config
|
|
38
|
-
* @param context
|
|
39
|
-
* @returns
|
|
40
|
-
*/
|
|
41
|
-
export const buildConfigTransformer: TsConfigTransformer = (
|
|
42
|
-
config: TypescriptConfigMutator
|
|
43
|
-
) => {
|
|
44
|
-
const newConfig = commonTransformer(config, {});
|
|
45
|
-
newConfig.mergeTsConfig(tsConfig);
|
|
46
|
-
return newConfig;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
`;
|
|
50
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export function typescriptConfigFile() {
|
|
2
|
-
return `{
|
|
3
|
-
// add your compiler options here
|
|
4
|
-
|
|
5
|
-
"compilerOptions": {
|
|
6
|
-
// "target": "es2017",
|
|
7
|
-
// "module": "es2015",
|
|
8
|
-
// "moduleResolution": "node",
|
|
9
|
-
// "lib": ["es2017", "dom"],
|
|
10
|
-
// "experimentalDecorators": true,
|
|
11
|
-
// "esModuleInterop": true,
|
|
12
|
-
// "outDir": "dist",
|
|
13
|
-
// "sourceMap": true,
|
|
14
|
-
// "emitDecoratorMetadata": true,
|
|
15
|
-
// "allowJs": true,
|
|
16
|
-
// "baseUrl": ".",
|
|
17
|
-
// "jsx": "react"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
`;
|
|
21
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export function webpackConfigFile() {
|
|
2
|
-
return `
|
|
3
|
-
import { WebpackConfigTransformer, WebpackConfigMutator, WebpackConfigTransformContext } from '@teambit/webpack';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Transformation to apply for both preview and dev server
|
|
7
|
-
* @param config
|
|
8
|
-
* @param _context
|
|
9
|
-
*/
|
|
10
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11
|
-
function commonTransformation(config: WebpackConfigMutator, _context: WebpackConfigTransformContext) {
|
|
12
|
-
// Merge config with the webpack.config.js file if you choose to import a module export format config.
|
|
13
|
-
// config.merge([webpackConfig]);
|
|
14
|
-
// config.addAliases({});
|
|
15
|
-
// config.addModuleRule(youRuleHere);
|
|
16
|
-
return config;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Transformation for the preview only
|
|
21
|
-
* @param config
|
|
22
|
-
* @param context
|
|
23
|
-
* @returns
|
|
24
|
-
*/
|
|
25
|
-
export const previewConfigTransformer: WebpackConfigTransformer = (
|
|
26
|
-
config: WebpackConfigMutator,
|
|
27
|
-
context: WebpackConfigTransformContext
|
|
28
|
-
) => {
|
|
29
|
-
const newConfig = commonTransformation(config, context);
|
|
30
|
-
return newConfig;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Transformation for the dev server only
|
|
35
|
-
* @param config
|
|
36
|
-
* @param context
|
|
37
|
-
* @returns
|
|
38
|
-
*/
|
|
39
|
-
export const devServerConfigTransformer: WebpackConfigTransformer = (
|
|
40
|
-
config: WebpackConfigMutator,
|
|
41
|
-
context: WebpackConfigTransformContext
|
|
42
|
-
) => {
|
|
43
|
-
const newConfig = commonTransformation(config, context);
|
|
44
|
-
return newConfig;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
`;
|
|
48
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { ComponentContext, ComponentTemplate } from '@teambit/generator';
|
|
2
|
-
import { indexFile } from './files/index';
|
|
3
|
-
import { docFile } from './files/doc';
|
|
4
|
-
import { mainRuntimeFile } from './files/main.runtime';
|
|
5
|
-
import { previewRuntimeFile } from './files/preview.runtime';
|
|
6
|
-
import { aspectFile } from './files/aspect';
|
|
7
|
-
import { webpackConfigFile } from './files/webpack.config';
|
|
8
|
-
import { typescriptConfigFile } from './files/typescript/typescript.config';
|
|
9
|
-
import { globalStylesFile } from './files/typescript/styles';
|
|
10
|
-
import { tsTransformerFile } from './files/typescript/ts-transformer';
|
|
11
|
-
import { jestConfigFile } from './files/jest.config';
|
|
12
|
-
|
|
13
|
-
export const reactEnvTemplate: ComponentTemplate = {
|
|
14
|
-
name: 'react-env',
|
|
15
|
-
description: 'customize the base React env with your configs and tools',
|
|
16
|
-
hidden: true,
|
|
17
|
-
generateFiles: (context: ComponentContext) => {
|
|
18
|
-
return [
|
|
19
|
-
{
|
|
20
|
-
relativePath: 'index.ts',
|
|
21
|
-
content: indexFile(context),
|
|
22
|
-
isMain: true,
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
relativePath: `${context.name}.docs.mdx`,
|
|
26
|
-
content: docFile(context),
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
relativePath: `${context.name}.main.runtime.ts`,
|
|
30
|
-
content: mainRuntimeFile(context),
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
relativePath: `${context.name}.preview.runtime.ts`,
|
|
34
|
-
content: previewRuntimeFile(context),
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
relativePath: `${context.name}.aspect.ts`,
|
|
38
|
-
content: aspectFile(context),
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
relativePath: `webpack/webpack-transformers.ts`,
|
|
42
|
-
content: webpackConfigFile(),
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
relativePath: `typescript/tsconfig.json`,
|
|
46
|
-
content: typescriptConfigFile(),
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
relativePath: `typescript/styles.d.ts`,
|
|
50
|
-
content: globalStylesFile(),
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
relativePath: `typescript/ts-transformer.ts`,
|
|
54
|
-
content: tsTransformerFile(),
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
relativePath: `jest/jest.config.js`,
|
|
58
|
-
content: jestConfigFile(),
|
|
59
|
-
},
|
|
60
|
-
];
|
|
61
|
-
},
|
|
62
|
-
config: {
|
|
63
|
-
'teambit.envs/env': {},
|
|
64
|
-
'teambit.envs/envs': {
|
|
65
|
-
env: 'teambit.envs/env',
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export const componentFile = (context: ComponentContext) => {
|
|
4
|
-
const { name, nameCamelCase: Name } = context;
|
|
5
|
-
return {
|
|
6
|
-
relativePath: `${name}.tsx`,
|
|
7
|
-
content: `import { useState } from 'react';
|
|
8
|
-
|
|
9
|
-
export function ${Name}() {
|
|
10
|
-
const [count, setCount] = useState(0)
|
|
11
|
-
const increment = () => setCount((c) => c + 1)
|
|
12
|
-
return { count, increment }
|
|
13
|
-
}
|
|
14
|
-
`,
|
|
15
|
-
};
|
|
16
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export const compositionFile = (context: ComponentContext) => {
|
|
4
|
-
const { name, nameCamelCase: Name } = context;
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
relativePath: `${name}.composition.tsx`,
|
|
8
|
-
content: `import React from 'react';
|
|
9
|
-
import { ${Name} } from './${name}';
|
|
10
|
-
|
|
11
|
-
export const Basic${Name} = () => {
|
|
12
|
-
const { count, increment } = ${Name}();
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<>
|
|
16
|
-
<h1>The count is {count}</h1>
|
|
17
|
-
<button onClick={increment}>increment</button>
|
|
18
|
-
</>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
21
|
-
`,
|
|
22
|
-
};
|
|
23
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export const docsFile = (context: ComponentContext) => {
|
|
4
|
-
const { name, nameCamelCase: Name } = context;
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
relativePath: `${name}.docs.mdx`,
|
|
8
|
-
content: `---
|
|
9
|
-
description: 'A React Hook that increments a count by 1 each time it is called.'
|
|
10
|
-
labels: ['hook', 'counter']
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
import { ${Name} } from './${name}';
|
|
14
|
-
|
|
15
|
-
## A React Hook to increment a count
|
|
16
|
-
|
|
17
|
-
Increments the state of \`count\` by 1 each time \`increment\` is called
|
|
18
|
-
|
|
19
|
-
### Component usage
|
|
20
|
-
|
|
21
|
-
In this example clicking the button calls \`increment\` which increments the \`count\` by 1
|
|
22
|
-
|
|
23
|
-
\`\`\`js
|
|
24
|
-
import { ${Name} } from './${name}';
|
|
25
|
-
|
|
26
|
-
const { count, increment } = ${Name}();
|
|
27
|
-
|
|
28
|
-
<h1>The count is {count}</h1>
|
|
29
|
-
<button onClick={increment}>increment</button>
|
|
30
|
-
\`\`\`
|
|
31
|
-
`,
|
|
32
|
-
};
|
|
33
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { ComponentID } from '@teambit/component-id';
|
|
2
|
-
import type { ComponentContext } from '@teambit/generator';
|
|
3
|
-
import { indexFile } from './index-file';
|
|
4
|
-
|
|
5
|
-
// react hook convention is `useX` (lowercase "use")
|
|
6
|
-
// it is required to enable hook-specific linting rules
|
|
7
|
-
const useFoobarSnapshot = `export { useFooBar } from './use-foo-bar';
|
|
8
|
-
`; // trailing line break
|
|
9
|
-
|
|
10
|
-
describe('templates: react-hook, index-file', () => {
|
|
11
|
-
it('should match snapshot', () => {
|
|
12
|
-
const ctx: ComponentContext = {
|
|
13
|
-
name: 'use-foo-bar',
|
|
14
|
-
namePascalCase: 'UseFooBar',
|
|
15
|
-
nameCamelCase: 'useFooBar',
|
|
16
|
-
componentId: ComponentID.fromString('baz.qux/use/foo/bar'),
|
|
17
|
-
aspectId: ComponentID.fromString('baz.qux/use/foo/my-aspect'),
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const result = indexFile(ctx);
|
|
21
|
-
|
|
22
|
-
expect(result.content).toEqual(useFoobarSnapshot);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export const indexFile = (context: ComponentContext) => {
|
|
4
|
-
const { name, nameCamelCase: Name } = context;
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
relativePath: 'index.ts',
|
|
8
|
-
content: `export { ${Name} } from './${name}';
|
|
9
|
-
`,
|
|
10
|
-
};
|
|
11
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ComponentContext } from '@teambit/generator';
|
|
2
|
-
|
|
3
|
-
export const testFile = (context: ComponentContext) => {
|
|
4
|
-
const { name, nameCamelCase: Name } = context;
|
|
5
|
-
|
|
6
|
-
return {
|
|
7
|
-
relativePath: `${name}.spec.tsx`,
|
|
8
|
-
content: `import { renderHook, act } from '@testing-library/react-hooks';
|
|
9
|
-
import { ${Name} } from './${name}';
|
|
10
|
-
|
|
11
|
-
it('should increment counter', () => {
|
|
12
|
-
const { result } = renderHook(() => ${Name}())
|
|
13
|
-
act(() => {
|
|
14
|
-
result.current.increment()
|
|
15
|
-
})
|
|
16
|
-
expect(result.current.count).toBe(1)
|
|
17
|
-
})
|
|
18
|
-
`,
|
|
19
|
-
};
|
|
20
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ComponentTemplate, ComponentContext } from '@teambit/generator';
|
|
2
|
-
import { componentFile } from './files/component';
|
|
3
|
-
import { compositionFile } from './files/composition';
|
|
4
|
-
import { docsFile } from './files/docs';
|
|
5
|
-
import { testFile } from './files/test';
|
|
6
|
-
import { indexFile } from './files/index-file';
|
|
7
|
-
|
|
8
|
-
export const reactHook: ComponentTemplate = {
|
|
9
|
-
name: 'react-hook',
|
|
10
|
-
description: 'a react hook component',
|
|
11
|
-
hidden: true,
|
|
12
|
-
generateFiles: (context: ComponentContext) => {
|
|
13
|
-
return [indexFile(context), componentFile(context), compositionFile(context), docsFile(context), testFile(context)];
|
|
14
|
-
},
|
|
15
|
-
config: {
|
|
16
|
-
'teambit.react/react': {},
|
|
17
|
-
'teambit.envs/envs': {
|
|
18
|
-
env: 'teambit.react/react',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
};
|
|
File without changes
|
|
File without changes
|