@teambit/node 0.0.707 → 0.0.710

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 (66) hide show
  1. package/artifacts/env-template/public/162.js +6 -2
  2. package/artifacts/env-template/public/{413.js → 624.js} +4 -4
  3. package/artifacts/env-template/public/793.js +17 -17
  4. package/artifacts/env-template/public/assets-manifest.json +13 -15
  5. package/artifacts/env-template/public/{compositions.60e7ad86acf6c3fc7258.js → compositions.e86ca82917601a50c1de.js} +1 -1
  6. package/artifacts/env-template/public/compositions.html +1 -1
  7. package/artifacts/env-template/public/{overview.7d2a3622759390957aaa.js → overview.c22cec3a6de6d04dd2d6.js} +2 -2
  8. package/artifacts/env-template/public/overview.html +1 -1
  9. package/artifacts/env-template/public/{preview-root.cd80fcaec61d81a584f1.js → preview-root.f8526a284a6e4a3e0885.js} +1 -1
  10. package/artifacts/env-template/public/service-worker.js +1 -1
  11. package/artifacts/env-template/public/static/css/{compositions.cd8be53f.css → compositions.4138c069.css} +1 -1
  12. package/artifacts/env-template/public/static/css/{previewRoot.a16607da.css → previewRoot.c0db5bec.css} +1 -1
  13. package/artifacts/preview/teambit_harmony_node-preview.js +2 -2
  14. package/{compositions-1649733938651.js → compositions-1650252279523.js} +0 -0
  15. package/dist/templates/node-env/files/aspect.d.ts +2 -0
  16. package/dist/templates/node-env/files/aspect.js +20 -0
  17. package/dist/templates/node-env/files/aspect.js.map +1 -0
  18. package/dist/templates/node-env/files/doc.d.ts +2 -1
  19. package/dist/templates/node-env/files/doc.js +173 -5
  20. package/dist/templates/node-env/files/doc.js.map +1 -1
  21. package/dist/templates/node-env/files/index.js +5 -3
  22. package/dist/templates/node-env/files/index.js.map +1 -1
  23. package/dist/templates/node-env/files/jest.config.d.ts +1 -0
  24. package/dist/templates/node-env/files/jest.config.js +30 -0
  25. package/dist/templates/node-env/files/jest.config.js.map +1 -0
  26. package/dist/templates/node-env/files/main.runtime.d.ts +2 -0
  27. package/dist/templates/node-env/files/main.runtime.js +103 -0
  28. package/dist/templates/node-env/files/main.runtime.js.map +1 -0
  29. package/dist/templates/node-env/files/preview.runtime.d.ts +2 -0
  30. package/dist/templates/node-env/files/preview.runtime.js +38 -0
  31. package/dist/templates/node-env/files/preview.runtime.js.map +1 -0
  32. package/dist/templates/node-env/files/typescript/styles.d.ts +1 -0
  33. package/dist/templates/node-env/files/typescript/styles.js +16 -0
  34. package/dist/templates/node-env/files/typescript/styles.js.map +1 -0
  35. package/dist/templates/node-env/files/typescript/ts-transformer.d.ts +1 -0
  36. package/dist/templates/node-env/files/typescript/ts-transformer.js +59 -0
  37. package/dist/templates/node-env/files/typescript/ts-transformer.js.map +1 -0
  38. package/dist/templates/node-env/files/typescript/typescript.config.d.ts +1 -0
  39. package/dist/templates/node-env/files/typescript/typescript.config.js +30 -0
  40. package/dist/templates/node-env/files/typescript/typescript.config.js.map +1 -0
  41. package/dist/templates/node-env/files/webpack.config.d.ts +1 -0
  42. package/dist/templates/node-env/files/webpack.config.js +57 -0
  43. package/dist/templates/node-env/files/webpack.config.js.map +1 -0
  44. package/dist/templates/node-env/index.js +99 -8
  45. package/dist/templates/node-env/index.js.map +1 -1
  46. package/{overview-1649733938651.js → overview-1650252279523.js} +0 -0
  47. package/package-tar/teambit-node-0.0.710.tgz +0 -0
  48. package/package.json +16 -16
  49. package/{preview-1649733938651.js → preview-1650252279523.js} +2 -2
  50. package/templates/node-env/files/aspect.ts +10 -0
  51. package/templates/node-env/files/doc.ts +172 -5
  52. package/templates/node-env/files/index.ts +5 -3
  53. package/templates/node-env/files/jest.config.ts +21 -0
  54. package/templates/node-env/files/main.runtime.ts +93 -0
  55. package/templates/node-env/files/preview.runtime.ts +27 -0
  56. package/templates/node-env/files/typescript/styles.ts +7 -0
  57. package/templates/node-env/files/typescript/ts-transformer.ts +50 -0
  58. package/templates/node-env/files/typescript/typescript.config.ts +21 -0
  59. package/templates/node-env/files/webpack.config.ts +48 -0
  60. package/templates/node-env/index.ts +41 -6
  61. package/artifacts/env-template/public/static/css/overview.7bb7dce6.css +0 -1
  62. package/dist/templates/node-env/files/extension.d.ts +0 -2
  63. package/dist/templates/node-env/files/extension.js +0 -34
  64. package/dist/templates/node-env/files/extension.js.map +0 -1
  65. package/package-tar/teambit-node-0.0.707.tgz +0 -0
  66. package/templates/node-env/files/extension.ts +0 -25
