@teambit/react 0.0.588 → 0.0.589

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 (49) hide show
  1. package/dist/react-app-options.d.ts +6 -2
  2. package/dist/react.application.js +0 -1
  3. package/dist/react.application.js.map +1 -1
  4. package/dist/react.main.runtime.js +2 -2
  5. package/dist/templates/react-app/files/app-plugin.d.ts +2 -0
  6. package/dist/templates/react-app/files/app-plugin.js +24 -0
  7. package/dist/templates/react-app/files/app-plugin.js.map +1 -0
  8. package/dist/templates/react-app/files/app.js +3 -3
  9. package/dist/templates/react-app/files/app.js.map +1 -1
  10. package/dist/templates/react-app/files/doc.d.ts +1 -1
  11. package/dist/templates/react-app/files/doc.js +7 -11
  12. package/dist/templates/react-app/files/doc.js.map +1 -1
  13. package/dist/templates/react-app/files/index.d.ts +1 -1
  14. package/dist/templates/react-app/files/index.js +1 -7
  15. package/dist/templates/react-app/files/index.js.map +1 -1
  16. package/dist/templates/react-app/index.js +11 -24
  17. package/dist/templates/react-app/index.js.map +1 -1
  18. package/dist/templates/react-component/files/component.js +5 -5
  19. package/dist/templates/react-component/files/component.js.map +1 -1
  20. package/dist/templates/react-component/files/composition.js +5 -3
  21. package/dist/templates/react-component/files/composition.js.map +1 -1
  22. package/dist/templates/react-component/files/docs.js +5 -9
  23. package/dist/templates/react-component/files/docs.js.map +1 -1
  24. package/dist/templates/react-component/index.js.map +1 -1
  25. package/dist/templates/workspace-common/files/workspace-config.d.ts +1 -1
  26. package/dist/templates/workspace-common/files/workspace-config.js +27 -18
  27. package/dist/templates/workspace-common/files/workspace-config.js.map +1 -1
  28. package/dist/webpack/webpack.config.base.js +2 -2
  29. package/package-tar/teambit-react-0.0.589.tgz +0 -0
  30. package/package.json +26 -26
  31. package/templates/react-app/files/app-plugin.ts +14 -0
  32. package/templates/react-app/files/app.ts +3 -3
  33. package/templates/react-app/files/doc.ts +5 -11
  34. package/templates/react-app/files/index.ts +2 -7
  35. package/templates/react-app/index.ts +3 -8
  36. package/templates/react-component/files/component.ts +5 -5
  37. package/templates/react-component/files/composition.ts +5 -3
  38. package/templates/react-component/files/docs.ts +5 -9
  39. package/templates/react-component/index.ts +0 -1
  40. package/templates/workspace-common/files/workspace-config.ts +27 -19
  41. package/dist/templates/react-app/files/aspect.d.ts +0 -2
  42. package/dist/templates/react-app/files/aspect.js +0 -20
  43. package/dist/templates/react-app/files/aspect.js.map +0 -1
  44. package/dist/templates/react-app/files/main.runtime.d.ts +0 -2
  45. package/dist/templates/react-app/files/main.runtime.js +0 -32
  46. package/dist/templates/react-app/files/main.runtime.js.map +0 -1
  47. package/package-tar/teambit-react-0.0.588.tgz +0 -0
  48. package/templates/react-app/files/aspect.ts +0 -10
  49. package/templates/react-app/files/main.runtime.ts +0 -22
