@teambit/node 1.0.41 → 1.0.42

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 (161) hide show
  1. package/artifacts/env-template/public/{29.aabccd461805a58cd99a.js → 29.ddc7bc194190fac98e8b.js} +18 -18
  2. package/artifacts/env-template/public/{238.64be32cc6d4bc396b35e.js → 293.4bce474b96c9eb955917.js} +4 -4
  3. package/artifacts/env-template/public/assets-manifest.json +12 -12
  4. package/artifacts/env-template/public/{compositions.2f6adb00de8250ec25bb.js → compositions.87d6238bc3f9ad09db15.js} +1 -1
  5. package/artifacts/env-template/public/compositions.html +1 -1
  6. package/artifacts/env-template/public/{overview.6046b45c5c5ed35f09bb.js → overview.4bebd06a33f1cc723194.js} +1 -1
  7. package/artifacts/env-template/public/overview.html +1 -1
  8. package/artifacts/env-template/public/{peers.b59dd85dd7ea760e8208.js → peers.f9dd17dc213c6e0d0102.js} +1 -1
  9. package/artifacts/env-template/public/{preview-root.983463c786334e1fbaf1.js → preview-root.3b62d04b3a7f234bd8ca.js} +1 -1
  10. package/dist/node.aspect.js +2 -4
  11. package/dist/node.aspect.js.map +1 -1
  12. package/dist/node.env.js +1 -2
  13. package/dist/node.env.js.map +1 -1
  14. package/dist/node.main.runtime.d.ts +6 -3
  15. package/dist/node.main.runtime.js +21 -25
  16. package/dist/node.main.runtime.js.map +1 -1
  17. package/dist/node.templates.d.ts +3 -0
  18. package/dist/node.templates.js +33 -0
  19. package/dist/node.templates.js.map +1 -0
  20. package/dist/node.ui.runtime.js +1 -2
  21. package/dist/node.ui.runtime.js.map +1 -1
  22. package/dist/{preview-1698981534427.js → preview-1699364645970.js} +2 -2
  23. package/package.json +23 -20
  24. package/dist/templates/entity/index.d.ts +0 -0
  25. package/dist/templates/entity/index.js +0 -3
  26. package/dist/templates/entity/index.js.map +0 -1
  27. package/dist/templates/express-app/files/app-root.d.ts +0 -5
  28. package/dist/templates/express-app/files/app-root.js +0 -39
  29. package/dist/templates/express-app/files/app-root.js.map +0 -1
  30. package/dist/templates/express-app/files/composition.d.ts +0 -5
  31. package/dist/templates/express-app/files/composition.js +0 -20
  32. package/dist/templates/express-app/files/composition.js.map +0 -1
  33. package/dist/templates/express-app/files/doc.d.ts +0 -5
  34. package/dist/templates/express-app/files/doc.js +0 -35
  35. package/dist/templates/express-app/files/doc.js.map +0 -1
  36. package/dist/templates/express-app/files/get-port.d.ts +0 -4
  37. package/dist/templates/express-app/files/get-port.js +0 -21
  38. package/dist/templates/express-app/files/get-port.js.map +0 -1
  39. package/dist/templates/express-app/files/index.d.ts +0 -6
  40. package/dist/templates/express-app/files/index.js +0 -17
  41. package/dist/templates/express-app/files/index.js.map +0 -1
  42. package/dist/templates/express-app/files/mock-route.d.ts +0 -4
  43. package/dist/templates/express-app/files/mock-route.js +0 -23
  44. package/dist/templates/express-app/files/mock-route.js.map +0 -1
  45. package/dist/templates/express-app/files/node-app.d.ts +0 -5
  46. package/dist/templates/express-app/files/node-app.js +0 -23
  47. package/dist/templates/express-app/files/node-app.js.map +0 -1
  48. package/dist/templates/express-app/files/route.d.ts +0 -4
  49. package/dist/templates/express-app/files/route.js +0 -29
  50. package/dist/templates/express-app/files/route.js.map +0 -1
  51. package/dist/templates/express-app/files/test.d.ts +0 -5
  52. package/dist/templates/express-app/files/test.js +0 -19
  53. package/dist/templates/express-app/files/test.js.map +0 -1
  54. package/dist/templates/express-app/index.d.ts +0 -2
  55. package/dist/templates/express-app/index.js +0 -79
  56. package/dist/templates/express-app/index.js.map +0 -1
  57. package/dist/templates/express-route/files/composition.d.ts +0 -5
  58. package/dist/templates/express-route/files/composition.js +0 -20
  59. package/dist/templates/express-route/files/composition.js.map +0 -1
  60. package/dist/templates/express-route/files/doc.d.ts +0 -5
  61. package/dist/templates/express-route/files/doc.js +0 -24
  62. package/dist/templates/express-route/files/doc.js.map +0 -1
  63. package/dist/templates/express-route/files/index.d.ts +0 -6
  64. package/dist/templates/express-route/files/index.js +0 -16
  65. package/dist/templates/express-route/files/index.js.map +0 -1
  66. package/dist/templates/express-route/files/main.d.ts +0 -5
  67. package/dist/templates/express-route/files/main.js +0 -21
  68. package/dist/templates/express-route/files/main.js.map +0 -1
  69. package/dist/templates/express-route/files/test.d.ts +0 -5
  70. package/dist/templates/express-route/files/test.js +0 -19
  71. package/dist/templates/express-route/files/test.js.map +0 -1
  72. package/dist/templates/express-route/index.d.ts +0 -2
  73. package/dist/templates/express-route/index.js +0 -51
  74. package/dist/templates/express-route/index.js.map +0 -1
  75. package/dist/templates/node/files/composition.d.ts +0 -5
  76. package/dist/templates/node/files/composition.js +0 -20
  77. package/dist/templates/node/files/composition.js.map +0 -1
  78. package/dist/templates/node/files/doc.d.ts +0 -5
  79. package/dist/templates/node/files/doc.js +0 -24
  80. package/dist/templates/node/files/doc.js.map +0 -1
  81. package/dist/templates/node/files/index.d.ts +0 -6
  82. package/dist/templates/node/files/index.js +0 -16
  83. package/dist/templates/node/files/index.js.map +0 -1
  84. package/dist/templates/node/files/main.d.ts +0 -5
  85. package/dist/templates/node/files/main.js +0 -17
  86. package/dist/templates/node/files/main.js.map +0 -1
  87. package/dist/templates/node/files/test.d.ts +0 -5
  88. package/dist/templates/node/files/test.js +0 -19
  89. package/dist/templates/node/files/test.js.map +0 -1
  90. package/dist/templates/node/index.d.ts +0 -2
  91. package/dist/templates/node/index.js +0 -58
  92. package/dist/templates/node/index.js.map +0 -1
  93. package/dist/templates/node-env/files/aspect.d.ts +0 -2
  94. package/dist/templates/node-env/files/aspect.js +0 -19
  95. package/dist/templates/node-env/files/aspect.js.map +0 -1
  96. package/dist/templates/node-env/files/doc.d.ts +0 -2
  97. package/dist/templates/node-env/files/doc.js +0 -187
  98. package/dist/templates/node-env/files/doc.js.map +0 -1
  99. package/dist/templates/node-env/files/index.d.ts +0 -2
  100. package/dist/templates/node-env/files/index.js +0 -19
  101. package/dist/templates/node-env/files/index.js.map +0 -1
  102. package/dist/templates/node-env/files/jest.config.d.ts +0 -1
  103. package/dist/templates/node-env/files/jest.config.js +0 -29
  104. package/dist/templates/node-env/files/jest.config.js.map +0 -1
  105. package/dist/templates/node-env/files/main.runtime.d.ts +0 -2
  106. package/dist/templates/node-env/files/main.runtime.js +0 -104
  107. package/dist/templates/node-env/files/main.runtime.js.map +0 -1
  108. package/dist/templates/node-env/files/preview.runtime.d.ts +0 -2
  109. package/dist/templates/node-env/files/preview.runtime.js +0 -37
  110. package/dist/templates/node-env/files/preview.runtime.js.map +0 -1
  111. package/dist/templates/node-env/files/typescript/styles.d.ts +0 -1
  112. package/dist/templates/node-env/files/typescript/styles.js +0 -15
  113. package/dist/templates/node-env/files/typescript/styles.js.map +0 -1
  114. package/dist/templates/node-env/files/typescript/ts-transformer.d.ts +0 -1
  115. package/dist/templates/node-env/files/typescript/ts-transformer.js +0 -58
  116. package/dist/templates/node-env/files/typescript/ts-transformer.js.map +0 -1
  117. package/dist/templates/node-env/files/typescript/typescript.config.d.ts +0 -1
  118. package/dist/templates/node-env/files/typescript/typescript.config.js +0 -29
  119. package/dist/templates/node-env/files/typescript/typescript.config.js.map +0 -1
  120. package/dist/templates/node-env/files/webpack.config.d.ts +0 -1
  121. package/dist/templates/node-env/files/webpack.config.js +0 -56
  122. package/dist/templates/node-env/files/webpack.config.js.map +0 -1
  123. package/dist/templates/node-env/index.d.ts +0 -2
  124. package/dist/templates/node-env/index.js +0 -124
  125. package/dist/templates/node-env/index.js.map +0 -1
  126. package/templates/entity/index.ts +0 -0
  127. package/templates/express-app/files/app-root.ts +0 -33
  128. package/templates/express-app/files/composition.ts +0 -14
  129. package/templates/express-app/files/doc.ts +0 -26
  130. package/templates/express-app/files/get-port.ts +0 -13
  131. package/templates/express-app/files/index.ts +0 -11
  132. package/templates/express-app/files/mock-route.ts +0 -15
  133. package/templates/express-app/files/node-app.ts +0 -17
  134. package/templates/express-app/files/route.ts +0 -21
  135. package/templates/express-app/files/test.ts +0 -13
  136. package/templates/express-app/index.ts +0 -35
  137. package/templates/express-route/files/composition.ts +0 -14
  138. package/templates/express-route/files/doc.ts +0 -18
  139. package/templates/express-route/files/index.ts +0 -10
  140. package/templates/express-route/files/main.ts +0 -15
  141. package/templates/express-route/files/test.ts +0 -13
  142. package/templates/express-route/index.ts +0 -27
  143. package/templates/node/files/composition.ts +0 -14
  144. package/templates/node/files/doc.ts +0 -18
  145. package/templates/node/files/index.ts +0 -10
  146. package/templates/node/files/main.ts +0 -11
  147. package/templates/node/files/test.ts +0 -13
  148. package/templates/node/index.ts +0 -21
  149. package/templates/node-env/files/aspect.ts +0 -10
  150. package/templates/node-env/files/doc.ts +0 -178
  151. package/templates/node-env/files/index.ts +0 -10
  152. package/templates/node-env/files/jest.config.ts +0 -21
  153. package/templates/node-env/files/main.runtime.ts +0 -95
  154. package/templates/node-env/files/preview.runtime.ts +0 -27
  155. package/templates/node-env/files/typescript/styles.ts +0 -7
  156. package/templates/node-env/files/typescript/ts-transformer.ts +0 -50
  157. package/templates/node-env/files/typescript/typescript.config.ts +0 -21
  158. package/templates/node-env/files/webpack.config.ts +0 -48
  159. package/templates/node-env/index.ts +0 -68
  160. /package/{compositions-1698981534427.js → compositions-1699364645970.js} +0 -0
  161. /package/{overview-1698981534427.js → overview-1699364645970.js} +0 -0