@@ -25,10 +25,80 @@ function _doc() {
25
25
  return data;
26
26
  }
27
27
 
28
- function _extension() {
29
- const data = require("./files/extension");
28
+ function _main() {
29
+ const data = require("./files/main.runtime");
30
30
 
31
- _extension = function () {
31
+ _main = function () {
32
+ return data;
33
+ };
34
+
35
+ return data;
36
+ }
37
+
38
+ function _preview() {
39
+ const data = require("./files/preview.runtime");
40
+
41
+ _preview = function () {
42
+ return data;
43
+ };
44
+
45
+ return data;
46
+ }
47
+
48
+ function _aspect() {
49
+ const data = require("./files/aspect");
50
+
51
+ _aspect = function () {
52
+ return data;
53
+ };
54
+
55
+ return data;
56
+ }
57
+
58
+ function _webpack() {
59
+ const data = require("./files/webpack.config");
60
+
61
+ _webpack = function () {
62
+ return data;
63
+ };
64
+
65
+ return data;
66
+ }
67
+
68
+ function _typescript() {
69
+ const data = require("./files/typescript/typescript.config");
70
+
71
+ _typescript = function () {
72
+ return data;
73
+ };
74
+
75
+ return data;
76
+ }
77
+
78
+ function _styles() {
79
+ const data = require("./files/typescript/styles");
80
+
81
+ _styles = function () {
82
+ return data;
83
+ };
84
+
85
+ return data;
86
+ }
87
+
88
+ function _tsTransformer() {
89
+ const data = require("./files/typescript/ts-transformer");
90
+
91
+ _tsTransformer = function () {
92
+ return data;
93
+ };
94
+
95
+ return data;
96
+ }
97
+
98
+ function _jest() {
99
+ const data = require("./files/jest.config");
100
+
101
+ _jest = function () {
32
102
  return data;
33
103
  };
34
104
 
@@ -45,16 +115,37 @@ const nodeEnvTemplate = {
45
115
  isMain: true
46
116
  }, {
47
117
  relativePath: `${context.name}.docs.mdx`,
48
- content: (0, _doc().docFile)()
118
+ content: (0, _doc().docFile)(context)
119
+ }, {
120
+ relativePath: `${context.name}.main.runtime.ts`,
121
+ content: (0, _main().mainRuntimeFile)(context)
122
+ }, {
123
+ relativePath: `${context.name}.preview.runtime.ts`,
124
+ content: (0, _preview().previewRuntimeFile)(context)
125
+ }, {
126
+ relativePath: `${context.name}.aspect.ts`,
127
+ content: (0, _aspect().aspectFile)(context)
128
+ }, {
129
+ relativePath: `webpack/webpack-transformers.ts`,
130
+ content: (0, _webpack().webpackConfigFile)()
131
+ }, {
132
+ relativePath: `typescript/tsconfig.json`,
133
+ content: (0, _typescript().typescriptConfigFile)()
134
+ }, {
135
+ relativePath: `typescript/styles.d.ts`,
136
+ content: (0, _styles().globalStylesFile)()
137
+ }, {
138
+ relativePath: `typescript/ts-transformer.ts`,
139
+ content: (0, _tsTransformer().tsTransformerFile)()
49
140
  }, {
50
- relativePath: `${context.name}.extension.ts`,
51
- content: (0, _extension().extensionFile)(context)
141
+ relativePath: `jest/jest.config.js`,
142
+ content: (0, _jest().jestConfigFile)()
52
143
  }];
53
144
  },
54
145
  config: {
55
- 'teambit.harmony/aspect': {},
146
+ 'teambit.envs/env': {},
56
147
  'teambit.envs/envs': {
57
- env: 'teambit.harmony/aspect'
148
+ env: 'teambit.envs/env'
58
149
  }
59
150
  }
60
151
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["nodeEnvTemplate","name","description","generateFiles","context","relativePath","content","isMain","config","env"],"mappings":";;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,eAAkC,GAAG;AAChDC,EAAAA,IAAI,EAAE,UAD0C;AAEhDC,EAAAA,WAAW,EAAE,yDAFmC;AAGhDC,EAAAA,aAAa,EAAGC,OAAD,IAA+B;AAC5C,WAAO,CACL;AACEC,MAAAA,YAAY,EAAE,UADhB;AAEEC,MAAAA,OAAO,EAAE,wBAAUF,OAAV,CAFX;AAGEG,MAAAA,MAAM,EAAE;AAHV,KADK,EAML;AACEF,MAAAA,YAAY,EAAG,GAAED,OAAO,CAACH,IAAK,WADhC;AAEEK,MAAAA,OAAO,EAAE;AAFX,KANK,EAUL;AACED,MAAAA,YAAY,EAAG,GAAED,OAAO,CAACH,IAAK,eADhC;AAEEK,MAAAA,OAAO,EAAE,gCAAcF,OAAd;AAFX,KAVK,CAAP;AAeD,GAnB+C;AAoBhDI,EAAAA,MAAM,EAAE;AACN,8BAA0B,EADpB;AAEN,yBAAqB;AACnBC,MAAAA,GAAG,EAAE;AADc;AAFf;AApBwC,CAA3C","sourcesContent":["import { ComponentContext, ComponentTemplate } from '@teambit/generator';\nimport { indexFile } from './files/index';\nimport { docFile } from './files/doc';\nimport { extensionFile } from './files/extension';\n\nexport const nodeEnvTemplate: ComponentTemplate = {\n name: 'node-env',\n description: 'customize the base Node env with your configs and tools',\n generateFiles: (context: ComponentContext) => {\n return [\n {\n relativePath: 'index.ts',\n content: indexFile(context),\n isMain: true,\n },\n {\n relativePath: `${context.name}.docs.mdx`,\n content: docFile(),\n },\n {\n relativePath: `${context.name}.extension.ts`,\n content: extensionFile(context),\n },\n ];\n },\n config: {\n 'teambit.harmony/aspect': {},\n 'teambit.envs/envs': {\n env: 'teambit.harmony/aspect',\n },\n },\n};\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":["nodeEnvTemplate","name","description","generateFiles","context","relativePath","content","isMain","config","env"],"mappings":";;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,MAAMA,eAAkC,GAAG;AAChDC,EAAAA,IAAI,EAAE,UAD0C;AAEhDC,EAAAA,WAAW,EAAE,yDAFmC;AAGhDC,EAAAA,aAAa,EAAGC,OAAD,IAA+B;AAC5C,WAAO,CACL;AACEC,MAAAA,YAAY,EAAE,UADhB;AAEEC,MAAAA,OAAO,EAAE,wBAAUF,OAAV,CAFX;AAGEG,MAAAA,MAAM,EAAE;AAHV,KADK,EAML;AACEF,MAAAA,YAAY,EAAG,GAAED,OAAO,CAACH,IAAK,WADhC;AAEEK,MAAAA,OAAO,EAAE,oBAAQF,OAAR;AAFX,KANK,EAUL;AACEC,MAAAA,YAAY,EAAG,GAAED,OAAO,CAACH,IAAK,kBADhC;AAEEK,MAAAA,OAAO,EAAE,6BAAgBF,OAAhB;AAFX,KAVK,EAcL;AACEC,MAAAA,YAAY,EAAG,GAAED,OAAO,CAACH,IAAK,qBADhC;AAEEK,MAAAA,OAAO,EAAE,mCAAmBF,OAAnB;AAFX,KAdK,EAkBL;AACEC,MAAAA,YAAY,EAAG,GAAED,OAAO,CAACH,IAAK,YADhC;AAEEK,MAAAA,OAAO,EAAE,0BAAWF,OAAX;AAFX,KAlBK,EAsBL;AACEC,MAAAA,YAAY,EAAG,iCADjB;AAEEC,MAAAA,OAAO,EAAE;AAFX,KAtBK,EA0BL;AACED,MAAAA,YAAY,EAAG,0BADjB;AAEEC,MAAAA,OAAO,EAAE;AAFX,KA1BK,EA8BL;AACED,MAAAA,YAAY,EAAG,wBADjB;AAEEC,MAAAA,OAAO,EAAE;AAFX,KA9BK,EAkCL;AACED,MAAAA,YAAY,EAAG,8BADjB;AAEEC,MAAAA,OAAO,EAAE;AAFX,KAlCK,EAsCL;AACED,MAAAA,YAAY,EAAG,qBADjB;AAEEC,MAAAA,OAAO,EAAE;AAFX,KAtCK,CAAP;AA2CD,GA/C+C;AAgDhDE,EAAAA,MAAM,EAAE;AACN,wBAAoB,EADd;AAEN,yBAAqB;AACnBC,MAAAA,GAAG,EAAE;AADc;AAFf;AAhDwC,CAA3C","sourcesContent":["import { ComponentContext, ComponentTemplate } from '@teambit/generator';\nimport { indexFile } from './files/index';\nimport { docFile } from './files/doc';\nimport { mainRuntimeFile } from './files/main.runtime';\nimport { previewRuntimeFile } from './files/preview.runtime';\nimport { aspectFile } from './files/aspect';\nimport { webpackConfigFile } from './files/webpack.config';\nimport { typescriptConfigFile } from './files/typescript/typescript.config';\nimport { globalStylesFile } from './files/typescript/styles';\nimport { tsTransformerFile } from './files/typescript/ts-transformer';\nimport { jestConfigFile } from './files/jest.config';\n\nexport const nodeEnvTemplate: ComponentTemplate = {\n name: 'node-env',\n description: 'customize the base Node env with your configs and tools',\n generateFiles: (context: ComponentContext) => {\n return [\n {\n relativePath: 'index.ts',\n content: indexFile(context),\n isMain: true,\n },\n {\n relativePath: `${context.name}.docs.mdx`,\n content: docFile(context),\n },\n {\n relativePath: `${context.name}.main.runtime.ts`,\n content: mainRuntimeFile(context),\n },\n {\n relativePath: `${context.name}.preview.runtime.ts`,\n content: previewRuntimeFile(context),\n },\n {\n relativePath: `${context.name}.aspect.ts`,\n content: aspectFile(context),\n },\n {\n relativePath: `webpack/webpack-transformers.ts`,\n content: webpackConfigFile(),\n },\n {\n relativePath: `typescript/tsconfig.json`,\n content: typescriptConfigFile(),\n },\n {\n relativePath: `typescript/styles.d.ts`,\n content: globalStylesFile(),\n },\n {\n relativePath: `typescript/ts-transformer.ts`,\n content: tsTransformerFile(),\n },\n {\n relativePath: `jest/jest.config.js`,\n content: jestConfigFile(),\n },\n ];\n },\n config: {\n 'teambit.envs/env': {},\n 'teambit.envs/envs': {\n env: 'teambit.envs/env',\n },\n },\n};\n"]}
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/node",
3
- "version": "0.0.707",
3
+ "version": "0.0.710",
4
4
  "homepage": "https://bit.dev/teambit/harmony/node",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.harmony",
8
8
  "name": "node",
9
- "version": "0.0.707"
9
+ "version": "0.0.710"
10
10
  },