@@ -14,13 +14,17 @@ export declare type ReactAppOptions = {
14
14
  */
15
15
  ssr?: boolean;
16
16
  /**
17
- * instance of bundler to use.
17
+ * instance of bundler to use. default is Webpack.
18
18
  */
19
19
  bundler?: Bundler;
20
20
  /**
21
- * instance of dev server to use.
21
+ * instance of dev server to use. default is Webpack.
22
22
  */
23
23
  devServer?: DevServer;
24
+ /**
25
+ * decide whether to prerender your app. accepts an array of routes. if none, prerender would not apply.
26
+ */
27
+ prerender?: string[];
24
28
  /**
25
29
  * deploy function.
26
30
  */
@@ -65,7 +65,6 @@ class ReactApp {
65
65
  async run(context) {
66
66
  const devServerContext = this.getDevServerContext(context);
67
67
  const devServer = this.reactEnv.getDevServer(devServerContext, [configMutator => {
68
- // configMutator.addTopLevel('output', { publicPath: `/public/${this.name}` });
69
68
  configMutator.addTopLevel('devServer', {
70
69
  historyApiFallback: {
71
70
  index: '/index.html',
@@ -1 +1 @@
1
- {"version":3,"sources":["react.application.ts"],"names":["ReactApp","constructor","name","entry","portRange","reactEnv","deploy","prerenderRoutes","run","context","devServerContext","getDevServerContext","devServer","getDevServer","configMutator","addTopLevel","historyApiFallback","index","disableDotRule","raw","output","publicPath","from","to","port","Port","getPort","listen","build","aspectId","appCapsule","env","publicDir","outputPath","path","distDir","getCompiler","entries","map","require","resolve","bundlerContext","Object","assign","targets","components","component","rootPath","bundler","getBundler","addPlugin","PrerenderSPAPlugin","staticDir","routes","postProcess","renderedRoute","originalRoute","deployContext","applicationType","title"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAKA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,QAAN,CAAsC;AAC3CC,EAAAA,WAAW,CACAC,IADA,EAEAC,KAFA,EAGAC,SAHA,EAIDC,QAJC,EAKAC,MALA,EAMAC,eANA,EAOT;AAAA,SANSL,IAMT,GANSA,IAMT;AAAA,SALSC,KAKT,GALSA,KAKT;AAAA,SAJSC,SAIT,GAJSA,SAIT;AAAA,SAHQC,QAGR,GAHQA,QAGR;AAAA,SAFSC,MAET,GAFSA,MAET;AAAA,SADSC,eACT,GADSA,eACT;AAAA,6DAEgB,OAFhB;AAAE;;AAIK,QAAHC,GAAG,CAACC,OAAD,EAAuC;AAC9C,UAAMC,gBAAgB,GAAG,KAAKC,mBAAL,CAAyBF,OAAzB,CAAzB;AACA,UAAMG,SAAS,GAAG,KAAKP,QAAL,CAAcQ,YAAd,CAA2BH,gBAA3B,EAA6C,CAC5DI,aAAD,IAAmB;AACjB;AACAA,MAAAA,aAAa,CAACC,WAAd,CAA0B,WAA1B,EAAuC;AACrCC,QAAAA,kBAAkB,EAAE;AAClBC,UAAAA,KAAK,EAAE,aADW;AAElBC,UAAAA,cAAc,EAAE;AAFE;AADiB,OAAvC;AAOA,UAAI,CAACJ,aAAa,CAACK,GAAd,CAAkBC,MAAvB,EAA+BN,aAAa,CAACK,GAAd,CAAkBC,MAAlB,GAA2B,EAA3B;AAC/BN,MAAAA,aAAa,CAACK,GAAd,CAAkBC,MAAlB,CAAyBC,UA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ender-spa-plugin';\nimport { join, basename } from 'path';\nimport { Capsule } from '@teambit/isolator';\nimport { Application, AppContext, DeployContext } from '@teambit/application';\nimport { BuildContext } from '@teambit/builder';\nimport { Bundler, BundlerContext, DevServerContext } from '@teambit/bundler';\nimport { Port } from '@teambit/toolbox.network.get-port';\nimport { ReactEnv } from './react.env';\n\nexport class ReactApp implements Application {\n constructor(\n readonly name: string,\n readonly entry: string[],\n readonly portRange: number[],\n private reactEnv: ReactEnv,\n readonly deploy?: (context: DeployContext) => Promise<void>,\n readonly prerenderRoutes?: string[]\n ) {}\n\n applicationType = 'react';\n\n async run(context: AppContext): Promise<number> {\n const devServerContext = this.getDevServerContext(context);\n const devServer = this.reactEnv.getDevServer(devServerContext, [\n (configMutator) => {\n // configMutator.addTopLevel('output', { publicPath: `/public/${this.name}` });\n configMutator.addTopLevel('devServer', {\n historyApiFallback: {\n index: '/index.html',\n disableDotRule: true,\n },\n });\n\n if (!configMutator.raw.output) configMutator.raw.output = {};\n configMutator.raw.output.publicPath = '/';\n\n return configMutator;\n },\n ]);\n const [from, to] = this.portRange;\n const port = await Port.getPort(from, to);\n await devServer.listen(port);\n return port;\n }\n\n async build(context: BuildContext, aspectId: string, appCapsule: Capsule): Promise<DeployContext> {\n const reactEnv: ReactEnv = context.env;\n const publicDir = join('applications', this.name, 'build');\n const outputPath = join(appCapsule.path, publicDir);\n const { distDir } = reactEnv.getCompiler();\n const entries = this.entry.map((entry) => require.resolve(`${appCapsule.path}/${distDir}/${basename(entry)}`));\n const bundlerContext: BundlerContext = Object.assign(context, {\n targets: [\n {\n components: [appCapsule?.component],\n entries,\n outputPath,\n },\n ],\n entry: [],\n rootPath: '/',\n });\n const bundler: Bundler = await reactEnv.getBundler(bundlerContext, [\n (configMutator) => {\n configMutator.addTopLevel('output', { path: join(outputPath, 'public'), publicPath: `/` });\n configMutator.addPlugin(\n new PrerenderSPAPlugin({\n staticDir: join(outputPath, 'public'),\n routes: this.prerenderRoutes,\n postProcess(renderedRoute) {\n renderedRoute.outputPath = join(outputPath, 'public', `${renderedRoute.originalRoute}.html`);\n return renderedRoute;\n },\n })\n );\n return configMutator;\n },\n ]);\n await bundler.run();\n const deployContext = Object.assign(context, {\n applicationType: this.applicationType,\n aspectId,\n publicDir: join(appCapsule.path, publicDir, 'public'),\n });\n return deployContext;\n }\n\n private getDevServerContext(context: AppContext): DevServerContext {\n return Object.assign(context, {\n entry: this.entry,\n rootPath: '',\n publicPath: `public/${this.name}`,\n title: this.name,\n });\n }\n}\n"]}
1
+ {"version":3,"sources":["react.application.ts"],"names":["ReactApp","constructor","name","entry","portRange","reactEnv","deploy","prerenderRoutes","run","context","devServerContext","getDevServerContext","devServer","getDevServer","configMutator","addTopLevel","historyApiFallback","index","disableDotRule","raw","output","publicPath","from","to","port","Port","getPort","listen","build","aspectId","appCapsule","env","publicDir","outputPath","path","distDir","getCompiler","entries","map","require","resolve","bundlerContext","Object","assign","targets","components","component","rootPath","bundler","getBundler","addPlugin","PrerenderSPAPlugin","staticDir","routes","postProcess","renderedRoute","originalRoute","deployContext","applicationType","title"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAKA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGO,MAAMA,QAAN,CAAsC;AAC3CC,EAAAA,WAAW,CACAC,IADA,EAEAC,KAFA,EAGAC,SAHA,EAIDC,QAJC,EAKAC,MALA,EAMAC,eANA,EAOT;AAAA,SANSL,IAMT,GANSA,IAMT;AAAA,SALSC,KAKT,GALSA,KAKT;AAAA,SAJSC,SAIT,GAJSA,SAIT;AAAA,SAHQC,QAGR,GAHQA,QAGR;AAAA,SAFSC,MAET,GAFSA,MAET;AAAA,SADSC,eACT,GADSA,eACT;AAAA,6DAEgB,OAFhB;AAAE;;AAIK,QAAHC,GAAG,CAACC,OAAD,EAAuC;AAC9C,UAAMC,g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;AAG3CG,MAAAA,SAAS,EAAE,kBAAKF,UAAU,CAACI,IAAhB,EAAsBF,SAAtB,EAAiC,QAAjC;AAHgC,KAAvB,CAAtB;AAKA,WAAOyB,aAAP;AACD;;AAEO9C,EAAAA,mBAAmB,CAACF,OAAD,EAAwC;AACjE,WAAOiC,MAAM,CAACC,MAAP,CAAclC,OAAd,EAAuB;AAC5BN,MAAAA,KAAK,EAAE,KAAKA,KADgB;AAE5B4C,MAAAA,QAAQ,EAAE,EAFkB;AAG5B1B,MAAAA,UAAU,EAAG,UAAS,KAAKnB,IAAK,EAHJ;AAI5ByD,MAAAA,KAAK,EAAE,KAAKzD;AAJgB,KAAvB,CAAP;AAMD;;AApF0C","sourcesContent":["import PrerenderSPAPlugin from '@dreysolano/prerender-spa-plugin';\nimport { join, basename } from 'path';\nimport { Capsule } from '@teambit/isolator';\nimport { Application, AppContext, DeployContext } from '@teambit/application';\nimport { BuildContext } from '@teambit/builder';\nimport { Bundler, BundlerContext, DevServerContext } from '@teambit/bundler';\nimport { Port } from '@teambit/toolbox.network.get-port';\nimport { ReactEnv } from './react.env';\n\nexport class ReactApp implements Application {\n constructor(\n readonly name: string,\n readonly entry: string[],\n readonly portRange: number[],\n private reactEnv: ReactEnv,\n readonly deploy?: (context: DeployContext) => Promise<void>,\n readonly prerenderRoutes?: string[]\n ) {}\n\n applicationType = 'react';\n\n async run(context: AppContext): Promise<number> {\n const devServerContext = this.getDevServerContext(context);\n const devServer = this.reactEnv.getDevServer(devServerContext, [\n (configMutator) => {\n configMutator.addTopLevel('devServer', {\n historyApiFallback: {\n index: '/index.html',\n disableDotRule: true,\n },\n });\n\n if (!configMutator.raw.output) configMutator.raw.output = {};\n configMutator.raw.output.publicPath = '/';\n\n return configMutator;\n },\n ]);\n const [from, to] = this.portRange;\n const port = await Port.getPort(from, to);\n await devServer.listen(port);\n return port;\n }\n\n async build(context: BuildContext, aspectId: string, appCapsule: Capsule): Promise<DeployContext> {\n const reactEnv: ReactEnv = context.env;\n const publicDir = join('applications', this.name, 'build');\n const outputPath = join(appCapsule.path, publicDir);\n const { distDir } = reactEnv.getCompiler();\n const entries = this.entry.map((entry) => require.resolve(`${appCapsule.path}/${distDir}/${basename(entry)}`));\n const bundlerContext: BundlerContext = Object.assign(context, {\n targets: [\n {\n components: [appCapsule?.component],\n entries,\n outputPath,\n },\n ],\n entry: [],\n rootPath: '/',\n });\n const bundler: Bundler = await reactEnv.getBundler(bundlerContext, [\n (configMutator) => {\n configMutator.addTopLevel('output', { path: join(outputPath, 'public'), publicPath: `/` });\n configMutator.addPlugin(\n new PrerenderSPAPlugin({\n staticDir: join(outputPath, 'public'),\n routes: this.prerenderRoutes,\n postProcess(renderedRoute) {\n renderedRoute.outputPath = join(outputPath, 'public', `${renderedRoute.originalRoute}.html`);\n return renderedRoute;\n },\n })\n );\n return configMutator;\n },\n ]);\n await bundler.run();\n const deployContext = Object.assign(context, {\n applicationType: this.applicationType,\n aspectId,\n publicDir: join(appCapsule.path, publicDir, 'public'),\n });\n return deployContext;\n }\n\n private getDevServerContext(context: AppContext): DevServerContext {\n return Object.assign(context, {\n entry: this.entry,\n rootPath: '',\n publicPath: `public/${this.name}`,\n title: this.name,\n });\n }\n}\n"]}
@@ -253,9 +253,9 @@ function _react6() {
253
253
  return data;
254
254
  }
255
255
 
256
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
256
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
257
257
 
258
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
258
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
259
259
 
260
260
  class ReactMain {
261
261
  constructor(
@@ -0,0 +1,2 @@
1
+ import { ComponentContext } from '@teambit/generator';
2
+ export declare function appPlugin({ name, namePascalCase: Name }: ComponentContext): string;
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.appPlugin = appPlugin;
7
+
8
+ function appPlugin({
9
+ name,
10
+ namePascalCase: Name
11
+ }) {
12
+ return `import { ReactAppOptions } from '@teambit/react';
13
+
14
+ export const ${Name}App: ReactAppOptions = {
15
+ name: '${name}',
16
+ entry: [require.resolve('./${name}.app-root')],
17
+ prerenderRoutes: ['/'],
18
+ };
19
+
20
+ export default ${Name}App;
21
+ `;
22
+ }
23
+
24
+ //# sourceMappingURL=app-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["app-plugin.ts"],"names":["appPlugin","name","namePascalCase","Name"],"mappings":";;;;;;;AAEO,SAASA,SAAT,CAAmB;AAAEC,EAAAA,IAAF;AAAQC,EAAAA,cAAc,EAAEC;AAAxB,CAAnB,EAAqE;AAC1E,SAAQ;AACV;AACA,eAAeA,IAAK;AACpB,WAAWF,IAAK;AAChB,+BAA+BA,IAAK;AACpC;AACA;AACA;AACA,iBAAiBE,IAAK;AACtB,CATE;AAUD","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport function appPlugin({ name, namePascalCase: Name }: ComponentContext) {\n return `import { ReactAppOptions } from '@teambit/react';\n\nexport const ${Name}App: ReactAppOptions = {\n name: '${name}',\n entry: [require.resolve('./${name}.app-root')],\n prerenderRoutes: ['/'],\n};\n\nexport default ${Name}App;\n`;\n}\n"]}
@@ -9,7 +9,7 @@ function appFile({
9
9
  namePascalCase: Name
10
10
  }) {
11
11
  return `import React from 'react';
12
- import { BrowserRouter, Switch, Route } from 'react-router-dom';
12
+ import { BrowserRouter, Routes, Route } from 'react-router-dom';
13
13
 
14
14
  export function ${Name}App() {
15
15
  return (
@@ -17,8 +17,8 @@ export function ${Name}App() {
17
17
 
18
18
  {/* header component */}
19
19
 
20
- <Switch>
21
- <Route path="/">
20
+ <Routes>
21
+ <Route path="/" element={<div>Hello World!!</div>}>
22
22
  {/* home page component */}
23
23
  </Route>
24
24
 
@@ -1 +1 @@
1
- {"version":3,"sources":["app.ts"],"names":["appFile","namePascalCase","Name"],"mappings":";;;;;;;AAEO,SAASA,OAAT,CAAiB;AAAEC,EAAAA,cAAc,EAAEC;AAAlB,CAAjB,EAA6D;AAClE,SAAQ;AACV;AACA;AACA,kBAAkBA,IAAK;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAzBE;AA0BD","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport function appFile({ namePascalCase: Name }: ComponentContext) {\n return `import React from 'react';\nimport { BrowserRouter, Switch, Route } from 'react-router-dom';\n\nexport function ${Name}App() {\n return (\n <BrowserRouter>\n\n {/* header component */}\n\n <Switch>\n <Route path=\"/\">\n {/* home page component */}\n </Route>\n\n <Route path=\"/about\">\n {/* about page component */}\n </Route>\n\n </Switch>\n\n {/* footer component */}\n\n </BrowserRouter>\n );\n}\n`;\n}\n"]}
1
+ {"version":3,"sources":["app.ts"],"names":["appFile","namePascalCase","Name"],"mappings":";;;;;;;AAEO,SAASA,OAAT,CAAiB;AAAEC,EAAAA,cAAc,EAAEC;AAAlB,CAAjB,EAA6D;AAClE,SAAQ;AACV;AACA;AACA,kBAAkBA,IAAK;AACvB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAzBE;AA0BD","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport function appFile({ namePascalCase: Name }: ComponentContext) {\n return `import React from 'react';\nimport { BrowserRouter, Routes, Route } from 'react-router-dom';\n\nexport function ${Name}App() {\n return (\n <BrowserRouter>\n\n {/* header component */}\n\n <Routes>\n <Route path=\"/\" element={<div>Hello World!!</div>}>\n {/* home page component */}\n </Route>\n\n <Route path=\"/about\">\n {/* about page component */}\n </Route>\n\n </Switch>\n\n {/* footer component */}\n\n </BrowserRouter>\n );\n}\n`;\n}\n"]}
@@ -1,2 +1,2 @@
1
1
  import { ComponentContext } from '@teambit/generator';
2
- export declare function docFile({ name }: ComponentContext): string;
2
+ export declare function docFile({ name, componentId, nameCamelCase }: ComponentContext): string;
@@ -6,23 +6,19 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.docFile = docFile;
7
7
 
8
8
  function docFile({
9
- name
9
+ name,
10
+ componentId,
11
+ nameCamelCase
10
12
  }) {
11
13
  return `---
12
- description: Application.
13
- labels: ['env', 'app']
14
+ description: ${nameCamelCase} application component.
15
+ labels: ['${name}', 'app']
14
16
  ---
15
17
 
16
- ## Application component
17
-
18
- - The app file contains components from react router dom so you can add here all routes for your app and include all your page components.
19
- - The main runtime file contains what is needed to build your application as a React app.
20
- - The app root file renders your app to the DOM.
21
- - The compositions file renders your app so it can be seen in the compositions tab.
22
- - The aspect file contains the id of the aspect. You will need to modify this with your own org name, scope name and namespace if any, and then add it to your \`workspace.json\` file at root level like:
18
+ Configure the app plugin on your workspace:
23
19
 
24
20
  \`\`\`json
25
- "org-name.scope-name/namespace/name": {},
21
+ "${componentId.toString()}": {},
26
22
  \`\`\`
27
23
 
28
24
  ### Run the application
@@ -1 +1 @@
1
- {"version":3,"sources":["doc.ts"],"names":["docFile","name"],"mappings":";;;;;;;AAEO,SAASA,OAAT,CAAiB;AAAEC,EAAAA;AAAF,CAAjB,EAA6C;AAClD,SAAQ;AACV;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAUA,IAAK;AACf;AACA,CAxBE;AAyBD","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport function docFile({ name }: ComponentContext) {\n return `---\ndescription: Application.\nlabels: ['env', 'app']\n---\n\n## Application component\n\n- The app file contains components from react router dom so you can add here all routes for your app and include all your page components.\n- The main runtime file contains what is needed to build your application as a React app.\n- The app root file renders your app to the DOM.\n- The compositions file renders your app so it can be seen in the compositions tab.\n- The aspect file contains the id of the aspect. You will need to modify this with your own org name, scope name and namespace if any, and then add it to your \\`workspace.json\\` file at root level like:\n\n\\`\\`\\`json\n\"org-name.scope-name/namespace/name\": {},\n\\`\\`\\`\n\n### Run the application\n\nYou can run your application on a separate port to see it outside of the Bit workspace\n\n\\`\\`\\`bash\nbit run ${name}\n\\`\\`\\`\n`;\n}\n"]}
1
+ {"version":3,"sources":["doc.ts"],"names":["docFile","name","componentId","nameCamelCase","toString"],"mappings":";;;;;;;AAEO,SAASA,OAAT,CAAiB;AAAEC,EAAAA,IAAF;AAAQC,EAAAA,WAAR;AAAqBC,EAAAA;AAArB,CAAjB,EAAyE;AAC9E,SAAQ;AACV,eAAeA,aAAc;AAC7B,YAAYF,IAAK;AACjB;AACA;AACA;AACA;AACA;AACA,GAAGC,WAAW,CAACE,QAAZ,EAAuB;AAC1B;AACA;AACA;AACA;AACA;AACA;AACA;AACA,UAAUH,IAAK;AACf;AACA,CAlBE;AAmBD","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport function docFile({ name, componentId, nameCamelCase }: ComponentContext) {\n return `---\ndescription: ${nameCamelCase} application component.\nlabels: ['${name}', 'app']\n---\n\nConfigure the app plugin on your workspace:\n\n\\`\\`\\`json\n\"${componentId.toString()}\": {},\n\\`\\`\\`\n\n### Run the application\n\nYou can run your application on a separate port to see it outside of the Bit workspace\n\n\\`\\`\\`bash\nbit run ${name}\n\\`\\`\\`\n`;\n}\n"]}
@@ -1,2 +1,2 @@
1
1
  import { ComponentContext } from '@teambit/generator';
2
- export declare function indexFile({ name, namePascalCase: Name }: ComponentContext): string;
2
+ export declare function indexFile({ namePascalCase: Name }: ComponentContext): string;
@@ -6,15 +6,9 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.indexFile = indexFile;
7
7
 
8
8
  function indexFile({
9
- name,
10
9
  namePascalCase: Name
11
10
  }) {
12
- return `import { ${Name}Aspect } from './${name}.aspect';
13
-
14
- export type { ${Name}Main } from './${name}.main.runtime';
15
- export default ${Name}Aspect;
16
- export { ${Name}Aspect };
17
- `;
11
+ return `export { ${Name}App } from './app';`;
18
12
  }
19
13
 
20
14
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["indexFile","name","namePascalCase","Name"],"mappings":";;;;;;;AAEO,SAASA,SAAT,CAAmB;AAAEC,EAAAA,IAAF;AAAQC,EAAAA,cAAc,EAAEC;AAAxB,CAAnB,EAAqE;AAC1E,SAAQ,YAAWA,IAAK,oBAAmBF,IAAK;AAClD;AACA,gBAAgBE,IAAK,kBAAiBF,IAAK;AAC3C,iBAAiBE,IAAK;AACtB,WAAWA,IAAK;AAChB,CALE;AAMD","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport function indexFile({ name, namePascalCase: Name }: ComponentContext) {\n return `import { ${Name}Aspect } from './${name}.aspect';\n\nexport type { ${Name}Main } from './${name}.main.runtime';\nexport default ${Name}Aspect;\nexport { ${Name}Aspect };\n`;\n}\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":["indexFile","namePascalCase","Name"],"mappings":";;;;;;;AAEO,SAASA,SAAT,CAAmB;AAAEC,EAAAA,cAAc,EAAEC;AAAlB,CAAnB,EAA+D;AACpE,SAAQ,YAAWA,IAAK,qBAAxB;AACD","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport function indexFile({ namePascalCase: Name }: ComponentContext) {\n return `export { ${Name}App } from './app';`;\n}\n"]}
@@ -5,30 +5,30 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.reactAppTemplate = void 0;
7
7
 
8
- function _index() {
9
- const data = require("./files/index");
8
+ function _appPlugin() {
9
+ const data = require("./files/app-plugin");
10
10
 
11
- _index = function () {
11
+ _appPlugin = function () {
12
12
  return data;
13
13
  };
14
14
 
15
15
  return data;
16
16
  }
17
17
 
18
- function _doc() {
19
- const data = require("./files/doc");
18
+ function _index() {
19
+ const data = require("./files/index");
20
20
 
21
- _doc = function () {
21
+ _index = function () {
22
22
  return data;
23
23
  };
24
24
 
25
25
  return data;
26
26
  }
27
27
 
28
- function _main() {
29
- const data = require("./files/main.runtime");
28
+ function _doc() {
29
+ const data = require("./files/doc");
30
30
 
31
- _main = function () {
31
+ _doc = function () {
32
32
  return data;
33
33
  };
34
34
 
@@ -45,16 +45,6 @@ function _compositions() {
45
45
  return data;
46
46
  }
47
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
48
  function _app() {
59
49
  const data = require("./files/app");
60
50
 
@@ -88,14 +78,11 @@ const reactAppTemplate = {
88
78
  relativePath: `${context.name}.docs.mdx`,
89
79
  content: (0, _doc().docFile)(context)
90
80
  }, {
91
- relativePath: `${context.name}.main.runtime.ts`,
92
- content: (0, _main().mainRuntimeFile)(context)
81
+ relativePath: `${context.name}.react-app.ts`,
82
+ content: (0, _appPlugin().appPlugin)(context)
93
83
  }, {
94
84
  relativePath: `${context.name}.compositions.tsx`,
95
85
  content: (0, _compositions().compositionsFile)(context)
96
- }, {
97
- relativePath: `${context.name}.aspect.ts`,
98
- content: (0, _aspect().aspectFile)(context)
99
86
  }, {
100
87
  relativePath: `app.tsx`,
101
88
  content: (0, _app().appFile)(context)
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["reactAppTemplate","name","hidden","description","generateFiles","context","relativePath","content","isMain"],"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;;AAEO,MAAMA,gBAAmC,GAAG;AACjDC,EAAAA,IAAI,EAAE,WAD2C;AAEjDC,EAAAA,MAAM,EAAE,IAFyC;AAGjDC,EAAAA,WAAW,EAAE,qBAHoC;AAIjDC,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,CAACJ,IAAK,WADhC;AAEEM,MAAAA,OAAO,EAAE,oBAAQF,OAAR;AAFX,KANK,EAUL;AACEC,MAAAA,YAAY,EAAG,GAAED,OAAO,CAACJ,IAAK,kBADhC;AAEEM,MAAAA,OAAO,EAAE,6BAAgBF,OAAhB;AAFX,KAVK,EAcL;AACEC,MAAAA,YAAY,EAAG,GAAED,OAAO,CAACJ,IAAK,mBADhC;AAEEM,MAAAA,OAAO,EAAE,sCAAiBF,OAAjB;AAFX,KAdK,EAkBL;AACEC,MAAAA,YAAY,EAAG,GAAED,OAAO,CAACJ,IAAK,YADhC;AAEEM,MAAAA,OAAO,EAAE,0BAAWF,OAAX;AAFX,KAlBK,EAsBL;AACEC,MAAAA,YAAY,EAAG,SADjB;AAEEC,MAAAA,OAAO,EAAE,oBAAQF,OAAR;AAFX,KAtBK,EA0BL;AACEC,MAAAA,YAAY,EAAG,GAAED,OAAO,CAACJ,IAAK,eADhC;AAEEM,MAAAA,OAAO,EAAE,4BAAYF,OAAZ;AAFX,KA1BK,CAAP;AA+BD;AApCgD,CAA5C","sourcesContent":["import { ComponentContext, ComponentTemplate } from '@teambit/generator';\nimport { indexFile } from './files/index';\nimport { docFile } from './files/doc';\nimport { mainRuntimeFile } from './files/main.runtime';\nimport { compositionsFile } from './files/compositions';\nimport { aspectFile } from './files/aspect';\nimport { appFile } from './files/app';\nimport { appRootFile } from './files/app-root';\n\nexport const reactAppTemplate: ComponentTemplate = {\n name: 'react-app',\n hidden: true,\n description: 'Creates a React app',\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}.compositions.tsx`,\n content: compositionsFile(context),\n },\n {\n relativePath: `${context.name}.aspect.ts`,\n content: aspectFile(context),\n },\n {\n relativePath: `app.tsx`,\n content: appFile(context),\n },\n {\n relativePath: `${context.name}.app-root.tsx`,\n content: appRootFile(context),\n },\n ];\n },\n};\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":["reactAppTemplate","name","hidden","description","generateFiles","context","relativePath","content","isMain"],"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;;AAEO,MAAMA,gBAAmC,GAAG;AACjDC,EAAAA,IAAI,EAAE,WAD2C;AAEjDC,EAAAA,MAAM,EAAE,IAFyC;AAGjDC,EAAAA,WAAW,EAAE,qBAHoC;AAIjDC,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,CAACJ,IAAK,WADhC;AAEEM,MAAAA,OAAO,EAAE,oBAAQF,OAAR;AAFX,KANK,EAUL;AACEC,MAAAA,YAAY,EAAG,GAAED,OAAO,CAACJ,IAAK,eADhC;AAEEM,MAAAA,OAAO,EAAE,4BAAUF,OAAV;AAFX,KAVK,EAcL;AACEC,MAAAA,YAAY,EAAG,GAAED,OAAO,CAACJ,IAAK,mBADhC;AAEEM,MAAAA,OAAO,EAAE,sCAAiBF,OAAjB;AAFX,KAdK,EAkBL;AACEC,MAAAA,YAAY,EAAG,SADjB;AAEEC,MAAAA,OAAO,EAAE,oBAAQF,OAAR;AAFX,KAlBK,EAsBL;AACEC,MAAAA,YAAY,EAAG,GAAED,OAAO,CAACJ,IAAK,eADhC;AAEEM,MAAAA,OAAO,EAAE,4BAAYF,OAAZ;AAFX,KAtBK,CAAP;AA2BD;AAhCgD,CAA5C","sourcesContent":["import { ComponentContext, ComponentTemplate } from '@teambit/generator';\nimport { appPlugin } from './files/app-plugin';\nimport { indexFile } from './files/index';\nimport { docFile } from './files/doc';\nimport { compositionsFile } from './files/compositions';\nimport { appFile } from './files/app';\nimport { appRootFile } from './files/app-root';\n\nexport const reactAppTemplate: ComponentTemplate = {\n name: 'react-app',\n hidden: true,\n description: 'Creates a React app',\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}.react-app.ts`,\n content: appPlugin(context),\n },\n {\n relativePath: `${context.name}.compositions.tsx`,\n content: compositionsFile(context),\n },\n {\n relativePath: `app.tsx`,\n content: appFile(context),\n },\n {\n relativePath: `${context.name}.app-root.tsx`,\n content: appRootFile(context),\n },\n ];\n },\n};\n"]}
@@ -12,19 +12,19 @@ const componentFile = context => {
12
12
  } = context;
13
13
  return {
14
14
  relativePath: `${name}.tsx`,
15
- content: `import React from 'react';
15
+ content: `import React, { ReactNode } from 'react';
16
16
 
17
17
  export type ${Name}Props = {
18
18
  /**
19
- * a text to be rendered in the component.
19
+ * a node to be rendered in the special component.
20
20
  */
21
- text: string
21
+ children?: ReactNode;
22
22
  };
23
23
 
24
- export function ${Name}({ text }: ${Name}Props) {
24
+ export function ${Name}({ children }: ${Name}Props) {
25
25
  return (
26
26
  <div>
27
- {text}
27
+ {children}
28
28
  </div>
29
29
  );
30
30
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["component.ts"],"names":["componentFile","context","name","namePascalCase","Name","relativePath","content"],"mappings":";;;;;;;AAEO,MAAMA,aAAa,GAAIC,OAAD,IAA+B;AAC1D,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,cAAc,EAAEC;AAAxB,MAAiCH,OAAvC;AACA,SAAO;AACLI,IAAAA,YAAY,EAAG,GAAEH,IAAK,MADjB;AAELI,IAAAA,OAAO,EAAG;AACd;AACA,cAAcF,IAAK;AACnB;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkBA,IAAK,cAAaA,IAAK;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AAlBS,GAAP;AAoBD,CAtBM","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport const componentFile = (context: ComponentContext) => {\n const { name, namePascalCase: Name } = context;\n return {\n relativePath: `${name}.tsx`,\n content: `import React from 'react';\n\nexport type ${Name}Props = {\n /**\n * a text to be rendered in the component.\n */\n text: string\n};\n\nexport function ${Name}({ text }: ${Name}Props) {\n return (\n <div>\n {text}\n </div>\n );\n}\n`,\n };\n};\n"]}
1
+ {"version":3,"sources":["component.ts"],"names":["componentFile","context","name","namePascalCase","Name","relativePath","content"],"mappings":";;;;;;;AAEO,MAAMA,aAAa,GAAIC,OAAD,IAA+B;AAC1D,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,cAAc,EAAEC;AAAxB,MAAiCH,OAAvC;AACA,SAAO;AACLI,IAAAA,YAAY,EAAG,GAAEH,IAAK,MADjB;AAELI,IAAAA,OAAO,EAAG;AACd;AACA,cAAcF,IAAK;AACnB;AACA;AACA;AACA;AACA;AACA;AACA,kBAAkBA,IAAK,kBAAiBA,IAAK;AAC7C;AACA;AACA;AACA;AACA;AACA;AACA;AAlBS,GAAP;AAoBD,CAtBM","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport const componentFile = (context: ComponentContext) => {\n const { name, namePascalCase: Name } = context;\n return {\n relativePath: `${name}.tsx`,\n content: `import React, { ReactNode } from 'react';\n\nexport type ${Name}Props = {\n /**\n * a node to be rendered in the special component.\n */\n children?: ReactNode;\n};\n\nexport function ${Name}({ children }: ${Name}Props) {\n return (\n <div>\n {children}\n </div>\n );\n}\n`,\n };\n};\n"]}
@@ -15,9 +15,11 @@ const compositionFile = context => {
15
15
  content: `import React from 'react';
16
16
  import { ${Name} } from './${name}';
17
17
 
18
- export const Basic${Name} = () => (
19
- <${Name} text="hello from ${Name}" />
20
- );
18
+ export const Basic${Name} = () => {
19
+ return (
20
+ <${Name}>hello world!</${Name}>
21
+ );
22
+ }
21
23
  `
22
24
  };
23
25
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["composition.ts"],"names":["compositionFile","context","name","namePascalCase","Name","relativePath","content"],"mappings":";;;;;;;AAEO,MAAMA,eAAe,GAAIC,OAAD,IAA+B;AAC5D,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,cAAc,EAAEC;AAAxB,MAAiCH,OAAvC;AAEA,SAAO;AACLI,IAAAA,YAAY,EAAG,GAAEH,IAAK,kBADjB;AAELI,IAAAA,OAAO,EAAG;AACd,WAAWF,IAAK,cAAaF,IAAK;AAClC;AACA,oBAAoBE,IAAK;AACzB,KAAKA,IAAK,qBAAoBA,IAAK;AACnC;AACA;AARS,GAAP;AAUD,CAbM","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport const compositionFile = (context: ComponentContext) => {\n const { name, namePascalCase: Name } = context;\n\n return {\n relativePath: `${name}.composition.tsx`,\n content: `import React from 'react';\nimport { ${Name} } from './${name}';\n\nexport const Basic${Name} = () => (\n <${Name} text=\"hello from ${Name}\" />\n);\n`,\n };\n};\n"]}
1
+ {"version":3,"sources":["composition.ts"],"names":["compositionFile","context","name","namePascalCase","Name","relativePath","content"],"mappings":";;;;;;;AAEO,MAAMA,eAAe,GAAIC,OAAD,IAA+B;AAC5D,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,cAAc,EAAEC;AAAxB,MAAiCH,OAAvC;AAEA,SAAO;AACLI,IAAAA,YAAY,EAAG,GAAEH,IAAK,kBADjB;AAELI,IAAAA,OAAO,EAAG;AACd,WAAWF,IAAK,cAAaF,IAAK;AAClC;AACA,oBAAoBE,IAAK;AACzB;AACA,OAAOA,IAAK,kBAAiBA,IAAK;AAClC;AACA;AACA;AAVS,GAAP;AAYD,CAfM","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport const compositionFile = (context: ComponentContext) => {\n const { name, namePascalCase: Name } = context;\n\n return {\n relativePath: `${name}.composition.tsx`,\n content: `import React from 'react';\nimport { ${Name} } from './${name}';\n\nexport const Basic${Name} = () => {\n return (\n <${Name}>hello world!</${Name}>\n );\n}\n`,\n };\n};\n"]}
@@ -13,26 +13,22 @@ const docsFile = context => {
13
13
  return {
14
14
  relativePath: `${name}.docs.mdx`,
15
15
  content: `---
16
- description: 'A ${Name} component.'
17
- labels: ['label1', 'label2', 'label3']
16
+ description: A ${Name} component.
18
17
  ---
19
18
 
20
19
  import { ${Name} } from './${name}';
21
20
 
22
- ## React Component for rendering text
23
-
24
- A basic div that renders some text
21
+ A component that does something special and renders text in a div.
25
22
 
26
23
  ### Component usage
27
24
  \`\`\`js
28
- <${Name} text="hello from ${Name}" />
25
+ <${Name}>Hello world!</${Name}>
29
26
  \`\`\`
30
27
 
31
- ### Using props to customize the text
28
+ ### Render hello world!
32
29
 
33
- Modify the text to see it change live:
34
30
  \`\`\`js live
35
- <${Name} text="hello from ${Name}" />
31
+ <${Name}>Hello world!</${Name}>
36
32
  \`\`\`
37
33
  `
38
34
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["docs.ts"],"names":["docsFile","context","name","namePascalCase","Name","relativePath","content"],"mappings":";;;;;;;AAEO,MAAMA,QAAQ,GAAIC,OAAD,IAA+B;AACrD,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,cAAc,EAAEC;AAAxB,MAAiCH,OAAvC;AAEA,SAAO;AACLI,IAAAA,YAAY,EAAG,GAAEH,IAAK,WADjB;AAELI,IAAAA,OAAO,EAAG;AACd,kBAAkBF,IAAK;AACvB;AACA;AACA;AACA,WAAWA,IAAK,cAAaF,IAAK;AAClC;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GAAGE,IAAK,qBAAoBA,IAAK;AACjC;AACA;AACA;AACA;AACA;AACA;AACA,GAAGA,IAAK,qBAAoBA,IAAK;AACjC;AACA;AAxBS,GAAP;AA0BD,CA7BM","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport const docsFile = (context: ComponentContext) => {\n const { name, namePascalCase: Name } = context;\n\n return {\n relativePath: `${name}.docs.mdx`,\n content: `---\ndescription: 'A ${Name} component.'\nlabels: ['label1', 'label2', 'label3']\n---\n\nimport { ${Name} } from './${name}';\n\n## React Component for rendering text\n\nA basic div that renders some text\n\n### Component usage\n\\`\\`\\`js\n<${Name} text=\"hello from ${Name}\" />\n\\`\\`\\`\n\n### Using props to customize the text\n\nModify the text to see it change live:\n\\`\\`\\`js live\n<${Name} text=\"hello from ${Name}\" />\n\\`\\`\\`\n`,\n };\n};\n"]}
1
+ {"version":3,"sources":["docs.ts"],"names":["docsFile","context","name","namePascalCase","Name","relativePath","content"],"mappings":";;;;;;;AAEO,MAAMA,QAAQ,GAAIC,OAAD,IAA+B;AACrD,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,cAAc,EAAEC;AAAxB,MAAiCH,OAAvC;AAEA,SAAO;AACLI,IAAAA,YAAY,EAAG,GAAEH,IAAK,WADjB;AAELI,IAAAA,OAAO,EAAG;AACd,iBAAiBF,IAAK;AACtB;AACA;AACA,WAAWA,IAAK,cAAaF,IAAK;AAClC;AACA;AACA;AACA;AACA;AACA,GAAGE,IAAK,kBAAiBA,IAAK;AAC9B;AACA;AACA;AACA;AACA;AACA,GAAGA,IAAK,kBAAiBA,IAAK;AAC9B;AACA;AApBS,GAAP;AAsBD,CAzBM","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport const docsFile = (context: ComponentContext) => {\n const { name, namePascalCase: Name } = context;\n\n return {\n relativePath: `${name}.docs.mdx`,\n content: `---\ndescription: A ${Name} component.\n---\n\nimport { ${Name} } from './${name}';\n\nA component that does something special and renders text in a div.\n\n### Component usage\n\\`\\`\\`js\n<${Name}>Hello world!</${Name}>\n\\`\\`\\`\n\n### Render hello world!\n\n\\`\\`\\`js live\n<${Name}>Hello world!</${Name}>\n\\`\\`\\`\n`,\n };\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["index.ts"],"names":["reactComponent","name","description","generateFiles","context","namePascalC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,SAAD,EAAY,gCAAcH,OAAd,CAAZ,EAAoC,oCAAgBA,OAAhB,CAApC,EAA8D,sBAASA,OAAT,CAA9D,EAAiF,sBAASA,OAAT,CAAjF,CAAP;AACD;AAfwD,CAApD","sourcesContent":["import { ComponentTemplate, ComponentContext } from '@teambit/generator';\nimport { componentFile } from './files/component';\nimport { compositionFile } from './files/composition';\nimport { docsFile } from './files/docs';\nimport { testFile } from './files/test';\n\nexport const reactComponent: ComponentTemplate = {\n name: 'react',\n description: 'a basic react component',\n\n generateFiles: (context: ComponentContext) => {\n const { name, namePascalCase: Name } = context;\n const indexFile = {\n relativePath: 'index.ts',\n content: `export { ${Name} } from './${name}';\nexport type { ${Name}Props } from './${name}';\n`,\n };\n\n return [indexFile, componentFile(context), compositionFile(context), docsFile(context), testFile(context)];\n },\n};\n\nexport const deprecatedReactComponent: ComponentTemplate = {\n name: 'react-component',\n description: 'a basic react component',\n hidden: true,\n\n generateFiles: (context: ComponentContext) => {\n const { name, namePascalCase: Name } = context;\n const indexFile = {\n relativePath: 'index.ts',\n content: `export { ${Name} } from './${name}';\nexport type { ${Name}Props } from './${name}';\n`,\n };\n\n return [indexFile, componentFile(context), compositionFile(context), docsFile(context), testFile(context)];\n },\n};\n"]}
1
+ {"version":3,"sources":["index.ts"],"names":["reactComponent","name","description","generateFiles","context","namePascalCase","Name","indexFile","relativePath","content","deprecatedReactComponent","hidden"],"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;;AAEO,MAAMA,cAAiC,GAAG;AAC/CC,EAAAA,IAAI,EAAE,OADyC;AAE/CC,EAAAA,WAAW,EAAE,yBAFkC;AAG/CC,EAAAA,aAAa,EAAGC,OAAD,IAA+B;AAC5C,UAAM;AAAEH,MAAAA,IAAF;AAAQI,MAAAA,cAAc,EAAEC;AAAxB,QAAiCF,OAAvC;AACA,UAAMG,SAAS,GAAG;AAChBC,MAAAA,YAAY,EAAE,UADE;AAEhBC,MAAAA,OAAO,EAAG,YAAWH,IAAK,cAAaL,IAAK;AAClD,gBAAgBK,IAAK,mBAAkBL,IAAK;AAC5C;AAJsB,KAAlB;AAOA,WAAO,CAACM,SAAD,EAAY,gCAAcH,OAAd,CAAZ,EAAoC,oCAAgBA,OAAhB,CAApC,EAA8D,sBAASA,OAAT,CAA9D,EAAiF,sBAASA,OAAT,CAAjF,CAAP;AACD;AAb8C,CAA1C;;AAgBA,MAAMM,wBAA2C,GAAG;AACzDT,EAAAA,IAAI,EAAE,iBADmD;AAEzDC,EAAAA,WAAW,EAAE,yBAF4C;AAGzDS,EAAAA,MAAM,EAAE,IAHiD;AAKzDR,EAAAA,aAAa,EAAGC,OAAD,IAA+B;AAC5C,UAAM;AAAEH,MAAAA,IAAF;AAAQI,MAAAA,cAAc,EAAEC;AAAxB,QAAiCF,OAAvC;AACA,UAAMG,SAAS,GAAG;AAChBC,MAAAA,YAAY,EAAE,UADE;AAEhBC,MAAAA,OAAO,EAAG,YAAWH,IAAK,cAAaL,IAAK;AAClD,gBAAgBK,IAAK,mBAAkBL,IAAK;AAC5C;AAJsB,KAAlB;AAOA,WAAO,CAACM,SAAD,EAAY,gCAAcH,OAAd,CAAZ,EAAoC,oCAAgBA,OAAhB,CAApC,EAA8D,sBAASA,OAAT,CAA9D,EAAiF,sBAASA,OAAT,CAAjF,CAAP;AACD;AAfwD,CAApD","sourcesContent":["import { ComponentTemplate, ComponentContext } from '@teambit/generator';\nimport { componentFile } from './files/component';\nimport { compositionFile } from './files/composition';\nimport { docsFile } from './files/docs';\nimport { testFile } from './files/test';\n\nexport const reactComponent: ComponentTemplate = {\n name: 'react',\n description: 'a basic react component',\n generateFiles: (context: ComponentContext) => {\n const { name, namePascalCase: Name } = context;\n const indexFile = {\n relativePath: 'index.ts',\n content: `export { ${Name} } from './${name}';\nexport type { ${Name}Props } from './${name}';\n`,\n };\n\n return [indexFile, componentFile(context), compositionFile(context), docsFile(context), testFile(context)];\n },\n};\n\nexport const deprecatedReactComponent: ComponentTemplate = {\n name: 'react-component',\n description: 'a basic react component',\n hidden: true,\n\n generateFiles: (context: ComponentContext) => {\n const { name, namePascalCase: Name } = context;\n const indexFile = {\n relativePath: 'index.ts',\n content: `export { ${Name} } from './${name}';\nexport type { ${Name}Props } from './${name}';\n`,\n };\n\n return [indexFile, componentFile(context), compositionFile(context), docsFile(context), testFile(context)];\n },\n};\n"]}
@@ -1,2 +1,2 @@
1
1
  import { WorkspaceContext } from '@teambit/generator';
2
- export declare function workspaceConfig({ name, defaultScope, empty }: WorkspaceContext): Promise<string>;
2
+ export declare function workspaceConfig({ name, defaultScope }: WorkspaceContext): Promise<string>;
@@ -29,8 +29,7 @@ function _commentJson() {
29
29
 
30
30
  async function workspaceConfig({
31
31
  name,
32
- defaultScope,
33
- empty
32
+ defaultScope
34
33
  }) {
35
34
  const scope = defaultScope || 'company.scope';
36
35
  const configParsed = await (0, _config().getWorkspaceConfigTemplateParsed)();
@@ -55,26 +54,36 @@ async function workspaceConfig({
55
54
  }
56
55
  };
57
56
  const variants = {
58
- 'teambit.workspace/variants': empty ? {
59
- '*': {
60
- 'teambit.react/react': {}
61
- }
62
- } : (0, _commentJson().parse)(`{
63
- "{ui/**}, {pages/**}": {
64
- // uses the custom env
65
- "${scope}/envs/my-react": {},
66
- // uncomment the line below if you remove the custom env and remove the line above
67
- // "teambit.react/react": {},
57
+ 'teambit.workspace/variants': (0, _commentJson().parse)(`{
58
+ /**
59
+ * configures all components with namespaces 'ui', 'blocks', 'pages' and 'themes'
60
+ * to use the default React development environment.
61
+ *
62
+ */
63
+ "{ui/**}, {blocks/**}, {pages/**}, {themes/**}": {
64
+ "teambit.react/react": {}
68
65
  },
69
- "{themes/**}": {
70
- "teambit.react/react": {},
66
+
67
+ /**
68
+ * configures components with namespaces 'entities', 'modules' and 'functions' to use the
69
+ * default NodeJS dev environment.
70
+ */
71
+ "{entities/**}, {modules/**}, {functions/**}": {
72
+ "teambit.harmony/node": {}
71
73
  },
74
+ /**
75
+ * configures components with namespace 'content' to use the MDX dev environment.
76
+ */
72
77
  "{content/**}": {
73
- "teambit.mdx/mdx": {},
74
- },
75
- "{envs/**}, {extensions/**}": {
76
- "teambit.harmony/aspect": {},
78
+ "teambit.mdx/mdx": {}
77
79
  },
80
+
81
+ /**
82
+ * configures components with namespaces 'envs' and 'aspects' to use the default Aspect development environment.
83
+ */
84
+ "{envs/**}, {aspects/**}": {
85
+ "teambit.harmony/aspect": {}
86
+ }
78
87
  }`)
79
88
  };
80
89
  const configMerged = (0, _commentJson().assign)(configParsed, variants);
@@ -1 +1 @@
1
- {"version":3,"sources":["workspace-config.ts"],"names":["workspaceConfig","name","defaultScope","empty","scope","configParsed","packageManager","policy","dependencies","peerDependencies","react","variants","configMerged"],"mappings":";;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,eAAeA,eAAf,CAA+B;AAAEC,EAAAA,IAAF;AAAQC,EAAAA,YAAR;AAAsBC,EAAAA;AAAtB,CAA/B,EAAgF;AACrF,QAAMC,KAAK,GAAGF,YAAY,IAAI,eAA9B;AACA,QAAMG,YAAY,GAAG,MAAM,iDAA3B;AACAA,EAAAA,YAAY,CAAC,6BAAD,CAAZ,CAA4CJ,IAA5C,GAAmDA,IAAnD;AACAI,EAAAA,YAAY,CAAC,6BAAD,CAAZ,CAA4CH,YAA5C,GAA2DE,KAA3D;AACAC,EAAAA,YAAY,CAAC,0CAAD,CAAZ,CAAyDC,cAAzD,GAA0E,2BAA1E;AACAD,EAAAA,YAAY,CAAC,0CAAD,CAAZ,CAAyDE,MAAzD,GAAkE;AAChEC,IAAAA,YAAY,EAAE;AACZ,0CAAoC,UADxB;AAEZ,0CAAoC,QAFxB;AAGZ,qCAA+B,OAHnB;AAIZ,8BAAwB,QAJZ;AAKZ,4BAAsB,QALV;AAMZ,gCAA0B,OANd;AAOZ,2BAAqB,QAPT;AAQZ,6BAAuB;AARX,KADkD;AAWhEC,IAAAA,gBAAgB,EAAE;AAChB,gCAA0B,QADV;AAEhBC,MAAAA,KAAK,EAAE,QAFS;AAGhB,mBAAa;AAHG;AAX8C,GAAlE;AAkBA,QAAMC,QAAQ,GAAG;AACf,kCAA8BR,KAAK,GAC/B;AACE,WAAK;AACH,+BAAuB;AADpB;AADP,KAD+B,GAM/B,0BAAO;AACf;AACA;AACA,WAAWC,KAAM;AACjB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAhBQ;AAPW,GAAjB;AA0BA,QAAMQ,YAAY,GAAG,2BAAOP,YAAP,EAAqBM,QAArB,CAArB;AAEA,SAAO,wCAAyBC,YAAzB,CAAP;AACD","sourcesContent":["import { WorkspaceContext } from '@teambit/generator';\nimport { getWorkspaceConfigTemplateParsed, stringifyWorkspaceConfig } from '@teambit/config';\nimport { parse, assign } from 'comment-json';\n\nexport async function workspaceConfig({ name, defaultScope, empty }: WorkspaceContext) {\n const scope = defaultScope || 'company.scope';\n const configParsed = await getWorkspaceConfigTemplateParsed();\n configParsed['teambit.workspace/workspace'].name = name;\n configParsed['teambit.workspace/workspace'].defaultScope = scope;\n configParsed['teambit.dependencies/dependency-resolver'].packageManager = 'teambit.dependencies/pnpm';\n configParsed['teambit.dependencies/dependency-resolver'].policy = {\n dependencies: {\n '@teambit/eslint-config-bit-react': '~0.0.367',\n '@typescript-eslint/eslint-plugin': '4.29.3',\n 'eslint-import-resolver-node': '0.3.6',\n 'eslint-plugin-import': '2.22.1',\n 'eslint-plugin-jest': '24.4.0',\n 'eslint-plugin-jsx-a11y': '6.4.1',\n 'eslint-plugin-mdx': '1.15.0',\n 'eslint-plugin-react': '7.25.1',\n },\n peerDependencies: {\n '@testing-library/react': '12.0.0',\n react: '17.0.2',\n 'react-dom': '17.0.2',\n },\n };\n\n const variants = {\n 'teambit.workspace/variants': empty\n ? {\n '*': {\n 'teambit.react/react': {},\n },\n }\n : parse(`{\n \"{ui/**}, {pages/**}\": {\n // uses the custom env\n \"${scope}/envs/my-react\": {},\n // uncomment the line below if you remove the custom env and remove the line above\n // \"teambit.react/react\": {},\n },\n \"{themes/**}\": {\n \"teambit.react/react\": {},\n },\n \"{content/**}\": {\n \"teambit.mdx/mdx\": {},\n },\n \"{envs/**}, {extensions/**}\": {\n \"teambit.harmony/aspect\": {},\n },\n }`),\n };\n\n const configMerged = assign(configParsed, variants);\n\n return stringifyWorkspaceConfig(configMerged);\n}\n"]}
1
+ {"version":3,"sources":["workspace-config.ts"],"names":["workspaceConfig","name","defaultScope","scope","configParsed","packageManager","policy","dependencies","peerDependencies","react","variants","configMerged"],"mappings":";;;;;;;;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAEO,eAAeA,eAAf,CAA+B;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,CAA/B,EAAyE;AAC9E,QAAMC,KAAK,GAAGD,YAAY,IAAI,eAA9B;AACA,QAAME,YAAY,GAAG,MAAM,iDAA3B;AACAA,EAAAA,YAAY,CAAC,6BAAD,CAAZ,CAA4CH,IAA5C,GAAmDA,IAAnD;AACAG,EAAAA,YAAY,CAAC,6BAAD,CAAZ,CAA4CF,YAA5C,GAA2DC,KAA3D;AACAC,EAAAA,YAAY,CAAC,0CAAD,CAAZ,CAAyDC,cAAzD,GAA0E,2BAA1E;AACAD,EAAAA,YAAY,CAAC,0CAAD,CAAZ,CAAyDE,MAAzD,GAAkE;AAChEC,IAAAA,YAAY,EAAE;AACZ,0CAAoC,UADxB;AAEZ,0CAAoC,QAFxB;AAGZ,qCAA+B,OAHnB;AAIZ,8BAAwB,QAJZ;AAKZ,4BAAsB,QALV;AAMZ,gCAA0B,OANd;AAOZ,2BAAqB,QAPT;AAQZ,6BAAuB;AARX,KADkD;AAWhEC,IAAAA,gBAAgB,EAAE;AAChB,gCAA0B,QADV;AAEhBC,MAAAA,KAAK,EAAE,QAFS;AAGhB,mBAAa;AAHG;AAX8C,GAAlE;AAkBA,QAAMC,QAAQ,GAAG;AACf,kCAA8B,0BAAO;AACzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MA9BkC;AADf,GAAjB;AAkCA,QAAMC,YAAY,GAAG,2BAAOP,YAAP,EAAqBM,QAArB,CAArB;AAEA,SAAO,wCAAyBC,YAAzB,CAAP;AACD","sourcesContent":["import { WorkspaceContext } from '@teambit/generator';\nimport { getWorkspaceConfigTemplateParsed, stringifyWorkspaceConfig } from '@teambit/config';\nimport { parse, assign } from 'comment-json';\n\nexport async function workspaceConfig({ name, defaultScope }: WorkspaceContext) {\n const scope = defaultScope || 'company.scope';\n const configParsed = await getWorkspaceConfigTemplateParsed();\n configParsed['teambit.workspace/workspace'].name = name;\n configParsed['teambit.workspace/workspace'].defaultScope = scope;\n configParsed['teambit.dependencies/dependency-resolver'].packageManager = 'teambit.dependencies/pnpm';\n configParsed['teambit.dependencies/dependency-resolver'].policy = {\n dependencies: {\n '@teambit/eslint-config-bit-react': '~0.0.367',\n '@typescript-eslint/eslint-plugin': '4.29.3',\n 'eslint-import-resolver-node': '0.3.6',\n 'eslint-plugin-import': '2.22.1',\n 'eslint-plugin-jest': '24.4.0',\n 'eslint-plugin-jsx-a11y': '6.4.1',\n 'eslint-plugin-mdx': '1.15.0',\n 'eslint-plugin-react': '7.25.1',\n },\n peerDependencies: {\n '@testing-library/react': '12.0.0',\n react: '17.0.2',\n 'react-dom': '17.0.2',\n },\n };\n\n const variants = {\n 'teambit.workspace/variants': parse(`{\n /**\n * configures all components with namespaces 'ui', 'blocks', 'pages' and 'themes'\n * to use the default React development environment.\n *\n */\n \"{ui/**}, {blocks/**}, {pages/**}, {themes/**}\": {\n \"teambit.react/react\": {}\n },\n \n /**\n * configures components with namespaces 'entities', 'modules' and 'functions' to use the \n * default NodeJS dev environment.\n */\n \"{entities/**}, {modules/**}, {functions/**}\": {\n \"teambit.harmony/node\": {}\n },\n /**\n * configures components with namespace 'content' to use the MDX dev environment.\n */\n \"{content/**}\": {\n \"teambit.mdx/mdx\": {}\n },\n \n /**\n * configures components with namespaces 'envs' and 'aspects' to use the default Aspect development environment.\n */\n \"{envs/**}, {aspects/**}\": {\n \"teambit.harmony/aspect\": {}\n }\n }`),\n };\n\n const configMerged = assign(configParsed, variants);\n\n return stringifyWorkspaceConfig(configMerged);\n}\n"]}
@@ -97,9 +97,9 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
97
97
 
98
98
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
99
99
 
100
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
100
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
101
101
 
102
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
102
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2().default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
103
103
 
104
104
  const styleLoaderPath = require.resolve('style-loader');
105
105
 
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@teambit/react",
3
- "version": "0.0.588",
3
+ "version": "0.0.589",
4
4
  "homepage": "https://bit.dev/teambit/react/react",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.react",
8
8
  "name": "react",
9
- "version": "0.0.588"
9
+ "version": "0.0.589"
10
10
  },
11
11
  "dependencies": {
12
12
  "react-error-boundary": "^3.0.0",
@@ -79,40 +79,40 @@
79
79
  "@teambit/react.instructions.react.adding-compositions": "0.0.6",
80
80
  "@teambit/react.instructions.react.adding-tests": "0.0.6",
81
81
  "@teambit/design.ui.pages.standalone-not-found-page": "0.0.354",
82
- "@teambit/preview": "0.0.588",
82
+ "@teambit/preview": "0.0.589",
83
83
  "@teambit/react.ui.error-fallback": "0.0.105",
84
84
  "@teambit/react.ui.loader-fallback": "0.0.84",
85
85
  "@teambit/compositions.ui.hooks.use-composition": "0.0.158",
86
86
  "@teambit/design.ui.input.option-button": "0.0.26",
87
87
  "@teambit/design.ui.tooltip": "0.0.352",
88
- "@teambit/application": "0.0.230",
89
- "@teambit/bundler": "0.0.588",
90
- "@teambit/builder": "0.0.588",
91
- "@teambit/isolator": "0.0.588",
88
+ "@teambit/application": "0.0.231",
89
+ "@teambit/bundler": "0.0.589",
90
+ "@teambit/builder": "0.0.589",
91
+ "@teambit/isolator": "0.0.589",
92
92
  "@teambit/toolbox.network.get-port": "0.0.108",
93
- "@teambit/compiler": "0.0.588",
93
+ "@teambit/compiler": "0.0.589",
94
94
  "@teambit/component.modules.component-url": "0.0.115",
95
- "@teambit/component": "0.0.588",
96
- "@teambit/envs": "0.0.588",
97
- "@teambit/eslint": "0.0.588",
98
- "@teambit/formatter": "0.0.139",
99
- "@teambit/jest": "0.0.588",
100
- "@teambit/linter": "0.0.588",
101
- "@teambit/pkg": "0.0.588",
102
- "@teambit/prettier": "0.0.139",
95
+ "@teambit/component": "0.0.589",
96
+ "@teambit/envs": "0.0.589",
97
+ "@teambit/eslint": "0.0.589",
98
+ "@teambit/formatter": "0.0.140",
99
+ "@teambit/jest": "0.0.589",
100
+ "@teambit/linter": "0.0.589",
101
+ "@teambit/pkg": "0.0.589",
102
+ "@teambit/prettier": "0.0.140",
103
103
  "@teambit/react.ui.highlighter.component-metadata.bit-component-meta": "0.0.16",
104
- "@teambit/schema": "0.0.588",
105
- "@teambit/tester": "0.0.588",
106
- "@teambit/typescript": "0.0.588",
107
- "@teambit/webpack": "0.0.588",
108
- "@teambit/workspace": "0.0.588",
104
+ "@teambit/schema": "0.0.589",
105
+ "@teambit/tester": "0.0.589",
106
+ "@teambit/typescript": "0.0.589",
107
+ "@teambit/webpack": "0.0.589",
108
+ "@teambit/workspace": "0.0.589",
109
109
  "@teambit/cli": "0.0.404",
110
- "@teambit/dependency-resolver": "0.0.588",
111
- "@teambit/generator": "0.0.588",
112
- "@teambit/graphql": "0.0.588",
110
+ "@teambit/dependency-resolver": "0.0.589",
111
+ "@teambit/generator": "0.0.589",
112
+ "@teambit/graphql": "0.0.589",
113
113
  "@teambit/react.ui.highlighter-provider": "0.0.174",
114
- "@teambit/compositions": "0.0.588",
115
- "@teambit/ui": "0.0.588",
114
+ "@teambit/compositions": "0.0.589",
115
+ "@teambit/ui": "0.0.589",
116
116
  "@teambit/react.eslint-config-bit-react": "0.0.482",
117
117
  "@teambit/mdx.modules.mdx-loader": "0.0.482",
118
118
  "@teambit/react.babel.bit-react-transformer": "0.0.490",
@@ -0,0 +1,14 @@
1
+ import { ComponentContext } from '@teambit/generator';
2
+
3
+ export function appPlugin({ name, namePascalCase: Name }: ComponentContext) {
4
+ return `import { ReactAppOptions } from '@teambit/react';
5
+
6
+ export const ${Name}App: ReactAppOptions = {
7
+ name: '${name}',
8
+ entry: [require.resolve('./${name}.app-root')],
9
+ prerenderRoutes: ['/'],
10
+ };
11
+
12
+ export default ${Name}App;
13
+ `;
14
+ }
@@ -2,7 +2,7 @@ import { ComponentContext } from '@teambit/generator';
2
2
 
3
3
  export function appFile({ namePascalCase: Name }: ComponentContext) {
4
4
  return `import React from 'react';
5
- import { BrowserRouter, Switch, Route } from 'react-router-dom';
5
+ import { BrowserRouter, Routes, Route } from 'react-router-dom';
6
6
 
7
7
  export function ${Name}App() {
8
8
  return (
@@ -10,8 +10,8 @@ export function ${Name}App() {
10
10
 
11
11
  {/* header component */}
12
12
 
13
- <Switch>
14
- <Route path="/">
13
+ <Routes>
14
+ <Route path="/" element={<div>Hello World!!</div>}>
15
15
  {/* home page component */}
16
16
  </Route>
17
17
 
@@ -1,21 +1,15 @@
1
1
  import { ComponentContext } from '@teambit/generator';
2
2
 
3
- export function docFile({ name }: ComponentContext) {
3
+ export function docFile({ name, componentId, nameCamelCase }: ComponentContext) {
4
4
  return `---
5
- description: Application.
6
- labels: ['env', 'app']
5
+ description: ${nameCamelCase} application component.
6
+ labels: ['${name}', 'app']
7
7
  ---
8
8
 
9
- ## Application component
10
-
11
- - The app file contains components from react router dom so you can add here all routes for your app and include all your page components.
12
- - The main runtime file contains what is needed to build your application as a React app.
13
- - The app root file renders your app to the DOM.
14
- - The compositions file renders your app so it can be seen in the compositions tab.
15
- - The aspect file contains the id of the aspect. You will need to modify this with your own org name, scope name and namespace if any, and then add it to your \`workspace.json\` file at root level like:
9
+ Configure the app plugin on your workspace:
16
10
 
17
11
  \`\`\`json
18
- "org-name.scope-name/namespace/name": {},
12
+ "${componentId.toString()}": {},
19
13
  \`\`\`
20
14
 
21
15
  ### Run the application
@@ -1,10 +1,5 @@
1
1
  import { ComponentContext } from '@teambit/generator';
2
2
 
3
- export function indexFile({ name, namePascalCase: 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
- `;
3
+ export function indexFile({ namePascalCase: Name }: ComponentContext) {
4
+ return `export { ${Name}App } from './app';`;
10
5
  }
@@ -1,9 +1,8 @@
1
1
  import { ComponentContext, ComponentTemplate } from '@teambit/generator';
2
+ import { appPlugin } from './files/app-plugin';
2
3
  import { indexFile } from './files/index';
3
4
  import { docFile } from './files/doc';
4
- import { mainRuntimeFile } from './files/main.runtime';
5
5
  import { compositionsFile } from './files/compositions';
6
- import { aspectFile } from './files/aspect';
7
6
  import { appFile } from './files/app';
8
7
  import { appRootFile } from './files/app-root';
9
8
 
@@ -23,17 +22,13 @@ export const reactAppTemplate: ComponentTemplate = {
23
22
  content: docFile(context),
24
23
  },
25
24
  {
26
- relativePath: `${context.name}.main.runtime.ts`,
27
- content: mainRuntimeFile(context),
25
+ relativePath: `${context.name}.react-app.ts`,
26
+ content: appPlugin(context),
28
27
  },
29
28
  {
30
29
  relativePath: `${context.name}.compositions.tsx`,
31
30
  content: compositionsFile(context),
32
31
  },
33
- {
34
- relativePath: `${context.name}.aspect.ts`,
35
- content: aspectFile(context),
36
- },
37
32
  {
38
33
  relativePath: `app.tsx`,
39
34
  content: appFile(context),
@@ -4,19 +4,19 @@ export const componentFile = (context: ComponentContext) => {
4
4
  const { name, namePascalCase: Name } = context;
5
5
  return {
6
6
  relativePath: `${name}.tsx`,
7
- content: `import React from 'react';
7
+ content: `import React, { ReactNode } from 'react';
8
8
 
9
9
  export type ${Name}Props = {
10
10
  /**
11
- * a text to be rendered in the component.
11
+ * a node to be rendered in the special component.
12
12
  */
13
- text: string
13
+ children?: ReactNode;
14
14
  };
15
15
 
16
- export function ${Name}({ text }: ${Name}Props) {
16
+ export function ${Name}({ children }: ${Name}Props) {
17
17
  return (
18
18
  <div>
19
- {text}
19
+ {children}
20
20
  </div>
21
21
  );
22
22
  }
@@ -8,9 +8,11 @@ export const compositionFile = (context: ComponentContext) => {
8
8
  content: `import React from 'react';
9
9
  import { ${Name} } from './${name}';
10
10
 
11
- export const Basic${Name} = () => (
12
- <${Name} text="hello from ${Name}" />
13
- );
11
+ export const Basic${Name} = () => {
12
+ return (
13
+ <${Name}>hello world!</${Name}>
14
+ );
15
+ }
14
16
  `,
15
17
  };
16
18
  };
@@ -6,26 +6,22 @@ export const docsFile = (context: ComponentContext) => {
6
6
  return {
7
7
  relativePath: `${name}.docs.mdx`,
8
8
  content: `---
9
- description: 'A ${Name} component.'
10
- labels: ['label1', 'label2', 'label3']
9
+ description: A ${Name} component.
11
10
  ---
12
11
 
13
12
  import { ${Name} } from './${name}';
14
13
 
15
- ## React Component for rendering text
16
-
17
- A basic div that renders some text
14
+ A component that does something special and renders text in a div.
18
15
 
19
16
  ### Component usage
20
17
  \`\`\`js
21
- <${Name} text="hello from ${Name}" />
18
+ <${Name}>Hello world!</${Name}>
22
19
  \`\`\`
23
20
 
24
- ### Using props to customize the text
21
+ ### Render hello world!
25
22
 
26
- Modify the text to see it change live:
27
23
  \`\`\`js live
28
- <${Name} text="hello from ${Name}" />
24
+ <${Name}>Hello world!</${Name}>
29
25
  \`\`\`
30
26
  `,
31
27
  };
@@ -7,7 +7,6 @@ import { testFile } from './files/test';
7
7
  export const reactComponent: ComponentTemplate = {
8
8
  name: 'react',
9
9
  description: 'a basic react component',
10
-
11
10
  generateFiles: (context: ComponentContext) => {
12
11
  const { name, namePascalCase: Name } = context;
13
12
  const indexFile = {
@@ -2,7 +2,7 @@ import { WorkspaceContext } from '@teambit/generator';
2
2
  import { getWorkspaceConfigTemplateParsed, stringifyWorkspaceConfig } from '@teambit/config';
3
3
  import { parse, assign } from 'comment-json';
4
4
 
5
- export async function workspaceConfig({ name, defaultScope, empty }: WorkspaceContext) {
5
+ export async function workspaceConfig({ name, defaultScope }: WorkspaceContext) {
6
6
  const scope = defaultScope || 'company.scope';
7
7
  const configParsed = await getWorkspaceConfigTemplateParsed();
8
8
  configParsed['teambit.workspace/workspace'].name = name;
@@ -27,28 +27,36 @@ export async function workspaceConfig({ name, defaultScope, empty }: WorkspaceCo
27
27
  };
28
28
 
29
29
  const variants = {
30
- 'teambit.workspace/variants': empty
31
- ? {
32
- '*': {
33
- 'teambit.react/react': {},
34
- },
35
- }
36
- : parse(`{
37
- "{ui/**}, {pages/**}": {
38
- // uses the custom env
39
- "${scope}/envs/my-react": {},
40
- // uncomment the line below if you remove the custom env and remove the line above
41
- // "teambit.react/react": {},
30
+ 'teambit.workspace/variants': parse(`{
31
+ /**
32
+ * configures all components with namespaces 'ui', 'blocks', 'pages' and 'themes'
33
+ * to use the default React development environment.
34
+ *
35
+ */
36
+ "{ui/**}, {blocks/**}, {pages/**}, {themes/**}": {
37
+ "teambit.react/react": {}
42
38
  },
43
- "{themes/**}": {
44
- "teambit.react/react": {},
39
+
40
+ /**
41
+ * configures components with namespaces 'entities', 'modules' and 'functions' to use the
42
+ * default NodeJS dev environment.
43
+ */
44
+ "{entities/**}, {modules/**}, {functions/**}": {
45
+ "teambit.harmony/node": {}
45
46
  },
47
+ /**
48
+ * configures components with namespace 'content' to use the MDX dev environment.
49
+ */
46
50
  "{content/**}": {
47
- "teambit.mdx/mdx": {},
48
- },
49
- "{envs/**}, {extensions/**}": {
50
- "teambit.harmony/aspect": {},
51
+ "teambit.mdx/mdx": {}
51
52
  },
53
+
54
+ /**
55
+ * configures components with namespaces 'envs' and 'aspects' to use the default Aspect development environment.
56
+ */
57
+ "{envs/**}, {aspects/**}": {
58
+ "teambit.harmony/aspect": {}
59
+ }
52
60
  }`),
53
61
  };
54
62
 
@@ -1,2 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
- export declare function aspectFile({ name, namePascalCase: Name }: ComponentContext): string;
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.aspectFile = aspectFile;
7
-
8
- function aspectFile({
9
- name,
10
- namePascalCase: Name
11
- }) {
12
- return `import { Aspect } from '@teambit/harmony';
13
-
14
- export const ${Name}Aspect = Aspect.create({
15
- id: 'YourOrgName.YourScopeName/namespace?/${name}'
16
- });
17
- `;
18
- }
19
-
20
- //# sourceMappingURL=aspect.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["aspect.ts"],"names":["aspectFile","name","namePascalCase","Name"],"mappings":";;;;;;;AAEO,SAASA,UAAT,CAAoB;AAAEC,EAAAA,IAAF;AAAQC,EAAAA,cAAc,EAAEC;AAAxB,CAApB,EAAsE;AAC3E,SAAQ;AACV;AACA,eAAeA,IAAK;AACpB,8CAA8CF,IAAK;AACnD;AACA,CALE;AAMD","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport function aspectFile({ name, namePascalCase: Name }: ComponentContext) {\n return `import { Aspect } from '@teambit/harmony';\n\nexport const ${Name}Aspect = Aspect.create({\n id: 'YourOrgName.YourScopeName/namespace?/${name}'\n});\n`;\n}\n"]}
@@ -1,2 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
- export declare function mainRuntimeFile({ name, namePascalCase: Name }: ComponentContext): string;
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.mainRuntimeFile = mainRuntimeFile;
7
-
8
- function mainRuntimeFile({
9
- name,
10
- namePascalCase: Name
11
- }) {
12
- return `import { MainRuntime } from '@teambit/cli';
13
- import { ReactAspect, ReactMain } from '@teambit/react';
14
- import { ${Name}Aspect } from './${name}.aspect';
15
-
16
- export class ${Name}Main {
17
- static slots = [];
18
- static dependencies = [ReactAspect];
19
- static runtime = MainRuntime;
20
- static async provider([react]: [ReactMain]) {
21
- react.registerReactApp({
22
- name: '${name}',
23
- entry: ['dist/${name}.app-root']
24
- });
25
- return new ${Name}Main();
26
- }
27
- }
28
- ${Name}Aspect.addRuntime(${Name}Main);
29
- `;
30
- }
31
-
32
- //# sourceMappingURL=main.runtime.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["main.runtime.ts"],"names":["mainRuntimeFile","name","namePascalCase","Name"],"mappings":";;;;;;;AAEO,SAASA,eAAT,CAAyB;AAAEC,EAAAA,IAAF;AAAQC,EAAAA,cAAc,EAAEC;AAAxB,CAAzB,EAA2E;AAChF,SAAQ;AACV;AACA,WAAWA,IAAK,oBAAmBF,IAAK;AACxC;AACA,eAAeE,IAAK;AACpB;AACA;AACA;AACA;AACA;AACA,eAAeF,IAAK;AACpB,sBAAsBA,IAAK;AAC3B;AACA,iBAAiBE,IAAK;AACtB;AACA;AACA,EAAEA,IAAK,qBAAoBA,IAAK;AAChC,CAjBE;AAkBD","sourcesContent":["import { ComponentContext } from '@teambit/generator';\n\nexport function mainRuntimeFile({ name, namePascalCase: Name }: ComponentContext) {\n return `import { MainRuntime } from '@teambit/cli';\nimport { ReactAspect, ReactMain } from '@teambit/react';\nimport { ${Name}Aspect } from './${name}.aspect';\n\nexport class ${Name}Main {\n static slots = [];\n static dependencies = [ReactAspect];\n static runtime = MainRuntime;\n static async provider([react]: [ReactMain]) {\n react.registerReactApp({\n name: '${name}',\n entry: ['dist/${name}.app-root']\n });\n return new ${Name}Main();\n }\n}\n${Name}Aspect.addRuntime(${Name}Main);\n`;\n}\n"]}
@@ -1,10 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function aspectFile({ name, namePascalCase: Name }: ComponentContext) {
4
- return `import { Aspect } from '@teambit/harmony';
5
-
6
- export const ${Name}Aspect = Aspect.create({
7
- id: 'YourOrgName.YourScopeName/namespace?/${name}'
8
- });
9
- `;
10
- }
@@ -1,22 +0,0 @@
1
- import { ComponentContext } from '@teambit/generator';
2
-
3
- export function mainRuntimeFile({ name, namePascalCase: Name }: ComponentContext) {
4
- return `import { MainRuntime } from '@teambit/cli';
5
- import { ReactAspect, ReactMain } from '@teambit/react';
6
- import { ${Name}Aspect } from './${name}.aspect';
7
-
8
- export class ${Name}Main {
9
- static slots = [];
10
- static dependencies = [ReactAspect];
11
- static runtime = MainRuntime;
12
- static async provider([react]: [ReactMain]) {
13
- react.registerReactApp({
14
- name: '${name}',
15
- entry: ['dist/${name}.app-root']
16
- });
17
- return new ${Name}Main();
18
- }
19
- }
20
- ${Name}Aspect.addRuntime(${Name}Main);
21
- `;
22
- }