@teambit/react 0.0.804 → 0.0.807

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 (50) hide show
  1. package/apps/web/compute-results.ts +3 -1
  2. package/apps/web/react-app-options.ts +6 -1
  3. package/apps/web/react-build-result.ts +1 -0
  4. package/apps/web/react.app-type.ts +1 -0
  5. package/apps/web/react.application.ts +62 -83
  6. package/apps/web/webpack/mutators.ts +69 -0
  7. package/apps/web/webpack/webpack.app.ssr.config.ts +24 -0
  8. package/artifacts/__bit_junit.xml +2 -2
  9. package/artifacts/env-template/public/{22.20acd98351f2158a41da.js → 22.0f657f2dfdd8e90d81ba.js} +0 -0
  10. package/artifacts/env-template/public/{994.bb73ab7fa3ec9ae9dc3b.js → 502.1f3ad81d16d1a387ed6e.js} +19 -11
  11. package/artifacts/env-template/public/assets-manifest.json +14 -14
  12. package/artifacts/env-template/public/{compositions.52254428c46016cd7126.js → compositions.1a2eae0121924a2382b5.js} +1 -1
  13. package/artifacts/env-template/public/compositions.html +1 -1
  14. package/artifacts/env-template/public/{overview.feaf6bb95eb88100792c.js → overview.4c90e935a13e148728cc.js} +1 -1
  15. package/artifacts/env-template/public/overview.html +1 -1
  16. package/artifacts/env-template/public/peers.9bf322cedc753fa8456b.js +1 -0
  17. package/artifacts/env-template/public/{preview-root.3a0d522c80063747b87d.js → preview-root.6f380ef699dc27c5b1d6.js} +1 -1
  18. package/artifacts/env-template/public/static/css/{994.90cfc900.css → 502.f6840c3e.css} +1 -1
  19. package/artifacts/preview/teambit_react_react-preview.js +1 -1
  20. package/{compositions-1659347901202.js → compositions-1659583874630.js} +0 -0
  21. package/dist/apps/web/compute-results.d.ts +2 -1
  22. package/dist/apps/web/compute-results.js +3 -1
  23. package/dist/apps/web/compute-results.js.map +1 -1
  24. package/dist/apps/web/react-app-options.d.ts +5 -1
  25. package/dist/apps/web/react-app-options.js.map +1 -1
  26. package/dist/apps/web/react-build-result.d.ts +1 -0
  27. package/dist/apps/web/react-build-result.js.map +1 -1
  28. package/dist/apps/web/react.app-type.js +1 -1
  29. package/dist/apps/web/react.app-type.js.map +1 -1
  30. package/dist/apps/web/react.application.d.ts +8 -4
  31. package/dist/apps/web/react.application.js +62 -95
  32. package/dist/apps/web/react.application.js.map +1 -1
  33. package/dist/apps/web/webpack/mutators.d.ts +3 -0
  34. package/dist/apps/web/webpack/mutators.js +91 -0
  35. package/dist/apps/web/webpack/mutators.js.map +1 -1
  36. package/dist/apps/web/webpack/webpack.app.ssr.config.d.ts +6 -0
  37. package/dist/apps/web/webpack/webpack.app.ssr.config.js +29 -0
  38. package/dist/apps/web/webpack/webpack.app.ssr.config.js.map +1 -1
  39. package/dist/react.main.runtime.d.ts +3 -2
  40. package/dist/react.main.runtime.js +4 -3
  41. package/dist/react.main.runtime.js.map +1 -1
  42. package/dist/webpack/webpack.config.base.js +15 -1
  43. package/dist/webpack/webpack.config.base.js.map +1 -1
  44. package/{overview-1659347901202.js → overview-1659583874630.js} +0 -0
  45. package/package-tar/teambit-react-0.0.807.tgz +0 -0
  46. package/package.json +32 -30
  47. package/{preview-1659347901202.js → preview-1659583874630.js} +2 -2
  48. package/webpack/webpack.config.base.ts +2 -1
  49. package/artifacts/env-template/public/peers.1d2b76311bfbf98a86fc.js +0 -1
  50. package/package-tar/teambit-react-0.0.804.tgz +0 -0
@@ -8,4 +8,4 @@ It enables you to quickly set up a dev environment that follows best practices f
8
8
  }
9
9
  `)),(0,_react2.mdx)("h2",null,"Creating Components"),(0,_react2.mdx)("p",null,"React env provides a set of component templates that can be used to speed-up and standardize your component development:"),(0,_react2.mdx)("p",null,"To list all available templates:"),(0,_react2.mdx)("pre",null,(0,_react2.mdx)("code",{parentName:"pre",className:"language-bash"},`bit templates
10
10
  `)),(0,_react2.mdx)("ul",null,(0,_react2.mdx)("li",{parentName:"ul"},(0,_react2.mdx)("inlineCode",{parentName:"li"},"react")," a basic React UI component."),(0,_react2.mdx)("li",{parentName:"ul"},(0,_react2.mdx)("inlineCode",{parentName:"li"},"react-context")," a react context component."),(0,_react2.mdx)("li",{parentName:"ul"},(0,_react2.mdx)("inlineCode",{parentName:"li"},"react-hook")," a react hook component."),(0,_react2.mdx)("li",{parentName:"ul"},(0,_react2.mdx)("inlineCode",{parentName:"li"},"mdx-component")," an MDX component."),(0,_react2.mdx)("li",{parentName:"ul"},(0,_react2.mdx)("inlineCode",{parentName:"li"},"react-component-js")," a basic React component in JS."),(0,_react2.mdx)("li",{parentName:"ul"},(0,_react2.mdx)("inlineCode",{parentName:"li"},"react-env")," boilerplate for a customized environment 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-bash"},`bit create react ui/my-welcome
