@teambit/node 0.0.1048 → 0.0.1049

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.
@@ -1,172 +0,0 @@
1
- (function(root,factory){typeof exports=="object"&&typeof module=="object"?module.exports=factory():typeof define=="function"&&define.amd?define([],factory):typeof exports=="object"?exports["teambit.harmony/node-preview"]=factory():root["teambit.harmony/node-preview"]=factory()})(self,function(){return(()=>{var __webpack_modules__={305:(__unused_webpack_module,exports2,__webpack_require__2)=>{"use strict";var __webpack_unused_export__,__bit_component={id:"teambit.harmony/aspect-docs/node@0.0.151",homepage:"https://bit.cloud/teambit/harmony/aspect-docs/node",exported:!0};__webpack_unused_export__={value:!0},Object.defineProperty(exports2,"N",{enumerable:!0,get:function(){return _node.default}});var _node=_interopRequireDefault(__webpack_require__2(989));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}_interopRequireDefault.__bit_component=__bit_component},989:(__unused_webpack_module,exports2,__webpack_require__2)=>{"use strict";var __bit_component={id:"teambit.harmony/aspect-docs/node@0.0.151",homepage:"https://bit.cloud/teambit/harmony/aspect-docs/node",exported:!0};Object.defineProperty(exports2,"__esModule",{value:!0}),exports2.default=MDXContent;var _react=_interopRequireDefault(__webpack_require__2(804)),_react2=__webpack_require__2(57),_excluded=["components"];function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}_interopRequireDefault.__bit_component=__bit_component;function _extends(){return _extends=Object.assign?Object.assign.bind():function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key])}return target},_extends.apply(this,arguments)}_extends.__bit_component=__bit_component;function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded),key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++)key=sourceSymbolKeys[i],!(excluded.indexOf(key)>=0)&&(!Object.prototype.propertyIsEnumerable.call(source,key)||(target[key]=source[key]))}return target}_objectWithoutProperties.__bit_component=__bit_component;function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={},sourceKeys=Object.keys(source),key,i;for(i=0;i<sourceKeys.length;i++)key=sourceKeys[i],!(excluded.indexOf(key)>=0)&&(target[key]=source[key]);return target}_objectWithoutPropertiesLoose.__bit_component=__bit_component;var layoutProps={},MDXLayout="wrapper";function MDXContent(_ref){var components=_ref.components,props=_objectWithoutProperties(_ref,_excluded);return(0,_react2.mdx)(MDXLayout,_extends({},layoutProps,props,{components,mdxType:"MDXLayout"}),(0,_react2.mdx)("p",null,"The built-in ",(0,_react2.mdx)("a",{parentName:"p",href:"https://bit.dev/teambit/harmony/node"},"Node Component Development Environment")," is a concrete composition of the ",(0,_react2.mdx)("a",{parentName:"p",href:"https://bit.dev/teambit/envs/envs"},"Env Aspect"),". Use it when getting started with Node components with Bit and later as a base for any future customization of your Node-based workflow."),(0,_react2.mdx)("p",null,"Node environment is composed out of the base ",(0,_react2.mdx)("a",{parentName:"p",href:"https://bit.dev/teambit/react/react"},"React Environment")," with some specific overrides for dependency management."),(0,_react2.mdx)("h2",null,"Use Node environment"),(0,_react2.mdx)("p",null,"To use this environment for your components, add it to any of the ",(0,_react2.mdx)("inlineCode",{parentName:"p"},"variants")," in your ",(0,_react2.mdx)("inlineCode",{parentName:"p"},"workspace.jsonc")," file as follows:"),(0,_react2.mdx)("pre",null,(0,_react2.mdx)("code",{parentName:"pre",className:"language-json",metastring:'title="workspace.jsonc"',title:'"workspace.jsonc"'},`{
2
- "teambit.workspace/variants": {
3
- "some/path": {
4
- "teambit.harmony/node": {}
5
- }
6
- }
7
- }
8
- `)),(0,_react2.mdx)("h2",null,"Create Node components"),(0,_react2.mdx)("p",null,"Node implements several component templates:"),(0,_react2.mdx)("ul",null,(0,_react2.mdx)("li",{parentName:"ul"},(0,_react2.mdx)("inlineCode",{parentName:"li"},"node-env")," boilerplate for customizing configuration.")),(0,_react2.mdx)("p",null,"Use any of these templates with the ",(0,_react2.mdx)("inlineCode",{parentName:"p"},"bit create")," command:"),(0,_react2.mdx)("pre",null,(0,_react2.mdx)("code",{parentName:"pre",className:"language-sh"},`bit create <template name> [components...]
9
- `)),(0,_react2.mdx)("h2",null,"Default Configuration and Services"),(0,_react2.mdx)("p",null,"Node, like all over Environments must implement a set of Service Handlers. For each service, Node compose a different tool and config by default."),(0,_react2.mdx)("blockquote",null,(0,_react2.mdx)("p",{parentName:"blockquote"},"Node is a composition of the React environment with some specific modifications. Most of the links here direct to the actual configs in React environment.")),(0,_react2.mdx)("table",null,(0,_react2.mdx)("thead",{parentName:"table"},(0,_react2.mdx)("tr",{parentName:"thead"},(0,_react2.mdx)("th",{parentName:"tr",align:null},"Service"),(0,_react2.mdx)("th",{parentName:"tr",align:null},"Aspect"),(0,_react2.mdx)("th",{parentName:"tr",align:null},"Base Configuration"))),(0,_react2.mdx)("tbody",{parentName:"table"},(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},"Compilation"),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/typescript/typescript"},"TypeScript")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/react/react/~code/typescript/tsconfig.json"},"tsconfig.json"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},"Testing"),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("strong",{parentName:"td"},"Jest")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/react/react/~code/jest/jest.config.js"},"jest.config.js"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},"Linting"),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("strong",{parentName:"td"},"ESLint")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/react/react/~code/eslint/eslintrc.ts"},"eslintrc.ts"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},"DevServer"),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("strong",{parentName:"td"},"Webpack")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/react/react/~code/webpack/webpack.config.preview.dev.ts"},"webpack.config.preview.dev.ts"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},"Preview (simulation)"),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("strong",{parentName:"td"},"Webpack")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/react/react/~code/webpack/webpack.config.preview.ts"},"webpack.config.preview.ts"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},"Package"),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("strong",{parentName:"td"},"PKG")),(0,_react2.mdx)("td",{parentName:"tr",align:null},"Base ",(0,_react2.mdx)("inlineCode",{parentName:"td"},"package.json")," props from ",(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/typescript/typescript/~code/typescript.main.runtime.ts"},"TypeScript Aspect"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},"Bundling"),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("strong",{parentName:"td"},"Webpack")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/react/react/~code/webpack/webpack.config.preview.ts"},"webpack.config.preview.ts"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},"Documentation"),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("em",{parentName:"td"},"Core implementation")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/react/react/~code/docs/index.tsx"},"Docs template"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},"Build pipeline"),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/pipelines/builder"},"Builder")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/react/react/~code/node.env.ts"},"Build pipeline"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},"Dependencies"),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("em",{parentName:"td"},"Core implementation")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/harmony/node/~code/node.env.ts"},"Env-dependencies"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},"Component Generator"),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/generator/generator"},"Generator")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/harmony/node/~code/templates/node-component.ts"},"example template"))))),(0,_react2.mdx)("h2",null,"Customize environment"),(0,_react2.mdx)("p",null,"All environments are extendible. You can take any pre-existing environment, and create a component to extend it. That component can then use APIs to:"),(0,_react2.mdx)("ul",null,(0,_react2.mdx)("li",{parentName:"ul"},"Override default configurations."),(0,_react2.mdx)("li",{parentName:"ul"},"Replace composed tools with others (for example - use Babel instead of TypeScript)."),(0,_react2.mdx)("li",{parentName:"ul"},"Add new services and capabilities.")),(0,_react2.mdx)("h3",null,"Create an extension"),(0,_react2.mdx)("p",null,"The first step is to create a component that extends Node. Use the ",(0,_react2.mdx)("inlineCode",{parentName:"p"},"node-env")," template from Node env."),(0,_react2.mdx)("pre",null,(0,_react2.mdx)("code",{parentName:"pre",className:"language-sh"},`bit create node-env extensions/custom-node
10
- `)),(0,_react2.mdx)("p",null,"As with any component, environments must themselves have an environment which compiles, builds, transpiles, etc, them. Bit has a special environment that knows how to create other environments - ",(0,_react2.mdx)("inlineCode",{parentName:"p"},"teambit.harmony/aspect"),". So for any component that is meant to be a Bit environment, you must set ",(0,_react2.mdx)("inlineCode",{parentName:"p"},"teambit.harmony/aspect")," as the environment for that component."),(0,_react2.mdx)("pre",null,(0,_react2.mdx)("code",{parentName:"pre",className:"language-json",metastring:'title="add variant for the extension and set the aspect env"',title:'"add',variant:!0,for:!0,the:!0,extension:!0,and:!0,set:!0,aspect:!0,'env"':!0},`{
11
- //...
12
- "teambit.workspace/variants": {
13
- //...
14
- "extensions/custom-node": {
15
- "teambit.harmony/aspect": {}
16
- }
17
- //...
18
- }
19
- }
20
- `)),(0,_react2.mdx)("p",null,"Validate the above by running ",(0,_react2.mdx)("inlineCode",{parentName:"p"},"bit env")," and see that the extension-component has ",(0,_react2.mdx)("inlineCode",{parentName:"p"},"teambit.harmony/aspect")," set as an environment."),(0,_react2.mdx)("p",null,"Now that you have a basic customized extension to start from, you can go ahead and configure it for your components in ",(0,_react2.mdx)("inlineCode",{parentName:"p"},"workspace.json"),":"),(0,_react2.mdx)("pre",null,(0,_react2.mdx)("code",{parentName:"pre",className:"language-json",metastring:'title="edit variants and set the new env"',title:'"edit',variants:!0,and:!0,set:!0,the:!0,new:!0,'env"':!0},`{
21
- //...
22
- "teambit.workspace/variants": {
23
- //...
24
- "[some]/[variant]": {
25
- "[yourscope]/extensions/custom-node": {}
26
- }
27
- //...
28
- }
29
- }
30
- `)),(0,_react2.mdx)("h3",null,"Customize configuration"),(0,_react2.mdx)("p",null,"Node implements a set of APIs you can use to merge your preferred configuration with its defaults. These APIs are called ",(0,_react2.mdx)("strong",{parentName:"p"},"transformers")," and they all start with the ",(0,_react2.mdx)("inlineCode",{parentName:"p"},"override")," pre-fix. Find ",(0,_react2.mdx)("a",{parentName:"p",href:"#transformers-api-docs"},"Available transformers here"),`.
31
- In case of a conflict, your config will override the default.`),(0,_react2.mdx)("pre",null,(0,_react2.mdx)("code",{parentName:"pre",className:"language-typescript",metastring:'{4,14} title="Customized TypeScript configuration"',"{4,14}":!0,title:'"Customized',TypeScript:!0,'configuration"':!0},`import { EnvsMain, EnvsAspect } from '@teambit/envs';
32
- import { NodeAspect, NodeMain } from '@teambit/node';
33
-
34
- const tsconfig = require('./typescript/tsconfig.json');
35
-
36
- export class CustomNodeExtension {
37
- constructor(private node: NodeMain) {}
38
-
39
- static dependencies: any = [EnvsAspect, NodeAspect];
40
-
41
- static async provider([envs, node]: [EnvsMain, NodeMain]) {
42
- const customNodeEnv = node.compose([node.overrideTsConfig(tsconfig)]);
43
-
44
- envs.registerEnv(customNodeEnv);
45
-
46
- return new CustomNodeExtension(node);
47
- }
48
- }
49
- `)),(0,_react2.mdx)("blockquote",null,(0,_react2.mdx)("p",{parentName:"blockquote"},"To override any specific configuration it's recommended to create a separate config file with your customized configuration and import it into the main ",(0,_react2.mdx)("inlineCode",{parentName:"p"},".extension.ts")," file where you can supply it to the relevant ",(0,_react2.mdx)("strong",{parentName:"p"},"transformers"),". See the tsconfig example in the above snippet.")),(0,_react2.mdx)("h3",null,"Composing tools and services"),(0,_react2.mdx)("p",null,`Environments use Environment Services by implementing a special class of methods called Service Handlers.
50
- The supplied transformers allow overriding of these services - for instance the `,(0,_react2.mdx)("inlineCode",{parentName:"p"},"overrideCompiler")," transformer allows overriding the environment's ",(0,_react2.mdx)("inlineCode",{parentName:"p"},"getCompiler()")," method."),(0,_react2.mdx)("p",null,"The below example uses the ",(0,_react2.mdx)("inlineCode",{parentName:"p"},"overrideCompiler")," transformer to override the ",(0,_react2.mdx)("inlineCode",{parentName:"p"},"getCompiler()")," Service Handler to change the compilation service."),(0,_react2.mdx)("ol",null,(0,_react2.mdx)("li",{parentName:"ol"},"Add a Babel config file to your custom environment and import/require it in your ",(0,_react2.mdx)("inlineCode",{parentName:"li"},".extension")," file"),(0,_react2.mdx)("li",{parentName:"ol"},"Create a new Babel compiler using the Babel aspect, and initialize it with the above babelConfig"),(0,_react2.mdx)("li",{parentName:"ol"},"Use the ",(0,_react2.mdx)("inlineCode",{parentName:"li"},"compose")," Env API to apply the compiler override transformer and add Babel as a transpiler in the environment")),(0,_react2.mdx)("pre",null,(0,_react2.mdx)("code",{parentName:"pre",className:"language-typescript",metastring:"{3,5,10-12,15,17-18,22-23}","{3,5,10-12,15,17-18,22-23}":!0},`import { EnvsMain, EnvsAspect } from '@teambit/envs';
51
- import { NodeAspect, NodeMain } from '@teambit/node';
52
- import { BabelAspect, BabelMain } from '@teambit/babel';
53
-
54
- const babelConfig = require('./babel/babel.config');
55
-
56
- export class CustomNodeExtension {
57
- constructor(private node: NodeMain) {}
58
-
59
- static dependencies: any = [EnvsAspect, NodeAspect, BabelAspect];
60
-
61
- static async provider([envs, node, babel]: [EnvsMain, NodeMain, BabelMain]) {
62
- const babelCompiler = babel.createCompiler({
63
- babelTransformOptions: babelConfig,
64
- });
65
-
66
- const customNodeEnv = node.compose([
67
- node.overrideCompiler(babelCompiler),
68
- node.overrideCompilerTasks([babelCompiler.createTask()]),
69
- ]);
70
-
71
- envs.registerEnv(customNodeEnv);
72
- return new CustomNodeExtension(node);
73
- }
74
- }
75
- `)),(0,_react2.mdx)("h3",null,"Transformers API docs"),(0,_react2.mdx)("p",null,"Use these APIs to customize the base Node environment default configuration with your extension. ",(0,_react2.mdx)("a",{parentName:"p",href:"#customizing-configuration"},"Read more here"),"."),(0,_react2.mdx)("h4",null,(0,_react2.mdx)("inlineCode",{parentName:"h4"},"overrideTsConfig(tsconfig: TsConfigSourceFile): EnvTransformer")),(0,_react2.mdx)("p",null,"Merges the environment's default TypeScript configuration with the contents of your ",(0,_react2.mdx)("a",{parentName:"p",href:"https://www.typescriptlang.org/handbook/tsconfig-json.html"},"typescript configuration file"),`.
76
- This config affects the transpilation carried out when rendering components on the local dev UI. To override the config used when building components, use `,(0,_react2.mdx)("inlineCode",{parentName:"p"},"overrideBuildTsConfig")," below."),(0,_react2.mdx)("pre",null,(0,_react2.mdx)("code",{parentName:"pre",className:"language-ts"},`// ...
77
- const tsconfig = require('./typescript/tsconfig.json');
78
- export class NodeExtension {
79
- // ...
80
-
81
- static async provider([envs, node]: [EnvsMain, NodeMain]) {
82
- const newNodeEnv = node.compose([
83
- node.overrideTsConfig(tsconfig)
84
- ]);
85
- }
86
- // ...
87
- `)),(0,_react2.mdx)("h4",null,(0,_react2.mdx)("inlineCode",{parentName:"h4"},"overrideBuildTsConfig(tsconfig: TsConfigSourceFile): EnvTransformer")),(0,_react2.mdx)("p",null,"Merges the environment's default TypeScript configuration with the contents of your ",(0,_react2.mdx)("a",{parentName:"p",href:"https://www.typescriptlang.org/handbook/tsconfig-json.html"},"typescript configuration file"),`.
88
- This config affects transpilation of component code during the build process, i.e. in preparation for packaging and exporting the component. To override the local ts config used when rendering components in the local UI, please use `,(0,_react2.mdx)("inlineCode",{parentName:"p"},"overrideTsConfig")," above."),(0,_react2.mdx)("pre",null,(0,_react2.mdx)("code",{parentName:"pre",className:"language-ts"},`// ...
89
- const tsconfig = require('./typescript/tsconfig.json');
90
- export class NodeExtension {
91
- // ...
92
-
93
- static async provider([envs, node]: [EnvsMain, NodeMain]) {
94
- const newNodeEnv = node.compose([
95
- node.overrideTsConfig(tsconfig)
96
- ]);
97
- }
98
- // ...
99
- `)),(0,_react2.mdx)("h4",null,(0,_react2.mdx)("inlineCode",{parentName:"h4"},"overridePreviewConfig(config: Configuration): EnvTransformer")),(0,_react2.mdx)("p",null,"Merges the Webpack configuration for the 'Preview' environment service, with the contents of your ",(0,_react2.mdx)("a",{parentName:"p",href:"https://webpack.js.org/configuration/"},"webpack configuration file"),`.
100
- This webpack configuration is used for building and rendering your components on the local dev server.`),(0,_react2.mdx)("pre",null,(0,_react2.mdx)("code",{parentName:"pre",className:"language-ts"},`// ...
101
- const webpackConfig = require('./webpack/webpack.config');
102
- export class NodeExtension {
103
- // ...
104
- static async provider([envs, node]: [EnvsMain, NodeMain]) {
105
- const newNodeEnv = node.compose([
106
- node.overridePreviewConfig(webpackConfig)
107
- ]);
108
- }
109
- // ...
110
- `)),(0,_react2.mdx)("h4",null,(0,_react2.mdx)("inlineCode",{parentName:"h4"},"overrideDevServerConfig(config: Configuration): EnvTransformer")),(0,_react2.mdx)("p",null,"Merges the Webpack configuration for the 'DevServer' environment service, with the contents of your ",(0,_react2.mdx)("a",{parentName:"p",href:"https://webpack.js.org/configuration/"},"webpack configuration file"),`.
111
- This configuration is used for building and rendering the dev server UI (but not your components, which use the PreviewConfig)`),(0,_react2.mdx)("pre",null,(0,_react2.mdx)("code",{parentName:"pre",className:"language-ts"},`// ...
112
- const webpackConfig = require('./webpack/webpack.config');
113
- export class NodeExtension {
114
- // ...
115
- static async provider([envs, node]: [EnvsMain, NodeMain]) {
116
- const newNodeEnv = node.compose([
117
- node.overrideDevServerConfig(webpackConfig)
118
- ]);
119
- }
120
- // ...
121
- `)),(0,_react2.mdx)("h4",null,(0,_react2.mdx)("inlineCode",{parentName:"h4"},"overrideJestConfig(jestConfigPath: string): EnvTransformer")),(0,_react2.mdx)("p",null,"Merges the default configuration for the Jest test runner with the contents of your (",(0,_react2.mdx)("a",{parentName:"p",href:"https://jestjs.io/en/configuration"},"jest.config configuration file"),")."),(0,_react2.mdx)("pre",null,(0,_react2.mdx)("code",{parentName:"pre",className:"language-ts"},`// ...
122
- export class NodeExtension {
123
- // ...
124
- static async provider([envs, node]: [EnvsMain, NodeMain]) {
125
- const newNodeEnv = node.compose([
126
- node.overrideJestConfig(require.resolve('./jest/jest.config'))
127
- ]);
128
- }
129
- // ...
130
- `)),(0,_react2.mdx)("h4",null,(0,_react2.mdx)("inlineCode",{parentName:"h4"},"overrideBuildPipe(tasks: BuildTask[]): EnvTransformer")),(0,_react2.mdx)("p",null,"This method receives an array of build tasks. It merges the provided tasks with the environment's default build pipeline (initiated either on a ",(0,_react2.mdx)("inlineCode",{parentName:"p"},"bit tag")," or ",(0,_react2.mdx)("inlineCode",{parentName:"p"},"bit build")," command)."),(0,_react2.mdx)("pre",null,(0,_react2.mdx)("code",{parentName:"pre",className:"language-ts"},`// ...
131
- // Import the task
132
- import { CustomTask } from './custom.task';
133
- export class CustomNode {
134
- // ...
135
- static async provider([envs, node]: [EnvsMain, NodeMain]) {
136
- // Get the environment's default build pipeline using the 'getBuildPipe' service handler
137
- const nodePipe = node.env.getBuildPipe();
138
- // Add the custom task to the end of the build tasks sequence.
139
- const tasks = [...nodePipe, new CustomTask()];
140
- const newNodeEnv = node.compose([node.overrideBuildPipe(tasks)]);
141
- // ...
142
- }
143
- }
144
- `)),(0,_react2.mdx)("h4",null,(0,_react2.mdx)("inlineCode",{parentName:"h4"},"overrideDependencies(dependencyPolicy: DependenciesPolicy): EnvTransformer")),(0,_react2.mdx)("p",null,`This method receives a dependency-policy object and merges it with the environment's default dependency policy for components using this environment.
145
- Each key-value pair in a dependency-policy object signifies the package and the version to be used. Use also the `,(0,_react2.mdx)("inlineCode",{parentName:"p"},"-")," and ",(0,_react2.mdx)("inlineCode",{parentName:"p"},"+")," notation to signify a module should moved between dependency types (dev, peer or standard)."),(0,_react2.mdx)("pre",null,(0,_react2.mdx)("code",{parentName:"pre",className:"language-js"},`// ...
146
- const newDependencies = {
147
- devDependencies: {
148
- '@types/jest': '~26.0.9',
149
- },
150
- };
151
-
152
- export class CustomNode {
153
- // ...
154
- static async provider([envs, node]: [EnvsMain, NodeMain]) {
155
- const newNodeEnv = node.compose([node.overrideDependencies(newDependencies)]);
156
- // ...
157
- }
158
- }
159
- `)),(0,_react2.mdx)("blockquote",null,(0,_react2.mdx)("p",{parentName:"blockquote"},"The above example shows the 'Node' library being removed as a (runtime) dependency and added as a peer dependency.")),(0,_react2.mdx)("h4",null,(0,_react2.mdx)("inlineCode",{parentName:"h4"},"overridePackageJsonProps(props: PackageJsonProps): EnvTransformer")),(0,_react2.mdx)("p",null,"Merges the provide props with the default properties added to the ",(0,_react2.mdx)("inlineCode",{parentName:"p"},"package.json")," file of every package generated from components using this environment."),(0,_react2.mdx)("pre",null,(0,_react2.mdx)("code",{parentName:"pre",className:"language-ts"},`// ...
160
- const newPackageProps = {
161
- main: 'dist/{main}.js',
162
- types: '{main}.ts',
163
- };
164
-
165
- export class CustomNode {
166
- // ...
167
- static async provider([envs, node]: [EnvsMain, NodeMain]) {
168
- const newNodeEnv = node.compose([node.overridePackageJsonProps(newPackageProps)]);
169
- // ...
170
- }
171
- }
172
- `)))}MDXContent.__bit_component=__bit_component,MDXContent.isMDXComponent=!0},530:(__unused_webpack_module,exports2,__webpack_require__2)=>{"use strict";var __bit_component={id:"teambit.harmony/node@0.0.1048",homepage:"https://bit.cloud/teambit/harmony/node",exported:!0},_interopRequireDefault=__webpack_require__2(370);Object.defineProperty(exports2,"__esModule",{value:!0}),exports2.Logo=void 0;function _react(){const data=_interopRequireDefault(__webpack_require__2(804));return _react=function(){return data},data}_react.__bit_component=__bit_component;const Logo=()=>_react().default.createElement("div",{style:{height:"100%",display:"flex",justifyContent:"center"}},_react().default.createElement("img",{style:{width:70},src:"https://static.bit.dev/extensions-icons/node.svg"}));Logo.__bit_component=__bit_component,exports2.Logo=Logo},57:module2=>{"use strict";module2.exports=MdxJsReact},804:module2=>{"use strict";module2.exports=React},370:module2=>{function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}module2.exports=_interopRequireDefault,module2.exports.__esModule=!0,module2.exports.default=module2.exports}},__webpack_module_cache__={};function __webpack_require__(moduleId){var cachedModule=__webpack_module_cache__[moduleId];if(cachedModule!==void 0)return cachedModule.exports;var module2=__webpack_module_cache__[moduleId]={exports:{}};return __webpack_modules__[moduleId](module2,module2.exports,__webpack_require__),module2.exports}__webpack_require__.d=(exports2,definition)=>{for(var key in definition)__webpack_require__.o(definition,key)&&!__webpack_require__.o(exports2,key)&&Object.defineProperty(exports2,key,{enumerable:!0,get:definition[key]})},__webpack_require__.o=(obj,prop)=>Object.prototype.hasOwnProperty.call(obj,prop),__webpack_require__.r=exports2=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(exports2,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(exports2,"__esModule",{value:!0})};var __webpack_exports__={};return(()=>{"use strict";__webpack_require__.r(__webpack_exports__),__webpack_require__.d(__webpack_exports__,{compositions:()=>compositions,compositions_metadata:()=>compositions_metadata,overview:()=>overview});var node_docs_namespaceObject={};__webpack_require__.r(node_docs_namespaceObject),__webpack_require__.d(node_docs_namespaceObject,{default:()=>MDXContent});var node_composition=__webpack_require__(530),external_React_=__webpack_require__(804),external_MdxJsReact_=__webpack_require__(57);const external_TeambitMdxUiMdxScopeContext_namespaceObject=TeambitMdxUiMdxScopeContext;var dist=__webpack_require__(305),_excluded=["components"];function _extends(){return _extends=Object.assign?Object.assign.bind():function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source)Object.prototype.hasOwnProperty.call(source,key)&&(target[key]=source[key])}return target},_extends.apply(this,arguments)}function _objectWithoutProperties(source,excluded){if(source==null)return{};var target=_objectWithoutPropertiesLoose(source,excluded),key,i;if(Object.getOwnPropertySymbols){var sourceSymbolKeys=Object.getOwnPropertySymbols(source);for(i=0;i<sourceSymbolKeys.length;i++)key=sourceSymbolKeys[i],!(excluded.indexOf(key)>=0)&&(!Object.prototype.propertyIsEnumerable.call(source,key)||(target[key]=source[key]))}return target}function _objectWithoutPropertiesLoose(source,excluded){if(source==null)return{};var target={},sourceKeys=Object.keys(source),key,i;for(i=0;i<sourceKeys.length;i++)key=sourceKeys[i],!(excluded.indexOf(key)>=0)&&(target[key]=source[key]);return target}var layoutProps={},MDXLayout="wrapper";function MDXContent(_ref){var components=_ref.components,props=_objectWithoutProperties(_ref,_excluded);return(0,external_MdxJsReact_.mdx)(MDXLayout,_extends({},layoutProps,props,{components,mdxType:"MDXLayout"}),(0,external_MdxJsReact_.mdx)(external_TeambitMdxUiMdxScopeContext_namespaceObject.MDXScopeProvider,{components:{Node:dist.N},mdxType:"MDXScopeProvider"},(0,external_MdxJsReact_.mdx)(dist.N,{mdxType:"Node"})))}MDXContent.isMDXComponent=!0;var __bit_component={id:"teambit.harmony/node@0.0.1048",homepage:"https://bit.cloud/teambit/harmony/node",exported:!0};const compositions=[node_composition],overview=[node_docs_namespaceObject],compositions_metadata={compositions:[{displayName:"Logo",identifier:"Logo"}]}})(),__webpack_exports__})()});