11
11
  "dependencies": {
12
12
  "lodash": "4.17.21",
@@ -15,21 +15,21 @@
15
15
  "@babel/runtime": "7.12.18",
16
16
  "core-js": "^3.0.0",
17
17
  "@teambit/harmony": "0.3.3",
18
- "@teambit/application": "0.0.349",
19
- "@teambit/logger": "0.0.562",
20
- "@teambit/react": "0.0.707",
21
- "@teambit/builder": "0.0.707",
22
- "@teambit/dependency-resolver": "0.0.707",
23
- "@teambit/envs": "0.0.707",
24
- "@teambit/tester": "0.0.707",
25
- "@teambit/typescript": "0.0.707",
26
- "@teambit/cli": "0.0.470",
27
- "@teambit/compiler": "0.0.707",
28
- "@teambit/generator": "0.0.707",
29
- "@teambit/pkg": "0.0.707",
30
- "@teambit/compositions": "0.0.707",
18
+ "@teambit/application": "0.0.352",
19
+ "@teambit/logger": "0.0.564",
20
+ "@teambit/react": "0.0.710",
21
+ "@teambit/builder": "0.0.710",
22
+ "@teambit/dependency-resolver": "0.0.710",
23
+ "@teambit/envs": "0.0.710",
24
+ "@teambit/tester": "0.0.710",
25
+ "@teambit/typescript": "0.0.710",
26
+ "@teambit/cli": "0.0.472",
27
+ "@teambit/compiler": "0.0.710",
28
+ "@teambit/generator": "0.0.710",
29
+ "@teambit/pkg": "0.0.710",
30
+ "@teambit/compositions": "0.0.710",
31
31
  "@teambit/design.ui.empty-box": "0.0.353",
32
- "@teambit/ui": "0.0.707"
32
+ "@teambit/ui": "0.0.710"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/react": "^17.0.8",
@@ -1,2 +1,2 @@
1
- export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_node@0.0.707/dist/node.composition.js')]
2
- export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_node@0.0.707/dist/node.docs.mdx')]
1
+ export const compositions = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_node@0.0.710/dist/node.composition.js')]
2
+ export const overview = [require('/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.harmony_node@0.0.710/dist/node.docs.mdx')]
@@ -0,0 +1,10 @@
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,11 +1,178 @@
1
- export function docFile() {
1
+ import { ComponentContext } from '@teambit/generator';
2
+
3
+ export function docFile({ name, componentId }: ComponentContext) {
2
4
  return `---
3
- labels: ['extension', 'node', 'env', 'environment']
4
- description: 'A customized extension for Node environment.'
5
+ description: 'A standard Node component development environment'
6
+ labels: ['node', 'typescript', 'env', 'extension']
5
7
  ---
6
8
 
7
- This is a customized extension for Node, based of the [Node Aspect](https://bit.cloud/teambit/harmony/node).
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:
8
174
 
9
- Explain here the modified configurations and tools applied.
175
+ \`\`\`ts
176
+ react.registerProvider([ThemeCompositions]);
10
177
  `;
11
178
  }
@@ -1,8 +1,10 @@
1
1
  import { ComponentContext } from '@teambit/generator';
2
2
 
3
3
  export function indexFile({ namePascalCase: Name, name }: ComponentContext) {
4
- return `import { ${Name}Extension } from './${name}.extension';
5
- export { ${Name}Extension };
6
- export default ${Name}Extension;
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 };
7
9
  `;
8
10
  }
@@ -0,0 +1,21 @@
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
+ }
@@ -0,0 +1,93 @@
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 { ${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-transformers";
16
+
17
+ export class ${Name}Main {
18
+ static slots = [];
19
+
20
+ static dependencies = [NodeAspect, EnvsAspect];
21
+
22
+ static runtime = MainRuntime;
23
+
24
+ //const webpackModifiers: UseWebpackModifiers = {
25
+ // previewConfig: [previewConfigTransformer],
26
+ // devServerConfig: [devServerConfigTransformer],
27
+ //};
28
+
29
+ //const tsModifiers: UseTypescriptModifiers = {
30
+ // devConfig: [devConfigTransformer],
31
+ // buildConfig: [buildConfigTransformer],
32
+ //};
33
+
34
+ static async provider([node, envs]: [NodeMain, EnvsMain]) {
35
+ const ${Name}Env = node.compose([
36
+ /**
37
+ * Uncomment to override the config files for TypeScript, Webpack or Jest
38
+ * Your config gets merged with the defaults
39
+ */
40
+
41
+ // node.useTypescript(tsModifiers), // note: this cannot be used in conjunction with node.overrideCompiler
42
+ // node.useWebpack(webpackModifiers),
43
+ // node.overrideJestConfig(require.resolve('./jest/jest.config')),
44
+
45
+ /**
46
+ * override the ESLint default config here then check your files for lint errors
47
+ * @example
48
+ * bit lint
49
+ * bit lint --fix
50
+ */
51
+ node.useEslint({
52
+ transformers: [
53
+ (config) => {
54
+ config.setRule('no-console', ['error']);
55
+ return config;
56
+ }
57
+ ]
58
+ }),
59
+
60
+ /**
61
+ * override the Prettier default config here the check your formatting
62
+ * @example
63
+ * bit format --check
64
+ * bit format
65
+ */
66
+ node.usePrettier({
67
+ transformers: [
68
+ (config) => {
69
+ config.setKey('tabWidth', 2);
70
+ return config;
71
+ }
72
+ ]
73
+ }),
74
+
75
+ /**
76
+ * override dependencies here
77
+ * @example
78
+ * Uncomment types to include version 17.0.3 of the types package
79
+ */
80
+ node.overrideDependencies({
81
+ devDependencies: {
82
+ // '@types/node': '16.11.7'
83
+ }
84
+ })
85
+ ]);
86
+ envs.registerEnv(${Name}Env);
87
+ return new ${Name}Main();
88
+ }
89
+ }
90
+
91
+ ${Name}Aspect.addRuntime(${Name}Main);
92
+ `;
93
+ }
@@ -0,0 +1,27 @@
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
+ }
@@ -0,0 +1,7 @@
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
+ }
@@ -0,0 +1,50 @@
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
+ }
@@ -0,0 +1,21 @@
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
+ }