11
- `)),(0,_react2.mdx)("h2",null,"Development services and configurations"),(0,_react2.mdx)("p",null,"The table below lists ",(0,_react2.mdx)("a",{parentName:"p",href:"/dev-services/dev-services-overview"},"dev services")," that are provided by the React env. Each service handles a specific component development operation. Each is implemented by the React env, using a specific set of configurations."),(0,_react2.mdx)("p",null,"To customize and extend the React env, ",(0,_react2.mdx)("a",{parentName:"p",href:"/envs/pre-configured-envs/react/extending-react#using-your-own-react-env-extension"},"create you own React env extension"),". You can replace the Aspects used by the env, or override their configurations (use the links provided in the 'customization' column)."),(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},"Default config"),(0,_react2.mdx)("th",{parentName:"tr",align:null},"Customization"))),(0,_react2.mdx)("tbody",{parentName:"table"},(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/docs/dev-services/compiler/compiler-overview"},"Compiler")),(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)("td",{parentName:"tr",align:null},"\u2022 ",(0,_react2.mdx)("a",{parentName:"td",href:"/frameworks/react/config-react-tools#typescript"},"TS compilation config")," ",(0,_react2.mdx)("br",null)," \u2022 ",(0,_react2.mdx)("a",{parentName:"td",href:"/docs/dev-services/compiler/configure-env-with-compiler"},"Replace compiler"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/tester/overview"},"Tester")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/defender/jest"},"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)("td",{parentName:"tr",align:null},"\u2022 ",(0,_react2.mdx)("a",{parentName:"td",href:"/frameworks/react/config-react-tools#jest"},"Jest config")," ",(0,_react2.mdx)("br",null)," \u2022 ",(0,_react2.mdx)("a",{parentName:"td",href:"/dev-services/tester/configure-env-with-tester"},"Replace Tester"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/linter/overview"},"Linting")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/defender/eslint"},"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)("td",{parentName:"tr",align:null},"\u2022 ",(0,_react2.mdx)("a",{parentName:"td",href:"/frameworks/react/config-react-tools#eslint"},"ESLint Config")," ",(0,_react2.mdx)("br",null)," \u2022 ",(0,_react2.mdx)("a",{parentName:"td",href:"/dev-services/linter/configure-env-with-linter"},"Replace Linter"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/formatter/overview"},"Formatter")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/defender/prettier"},"Prettier")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/react/react/~code/prettier/prettier.config.js"},"prettier.config.ts")),(0,_react2.mdx)("td",{parentName:"tr",align:null},"\u2022 ",(0,_react2.mdx)("a",{parentName:"td",href:"/frameworks/react/config-react-tools#prettier"},"Prettier config")," ",(0,_react2.mdx)("br",null)," \u2022 ",(0,_react2.mdx)("a",{parentName:"td",href:"/dev-services/formatter/configure-env-with-formatter"},"Replace Formatter"))),(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)("a",{parentName:"td",href:"https://bit.dev/teambit/webpack/webpack"},"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)("td",{parentName:"tr",align:null},"\u2022 Webpack config (for bundling in the workspace)")),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/docs/dev-services/preview/overview"},"Preview")),(0,_react2.mdx)("td",{parentName:"tr",align:null},"-"),(0,_react2.mdx)("td",{parentName:"tr",align:null}),(0,_react2.mdx)("td",{parentName:"tr",align:null},"\u2022 ",(0,_react2.mdx)("a",{parentName:"td",href:"/dev-services/preview/register-custom-preview"},"Add preview"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/docs/packages/packages-overview"},"Package")),(0,_react2.mdx)("td",{parentName:"tr",align:null},"-"),(0,_react2.mdx)("td",{parentName:"tr",align:null},"See the ",(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/typescript/typescript/~code/typescript.main.runtime.ts"},"TypeScript Aspect")," config"),(0,_react2.mdx)("td",{parentName:"tr",align:null},"\u2022 ",(0,_react2.mdx)("a",{parentName:"td",href:"/packages/managing-package-json#set-configuration-from-an-env"},"Add Env package config")," ",(0,_react2.mdx)("br",null)," \u2022 TypeScript's package config")),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},"Bundler"),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/webpack/webpack"},"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)("td",{parentName:"tr",align:null},"\u2022 Webpack config (for bundling during build)")),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/docs/dev-services/docs/docs-overview"},"Documentation")),(0,_react2.mdx)("td",{parentName:"tr",align:null},"-"),(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)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/docs/dev-services/docs/docs-templates"},"Replace docs template"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"http://localhost:3000/docs/dev-services/builder/builder-overview"},"Builder")),(0,_react2.mdx)("td",{parentName:"tr",align:null},"-"),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"http://localhost:3000/docs/dev-services/builder/builder-overview"},"Build pipeline")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/dev-services/builder/build-pipelines"},"Build pipelines"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/dependencies/dependencies-overview"},"Dependencies")),(0,_react2.mdx)("td",{parentName:"tr",align:null},"-"),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/react/react/~code/react.env.ts"},"Env-dependencies")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/dependencies/configuring-dependencies#configuring-dependencies-from-an-env"},"Env dependencies"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/docs/dev-services/generator/generator-overview"},"Generator")),(0,_react2.mdx)("td",{parentName:"tr",align:null},"-"),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/react/react/~code/templates/react-component.ts"},"React templates")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:""},"Add a component template"))))),(0,_react2.mdx)("h3",null,"Default React versions"),(0,_react2.mdx)("p",null,"By default, the React env sets the following dependency versions for components using it:"),(0,_react2.mdx)("ul",null,(0,_react2.mdx)("li",{parentName:"ul"},(0,_react2.mdx)("strong",{parentName:"li"},"react")," (peer dependency): ",(0,_react2.mdx)("inlineCode",{parentName:"li"},"^16.8.0 || ^17.0.0")),(0,_react2.mdx)("li",{parentName:"ul"},(0,_react2.mdx)("strong",{parentName:"li"},"react-dom")," (peer dependency): ",(0,_react2.mdx)("inlineCode",{parentName:"li"},"^16.8.0 || ^17.0.0")),(0,_react2.mdx)("li",{parentName:"ul"},(0,_react2.mdx)("strong",{parentName:"li"},"@types/react"),": ",(0,_react2.mdx)("inlineCode",{parentName:"li"},"^17.0.8")),(0,_react2.mdx)("li",{parentName:"ul"},(0,_react2.mdx)("strong",{parentName:"li"},"@types/react-dom"),": ",(0,_react2.mdx)("inlineCode",{parentName:"li"},"^17.0.5")))))}MDXContent.__bit_component=__bit_component,MDXContent.isMDXComponent=!0},164:(__unused_webpack_module,exports2,__webpack_require__2)=>{"use strict";var __bit_component={id:"teambit.react/react@0.0.804",homepage:"https://bit.dev/teambit/react/react",exported:!0},_interopRequireDefault=__webpack_require__2(244);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/react.svg"}));Logo.__bit_component=__bit_component,exports2.Logo=Logo},57:module2=>{"use strict";module2.exports=MdxJsReact},804:module2=>{"use strict";module2.exports=React},459:module2=>{"use strict";module2.exports=TeambitMdxUiMdxScopeContext}},__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,overview:()=>overview});var react_docs_namespaceObject={};__webpack_require__.r(react_docs_namespaceObject),__webpack_require__.d(react_docs_namespaceObject,{default:()=>MDXContent});var react_composition=__webpack_require__(164),external_React_=__webpack_require__(804),external_MdxJsReact_=__webpack_require__(57),external_TeambitMdxUiMdxScopeContext_=__webpack_require__(459),dist=__webpack_require__(906),_excluded=["components"];function _extends(){return _extends=Object.assign||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_.MDXScopeProvider,{components:{ReactOverview:dist.ZP},mdxType:"MDXScopeProvider"},(0,external_MdxJsReact_.mdx)(dist.ZP,{mdxType:"ReactOverview"})))}MDXContent.isMDXComponent=!0;const compositions=[react_composition],overview=[react_docs_namespaceObject]})(),__webpack_exports__})()});
11
+ `)),(0,_react2.mdx)("h2",null,"Development services and configurations"),(0,_react2.mdx)("p",null,"The table below lists ",(0,_react2.mdx)("a",{parentName:"p",href:"/dev-services/dev-services-overview"},"dev services")," that are provided by the React env. Each service handles a specific component development operation. Each is implemented by the React env, using a specific set of configurations."),(0,_react2.mdx)("p",null,"To customize and extend the React env, ",(0,_react2.mdx)("a",{parentName:"p",href:"/envs/pre-configured-envs/react/extending-react#using-your-own-react-env-extension"},"create you own React env extension"),". You can replace the Aspects used by the env, or override their configurations (use the links provided in the 'customization' column)."),(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},"Default config"),(0,_react2.mdx)("th",{parentName:"tr",align:null},"Customization"))),(0,_react2.mdx)("tbody",{parentName:"table"},(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/docs/dev-services/compiler/compiler-overview"},"Compiler")),(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)("td",{parentName:"tr",align:null},"\u2022 ",(0,_react2.mdx)("a",{parentName:"td",href:"/frameworks/react/config-react-tools#typescript"},"TS compilation config")," ",(0,_react2.mdx)("br",null)," \u2022 ",(0,_react2.mdx)("a",{parentName:"td",href:"/docs/dev-services/compiler/configure-env-with-compiler"},"Replace compiler"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/tester/overview"},"Tester")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/defender/jest"},"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)("td",{parentName:"tr",align:null},"\u2022 ",(0,_react2.mdx)("a",{parentName:"td",href:"/frameworks/react/config-react-tools#jest"},"Jest config")," ",(0,_react2.mdx)("br",null)," \u2022 ",(0,_react2.mdx)("a",{parentName:"td",href:"/dev-services/tester/configure-env-with-tester"},"Replace Tester"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/linter/overview"},"Linting")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/defender/eslint"},"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)("td",{parentName:"tr",align:null},"\u2022 ",(0,_react2.mdx)("a",{parentName:"td",href:"/frameworks/react/config-react-tools#eslint"},"ESLint Config")," ",(0,_react2.mdx)("br",null)," \u2022 ",(0,_react2.mdx)("a",{parentName:"td",href:"/dev-services/linter/configure-env-with-linter"},"Replace Linter"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/formatter/overview"},"Formatter")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/defender/prettier"},"Prettier")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/react/react/~code/prettier/prettier.config.js"},"prettier.config.ts")),(0,_react2.mdx)("td",{parentName:"tr",align:null},"\u2022 ",(0,_react2.mdx)("a",{parentName:"td",href:"/frameworks/react/config-react-tools#prettier"},"Prettier config")," ",(0,_react2.mdx)("br",null)," \u2022 ",(0,_react2.mdx)("a",{parentName:"td",href:"/dev-services/formatter/configure-env-with-formatter"},"Replace Formatter"))),(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)("a",{parentName:"td",href:"https://bit.dev/teambit/webpack/webpack"},"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)("td",{parentName:"tr",align:null},"\u2022 Webpack config (for bundling in the workspace)")),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/docs/dev-services/preview/overview"},"Preview")),(0,_react2.mdx)("td",{parentName:"tr",align:null},"-"),(0,_react2.mdx)("td",{parentName:"tr",align:null}),(0,_react2.mdx)("td",{parentName:"tr",align:null},"\u2022 ",(0,_react2.mdx)("a",{parentName:"td",href:"/dev-services/preview/register-custom-preview"},"Add preview"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/docs/packages/packages-overview"},"Package")),(0,_react2.mdx)("td",{parentName:"tr",align:null},"-"),(0,_react2.mdx)("td",{parentName:"tr",align:null},"See the ",(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/typescript/typescript/~code/typescript.main.runtime.ts"},"TypeScript Aspect")," config"),(0,_react2.mdx)("td",{parentName:"tr",align:null},"\u2022 ",(0,_react2.mdx)("a",{parentName:"td",href:"/packages/managing-package-json#set-configuration-from-an-env"},"Add Env package config")," ",(0,_react2.mdx)("br",null)," \u2022 TypeScript's package config")),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},"Bundler"),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/webpack/webpack"},"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)("td",{parentName:"tr",align:null},"\u2022 Webpack config (for bundling during build)")),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/docs/dev-services/docs/docs-overview"},"Documentation")),(0,_react2.mdx)("td",{parentName:"tr",align:null},"-"),(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)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/docs/dev-services/docs/docs-templates"},"Replace docs template"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"http://localhost:3000/docs/dev-services/builder/builder-overview"},"Builder")),(0,_react2.mdx)("td",{parentName:"tr",align:null},"-"),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"http://localhost:3000/docs/dev-services/builder/builder-overview"},"Build pipeline")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/dev-services/builder/build-pipelines"},"Build pipelines"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/dependencies/dependencies-overview"},"Dependencies")),(0,_react2.mdx)("td",{parentName:"tr",align:null},"-"),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/react/react/~code/react.env.ts"},"Env-dependencies")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/dependencies/configuring-dependencies#configuring-dependencies-from-an-env"},"Env dependencies"))),(0,_react2.mdx)("tr",{parentName:"tbody"},(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"/docs/dev-services/generator/generator-overview"},"Generator")),(0,_react2.mdx)("td",{parentName:"tr",align:null},"-"),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:"https://bit.dev/teambit/react/react/~code/templates/react-component.ts"},"React templates")),(0,_react2.mdx)("td",{parentName:"tr",align:null},(0,_react2.mdx)("a",{parentName:"td",href:""},"Add a component template"))))),(0,_react2.mdx)("h3",null,"Default React versions"),(0,_react2.mdx)("p",null,"By default, the React env sets the following dependency versions for components using it:"),(0,_react2.mdx)("ul",null,(0,_react2.mdx)("li",{parentName:"ul"},(0,_react2.mdx)("strong",{parentName:"li"},"react")," (peer dependency): ",(0,_react2.mdx)("inlineCode",{parentName:"li"},"^16.8.0 || ^17.0.0")),(0,_react2.mdx)("li",{parentName:"ul"},(0,_react2.mdx)("strong",{parentName:"li"},"react-dom")," (peer dependency): ",(0,_react2.mdx)("inlineCode",{parentName:"li"},"^16.8.0 || ^17.0.0")),(0,_react2.mdx)("li",{parentName:"ul"},(0,_react2.mdx)("strong",{parentName:"li"},"@types/react"),": ",(0,_react2.mdx)("inlineCode",{parentName:"li"},"^17.0.8")),(0,_react2.mdx)("li",{parentName:"ul"},(0,_react2.mdx)("strong",{parentName:"li"},"@types/react-dom"),": ",(0,_react2.mdx)("inlineCode",{parentName:"li"},"^17.0.5")))))}MDXContent.__bit_component=__bit_component,MDXContent.isMDXComponent=!0},950:(__unused_webpack_module,exports2,__webpack_require__2)=>{"use strict";var __bit_component={id:"teambit.react/react@0.0.807",homepage:"https://bit.dev/teambit/react/react",exported:!0},_interopRequireDefault=__webpack_require__2(244);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/react.svg"}));Logo.__bit_component=__bit_component,exports2.Logo=Logo},57:module2=>{"use strict";module2.exports=MdxJsReact},804:module2=>{"use strict";module2.exports=React},459:module2=>{"use strict";module2.exports=TeambitMdxUiMdxScopeContext}},__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,overview:()=>overview});var react_docs_namespaceObject={};__webpack_require__.r(react_docs_namespaceObject),__webpack_require__.d(react_docs_namespaceObject,{default:()=>MDXContent});var react_composition=__webpack_require__(950),external_React_=__webpack_require__(804),external_MdxJsReact_=__webpack_require__(57),external_TeambitMdxUiMdxScopeContext_=__webpack_require__(459),dist=__webpack_require__(906),_excluded=["components"];function _extends(){return _extends=Object.assign||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_.MDXScopeProvider,{components:{ReactOverview:dist.ZP},mdxType:"MDXScopeProvider"},(0,external_MdxJsReact_.mdx)(dist.ZP,{mdxType:"ReactOverview"})))}MDXContent.isMDXComponent=!0;const compositions=[react_composition],overview=[react_docs_namespaceObject]})(),__webpack_exports__})()});
@@ -2,6 +2,7 @@ import { BundlerResult } from '@teambit/bundler';
2
2
  import { ReactAppBuildResult } from './react-build-result';
3
3
  declare type resultsOptions = {
4
4
  publicDir: string;
5
+ ssrPublicDir?: string;
5
6
  };
6
- export declare function computeResults(results: BundlerResult[], { publicDir }: resultsOptions): Promise<ReactAppBuildResult>;
7
+ export declare function computeResults(results: BundlerResult[], { publicDir, ssrPublicDir }: resultsOptions): Promise<ReactAppBuildResult>;
7
8
  export {};
@@ -8,11 +8,13 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.computeResults = computeResults;
9
9
 
10
10
  async function computeResults(results, {
11
- publicDir
11
+ publicDir,
12
+ ssrPublicDir
12
13
  }) {
13
14
  const result = results[0];
14
15
  return {
15
16
  publicDir,
17
+ ssrPublicDir,
16
18
  errors: result.errors,
17
19
  warnings: result.warnings
18
20
  };
@@ -1 +1 @@
1
- {"version":3,"names":["computeResults","results","publicDir","result","errors","warnings"],"sources":["compute-results.ts"],"sourcesContent":["import { BundlerResult } from '@teambit/bundler';\nimport { ReactAppBuildResult } from './react-build-result';\n\ntype resultsOptions = {\n publicDir: string;\n};\nexport async function computeResults(\n results: BundlerResult[],\n { publicDir }: resultsOptions\n): Promise<ReactAppBuildResult> {\n const result = results[0];\n\n return {\n publicDir,\n errors: result.errors,\n warnings: result.warnings,\n };\n}\n"],"mappings":";;;;;;;;;AAMO,eAAeA,cAAf,CACLC,OADK,EAEL;EAAEC;AAAF,CAFK,EAGyB;EAC9B,MAAMC,MAAM,GAAGF,OAAO,CAAC,CAAD,CAAtB;EAEA,OAAO;IACLC,SADK;IAELE,MAAM,EAAED,MAAM,CAACC,MAFV;IAGLC,QAAQ,EAAEF,MAAM,CAACE;EAHZ,CAAP;AAKD"}
1
+ {"version":3,"names":["computeResults","results","publicDir","ssrPublicDir","result","errors","warnings"],"sources":["compute-results.ts"],"sourcesContent":["import { BundlerResult } from '@teambit/bundler';\nimport { ReactAppBuildResult } from './react-build-result';\n\ntype resultsOptions = {\n publicDir: string;\n ssrPublicDir?: string;\n};\nexport async function computeResults(\n results: BundlerResult[],\n { publicDir, ssrPublicDir }: resultsOptions\n): Promise<ReactAppBuildResult> {\n const result = results[0];\n\n return {\n publicDir,\n ssrPublicDir,\n errors: result.errors,\n warnings: result.warnings,\n };\n}\n"],"mappings":";;;;;;;;;AAOO,eAAeA,cAAf,CACLC,OADK,EAEL;EAAEC,SAAF;EAAaC;AAAb,CAFK,EAGyB;EAC9B,MAAMC,MAAM,GAAGH,OAAO,CAAC,CAAD,CAAtB;EAEA,OAAO;IACLC,SADK;IAELC,YAFK;IAGLE,MAAM,EAAED,MAAM,CAACC,MAHV;IAILC,QAAQ,EAAEF,MAAM,CAACE;EAJZ,CAAP;AAMD"}
@@ -61,7 +61,7 @@ export declare type ReactAppOptions = {
61
61
  /**
62
62
  * path to entry files of the application.
63
63
  */
64
- entry: string[] | (() => Promise<string[]>);
64
+ entry: string[] | ((path?: string) => Promise<string[]>);
65
65
  /**
66
66
  * path to server-rendered entrypoint of the app
67
67
  */
@@ -70,6 +70,10 @@ export declare type ReactAppOptions = {
70
70
  * instance of bundler to use. default is Webpack.
71
71
  */
72
72
  bundler?: Bundler;
73
+ /**
74
+ * instance of serverside bundler to use. default is Webpack.
75
+ */
76
+ ssrBundler?: Bundler;
73
77
  /**
74
78
  * instance of dev server to use. default is Webpack.
75
79
  */
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["react-app-options.ts"],"sourcesContent":["import { Bundler, DevServer } from '@teambit/bundler';\nimport { WebpackConfigTransformer } from '@teambit/webpack';\n\nimport { ReactDeployContext } from './deploy-context';\n\ntype prerenderedRoute = {\n /** The prerendered route, after following redirects */\n route: string;\n /** The original route passed, before redirects */\n originalRoute: string;\n /** The resulting HTML for the route */\n html: string;\n /**\n * The path to write the rendered HTML to.\n * This is null (automatically calculated after postProcess)\n * unless explicitly set. */\n outputPath?: string | null;\n};\n\n/** https://github.com/Tofandel/prerender-spa-plugin-next */\nexport type ReactAppPrerenderOptions = {\n /**\n * sub folder to output the prerender, inside the webpack output folder\n * @default '/'\n */\n staticDir?: string;\n\n /** The index file to fall back on for SPAs. */\n indexPath?: string;\n\n /**\n * routes to prerender\n */\n routes: string[];\n\n /**\n * the proxy server you want the prerender headless browser to run on\n */\n server?: {\n proxy: {\n [key: string]: {\n /** required by HPM.\n * @default 'http://localhost:8000/' */\n target: string;\n pathRewrite: { [key: string]: string };\n };\n };\n };\n\n /**\n * Post processing of the prerendered html. This is useful for adding meta tags to the html or changing the file name.\n */\n postProcess?: (prerenderRoute: prerenderedRoute) => prerenderedRoute;\n\n /** The renderer you'd like to use to prerender the app.\n * @default new require(\"@prerenderer/renderer-puppeteer\").\n */\n renderer?: any;\n\n /** options to pass to the renderer class's constructor */\n rendererOptions?: any;\n};\n\nexport type ReactAppOptions = {\n /**\n * name of the application.\n */\n name: string;\n\n /**\n * path to entry files of the application.\n */\n entry: string[] | (() => Promise<string[]>);\n\n /**\n * path to server-rendered entrypoint of the app\n */\n ssr?: string | (() => Promise<string>);\n\n /**\n * instance of bundler to use. default is Webpack.\n */\n bundler?: Bundler;\n\n /**\n * instance of dev server to use. default is Webpack.\n */\n devServer?: DevServer;\n\n /**\n * set webpack transformers\n */\n webpackTransformers?: WebpackConfigTransformer[];\n\n /**\n * decide whether to prerender your app. accepts an array of routes. if none, prerender would not apply.\n * e.g ['/plugins', '/learn', '/docs/quick-start]\n * You can also pass a configuration for the proxy, please refer here: https://github.com/webpack/docs/wiki/webpack-dev-server#proxy\n *\n */\n prerender?: ReactAppPrerenderOptions;\n\n /**\n * deploy function.\n */\n deploy?: (context: ReactDeployContext) => Promise<void>;\n\n /**\n * ranges of ports to use to run the app server.\n */\n portRange?: [start: number, end: number];\n\n /**\n * favicon for the app. You can pass an abs path (using require.resolve()) or a url.\n */\n favicon?: string;\n};\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["react-app-options.ts"],"sourcesContent":["import { Bundler, DevServer } from '@teambit/bundler';\nimport { WebpackConfigTransformer } from '@teambit/webpack';\n\nimport { ReactDeployContext } from './deploy-context';\n\ntype prerenderedRoute = {\n /** The prerendered route, after following redirects */\n route: string;\n /** The original route passed, before redirects */\n originalRoute: string;\n /** The resulting HTML for the route */\n html: string;\n /**\n * The path to write the rendered HTML to.\n * This is null (automatically calculated after postProcess)\n * unless explicitly set. */\n outputPath?: string | null;\n};\n\n/** https://github.com/Tofandel/prerender-spa-plugin-next */\nexport type ReactAppPrerenderOptions = {\n /**\n * sub folder to output the prerender, inside the webpack output folder\n * @default '/'\n */\n staticDir?: string;\n\n /** The index file to fall back on for SPAs. */\n indexPath?: string;\n\n /**\n * routes to prerender\n */\n routes: string[];\n\n /**\n * the proxy server you want the prerender headless browser to run on\n */\n server?: {\n proxy: {\n [key: string]: {\n /** required by HPM.\n * @default 'http://localhost:8000/' */\n target: string;\n pathRewrite: { [key: string]: string };\n };\n };\n };\n\n /**\n * Post processing of the prerendered html. This is useful for adding meta tags to the html or changing the file name.\n */\n postProcess?: (prerenderRoute: prerenderedRoute) => prerenderedRoute;\n\n /** The renderer you'd like to use to prerender the app.\n * @default new require(\"@prerenderer/renderer-puppeteer\").\n */\n renderer?: any;\n\n /** options to pass to the renderer class's constructor */\n rendererOptions?: any;\n};\n\nexport type ReactAppOptions = {\n /**\n * name of the application.\n */\n name: string;\n\n /**\n * path to entry files of the application.\n */\n entry: string[] | ((path?: string) => Promise<string[]>);\n\n /**\n * path to server-rendered entrypoint of the app\n */\n ssr?: string | (() => Promise<string>);\n\n /**\n * instance of bundler to use. default is Webpack.\n */\n bundler?: Bundler;\n\n /**\n * instance of serverside bundler to use. default is Webpack.\n */\n ssrBundler?: Bundler;\n\n /**\n * instance of dev server to use. default is Webpack.\n */\n devServer?: DevServer;\n\n /**\n * set webpack transformers\n */\n webpackTransformers?: WebpackConfigTransformer[];\n\n /**\n * decide whether to prerender your app. accepts an array of routes. if none, prerender would not apply.\n * e.g ['/plugins', '/learn', '/docs/quick-start]\n * You can also pass a configuration for the proxy, please refer here: https://github.com/webpack/docs/wiki/webpack-dev-server#proxy\n *\n */\n prerender?: ReactAppPrerenderOptions;\n\n /**\n * deploy function.\n */\n deploy?: (context: ReactDeployContext) => Promise<void>;\n\n /**\n * ranges of ports to use to run the app server.\n */\n portRange?: [start: number, end: number];\n\n /**\n * favicon for the app. You can pass an abs path (using require.resolve()) or a url.\n */\n favicon?: string;\n};\n"],"mappings":""}
@@ -5,4 +5,5 @@ export declare type ReactAppBuildResult = {
5
5
  * when using ssr, public dir is undefined.
6
6
  */
7
7
  publicDir?: string;
8
+ ssrPublicDir?: string;
8
9
  } & AppBuildResult;
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["react-build-result.ts"],"sourcesContent":["import { AppBuildResult } from '@teambit/application';\n\nexport type ReactAppBuildResult = {\n /**\n * the directory which includes the built application public assets.\n * when using ssr, public dir is undefined.\n */\n publicDir?: string;\n} & AppBuildResult;\n"],"mappings":""}
1
+ {"version":3,"names":[],"sources":["react-build-result.ts"],"sourcesContent":["import { AppBuildResult } from '@teambit/application';\n\nexport type ReactAppBuildResult = {\n /**\n * the directory which includes the built application public assets.\n * when using ssr, public dir is undefined.\n */\n publicDir?: string;\n ssrPublicDir?: string;\n} & AppBuildResult;\n"],"mappings":""}
@@ -23,7 +23,7 @@ class ReactAppType {
23
23
  }
24
24
 
25
25
  createApp(options) {
26
- return new (_react().ReactApp)(options.name, options.entry, options.ssr, options.portRange || [3000, 4000], this.reactEnv, options.prerender, options.bundler, options.devServer, options.webpackTransformers, options.deploy, options.favicon, this.logger);
26
+ return new (_react().ReactApp)(options.name, options.entry, options.ssr, options.portRange || [3000, 4000], this.reactEnv, options.prerender, options.bundler, options.ssrBundler, options.devServer, options.webpackTransformers, options.deploy, options.favicon, this.logger);
27
27
  }
28
28
 
29
29
  }
@@ -1 +1 @@
1
- {"version":3,"names":["ReactAppType","constructor","name","reactEnv","logger","createApp","options","ReactApp","entry","ssr","portRange","prerender","bundler","devServer","webpackTransformers","deploy","favicon"],"sources":["react.app-type.ts"],"sourcesContent":["import { ApplicationType } from '@teambit/application';\nimport type { Logger } from '@teambit/logger';\nimport { ReactAppOptions } from './react-app-options';\nimport { ReactApp } from './react.application';\nimport { ReactEnv } from '../../react.env';\n\nexport class ReactAppType implements ApplicationType<ReactAppOptions> {\n constructor(readonly name: string, private reactEnv: ReactEnv, private logger?: Logger) {}\n\n createApp(options: ReactAppOptions) {\n return new ReactApp(\n options.name,\n options.entry,\n options.ssr,\n options.portRange || [3000, 4000],\n this.reactEnv,\n options.prerender,\n options.bundler,\n options.devServer,\n options.webpackTransformers,\n options.deploy,\n options.favicon,\n this.logger\n );\n }\n}\n"],"mappings":";;;;;;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGO,MAAMA,YAAN,CAA+D;EACpEC,WAAW,CAAUC,IAAV,EAAgCC,QAAhC,EAA4DC,MAA5D,EAA6E;IAAA,KAAnEF,IAAmE,GAAnEA,IAAmE;IAAA,KAA7CC,QAA6C,GAA7CA,QAA6C;IAAA,KAAjBC,MAAiB,GAAjBA,MAAiB;EAAE;;EAE1FC,SAAS,CAACC,OAAD,EAA2B;IAClC,OAAO,KAAIC,iBAAJ,EACLD,OAAO,CAACJ,IADH,EAELI,OAAO,CAACE,KAFH,EAGLF,OAAO,CAACG,GAHH,EAILH,OAAO,CAACI,SAAR,IAAqB,CAAC,IAAD,EAAO,IAAP,CAJhB,EAKL,KAAKP,QALA,EAMLG,OAAO,CAACK,SANH,EAOLL,OAAO,CAACM,OAPH,EAQLN,OAAO,CAACO,SARH,EASLP,OAAO,CAACQ,mBATH,EAULR,OAAO,CAACS,MAVH,EAWLT,OAAO,CAACU,OAXH,EAYL,KAAKZ,MAZA,CAAP;EAcD;;AAlBmE"}
1
+ {"version":3,"names":["ReactAppType","constructor","name","reactEnv","logger","createApp","options","ReactApp","entry","ssr","portRange","prerender","bundler","ssrBundler","devServer","webpackTransformers","deploy","favicon"],"sources":["react.app-type.ts"],"sourcesContent":["import { ApplicationType } from '@teambit/application';\nimport type { Logger } from '@teambit/logger';\nimport { ReactAppOptions } from './react-app-options';\nimport { ReactApp } from './react.application';\nimport { ReactEnv } from '../../react.env';\n\nexport class ReactAppType implements ApplicationType<ReactAppOptions> {\n constructor(readonly name: string, private reactEnv: ReactEnv, private logger?: Logger) {}\n\n createApp(options: ReactAppOptions) {\n return new ReactApp(\n options.name,\n options.entry,\n options.ssr,\n options.portRange || [3000, 4000],\n this.reactEnv,\n options.prerender,\n options.bundler,\n options.ssrBundler,\n options.devServer,\n options.webpackTransformers,\n options.deploy,\n options.favicon,\n this.logger\n );\n }\n}\n"],"mappings":";;;;;;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGO,MAAMA,YAAN,CAA+D;EACpEC,WAAW,CAAUC,IAAV,EAAgCC,QAAhC,EAA4DC,MAA5D,EAA6E;IAAA,KAAnEF,IAAmE,GAAnEA,IAAmE;IAAA,KAA7CC,QAA6C,GAA7CA,QAA6C;IAAA,KAAjBC,MAAiB,GAAjBA,MAAiB;EAAE;;EAE1FC,SAAS,CAACC,OAAD,EAA2B;IAClC,OAAO,KAAIC,iBAAJ,EACLD,OAAO,CAACJ,IADH,EAELI,OAAO,CAACE,KAFH,EAGLF,OAAO,CAACG,GAHH,EAILH,OAAO,CAACI,SAAR,IAAqB,CAAC,IAAD,EAAO,IAAP,CAJhB,EAKL,KAAKP,QALA,EAMLG,OAAO,CAACK,SANH,EAOLL,OAAO,CAACM,OAPH,EAQLN,OAAO,CAACO,UARH,EASLP,OAAO,CAACQ,SATH,EAULR,OAAO,CAACS,mBAVH,EAWLT,OAAO,CAACU,MAXH,EAYLV,OAAO,CAACW,OAZH,EAaL,KAAKb,MAbA,CAAP;EAeD;;AAnBmE"}
@@ -8,30 +8,34 @@ import { ReactAppPrerenderOptions } from './react-app-options';
8
8
  import { ReactDeployContext } from '.';
9
9
  export declare class ReactApp implements Application {
10
10
  readonly name: string;
11
- readonly entry: string[] | (() => Promise<string[]>);
11
+ readonly entry: string[] | ((path?: string) => Promise<string[]>);
12
12
  readonly ssr: string | (() => Promise<string>) | undefined;
13
13
  readonly portRange: [number, number];
14
14
  private reactEnv;
15
15
  readonly prerender?: ReactAppPrerenderOptions | undefined;
16
16
  readonly bundler?: Bundler | undefined;
17
+ readonly ssrBundler?: Bundler | undefined;
17
18
  readonly devServer?: DevServer | undefined;
18
19
  readonly transformers: WebpackConfigTransformer[];
19
20
  readonly deploy?: ((context: ReactDeployContext) => Promise<void>) | undefined;
20
21
  readonly favicon?: string | undefined;
21
22
  private logger?;
22
- constructor(name: string, entry: string[] | (() => Promise<string[]>), ssr: string | (() => Promise<string>) | undefined, portRange: [number, number], reactEnv: ReactEnv, prerender?: ReactAppPrerenderOptions | undefined, bundler?: Bundler | undefined, devServer?: DevServer | undefined, transformers?: WebpackConfigTransformer[], deploy?: ((context: ReactDeployContext) => Promise<void>) | undefined, favicon?: string | undefined, logger?: Logger | undefined);
23
+ constructor(name: string, entry: string[] | ((path?: string) => Promise<string[]>), ssr: string | (() => Promise<string>) | undefined, portRange: [number, number], reactEnv: ReactEnv, prerender?: ReactAppPrerenderOptions | undefined, bundler?: Bundler | undefined, ssrBundler?: Bundler | undefined, devServer?: DevServer | undefined, transformers?: WebpackConfigTransformer[], deploy?: ((context: ReactDeployContext) => Promise<void>) | undefined, favicon?: string | undefined, logger?: Logger | undefined);
23
24
  readonly applicationType = "react-common-js";
24
25
  readonly dir = "public";
26
+ readonly ssrDir = "ssr";
25
27
  run(context: AppContext): Promise<number>;
26
28
  runSsr(context: AppContext): Promise<AppResult>;
27
29
  private buildClient;
28
30
  private buildSsr;
29
31
  build(context: AppBuildContext): Promise<ReactAppBuildResult>;
30
32
  private getBundler;
33
+ private getSsrBundler;
31
34
  private getDefaultBundler;
32
- private getESBuildConfig;
35
+ private getDefaultSsrBundler;
36
+ private getBuildContext;
33
37
  private getPublicDir;
34
- getEntries(): Promise<string[]>;
38
+ getEntries(path?: string): Promise<string[]>;
35
39
  getSsrEntries(): Promise<string[]>;
36
40
  private getDevServerContext;
37
41
  private getPeers;
@@ -42,7 +42,7 @@ function _toolboxNetwork() {
42
42
  }
43
43
 
44
44
  function _lodash() {
45
- const data = require("lodash");
45
+ const data = _interopRequireDefault(require("lodash.compact"));
46
46
 
47
47
  _lodash = function () {
48
48
  return data;
@@ -51,16 +51,6 @@ function _lodash() {
51
51
  return data;
52
52
  }
53
53
 
54
- function _terserWebpackPlugin() {
55
- const data = _interopRequireDefault(require("terser-webpack-plugin"));
56
-
57
- _terserWebpackPlugin = function () {
58
- return data;
59
- };
60
-
61
- return data;
62
- }
63
-
64
54
  function _bitError() {
65
55
  const data = require("@teambit/bit-error");
66
56
 
@@ -136,7 +126,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
136
126
  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; }
137
127
 
138
128
  class ReactApp {
139
- constructor(name, entry, ssr, portRange, reactEnv, prerender, bundler, devServer, transformers = [], deploy, favicon, logger) {
129
+ constructor(name, entry, ssr, portRange, reactEnv, prerender, bundler, ssrBundler, devServer, transformers = [], deploy, favicon, logger) {
140
130
  this.name = name;
141
131
  this.entry = entry;
142
132
  this.ssr = ssr;
@@ -144,6 +134,7 @@ class ReactApp {
144
134
  this.reactEnv = reactEnv;
145
135
  this.prerender = prerender;
146
136
  this.bundler = bundler;
137
+ this.ssrBundler = ssrBundler;
147
138
  this.devServer = devServer;
148
139
  this.transformers = transformers;
149
140
  this.deploy = deploy;
@@ -151,58 +142,7 @@ class ReactApp {
151
142
  this.logger = logger;
152
143
  (0, _defineProperty2().default)(this, "applicationType", 'react-common-js');
153
144
  (0, _defineProperty2().default)(this, "dir", 'public');
154
- (0, _defineProperty2().default)(this, "getESBuildConfig", (isPrerendering = this.prerender) => {
155
- // We don't want to use esbuild in case of prerendering since the headless browser puppeteer doesn't support
156
- // the output of esbuild
157
- if (isPrerendering) {
158
- return new (_terserWebpackPlugin().default)({
159
- extractComments: false,
160
- terserOptions: {
161
- parse: {
162
- // We want terser to parse ecma 8 code. However, we don't want it
163
- // to apply any minification steps that turns valid ecma 5 code
164
- // into invalid ecma 5 code. This is why the 'compress' and 'output'
165
- // sections only apply transformations that are ecma 5 safe
166
- // https://github.com/facebook/create-react-app/pull/4234
167
- ecma: 8
168
- },
169
- compress: {
170
- ecma: 5,
171
- warnings: false,
172
- // Disabled because of an issue with Uglify breaking seemingly valid code:
173
- // https://github.com/facebook/create-react-app/issues/2376
174
- // Pending further investigation:
175
- // https://github.com/mishoo/UglifyJS2/issues/2011
176
- comparisons: false,
177
- // Disabled because of an issue with Terser breaking valid code:
178
- // https://github.com/facebook/create-react-app/issues/5250
179
- // Pending further investigation:
180
- // https://github.com/terser-js/terser/issues/120
181
- inline: 2
182
- },
183
- mangle: {
184
- safari10: true
185
- },
186
- output: {
187
- ecma: 5,
188
- comments: false,
189
- // Turned on because emoji and regex is not minified properly using default
190
- // https://github.com/facebook/create-react-app/issues/2488
191
- ascii_only: true
192
- }
193
- }
194
- });
195
- }
196
-
197
- return new (_terserWebpackPlugin().default)({
198
- minify: _terserWebpackPlugin().default.esbuildMinify,
199
- // `terserOptions` options will be passed to `esbuild`
200
- // Link to options - https://esbuild.github.io/api/#minify
201
- terserOptions: {
202
- minify: true
203
- }
204
- });
205
- });
145
+ (0, _defineProperty2().default)(this, "ssrDir", 'ssr');
206
146
  }
207
147
 
208
148
  async run(context) {
@@ -312,8 +252,15 @@ class ReactApp {
312
252
  });
313
253
  const bundler = await this.getBundler(context);
314
254
  const bundleResult = await bundler.run();
255
+
256
+ if (this.ssr) {
257
+ const bunlder = await this.getSsrBundler(context);
258
+ await bunlder.run();
259
+ }
260
+
315
261
  return (0, _computeResults().computeResults)(bundleResult, {
316
- publicDir: `${this.getPublicDir(context.artifactsDir)}/${this.dir}`
262
+ publicDir: `${this.getPublicDir(context.artifactsDir)}/${this.dir}`,
263
+ ssrPublicDir: this.ssr ? `${this.getPublicDir(context.artifactsDir)}/${this.ssrDir}` : undefined
317
264
  });
318
265
  }
319
266
 
@@ -322,19 +269,64 @@ class ReactApp {
322
269
  return this.getDefaultBundler(context);
323
270
  }
324
271
 
272
+ getSsrBundler(context) {
273
+ if (this.ssrBundler) return this.ssrBundler;
274
+ return this.getDefaultSsrBundler(context);
275
+ }
276
+
325
277
  async getDefaultBundler(context) {
326
278
  const {
327
279
  capsule
328
280
  } = context;
281
+ const publicDir = this.getPublicDir(context.artifactsDir);
282
+ const outputPath = (0, _path().join)(capsule.path, publicDir);
283
+ const bundlerContext = await this.getBuildContext(context, {
284
+ outputPath
285
+ });
286
+ const transformers = (0, _lodash().default)([configMutator => configMutator.merge((0, _webpackAppSsr().buildConfig)({
287
+ outputPath: (0, _path().join)(outputPath, this.dir)
288
+ })), config => {
289
+ if (this.prerender) config.addPlugin((0, _plugins().prerenderPlugin)(this.prerender));
290
+ return config;
291
+ }, (0, _mutators().replaceTerserPlugin)({
292
+ prerender: !!this.prerender
293
+ }), ...this.transformers]);
329
294
  const reactEnv = context.env;
295
+ const bundler = await reactEnv.getBundler(bundlerContext, transformers);
296
+ return bundler;
297
+ }
298
+
299
+ async getDefaultSsrBundler(context) {
300
+ const {
301
+ capsule
302
+ } = context;
330
303
  const publicDir = this.getPublicDir(context.artifactsDir);
331
304
  const outputPath = (0, _path().join)(capsule.path, publicDir);
305
+ const bundlerContext = await this.getBuildContext(context, {
306
+ outputPath
307
+ });
308
+ const transformers = (0, _lodash().default)([configMutator => configMutator.merge((0, _webpackAppSsr().ssrBuildConfig)({
309
+ outputPath: (0, _path().join)(outputPath, this.ssrDir)
310
+ })), (0, _mutators().replaceTerserPlugin)({
311
+ prerender: !!this.prerender
312
+ }), ...this.transformers]);
313
+ const reactEnv = context.env;
314
+ const bundler = await reactEnv.getBundler(bundlerContext, transformers);
315
+ return bundler;
316
+ }
317
+
318
+ async getBuildContext(context, {
319
+ outputPath
320
+ }) {
321
+ const {
322
+ capsule
323
+ } = context;
324
+ const reactEnv = context.env;
332
325
  const {
333
326
  distDir
334
327
  } = reactEnv.getCompiler();
335
- const targetEntries = Array.isArray(this.entry) ? this.entry : await this.entry();
328
+ const targetEntries = await this.getEntries(`${capsule.path}/${distDir}`);
336
329
  const entries = targetEntries.map(entry => require.resolve(`${capsule.path}/${distDir}/${(0, _path().basename)(entry)}`));
337
- const staticDir = (0, _path().join)(outputPath, this.dir);
338
330
  const bundlerContext = Object.assign(context, {
339
331
  targets: [{
340
332
  components: [capsule === null || capsule === void 0 ? void 0 : capsule.component],
@@ -351,41 +343,16 @@ class ReactApp {
351
343
  envId: context.id
352
344
  }
353
345
  });
354
-
355
- const defaultTransformer = configMutator => {
356
- var _config$raw$optimizat;
357
-
358
- const config = configMutator.addTopLevel('output', {
359
- path: staticDir,
360
- publicPath: `/`,
361
- filename: '[name].[chunkhash].js'
362
- });
363
- if (this.prerender) config.addPlugin((0, _plugins().prerenderPlugin)(this.prerender));
364
-
365
- if ((_config$raw$optimizat = config.raw.optimization) !== null && _config$raw$optimizat !== void 0 && _config$raw$optimizat.minimizer) {
366
- var _config$raw$optimizat2, _config$raw$optimizat3;
367
-
368
- (0, _lodash().remove)((_config$raw$optimizat2 = config.raw.optimization) === null || _config$raw$optimizat2 === void 0 ? void 0 : _config$raw$optimizat2.minimizer, minimizer => {
369
- return minimizer.constructor.name === 'TerserPlugin';
370
- });
371
- (_config$raw$optimizat3 = config.raw.optimization) === null || _config$raw$optimizat3 === void 0 ? void 0 : _config$raw$optimizat3.minimizer.push(this.getESBuildConfig());
372
- }
373
-
374
- return config;
375
- };
376
-
377
- const transformers = [defaultTransformer, ...this.transformers];
378
- const bundler = await reactEnv.getBundler(bundlerContext, transformers);
379
- return bundler;
346
+ return bundlerContext;
380
347
  }
381
348
 
382
349
  getPublicDir(artifactsDir) {
383
350
  return (0, _path().join)(artifactsDir, this.applicationType, this.name);
384
351
  }
385
352
 
386
- async getEntries() {
353
+ async getEntries(path) {
387
354
  if (Array.isArray(this.entry)) return this.entry;
388
- return this.entry();
355
+ return this.entry(path);
389
356
  }
390
357
 
391
358
  async getSsrEntries() {
@@ -1 +1 @@
1
- {"version":3,"names":["ReactApp","constructor","name","entry","ssr","portRange","reactEnv","prerender","bundler","devServer","transformers","deploy","favicon","logger","isPrerendering","TerserPlugin","extractComments","terserOptions","parse","ecma","compress","warnings","comparisons","inline","mangle","safari10","output","comments","ascii_only","minify","esbuildMinify","run","context","from","to","port","Port","getPort","listen","devServerContext","getDevServerContext","getDevServer","addDevServer","setOutput","runSsr","clientBundle","buildClient","errors","length","info","serverBundle","buildSsr","app","loadSsrApp","workdir","appName","expressApp","createExpressSsr","assets","parseAssets","htmlConfig","title","templateContent","html","ctx","Object","assign","create","targets","entries","getEntries","components","appComponent","outputPath","resolve","calcOutputPath","hostDependencies","getPeers","aliasHostDependencies","capsuleNetwork","undefined","previousTasksResults","getBundler","config","merge","clientConfig","bundleResult","getSsrEntries","ssrConfig","build","computeResults","publicDir","getPublicDir","artifactsDir","dir","getDefaultBundler","capsule","env","join","path","distDir","getCompiler","targetEntries","Array","isArray","map","require","basename","staticDir","bundlerContext","component","hostRootDir","rootPath","metaData","initiator","envId","id","defaultTransformer","configMutator","addTopLevel","publicPath","filename","addPlugin","prerenderPlugin","raw","optimization","minimizer","remove","push","getESBuildConfig","applicationType","BitError","getPeerDependenciesList"],"sources":["react.application.ts"],"sourcesContent":["import { join, resolve, basename } from 'path';\nimport { Application, AppContext, AppBuildContext, AppResult } from '@teambit/application';\nimport type { Bundler, DevServer, BundlerContext, DevServerContext, BundlerHtmlConfig } from '@teambit/bundler';\nimport { Port } from '@teambit/toolbox.network.get-port';\nimport type { Logger } from '@teambit/logger';\nimport { remove } from 'lodash';\nimport TerserPlugin from 'terser-webpack-plugin';\nimport { WebpackConfigTransformer } from '@teambit/webpack';\nimport { BitError } from '@teambit/bit-error';\nimport { ReactEnv } from '../../react.env';\nimport { prerenderPlugin } from './plugins';\nimport { ReactAppBuildResult } from './react-build-result';\nimport { ReactAppPrerenderOptions } from './react-app-options';\nimport { html } from '../../webpack';\nimport { ReactDeployContext } from '.';\nimport { computeResults } from './compute-results';\nimport { clientConfig, ssrConfig, calcOutputPath } from './webpack/webpack.app.ssr.config';\nimport { addDevServer, setOutput } from './webpack/mutators';\nimport { createExpressSsr, loadSsrApp, parseAssets } from './ssr/ssr-express';\n\nexport class ReactApp implements Application {\n constructor(\n readonly name: string,\n readonly entry: string[] | (() => Promise<string[]>),\n readonly ssr: string | (() => Promise<string>) | undefined,\n readonly portRange: [number, number],\n private reactEnv: ReactEnv,\n readonly prerender?: ReactAppPrerenderOptions,\n readonly bundler?: Bundler,\n readonly devServer?: DevServer,\n readonly transformers: WebpackConfigTransformer[] = [],\n readonly deploy?: (context: ReactDeployContext) => Promise<void>,\n readonly favicon?: string,\n private logger?: Logger\n ) {}\n readonly applicationType = 'react-common-js';\n readonly dir = 'public';\n\n async run(context: AppContext): Promise<number> {\n const [from, to] = this.portRange;\n const port = await Port.getPort(from, to);\n\n if (this.devServer) {\n await this.devServer.listen(port);\n return port;\n }\n\n const devServerContext = await this.getDevServerContext(context);\n const devServer = this.reactEnv.getDevServer(devServerContext, [addDevServer, setOutput, ...this.transformers]);\n await devServer.listen(port);\n return port;\n }\n\n async runSsr(context: AppContext): Promise<AppResult> {\n const [from, to] = this.portRange;\n const port = await Port.getPort(from, to);\n\n // bundle client\n const clientBundle = await this.buildClient(context);\n if (clientBundle.errors.length > 0) return { errors: clientBundle.errors };\n this.logger?.info('[react.application] [ssr] client bundle - complete');\n\n // bundle server\n const serverBundle = await this.buildSsr(context);\n if (serverBundle.errors.length > 0) return { errors: serverBundle.errors };\n this.logger?.info('[react.application] [ssr] server bundle - complete');\n\n // load server-side runtime\n const app = await loadSsrApp(context.workdir, context.appName);\n this.logger?.info('[react.application] [ssr] bundle code - loaded');\n\n const expressApp = createExpressSsr({\n name: context.appName,\n workdir: context.workdir,\n port,\n app,\n assets: parseAssets(clientBundle.assets),\n logger: this.logger,\n });\n\n expressApp.listen(port);\n return { port };\n }\n\n private async buildClient(context: AppContext) {\n const htmlConfig: BundlerHtmlConfig[] = [\n {\n title: context.appName,\n templateContent: html(context.appName),\n minify: false,\n favicon: this.favicon,\n },\n ];\n\n // extend, including prototype methods\n const ctx: BundlerContext = Object.assign(Object.create(context), {\n html: htmlConfig,\n targets: [\n {\n entries: await this.getEntries(),\n components: [context.appComponent],\n outputPath: resolve(context.workdir, calcOutputPath(context.appName, 'browser')),\n hostDependencies: await this.getPeers(),\n aliasHostDependencies: true,\n },\n ],\n\n // @ts-ignore\n capsuleNetwork: undefined,\n previousTasksResults: [],\n });\n\n const bundler = await this.reactEnv.getBundler(ctx, [\n (config) => config.merge([clientConfig()]),\n ...this.transformers,\n ]);\n\n const bundleResult = await bundler.run();\n return bundleResult[0];\n }\n\n private async buildSsr(context: AppContext) {\n // extend, including prototype methods\n const ctx: BundlerContext = Object.assign(Object.create(context), {\n ...context,\n targets: [\n {\n entries: await this.getSsrEntries(),\n components: [context.appComponent],\n outputPath: resolve(context.workdir, calcOutputPath(context.appName, 'ssr')),\n hostDependencies: await this.getPeers(),\n aliasHostDependencies: true,\n },\n ],\n\n // @ts-ignore\n capsuleNetwork: undefined,\n previousTasksResults: [],\n });\n\n const bundler = await this.reactEnv.getBundler(ctx, [\n (config) => config.merge([ssrConfig()]),\n ...this.transformers,\n ]);\n\n const bundleResult = await bundler.run();\n return bundleResult[0];\n }\n\n async build(context: AppBuildContext): Promise<ReactAppBuildResult> {\n const htmlConfig: BundlerHtmlConfig[] = [\n {\n title: context.name,\n templateContent: html(context.name),\n minify: false,\n favicon: this.favicon,\n // filename: ''.html`,\n },\n ];\n Object.assign(context, {\n html: htmlConfig,\n });\n const bundler = await this.getBundler(context);\n const bundleResult = await bundler.run();\n\n return computeResults(bundleResult, { publicDir: `${this.getPublicDir(context.artifactsDir)}/${this.dir}` });\n }\n\n private getBundler(context: AppBuildContext) {\n if (this.bundler) return this.bundler;\n return this.getDefaultBundler(context);\n }\n private async getDefaultBundler(context: AppBuildContext) {\n const { capsule } = context;\n const reactEnv: ReactEnv = context.env as ReactEnv;\n const publicDir = this.getPublicDir(context.artifactsDir);\n const outputPath = join(capsule.path, publicDir);\n const { distDir } = reactEnv.getCompiler();\n const targetEntries = Array.isArray(this.entry) ? this.entry : await this.entry();\n const entries = targetEntries.map((entry) => require.resolve(`${capsule.path}/${distDir}/${basename(entry)}`));\n const staticDir = join(outputPath, this.dir);\n\n const bundlerContext: BundlerContext = Object.assign(context, {\n targets: [\n {\n components: [capsule?.component],\n entries,\n outputPath,\n hostRootDir: capsule?.path,\n hostDependencies: await this.getPeers(),\n aliasHostDependencies: true,\n },\n ],\n entry: [],\n rootPath: '/',\n metaData: {\n initiator: `building app: ${context.name}`,\n envId: context.id,\n },\n });\n\n const defaultTransformer: WebpackConfigTransformer = (configMutator) => {\n const config = configMutator.addTopLevel('output', {\n path: staticDir,\n publicPath: `/`,\n filename: '[name].[chunkhash].js',\n });\n if (this.prerender) config.addPlugin(prerenderPlugin(this.prerender));\n if (config.raw.optimization?.minimizer) {\n remove(config.raw.optimization?.minimizer, (minimizer) => {\n return minimizer.constructor.name === 'TerserPlugin';\n });\n\n config.raw.optimization?.minimizer.push(this.getESBuildConfig());\n }\n\n return config;\n };\n const transformers = [defaultTransformer, ...this.transformers];\n const bundler: Bundler = await reactEnv.getBundler(bundlerContext, transformers);\n return bundler;\n }\n private getESBuildConfig = (isPrerendering = this.prerender) => {\n // We don't want to use esbuild in case of prerendering since the headless browser puppeteer doesn't support\n // the output of esbuild\n\n if (isPrerendering) {\n return new TerserPlugin({\n extractComments: false,\n terserOptions: {\n parse: {\n // We want terser to parse ecma 8 code. However, we don't want it\n // to apply any minification steps that turns valid ecma 5 code\n // into invalid ecma 5 code. This is why the 'compress' and 'output'\n // sections only apply transformations that are ecma 5 safe\n // https://github.com/facebook/create-react-app/pull/4234\n ecma: 8,\n },\n compress: {\n ecma: 5,\n warnings: false,\n // Disabled because of an issue with Uglify breaking seemingly valid code:\n // https://github.com/facebook/create-react-app/issues/2376\n // Pending further investigation:\n // https://github.com/mishoo/UglifyJS2/issues/2011\n comparisons: false,\n // Disabled because of an issue with Terser breaking valid code:\n // https://github.com/facebook/create-react-app/issues/5250\n // Pending further investigation:\n // https://github.com/terser-js/terser/issues/120\n inline: 2,\n },\n mangle: {\n safari10: true,\n },\n output: {\n ecma: 5,\n comments: false,\n // Turned on because emoji and regex is not minified properly using default\n // https://github.com/facebook/create-react-app/issues/2488\n ascii_only: true,\n },\n },\n });\n }\n return new TerserPlugin({\n minify: TerserPlugin.esbuildMinify,\n // `terserOptions` options will be passed to `esbuild`\n // Link to options - https://esbuild.github.io/api/#minify\n terserOptions: {\n minify: true,\n },\n });\n };\n\n private getPublicDir(artifactsDir: string) {\n return join(artifactsDir, this.applicationType, this.name);\n }\n\n async getEntries(): Promise<string[]> {\n if (Array.isArray(this.entry)) return this.entry;\n return this.entry();\n }\n\n async getSsrEntries(): Promise<string[]> {\n if (!this.ssr) throw new BitError('tried to build ssr without ssr entries');\n if (typeof this.ssr === 'string') return [this.ssr];\n return [await this.ssr()];\n }\n\n private async getDevServerContext(context: AppContext): Promise<DevServerContext> {\n const entries = await this.getEntries();\n return Object.assign(context, {\n entry: entries,\n rootPath: '',\n publicPath: `public/${this.name}`,\n title: this.name,\n favicon: this.favicon,\n hostDependencies: await this.getPeers(),\n aliasHostDependencies: true,\n });\n }\n\n private getPeers(): Promise<string[]> {\n return this.reactEnv.getPeerDependenciesList();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;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AP;EACD;;AA7R0C"}
1
+ {"version":3,"names":["ReactApp","constructor","name","entry","ssr","portRange","reactEnv","prerender","bundler","ssrBundler","devServer","transformers","deploy","favicon","logger","run","context","from","to","port","Port","getPort","listen","devServerContext","getDevServerContext","getDevServer","addDevServer","setOutput","runSsr","clientBundle","buildClient","errors","length","info","serverBundle","buildSsr","app","loadSsrApp","workdir","appName","expressApp","createExpressSsr","assets","parseAssets","htmlConfig","title","templateContent","html","minify","ctx","Object","assign","create","targets","entries","getEntries","components","appComponent","outputPath","resolve","calcOutputPath","hostDependencies","getPeers","aliasHostDependencies","capsuleNetwork","undefined","previousTasksResults","getBundler","config","merge","clientConfig","bundleResult","getSsrEntries","ssrConfig","build","bunlder","getSsrBundler","computeResults","publicDir","getPublicDir","artifactsDir","dir","ssrPublicDir","ssrDir","getDefaultBundler","getDefaultSsrBundler","capsule","join","path","bundlerContext","getBuildContext","compact","configMutator","buildConfig","addPlugin","prerenderPlugin","replaceTerserPlugin","env","ssrBuildConfig","distDir","getCompiler","targetEntries","map","require","basename","component","hostRootDir","rootPath","metaData","initiator","envId","id","applicationType","Array","isArray","BitError","publicPath","getPeerDependenciesList"],"sources":["react.application.ts"],"sourcesContent":["import { join, resolve, basename } from 'path';\nimport { Application, AppContext, AppBuildContext, AppResult } from '@teambit/application';\nimport type { Bundler, DevServer, BundlerContext, DevServerContext, BundlerHtmlConfig } from '@teambit/bundler';\nimport { Port } from '@teambit/toolbox.network.get-port';\nimport type { Logger } from '@teambit/logger';\nimport compact from 'lodash.compact';\nimport { WebpackConfigTransformer } from '@teambit/webpack';\nimport { BitError } from '@teambit/bit-error';\nimport { ReactEnv } from '../../react.env';\nimport { prerenderPlugin } from './plugins';\nimport { ReactAppBuildResult } from './react-build-result';\nimport { ReactAppPrerenderOptions } from './react-app-options';\nimport { html } from '../../webpack';\nimport { ReactDeployContext } from '.';\nimport { computeResults } from './compute-results';\nimport { clientConfig, ssrConfig, calcOutputPath, ssrBuildConfig, buildConfig } from './webpack/webpack.app.ssr.config';\nimport { addDevServer, setOutput, replaceTerserPlugin } from './webpack/mutators';\nimport { createExpressSsr, loadSsrApp, parseAssets } from './ssr/ssr-express';\n\nexport class ReactApp implements Application {\n constructor(\n readonly name: string,\n readonly entry: string[] | ((path?: string) => Promise<string[]>),\n readonly ssr: string | (() => Promise<string>) | undefined,\n readonly portRange: [number, number],\n private reactEnv: ReactEnv,\n readonly prerender?: ReactAppPrerenderOptions,\n readonly bundler?: Bundler,\n readonly ssrBundler?: Bundler,\n readonly devServer?: DevServer,\n readonly transformers: WebpackConfigTransformer[] = [],\n readonly deploy?: (context: ReactDeployContext) => Promise<void>,\n readonly favicon?: string,\n private logger?: Logger\n ) {}\n readonly applicationType = 'react-common-js';\n readonly dir = 'public';\n readonly ssrDir = 'ssr';\n\n async run(context: AppContext): Promise<number> {\n const [from, to] = this.portRange;\n const port = await Port.getPort(from, to);\n\n if (this.devServer) {\n await this.devServer.listen(port);\n return port;\n }\n\n const devServerContext = await this.getDevServerContext(context);\n const devServer = this.reactEnv.getDevServer(devServerContext, [addDevServer, setOutput, ...this.transformers]);\n await devServer.listen(port);\n return port;\n }\n\n async runSsr(context: AppContext): Promise<AppResult> {\n const [from, to] = this.portRange;\n const port = await Port.getPort(from, to);\n\n // bundle client\n const clientBundle = await this.buildClient(context);\n if (clientBundle.errors.length > 0) return { errors: clientBundle.errors };\n this.logger?.info('[react.application] [ssr] client bundle - complete');\n\n // bundle server\n const serverBundle = await this.buildSsr(context);\n if (serverBundle.errors.length > 0) return { errors: serverBundle.errors };\n this.logger?.info('[react.application] [ssr] server bundle - complete');\n\n // load server-side runtime\n const app = await loadSsrApp(context.workdir, context.appName);\n this.logger?.info('[react.application] [ssr] bundle code - loaded');\n\n const expressApp = createExpressSsr({\n name: context.appName,\n workdir: context.workdir,\n port,\n app,\n assets: parseAssets(clientBundle.assets),\n logger: this.logger,\n });\n\n expressApp.listen(port);\n return { port };\n }\n\n private async buildClient(context: AppContext) {\n const htmlConfig: BundlerHtmlConfig[] = [\n {\n title: context.appName,\n templateContent: html(context.appName),\n minify: false,\n favicon: this.favicon,\n },\n ];\n\n // extend, including prototype methods\n const ctx: BundlerContext = Object.assign(Object.create(context), {\n html: htmlConfig,\n targets: [\n {\n entries: await this.getEntries(),\n components: [context.appComponent],\n outputPath: resolve(context.workdir, calcOutputPath(context.appName, 'browser')),\n hostDependencies: await this.getPeers(),\n aliasHostDependencies: true,\n },\n ],\n\n // @ts-ignore\n capsuleNetwork: undefined,\n previousTasksResults: [],\n });\n\n const bundler = await this.reactEnv.getBundler(ctx, [\n (config) => config.merge([clientConfig()]),\n ...this.transformers,\n ]);\n\n const bundleResult = await bundler.run();\n return bundleResult[0];\n }\n\n private async buildSsr(context: AppContext) {\n // extend, including prototype methods\n const ctx: BundlerContext = Object.assign(Object.create(context), {\n ...context,\n targets: [\n {\n entries: await this.getSsrEntries(),\n components: [context.appComponent],\n outputPath: resolve(context.workdir, calcOutputPath(context.appName, 'ssr')),\n hostDependencies: await this.getPeers(),\n aliasHostDependencies: true,\n },\n ],\n\n // @ts-ignore\n capsuleNetwork: undefined,\n previousTasksResults: [],\n });\n\n const bundler = await this.reactEnv.getBundler(ctx, [\n (config) => config.merge([ssrConfig()]),\n ...this.transformers,\n ]);\n\n const bundleResult = await bundler.run();\n return bundleResult[0];\n }\n\n async build(context: AppBuildContext): Promise<ReactAppBuildResult> {\n const htmlConfig: BundlerHtmlConfig[] = [\n {\n title: context.name,\n templateContent: html(context.name),\n minify: false,\n favicon: this.favicon,\n // filename: ''.html`,\n },\n ];\n Object.assign(context, {\n html: htmlConfig,\n });\n const bundler = await this.getBundler(context);\n const bundleResult = await bundler.run();\n\n if (this.ssr) {\n const bunlder = await this.getSsrBundler(context);\n await bunlder.run();\n }\n\n return computeResults(bundleResult, {\n publicDir: `${this.getPublicDir(context.artifactsDir)}/${this.dir}`,\n ssrPublicDir: this.ssr ? `${this.getPublicDir(context.artifactsDir)}/${this.ssrDir}` : undefined,\n });\n }\n\n private getBundler(context: AppBuildContext) {\n if (this.bundler) return this.bundler;\n return this.getDefaultBundler(context);\n }\n\n private getSsrBundler(context: AppBuildContext) {\n if (this.ssrBundler) return this.ssrBundler;\n return this.getDefaultSsrBundler(context);\n }\n\n private async getDefaultBundler(context: AppBuildContext) {\n const { capsule } = context;\n const publicDir = this.getPublicDir(context.artifactsDir);\n const outputPath = join(capsule.path, publicDir);\n\n const bundlerContext = await this.getBuildContext(context, { outputPath });\n const transformers: WebpackConfigTransformer[] = compact([\n (configMutator) => configMutator.merge(buildConfig({ outputPath: join(outputPath, this.dir) })),\n (config) => {\n if (this.prerender) config.addPlugin(prerenderPlugin(this.prerender));\n return config;\n },\n replaceTerserPlugin({ prerender: !!this.prerender }),\n ...this.transformers,\n ]);\n\n const reactEnv = context.env as ReactEnv;\n const bundler: Bundler = await reactEnv.getBundler(bundlerContext, transformers);\n return bundler;\n }\n\n private async getDefaultSsrBundler(context: AppBuildContext) {\n const { capsule } = context;\n const publicDir = this.getPublicDir(context.artifactsDir);\n const outputPath = join(capsule.path, publicDir);\n\n const bundlerContext = await this.getBuildContext(context, { outputPath });\n const transformers: WebpackConfigTransformer[] = compact([\n (configMutator) => configMutator.merge(ssrBuildConfig({ outputPath: join(outputPath, this.ssrDir) })),\n replaceTerserPlugin({ prerender: !!this.prerender }),\n ...this.transformers,\n ]);\n\n const reactEnv = context.env as ReactEnv;\n const bundler: Bundler = await reactEnv.getBundler(bundlerContext, transformers);\n return bundler;\n }\n\n private async getBuildContext(context: AppBuildContext, { outputPath }: { outputPath: string }) {\n const { capsule } = context;\n const reactEnv = context.env as ReactEnv;\n const { distDir } = reactEnv.getCompiler();\n const targetEntries = await this.getEntries(`${capsule.path}/${distDir}`);\n const entries = targetEntries.map((entry) => require.resolve(`${capsule.path}/${distDir}/${basename(entry)}`));\n\n const bundlerContext: BundlerContext = Object.assign(context, {\n targets: [\n {\n components: [capsule?.component],\n entries,\n outputPath,\n hostRootDir: capsule?.path,\n hostDependencies: await this.getPeers(),\n aliasHostDependencies: true,\n },\n ],\n entry: [],\n rootPath: '/',\n metaData: {\n initiator: `building app: ${context.name}`,\n envId: context.id,\n },\n });\n\n return bundlerContext;\n }\n\n private getPublicDir(artifactsDir: string) {\n return join(artifactsDir, this.applicationType, this.name);\n }\n\n async getEntries(path?: string): Promise<string[]> {\n if (Array.isArray(this.entry)) return this.entry;\n return this.entry(path);\n }\n\n async getSsrEntries(): Promise<string[]> {\n if (!this.ssr) throw new BitError('tried to build ssr without ssr entries');\n if (typeof this.ssr === 'string') return [this.ssr];\n return [await this.ssr()];\n }\n\n private async getDevServerContext(context: AppContext): Promise<DevServerContext> {\n const entries = await this.getEntries();\n return Object.assign(context, {\n entry: entries,\n rootPath: '',\n publicPath: `public/${this.name}`,\n title: this.name,\n favicon: this.favicon,\n hostDependencies: await this.getPeers(),\n aliasHostDependencies: true,\n });\n }\n\n private getPeers(): Promise<string[]> {\n return this.reactEnv.getPeerDependenciesList();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAGA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AAEA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;AACA;EAAA;;EAAA;IAAA;EAAA;;EAAA;AAAA;;;;;;AAEO,MAAMA,QAAN,CAAsC;EAC3CC,WAAW,CACAC,IADA,EAEAC,KAFA,EAGAC,GAHA,EAIAC,SAJA,EAKDC,QALC,EAMAC,SANA,EAOAC,OAPA,EA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;;EAEOV,YAAY,CAACC,YAAD,EAAuB;IACzC,OAAO,IAAAO,YAAA,EAAKP,YAAL,EAAmB,KAAKgC,eAAxB,EAAyC,KAAK9G,IAA9C,CAAP;EACD;;EAEe,MAAVqD,UAAU,CAACiC,IAAD,EAAmC;IACjD,IAAIyB,KAAK,CAACC,OAAN,CAAc,KAAK/G,KAAnB,CAAJ,EAA+B,OAAO,KAAKA,KAAZ;IAC/B,OAAO,KAAKA,KAAL,CAAWqF,IAAX,CAAP;EACD;;EAEkB,MAAbhB,aAAa,GAAsB;IACvC,IAAI,CAAC,KAAKpE,GAAV,EAAe,MAAM,KAAI+G,oBAAJ,EAAa,wCAAb,CAAN;IACf,IAAI,OAAO,KAAK/G,GAAZ,KAAoB,QAAxB,EAAkC,OAAO,CAAC,KAAKA,GAAN,CAAP;IAClC,OAAO,CAAC,MAAM,KAAKA,GAAL,EAAP,CAAP;EACD;;EAEgC,MAAnBoB,mBAAmB,CAACR,OAAD,EAAiD;IAChF,MAAMsC,OAAO,GAAG,MAAM,KAAKC,UAAL,EAAtB;IACA,OAAOL,MAAM,CAACC,MAAP,CAAcnC,OAAd,EAAuB;MAC5Bb,KAAK,EAAEmD,OADqB;MAE5BqD,QAAQ,EAAE,EAFkB;MAG5BS,UAAU,EAAG,UAAS,KAAKlH,IAAK,EAHJ;MAI5B2C,KAAK,EAAE,KAAK3C,IAJgB;MAK5BW,OAAO,EAAE,KAAKA,OALc;MAM5BgD,gBAAgB,EAAE,MAAM,KAAKC,QAAL,EANI;MAO5BC,qBAAqB,EAAE;IAPK,CAAvB,CAAP;EASD;;EAEOD,QAAQ,GAAsB;IACpC,OAAO,KAAKxD,QAAL,CAAc+G,uBAAd,EAAP;EACD;;AAzQ0C"}
@@ -1,3 +1,6 @@
1
1
  import { WebpackConfigMutator } from '@teambit/webpack';
2
2
  export declare function addDevServer(configMutator: WebpackConfigMutator): WebpackConfigMutator;
3
3
  export declare function setOutput(configMutator: WebpackConfigMutator): WebpackConfigMutator;
4
+ export declare function replaceTerserPlugin({ prerender }: {
5
+ prerender: boolean;
6
+ }): (configMutator: WebpackConfigMutator) => WebpackConfigMutator;