@@ -1,13 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function testFile(context: ComponentContext) {
4
- return {
5
- relativePath: `${context.name}.spec.ts`,
6
- content: `import { ${context.nameCamelCase} } from './${context.name}';
7
-
8
- it('should return the correct value', () => {
9
- expect(${context.nameCamelCase}()).toBe('Hello world!');
10
- });
11
- `,
12
- };
13
- }
@@ -1,35 +0,0 @@
1
- import { ComponentContext, ComponentTemplate } from '@teambit/generator';
2
- import { indexFile } from './files/index';
3
- import { docFile } from './files/doc';
4
- import { appRoot } from './files/app-root';
5
- import { nodeApp } from './files/node-app';
6
- import { getPort } from './files/get-port';
7
- import { mockRoute } from './files/mock-route';
8
- import { route } from './files/route';
9
- // import { testFile } from './files/test';
10
- // import { compositionFile } from './files/composition';
11
-
12
- export const expressAppTemplate: ComponentTemplate = {
13
- name: 'express-app',
14
- description: 'a bit express application',
15
- hidden: true,
16
- generateFiles: (context: ComponentContext) => {
17
- return [
18
- indexFile(context),
19
- docFile(context),
20
- appRoot(context),
21
- nodeApp(context),
22
- getPort(),
23
- mockRoute(),
24
- route(),
25
- // compositionFile(context),
26
- // testFile(context),
27
- ];
28
- },
29
- config: {
30
- 'teambit.harmony/aspect': {},
31
- 'teambit.envs/envs': {
32
- env: 'teambit.harmony/aspect',
33
- },
34
- },
35
- };
@@ -1,14 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function compositionFile(context: ComponentContext) {
4
- return {
5
- relativePath: `${context.name}.composition.tsx`,
6
- content: `import React from 'react';
7
- import { ${context.nameCamelCase} } from './${context.name}';
8
-
9
- export function ReturnsCorrectValue() {
10
- return <div>{${context.nameCamelCase}()}</div>;
11
- }
12
- `,
13
- };
14
- }
@@ -1,18 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function docFile(context: ComponentContext) {
4
- return {
5
- relativePath: `${context.name}.docs.mdx`,
6
- content: `---
7
- labels: ['express', 'node', 'route']
8
- description: 'An express route'
9
- ---
10
-
11
- API:
12
-
13
- \`\`\`ts
14
- function get${context.namePascalCase}Route()
15
- \`\`\`
16
- `,
17
- };
18
- }
@@ -1,10 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function indexFile(context: ComponentContext) {
4
- return {
5
- relativePath: 'index.ts',
6
- content: `export { get${context.namePascalCase}Route } from './${context.name}';
7
- `,
8
- isMain: true,
9
- };
10
- }
@@ -1,15 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function mainFile(context: ComponentContext) {
4
- return {
5
- relativePath: `${context.name}.ts`,
6
- content: `export function get${context.namePascalCase}Route() {
7
- return {
8
- method: 'get',
9
- route: '/${context.name}',
10
- middlewares: [async (req, res) => res.send('${context.name} response')]
11
- }
12
- }
13
- `,
14
- };
15
- }
@@ -1,13 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function testFile(context: ComponentContext) {
4
- return {
5
- relativePath: `${context.name}.spec.ts`,
6
- content: `import { ${context.nameCamelCase} } from './${context.name}';
7
-
8
- it('should return the correct value', () => {
9
- expect(${context.nameCamelCase}()).toBe('Hello world!');
10
- });
11
- `,
12
- };
13
- }
@@ -1,27 +0,0 @@
1
- import { ComponentContext, ComponentTemplate } from '@teambit/generator';
2
- import { indexFile } from './files/index';
3
- import { docFile } from './files/doc';
4
- import { mainFile } from './files/main';
5
- // import { testFile } from './files/test';
6
- // import { compositionFile } from './files/composition';
7
-
8
- export const expressRouteTemplate: ComponentTemplate = {
9
- name: 'express-route',
10
- description: 'an express route',
11
- hidden: true,
12
- generateFiles: (context: ComponentContext) => {
13
- return [
14
- indexFile(context),
15
- docFile(context),
16
- mainFile(context),
17
- // compositionFile(context),
18
- // testFile(context)
19
- ];
20
- },
21
- config: {
22
- 'teambit.harmony/node': {},
23
- 'teambit.envs/envs': {
24
- env: 'teambit.harmony/node',
25
- },
26
- },
27
- };
@@ -1,14 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function compositionFile(context: ComponentContext) {
4
- return {
5
- relativePath: `${context.name}.composition.tsx`,
6
- content: `import React from 'react';
7
- import { ${context.nameCamelCase} } from './${context.name}';
8
-
9
- export function ReturnsCorrectValue() {
10
- return <div>{${context.nameCamelCase}()}</div>;
11
- }
12
- `,
13
- };
14
- }
@@ -1,18 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function docFile(context: ComponentContext) {
4
- return {
5
- relativePath: `${context.name}.docs.mdx`,
6
- content: `---
7
- labels: ['module']
8
- description: 'A general purpose node module'
9
- ---
10
-
11
- API:
12
-
13
- \`\`\`ts
14
- function ${context.nameCamelCase}(): string;
15
- \`\`\`
16
- `,
17
- };
18
- }
@@ -1,10 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function indexFile(context: ComponentContext) {
4
- return {
5
- relativePath: 'index.ts',
6
- content: `export { ${context.nameCamelCase} } from './${context.name}';
7
- `,
8
- isMain: true,
9
- };
10
- }
@@ -1,11 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function mainFile(context: ComponentContext) {
4
- return {
5
- relativePath: `${context.name}.ts`,
6
- content: `export function ${context.nameCamelCase}() {
7
- return 'Hello world!';
8
- }
9
- `,
10
- };
11
- }
@@ -1,13 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function testFile(context: ComponentContext) {
4
- return {
5
- relativePath: `${context.name}.spec.ts`,
6
- content: `import { ${context.nameCamelCase} } from './${context.name}';
7
-
8
- it('should return the correct value', () => {
9
- expect(${context.nameCamelCase}()).toBe('Hello world!');
10
- });
11
- `,
12
- };
13
- }
@@ -1,21 +0,0 @@
1
- import { ComponentContext, ComponentTemplate } from '@teambit/generator';
2
- import { indexFile } from './files/index';
3
- import { docFile } from './files/doc';
4
- import { mainFile } from './files/main';
5
- import { testFile } from './files/test';
6
- import { compositionFile } from './files/composition';
7
-
8
- export const nodeTemplate: ComponentTemplate = {
9
- name: 'node',
10
- description: 'a Node.js module',
11
- hidden: true,
12
- generateFiles: (context: ComponentContext) => {
13
- return [indexFile(context), docFile(context), mainFile(context), compositionFile(context), testFile(context)];
14
- },
15
- config: {
16
- 'teambit.harmony/node': {},
17
- 'teambit.envs/envs': {
18
- env: 'teambit.harmony/node',
19
- },
20
- },
21
- };
@@ -1,10 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function aspectFile({ namePascalCase: Name, componentId }: ComponentContext) {
4
- return `import { Aspect } from '@teambit/harmony';
5
-
6
- export const ${Name}Aspect = Aspect.create({
7
- id: '${componentId}',
8
- });
9
- `;
10
- }
@@ -1,178 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function docFile({ name, componentId }: ComponentContext) {
4
- return `---
5
- description: 'A standard Node component development environment'
6
- labels: ['node', 'typescript', 'env', 'extension']
7
- ---
8
-
9
- ## Overview
10
-
11
- A customized version which extends the default Node component development environment created by teambit.
12
-
13
- This environment can be applied to all your components or a set of components via the command \`bit env set <pattern or component_id> ${componentId}\`, or under the variants of your \`workspace.json\` file.
14
- That means they will use your custom environment instead of the default environment. Environment components are just like any other Bit components in that they can be
15
- exported and then shared and used in various projects which makes it easier to create standards when working with many teams.
16
-
17
- ### Usage instructions
18
-
19
- #### Recommended usage:
20
-
21
- Run the command \`bit env set <"pattern" or component_id> ${componentId}\` where the pattern is a glob pattern to select multiple components. This will put the env
22
- config in your component's entry in the \`.bitmap\` file.
23
-
24
- :::Note - this will override any variants policy that tries to set an env for this component in the workspace.jsonc
25
- :::
26
-
27
- #### Alternative Usage
28
- Under the **variant** section of your \`workspace.json\` file choose which components you want to have the custom environment set. You can find the id of the extension in the \`${name}.aspect.ts\` file.
29
-
30
- \`\`\`json
31
- {
32
- "teambit.workspace/variants": {
33
- "{ui/**}, {pages/**}": {
34
- "${componentId}": {}
35
- }
36
- }
37
- }
38
- \`\`\`
39
-
40
- This usage may be deprecated in future in favour of the recommended usage above
41
-
42
- ## Runtime Configurations
43
-
44
- Extend the \`main.runtime\` file when you want to add custom configurations at runtime.
45
-
46
- ### Compilation
47
-
48
- By default, Component compilation is done with the TypeScript compiler. Target format is \`ES2015\` which
49
- supports execution from both NodeJS and browser runtimes for server-side rendering. You can modify the \`tsconfig.json\` file to add your own compiler options which will then be merged with the default configs set by teambit.
50
-
51
- Example:
52
-
53
- \`\`\`json
54
- {
55
- "compilerOptions": {
56
- "target": "es2017",
57
- "module": "es2015",
58
- "moduleResolution": "node",
59
- "lib": ["es2017", "dom"],
60
- "experimentalDecorators": true,
61
- "esModuleInterop": true,
62
- "outDir": "dist",
63
- "sourceMap": true,
64
- "emitDecoratorMetadata": true,
65
- "allowJs": true,
66
- "baseUrl": ".",
67
- "jsx": "react"
68
- }
69
- }
70
- \`\`\`
71
-
72
- ### Testing
73
-
74
- Component testing is done through [Jest](https://jestjs.io/) with the default \`teambit.react/react\` environment. You can modify the \`jestconfig.js\` file to add your own configurations which will then be merged with the default configs set by teambit.
75
-
76
- Example:
77
-
78
- To Override the Jest config to ignore transpiling from specific folders add this to the \`jestconfig.js\` file:
79
-
80
- \`\`\`js
81
- const reactJestConfig = require('@teambit/react/jest/jest.config');
82
- module.exports = {
83
- ...reactJestConfig,
84
- transformIgnorePatterns: ['/node_modules/(?!(prop-types|@teambit))']
85
- };
86
- \`\`\`
87
-
88
- ### Webpack
89
-
90
- Bit uses webpack 5 to bundle components. You can modify the \`webpack.config.js\` file to add your own configurations which will then be merged with the default configs set by teambit.
91
-
92
- Example:
93
-
94
- \`\`\`ts
95
- module.exports = {
96
- module: {
97
- // add your custom rules here
98
- rules: []
99
- }
100
- };
101
- \`\`\`
102
-
103
- ### ESLint
104
-
105
- Bit uses ESLint to lint your components. You can add your own rules in the \`${name}.main.runtime\` file.
106
-
107
- Example:
108
-
109
- \`\`\`ts
110
- react.useEslint({
111
- transformers: [
112
- (config) => {
113
- config.setRule('no-console', ['error']);
114
- // add more rules here
115
- return config;
116
- }
117
- ]
118
- }),
119
- \`\`\`
120
-
121
- To use ESLint:
122
-
123
- \`\`\`bash
124
- bit lint
125
- bit lint --fix
126
- \`\`\`
127
-
128
- ### Formatting
129
-
130
- Bit uses Prettier to format your components. You can add your own rules in the \`${name}.main.runtime\` file.
131
-
132
- Example:
133
-
134
- \`\`\`ts
135
- react.usePrettier({
136
- transformers: [
137
- (config) => {
138
- config.setKey('tabWidth', 2);
139
- // add more rules here
140
- return config;
141
- }
142
- ]
143
- }),
144
- \`\`\`
145
-
146
- To use Prettier:
147
-
148
- \`\`\`bash
149
- bit format --check
150
- bit format
151
- \`\`\`
152
-
153
- ### Dependencies
154
-
155
- Override the default dependencies in the \`${name}.main.runtime\` file to include react types of a different version for example.
156
-
157
- \`\`\`ts
158
- react.overrideDependencies({
159
- devDependencies: {
160
- '@types/react': '17.0.3'
161
- }
162
- });
163
- \`\`\`
164
-
165
- ## Preview Configurations
166
-
167
- Extend the \`${name}.preview.runtime\` file when you want to add your own customizations only for previewing in the Bit UI.
168
-
169
- ### Adding a Theme
170
-
171
- A custom theme has been added to the env which wraps all the composition files with the required theme so they can be developed with the correct themeing rather than the browsers default. This is added only in the preview runtime and not in the main runtime meaning it is only applied to compositions and not when consuming components. Adding a theme when consuming should be done at App level as you component may be consumed in various apps and have different themes applied depending on where it is consumed.
172
-
173
- Example:
174
-
175
- \`\`\`ts
176
- react.registerProvider([ThemeCompositions]);
177
- `;
178
- }
@@ -1,10 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function indexFile({ namePascalCase: Name, 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,21 +0,0 @@
1
- export function jestConfigFile() {
2
- return `
3
- // Override the Jest config to ignore transpiling from specific folders
4
- // See the base Jest config: https://bit.cloud/teambit/react/react/~code/jest/jest.config.js
5
-
6
- // const reactJestConfig = require('@teambit/react/jest/jest.config');
7
- // uncomment the line below and install the package if you want to use this function
8
- // const {
9
- // generateNodeModulesPattern,
10
- // } = require('@teambit/dependencies.modules.packages-excluder');
11
- // const packagesToExclude = ['@my-org', 'my-package-name'];
12
-
13
- // module.exports = {
14
- // ...reactJestConfig,
15
- // transformIgnorePatterns: [
16
- // '^.+\\.module\\.(css|sass|scss)$',
17
- // generateNodeModulesPattern({ packages: packagesToExclude }),
18
- // ],
19
- // };
20
- `;
21
- }
@@ -1,95 +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 { NodeAspect, NodeMain } from '@teambit/node'
6
- import { EnvsAspect, EnvsMain } from '@teambit/envs';
7
- import type { UseTypescriptModifiers, UseWebpackModifiers } from '@teambit/react';
8
- import { ${Name}Aspect } from './${name}.aspect';
9
- //import {
10
- // previewConfigTransformer,
11
- // devServerConfigTransformer
12
- //} from './webpack/webpack-transformers';
13
- //import {
14
- // devConfigTransformer,
15
- // buildConfigTransformer,
16
- //} from "./typescript/ts-transformer";
17
-
18
- export class ${Name}Main {
19
- static slots = [];
20
-
21
- static dependencies = [NodeAspect, EnvsAspect];
22
-
23
- static runtime = MainRuntime;
24
-
25
- static async provider([node, envs]: [NodeMain, EnvsMain]) {
26
-
27
- //const webpackModifiers: UseWebpackModifiers = {
28
- // previewConfig: [previewConfigTransformer],
29
- // devServerConfig: [devServerConfigTransformer],
30
- //};
31
-
32
- //const tsModifiers: UseTypescriptModifiers = {
33
- // devConfig: [devConfigTransformer],
34
- // buildConfig: [buildConfigTransformer],
35
- //};
36
-
37
- const ${Name}Env = node.compose([
38
- /**
39
- * Uncomment to override the config files for TypeScript, Webpack or Jest
40
- * Your config gets merged with the defaults
41
- */
42
-
43
- // node.useTypescript(tsModifiers), // note: this cannot be used in conjunction with node.overrideCompiler
44
- // node.useWebpack(webpackModifiers),
45
- // node.overrideJestConfig(require.resolve('./jest/jest.config')),
46
-
47
- /**
48
- * override the ESLint default config here then check your files for lint errors
49
- * @example
50
- * bit lint
51
- * bit lint --fix
52
- */
53
- node.useEslint({
54
- transformers: [
55
- (config) => {
56
- config.setRule('no-console', ['error']);
57
- return config;
58
- }
59
- ]
60
- }),
61
-
62
- /**
63
- * override the Prettier default config here the check your formatting
64
- * @example
65
- * bit format --check
66
- * bit format
67
- */
68
- node.usePrettier({
69
- transformers: [
70
- (config) => {
71
- config.setKey('tabWidth', 2);
72
- return config;
73
- }
74
- ]
75
- }),
76
-
77
- /**
78
- * override dependencies here
79
- * @example
80
- * Uncomment types to include version 17.0.3 of the types package
81
- */
82
- node.overrideDependencies({
83
- devDependencies: {
84
- // '@types/node': '16.11.7'
85
- }
86
- })
87
- ]);
88
- envs.registerEnv(${Name}Env);
89
- return new ${Name}Main();
90
- }
91
- }
92
-
93
- ${Name}Aspect.addRuntime(${Name}Main);
94
- `;
95
- }
@@ -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'; // the node env uses the react env's preview feature
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,7 +0,0 @@
1
- export function globalStylesFile() {
2
- return `
3
- /*
4
- Add your global styles here to be added for any component using this env
5
- */
6
- `;
7
- }
@@ -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
- }