@teambit/node 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.2f6adb00de8250ec25bb.js → compositions.6395ee2f67b53dc97071.js} +1 -1
- package/artifacts/env-template/public/compositions.html +1 -1
- package/artifacts/env-template/public/{overview.6046b45c5c5ed35f09bb.js → overview.c7aa3cd8774f1afeef8c.js} +1 -1
- package/artifacts/env-template/public/overview.html +1 -1
- package/artifacts/env-template/public/{peers.b59dd85dd7ea760e8208.js → peers.c906150070dc1e476b7a.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/node.aspect.js +2 -4
- package/dist/node.aspect.js.map +1 -1
- package/dist/node.env.js +1 -2
- package/dist/node.env.js.map +1 -1
- package/dist/node.main.runtime.d.ts +6 -3
- package/dist/node.main.runtime.js +21 -25
- package/dist/node.main.runtime.js.map +1 -1
- package/dist/node.templates.d.ts +3 -0
- package/dist/node.templates.js +33 -0
- package/dist/node.templates.js.map +1 -0
- package/dist/node.ui.runtime.js +1 -2
- package/dist/node.ui.runtime.js.map +1 -1
- package/dist/{preview-1698981534427.js → preview-1699369416537.js} +2 -2
- package/package.json +23 -20
- package/dist/templates/entity/index.d.ts +0 -0
- package/dist/templates/entity/index.js +0 -3
- package/dist/templates/entity/index.js.map +0 -1
- package/dist/templates/express-app/files/app-root.d.ts +0 -5
- package/dist/templates/express-app/files/app-root.js +0 -39
- package/dist/templates/express-app/files/app-root.js.map +0 -1
- package/dist/templates/express-app/files/composition.d.ts +0 -5
- package/dist/templates/express-app/files/composition.js +0 -20
- package/dist/templates/express-app/files/composition.js.map +0 -1
- package/dist/templates/express-app/files/doc.d.ts +0 -5
- package/dist/templates/express-app/files/doc.js +0 -35
- package/dist/templates/express-app/files/doc.js.map +0 -1
- package/dist/templates/express-app/files/get-port.d.ts +0 -4
- package/dist/templates/express-app/files/get-port.js +0 -21
- package/dist/templates/express-app/files/get-port.js.map +0 -1
- package/dist/templates/express-app/files/index.d.ts +0 -6
- package/dist/templates/express-app/files/index.js +0 -17
- package/dist/templates/express-app/files/index.js.map +0 -1
- package/dist/templates/express-app/files/mock-route.d.ts +0 -4
- package/dist/templates/express-app/files/mock-route.js +0 -23
- package/dist/templates/express-app/files/mock-route.js.map +0 -1
- package/dist/templates/express-app/files/node-app.d.ts +0 -5
- package/dist/templates/express-app/files/node-app.js +0 -23
- package/dist/templates/express-app/files/node-app.js.map +0 -1
- package/dist/templates/express-app/files/route.d.ts +0 -4
- package/dist/templates/express-app/files/route.js +0 -29
- package/dist/templates/express-app/files/route.js.map +0 -1
- package/dist/templates/express-app/files/test.d.ts +0 -5
- package/dist/templates/express-app/files/test.js +0 -19
- package/dist/templates/express-app/files/test.js.map +0 -1
- package/dist/templates/express-app/index.d.ts +0 -2
- package/dist/templates/express-app/index.js +0 -79
- package/dist/templates/express-app/index.js.map +0 -1
- package/dist/templates/express-route/files/composition.d.ts +0 -5
- package/dist/templates/express-route/files/composition.js +0 -20
- package/dist/templates/express-route/files/composition.js.map +0 -1
- package/dist/templates/express-route/files/doc.d.ts +0 -5
- package/dist/templates/express-route/files/doc.js +0 -24
- package/dist/templates/express-route/files/doc.js.map +0 -1
- package/dist/templates/express-route/files/index.d.ts +0 -6
- package/dist/templates/express-route/files/index.js +0 -16
- package/dist/templates/express-route/files/index.js.map +0 -1
- package/dist/templates/express-route/files/main.d.ts +0 -5
- package/dist/templates/express-route/files/main.js +0 -21
- package/dist/templates/express-route/files/main.js.map +0 -1
- package/dist/templates/express-route/files/test.d.ts +0 -5
- package/dist/templates/express-route/files/test.js +0 -19
- package/dist/templates/express-route/files/test.js.map +0 -1
- package/dist/templates/express-route/index.d.ts +0 -2
- package/dist/templates/express-route/index.js +0 -51
- package/dist/templates/express-route/index.js.map +0 -1
- package/dist/templates/node/files/composition.d.ts +0 -5
- package/dist/templates/node/files/composition.js +0 -20
- package/dist/templates/node/files/composition.js.map +0 -1
- package/dist/templates/node/files/doc.d.ts +0 -5
- package/dist/templates/node/files/doc.js +0 -24
- package/dist/templates/node/files/doc.js.map +0 -1
- package/dist/templates/node/files/index.d.ts +0 -6
- package/dist/templates/node/files/index.js +0 -16
- package/dist/templates/node/files/index.js.map +0 -1
- package/dist/templates/node/files/main.d.ts +0 -5
- package/dist/templates/node/files/main.js +0 -17
- package/dist/templates/node/files/main.js.map +0 -1
- package/dist/templates/node/files/test.d.ts +0 -5
- package/dist/templates/node/files/test.js +0 -19
- package/dist/templates/node/files/test.js.map +0 -1
- package/dist/templates/node/index.d.ts +0 -2
- package/dist/templates/node/index.js +0 -58
- package/dist/templates/node/index.js.map +0 -1
- package/dist/templates/node-env/files/aspect.d.ts +0 -2
- package/dist/templates/node-env/files/aspect.js +0 -19
- package/dist/templates/node-env/files/aspect.js.map +0 -1
- package/dist/templates/node-env/files/doc.d.ts +0 -2
- package/dist/templates/node-env/files/doc.js +0 -187
- package/dist/templates/node-env/files/doc.js.map +0 -1
- package/dist/templates/node-env/files/index.d.ts +0 -2
- package/dist/templates/node-env/files/index.js +0 -19
- package/dist/templates/node-env/files/index.js.map +0 -1
- package/dist/templates/node-env/files/jest.config.d.ts +0 -1
- package/dist/templates/node-env/files/jest.config.js +0 -29
- package/dist/templates/node-env/files/jest.config.js.map +0 -1
- package/dist/templates/node-env/files/main.runtime.d.ts +0 -2
- package/dist/templates/node-env/files/main.runtime.js +0 -104
- package/dist/templates/node-env/files/main.runtime.js.map +0 -1
- package/dist/templates/node-env/files/preview.runtime.d.ts +0 -2
- package/dist/templates/node-env/files/preview.runtime.js +0 -37
- package/dist/templates/node-env/files/preview.runtime.js.map +0 -1
- package/dist/templates/node-env/files/typescript/styles.d.ts +0 -1
- package/dist/templates/node-env/files/typescript/styles.js +0 -15
- package/dist/templates/node-env/files/typescript/styles.js.map +0 -1
- package/dist/templates/node-env/files/typescript/ts-transformer.d.ts +0 -1
- package/dist/templates/node-env/files/typescript/ts-transformer.js +0 -58
- package/dist/templates/node-env/files/typescript/ts-transformer.js.map +0 -1
- package/dist/templates/node-env/files/typescript/typescript.config.d.ts +0 -1
- package/dist/templates/node-env/files/typescript/typescript.config.js +0 -29
- package/dist/templates/node-env/files/typescript/typescript.config.js.map +0 -1
- package/dist/templates/node-env/files/webpack.config.d.ts +0 -1
- package/dist/templates/node-env/files/webpack.config.js +0 -56
- package/dist/templates/node-env/files/webpack.config.js.map +0 -1
- package/dist/templates/node-env/index.d.ts +0 -2
- package/dist/templates/node-env/index.js +0 -124
- package/dist/templates/node-env/index.js.map +0 -1
- package/templates/entity/index.ts +0 -0
- package/templates/express-app/files/app-root.ts +0 -33
- package/templates/express-app/files/composition.ts +0 -14
- package/templates/express-app/files/doc.ts +0 -26
- package/templates/express-app/files/get-port.ts +0 -13
- package/templates/express-app/files/index.ts +0 -11
- package/templates/express-app/files/mock-route.ts +0 -15
- package/templates/express-app/files/node-app.ts +0 -17
- package/templates/express-app/files/route.ts +0 -21
- package/templates/express-app/files/test.ts +0 -13
- package/templates/express-app/index.ts +0 -35
- package/templates/express-route/files/composition.ts +0 -14
- package/templates/express-route/files/doc.ts +0 -18
- package/templates/express-route/files/index.ts +0 -10
- package/templates/express-route/files/main.ts +0 -15
- package/templates/express-route/files/test.ts +0 -13
- package/templates/express-route/index.ts +0 -27
- package/templates/node/files/composition.ts +0 -14
- package/templates/node/files/doc.ts +0 -18
- package/templates/node/files/index.ts +0 -10
- package/templates/node/files/main.ts +0 -11
- package/templates/node/files/test.ts +0 -13
- package/templates/node/index.ts +0 -21
- package/templates/node-env/files/aspect.ts +0 -10
- package/templates/node-env/files/doc.ts +0 -178
- package/templates/node-env/files/index.ts +0 -10
- package/templates/node-env/files/jest.config.ts +0 -21
- package/templates/node-env/files/main.runtime.ts +0 -95
- package/templates/node-env/files/preview.runtime.ts +0 -27
- package/templates/node-env/files/typescript/styles.ts +0 -7
- package/templates/node-env/files/typescript/ts-transformer.ts +0 -50
- package/templates/node-env/files/typescript/typescript.config.ts +0 -21
- package/templates/node-env/files/webpack.config.ts +0 -48
- package/templates/node-env/index.ts +0 -68
- /package/{compositions-1698981534427.js → compositions-1699369416537.js} +0 -0
- /package/{overview-1698981534427.js → overview-1699369416537.js} +0 -0
|
@@ -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,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 nodeEnvTemplate: ComponentTemplate = {
|
|
14
|
-
name: 'node-env',
|
|
15
|
-
description: 'customize the base Node 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
|
-
};
|
|
File without changes
|
|
File without changes
|