catalyst-core-internal 0.0.1-beta.21 → 0.0.1-beta.22

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 (55) hide show
  1. package/bin/catalyst.js +1 -1
  2. package/{logger.js → dist/logger.js} +1 -1
  3. package/{router → dist/router}/ClientRouter.js +2 -2
  4. package/dist/router/ServerRouter.js +1 -0
  5. package/{scripts → dist/scripts}/build.js +7 -7
  6. package/dist/scripts/centralImport.js +1 -0
  7. package/{scripts → dist/scripts}/devBuild.js +7 -7
  8. package/{scripts → dist/scripts}/devServe.js +3 -3
  9. package/{scripts → dist/scripts}/loadEnvironmentVariables.js +1 -1
  10. package/dist/scripts/loadScriptsBeforeServerStarts.js +4 -0
  11. package/dist/scripts/registerAliases.js +2 -0
  12. package/{scripts → dist/scripts}/serve.js +3 -3
  13. package/dist/scripts/start.js +6 -0
  14. package/{scripts → dist/scripts}/validator.js +1 -1
  15. package/{server → dist/server}/expressServer.js +1 -1
  16. package/{server → dist/server}/renderer/handler.js +6 -6
  17. package/dist/server/startServer.js +6 -0
  18. package/{server → dist/server}/utils/validator.js +1 -1
  19. package/dist/webpack/base.babel.js +8 -0
  20. package/dist/webpack/development.client.babel.js +4 -0
  21. package/dist/webpack/production.client.babel.js +4 -0
  22. package/dist/webpack/production.ssr.babel.js +4 -0
  23. package/package.json +25 -5
  24. package/.eslintignore +0 -9
  25. package/.eslintrc +0 -91
  26. package/.husky/commit-msg +0 -1
  27. package/.husky/pre-commit +0 -1
  28. package/commitlint.config.js +0 -11
  29. package/router/ServerRouter.js +0 -1
  30. package/scripts/loadScriptsBeforeServerStarts.js +0 -5
  31. package/scripts/resiterAliases.js +0 -29
  32. package/scripts/start.js +0 -6
  33. package/server/startServer.js +0 -6
  34. package/tsconfig.json +0 -110
  35. package/webpack/base.babel.js +0 -8
  36. package/webpack/development.client.babel.js +0 -4
  37. package/webpack/production.client.babel.js +0 -4
  38. package/webpack/production.ssr.babel.js +0 -4
  39. /package/{caching.js → dist/caching.js} +0 -0
  40. /package/{index.js → dist/index.js} +0 -0
  41. /package/{router.js → dist/router.js} +0 -0
  42. /package/{scripts → dist/scripts}/checkVersion.js +0 -0
  43. /package/{scripts → dist/scripts}/scriptUtils.js +0 -0
  44. /package/{server → dist/server}/renderer/document/Body.js +0 -0
  45. /package/{server → dist/server}/renderer/document/Head.js +0 -0
  46. /package/{server → dist/server}/renderer/document/index.js +0 -0
  47. /package/{server → dist/server}/renderer/extract.js +0 -0
  48. /package/{server → dist/server}/renderer/index.js +0 -0
  49. /package/{server → dist/server}/renderer/render.js +0 -0
  50. /package/{server → dist/server}/utils/userAgentUtil.js +0 -0
  51. /package/{webpack → dist/webpack}/babel-plugins/remove-client.plugin.js +0 -0
  52. /package/{webpack → dist/webpack}/babel-plugins/remove-ssr.plugin.js +0 -0
  53. /package/{webpack → dist/webpack}/babel.config.client.js +0 -0
  54. /package/{webpack → dist/webpack}/babel.config.ssr.js +0 -0
  55. /package/{webpack → dist/webpack}/scssParams.js +0 -0
package/bin/catalyst.js CHANGED
@@ -13,7 +13,7 @@ const nodeArgs = scriptIndex > 0 ? args.slice(0, scriptIndex) : []
13
13
  if (["build", "start", "serve", "devBuild", "devServe"].includes(script)) {
14
14
  const result = spawnSync(
15
15
  process.execPath,
16
- nodeArgs.concat(require.resolve("../scripts/" + script)).concat(args.slice(scriptIndex + 1)),
16
+ nodeArgs.concat(require.resolve("../dist/scripts/" + script)).concat(args.slice(scriptIndex + 1)),
17
17
  { stdio: "inherit" }
18
18
  )
19
19
  if (result.signal) {
@@ -1,4 +1,4 @@
1
- "use strict";const winston=require("winston");const DailyRotateFile=require("winston-daily-rotate-file");const pc=require("picocolors");const{createLogger,format,transports}=winston;/**
1
+ "use strict";const pc=require("picocolors");const winston=require("winston");const DailyRotateFile=require("winston-daily-rotate-file");const{createLogger,format,transports}=winston;/**
2
2
  * @description Logger library with rotational strategy. Creates a logs folder in root.
3
3
  * With debug, error and info log directories with their respective log files.
4
4
  *
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _router=require("@tata1mg/router");var _utils=require("@routes/utils.js");/**
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _router=require("@tata1mg/router");const{preparedRoutes}=require(`${process.env.src_path}/src/js/routes/utils.js`);/**
2
2
  * @returns returns browsers routers (client routes)
3
- */const clientRouter=({store,routerInitialState})=>(0,_router.createBrowserRouter)((0,_utils.preparedRoutes)({store,routerInitialState}));var _default=exports.default=clientRouter;
3
+ */const clientRouter=({store,routerInitialState})=>(0,_router.createBrowserRouter)(preparedRoutes({store,routerInitialState}));var _default=exports.default=clientRouter;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _router=require("@tata1mg/router");const{preparedRoutes}=require(`${process.env.src_path}/src/js/routes/utils.js`);const ServerRouter=reduxData=>{const{store,intialData}=reduxData;return(0,_router.useRoutes)(preparedRoutes({store,routerInitialState:intialData}));};var _default=exports.default=ServerRouter;
@@ -1,10 +1,10 @@
1
1
  "use strict";const path=require("path");const{spawnSync}=require("child_process");const{green,cyan,yellow}=require("picocolors");const{name}=require(`${process.env.PWD}/package.json`);const{BUILD_OUTPUT_PATH}=require(`${process.env.PWD}/config/config.json`);const{arrayToObject,printBundleInformation}=require("./scriptUtils.js");/**
2
2
  * @description - creates a production build of the application.
3
- */function build(){const commandLineArguments=process.argv.slice(2);const argumentsObject=arrayToObject(commandLineArguments);const dirname=path.resolve(__dirname,"../");const command=`
4
- node ./scripts/checkVersion
5
- rm -rf ${process.env.PWD}/${BUILD_OUTPUT_PATH} & node ./scripts/loadScriptsBeforeServerStarts.js
6
- APPLICATION=${name||"catalyst_app"} webpack --config ./webpack/production.client.babel.js --progress
7
- APPLICATION=${name||"catalyst_app"} SSR=true webpack --config ./webpack/production.ssr.babel.js
8
- APPLICATION=${name||"catalyst_app"} npx babel ./server --out-dir ${process.env.PWD}/${BUILD_OUTPUT_PATH} --ignore '**/*.test.js,./server/renderer/handler.js' --quiet
3
+ */function build(){const commandLineArguments=process.argv.slice(2);const argumentsObject=arrayToObject(commandLineArguments);const dirname=path.resolve(__dirname,"../../");const command=`
4
+ node ./dist/scripts/checkVersion
5
+ rm -rf ${process.env.PWD}/${BUILD_OUTPUT_PATH} & node ./dist/scripts/loadScriptsBeforeServerStarts.js
6
+ APPLICATION=${name||"catalyst_app"} webpack --config ./dist/webpack/production.client.babel.js --progress
7
+ APPLICATION=${name||"catalyst_app"} SSR=true webpack --config ./dist/webpack/production.ssr.babel.js
8
+ APPLICATION=${name||"catalyst_app"} npx babel ./dist/server --out-dir ${process.env.PWD}/${BUILD_OUTPUT_PATH} --ignore '**/*.test.js,./dist/server/renderer/handler.js' --quiet
9
9
  APPLICATION=${name||"catalyst_app"} npx babel ${process.env.PWD}/server --out-dir ${process.env.PWD}/${BUILD_OUTPUT_PATH} --quiet
10
- `;console.log("Creating an optimized production build...");const result=spawnSync(command,[],{cwd:dirname,stdio:"inherit",shell:true,env:{...process.env,src_path:process.env.PWD,build_output_path:BUILD_OUTPUT_PATH,NODE_ENV:"production",IS_DEV_COMMAND:false,...argumentsObject}});if(result.error){console.error("Error occurred:",result.error);}else{console.log(green("Compiled successfully."));console.log("\nFile sizes after gzip:\n");printBundleInformation();console.log(`\nThe ${cyan(BUILD_OUTPUT_PATH)} folder is ready to be deployed.`);console.log("You may serve it with a serve command:");console.log(cyan("\n npm run serve"));console.log("\nFind out more about deployment here:");console.log(yellow("\n https://catalyst.1mg.com/public_docs/content/deployment\n"));}}build();
10
+ `;console.log("Creating an optimized production build...");const result=spawnSync(command,[],{cwd:dirname,stdio:"inherit",shell:true,env:{...process.env,src_path:process.env.PWD,BUILD_OUTPUT_PATH:BUILD_OUTPUT_PATH,NODE_ENV:"production",IS_DEV_COMMAND:false,...argumentsObject}});if(result.error){console.error("Error occurred:",result.error);}else{console.log(green("Compiled successfully."));console.log("\nFile sizes after gzip:\n");printBundleInformation();console.log(`\nThe ${cyan(BUILD_OUTPUT_PATH)} folder is ready to be deployed.`);console.log("You may serve it with a serve command:");console.log(cyan("\n npm run serve"));console.log("\nFind out more about deployment here:");console.log(yellow("\n https://catalyst.1mg.com/public_docs/content/deployment\n"));}}build();
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ROUTE_UTILS=void 0;const ROUTE_UTILS=exports.ROUTE_UTILS=`${process.env.src_path}/src/js/routes/utils.js`;
@@ -1,10 +1,10 @@
1
1
  "use strict";const path=require("path");const{spawnSync}=require("child_process");const{green,cyan,yellow}=require("picocolors");const{name}=require(`${process.env.PWD}/package.json`);const{BUILD_OUTPUT_PATH}=require(`${process.env.PWD}/config/config.json`);const{arrayToObject,printBundleInformation}=require("./scriptUtils.js");/**
2
2
  * @description - creates a production build of the application.
3
- */function devBuild(){const commandLineArguments=process.argv.slice(2);const argumentsObject=arrayToObject(commandLineArguments);const dirname=path.resolve(__dirname,"../");const command=`
4
- node ./scripts/checkVersion
5
- rm -rf ${process.env.PWD}/${BUILD_OUTPUT_PATH} & node ./scripts/loadScriptsBeforeServerStarts.js
6
- APPLICATION=${name||"catalyst_app"} webpack --config ./webpack/production.client.babel.js --progress
7
- APPLICATION=${name||"catalyst_app"} SSR=true webpack --config ./webpack/production.ssr.babel.js
8
- APPLICATION=${name||"catalyst_app"} npx babel ./server --out-dir ${process.env.PWD}/${BUILD_OUTPUT_PATH} --ignore '**/*.test.js,./server/renderer/handler.js' --quiet
3
+ */function devBuild(){const commandLineArguments=process.argv.slice(2);const argumentsObject=arrayToObject(commandLineArguments);const dirname=path.resolve(__dirname,"../../");const command=`
4
+ node ./dist/scripts/checkVersion
5
+ rm -rf ${process.env.PWD}/${BUILD_OUTPUT_PATH} & node ./dist/scripts/loadScriptsBeforeServerStarts.js
6
+ APPLICATION=${name||"catalyst_app"} webpack --config ./dist/webpack/production.client.babel.js --progress
7
+ APPLICATION=${name||"catalyst_app"} SSR=true webpack --config ./dist/webpack/production.ssr.babel.js
8
+ APPLICATION=${name||"catalyst_app"} npx babel ./dist/server --out-dir ${process.env.PWD}/${BUILD_OUTPUT_PATH} --ignore '**/*.test.js,./dist/server/renderer/handler.js' --quiet
9
9
  APPLICATION=${name||"catalyst_app"} npx babel ${process.env.PWD}/server --out-dir ${process.env.PWD}/${BUILD_OUTPUT_PATH} --quiet
10
- `;console.log("Creating an optimized local build...");const result=spawnSync(command,[],{cwd:dirname,stdio:"inherit",shell:true,env:{...process.env,src_path:process.env.PWD,build_output_path:BUILD_OUTPUT_PATH,NODE_ENV:"production",IS_DEV_COMMAND:true,...argumentsObject}});if(result.error){console.error("Error occurred:",result.error);}else{console.log(green("Compiled successfully."));console.log("\nFile sizes after gzip:\n");printBundleInformation();console.log(`\nThe ${cyan(BUILD_OUTPUT_PATH)} folder is ready to be deployed.`);console.log("You may serve it with a serve command:");console.log(cyan("\n npm run devServe"));console.log("\nFind out more about deployment here:");console.log(yellow("\n https://catalyst.1mg.com/public_docs/content/deployment\n"));}}devBuild();
10
+ `;console.log("Creating an optimized local build...");const result=spawnSync(command,[],{cwd:dirname,stdio:"inherit",shell:true,env:{...process.env,src_path:process.env.PWD,BUILD_OUTPUT_PATH:BUILD_OUTPUT_PATH,NODE_ENV:"production",IS_DEV_COMMAND:true,...argumentsObject}});if(result.error){console.error("Error occurred:",result.error);}else{console.log(green("Compiled successfully."));console.log("\nFile sizes after gzip:\n");printBundleInformation();console.log(`\nThe ${cyan(BUILD_OUTPUT_PATH)} folder is ready to be deployed.`);console.log("You may serve it with a serve command:");console.log(cyan("\n npm run devServe"));console.log("\nFind out more about deployment here:");console.log(yellow("\n https://catalyst.1mg.com/public_docs/content/deployment\n"));}}devBuild();
@@ -1,5 +1,5 @@
1
1
  "use strict";const path=require("path");const{spawnSync}=require("child_process");const{arrayToObject}=require("./scriptUtils");const{name}=require(`${process.env.PWD}/package.json`);const{BUILD_OUTPUT_PATH}=require(`${process.env.PWD}/config/config.json`);/**
2
2
  * @description - Serves production build of the application.
3
- */function devServe(){const commandLineArguments=process.argv.slice(2);const argumentsObject=arrayToObject(commandLineArguments);const dirname=path.resolve(__dirname,"../");const command=`
4
- APPLICATION=${name||"catalyst_app"} node -r ./scripts/loadScriptsBeforeServerStarts.js ${process.env.PWD}/${BUILD_OUTPUT_PATH}/startServer.js
5
- `;spawnSync(command,[],{cwd:dirname,stdio:"inherit",shell:true,env:{...process.env,src_path:process.env.PWD,build_output_path:BUILD_OUTPUT_PATH,NODE_ENV:"production",IS_DEV_COMMAND:true,...argumentsObject}});}devServe();
3
+ */function devServe(){const commandLineArguments=process.argv.slice(2);const argumentsObject=arrayToObject(commandLineArguments);const dirname=path.resolve(__dirname,"../../");const command=`
4
+ APPLICATION=${name||"catalyst_app"} node -r ./dist/scripts/loadScriptsBeforeServerStarts.js ${process.env.PWD}/${BUILD_OUTPUT_PATH}/startServer.js
5
+ `;spawnSync(command,[],{cwd:dirname,stdio:"inherit",shell:true,env:{...process.env,src_path:process.env.PWD,BUILD_OUTPUT_PATH:BUILD_OUTPUT_PATH,NODE_ENV:"production",IS_DEV_COMMAND:true,...argumentsObject}});}devServe();
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;const appConfig=require(`${process.env.src_path}/config/config.json`);const{validateConfigFile}=require("./validator.js");/**
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;const appConfig=require("@catalyst/template/config/config.json");const{validateConfigFile}=require("@catalyst/scripts/validator.js");/**
2
2
  * @description stores all config.json key value into process.env before server starts.
3
3
  */const loadEnvironmentVariables=()=>{if(validateConfigFile(appConfig)){for(let k in appConfig){// below code provides support for object handling present in config.
4
4
  // However, for usage on client the client logic in define plugin needs to be checked and updated
@@ -0,0 +1,4 @@
1
+ "use strict";var _registerAliases2=_interopRequireDefault(require("./registerAliases.js"));var _cssModulesRequireHook=_interopRequireDefault(require("@dr.pogodin/css-modules-require-hook"));var _path=_interopRequireDefault(require("path"));var _loadEnvironmentVariables=_interopRequireDefault(require("./loadEnvironmentVariables"));var _logger=require("@catalyst/logger.js");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}/* eslint-disable */const{cssModulesIdentifierDev}=require("@catalyst/root/config.json");// stores your config keys in enviorments variables
2
+ (0,_loadEnvironmentVariables.default)();// creates logger instance with provided config and stores them at global level.
3
+ (0,_logger.configureLogger)({enableDebugLogs:process.env.ENABLE_DEBUG_LOGS,enableFileLogging:process.env.ENABLE_FILE_LOGGING,enableConsoleLogging:process.env.ENABLE_CONSOLE_LOGGING});// compile css-variables in realtime in dev mode.
4
+ if(process.env.NODE_ENV==="development")(0,_cssModulesRequireHook.default)({extensions:[".scss",".css"],generateScopedName:cssModulesIdentifierDev,devMode:true,ignore:_path.default.join(process.env.src_path,"/src/static/css/base/(?!.*.scss$).*")});
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.catalystResultMap=void 0;var _path=_interopRequireDefault(require("path"));var _moduleAlias=_interopRequireDefault(require("module-alias"));var _package=require("../../package.json");var _validator=require("./validator.js");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const{_moduleAliases:templateModuleAliases}=require(`${process.env.src_path}/package.json`);const catalystResultMap=exports.catalystResultMap=Object.keys(_package._moduleAliases||[]).reduce((resultMap,aliasName)=>{const aliasPath=_package._moduleAliases[aliasName];if(aliasName?.includes("@catalyst/template")){if(aliasName?.includes("server")&&process.env.NODE_ENV==="production"){resultMap[aliasName]=_path.default.join(process.env.src_path,process.env.BUILD_OUTPUT_PATH);}else{resultMap[aliasName]=_path.default.join(process.env.src_path,aliasPath);}return resultMap;}if(aliasName?.includes("@catalyst")&&!aliasName?.includes("@catalyst/template")){if(aliasName?.includes("server")&&process.env.NODE_ENV==="production"){resultMap[aliasName]=_path.default.join(process.env.src_path,process.env.BUILD_OUTPUT_PATH);}else{resultMap[aliasName]=_path.default.join(__dirname,"../",aliasPath);}return resultMap;}return resultMap;},{});_moduleAlias.default.addAliases(catalystResultMap);// resolves module alias imports
2
+ if((0,_validator.validateModuleAlias)(templateModuleAliases)){_moduleAlias.default.addAliases(Object.keys(templateModuleAliases||[]).reduce((resultMap,aliasName)=>{const aliasPath=templateModuleAliases[aliasName];if(aliasPath.includes("server")){if(process.env.NODE_ENV!=="production"){resultMap[aliasName]=_path.default.join(process.env.src_path,aliasPath);}else{resultMap[aliasName]=_path.default.join(process.env.src_path,process.env.BUILD_OUTPUT_PATH);}}else resultMap[aliasName]=_path.default.join(process.env.src_path,aliasPath);return resultMap;},{}));}
@@ -1,5 +1,5 @@
1
1
  "use strict";const path=require("path");const{spawnSync}=require("child_process");const{arrayToObject}=require("./scriptUtils");const{name}=require(`${process.env.PWD}/package.json`);const{BUILD_OUTPUT_PATH}=require(`${process.env.PWD}/config/config.json`);/**
2
2
  * @description - Serves production build of the application.
3
- */function serve(){const commandLineArguments=process.argv.slice(2);const argumentsObject=arrayToObject(commandLineArguments);const dirname=path.resolve(__dirname,"../");const command=`
4
- APPLICATION=${name||"catalyst_app"} node -r ./scripts/loadScriptsBeforeServerStarts.js ${process.env.PWD}/${BUILD_OUTPUT_PATH}/startServer.js
5
- `;spawnSync(command,[],{cwd:dirname,stdio:"inherit",shell:true,env:{...process.env,src_path:process.env.PWD,build_output_path:BUILD_OUTPUT_PATH,NODE_ENV:"production",IS_DEV_COMMAND:false,...argumentsObject}});}serve();
3
+ */function serve(){const commandLineArguments=process.argv.slice(2);const argumentsObject=arrayToObject(commandLineArguments);const dirname=path.resolve(__dirname,"../../");const command=`
4
+ APPLICATION=${name||"catalyst_app"} node -r ./dist/scripts/loadScriptsBeforeServerStarts.js ${process.env.PWD}/${BUILD_OUTPUT_PATH}/startServer.js
5
+ `;spawnSync(command,[],{cwd:dirname,stdio:"inherit",shell:true,env:{...process.env,src_path:process.env.PWD,BUILD_OUTPUT_PATH:BUILD_OUTPUT_PATH,NODE_ENV:"production",IS_DEV_COMMAND:false,...argumentsObject}});}serve();
@@ -0,0 +1,6 @@
1
+ "use strict";const path=require("path");const{spawnSync}=require("child_process");const{arrayToObject}=require("./scriptUtils");const{name}=require(`${process.env.PWD}/package.json`);const{BUILD_OUTPUT_PATH}=require(`${process.env.PWD}/config/config.json`);/**
2
+ * @description - starts webpack dev server and node server.
3
+ */function start(){const commandLineArguments=process.argv.slice(2);const argumentsObject=arrayToObject(commandLineArguments);const dirname=path.resolve(__dirname,"../../");const command=`
4
+ node ./dist/scripts/checkVersion
5
+ npx babel-node -r ./dist/scripts/loadScriptsBeforeServerStarts.js ./dist/webpack/development.client.babel --no-warnings=ExperimentalWarning --no-warnings=BABEL & npx babel-node -r ./dist/scripts/loadScriptsBeforeServerStarts.js ./dist/server/startServer.js --watch-path=${process.env.PWD}/server --watch-path=${process.env.PWD}/src --ignore='__IGNORE__' --no-warnings=ExperimentalWarning --no-warnings=BABEL
6
+ `;spawnSync(command,[],{cwd:dirname,stdio:"inherit",shell:true,env:{...process.env,src_path:process.env.PWD,NODE_ENV:"development",IS_DEV_COMMAND:false,APPLICATION:name||"catalyst_app",BUILD_OUTPUT_PATH:BUILD_OUTPUT_PATH,...argumentsObject}});}start();
@@ -1 +1 @@
1
- "use strict";const pc=require("picocolors");const handleError=e=>{console.log(pc.red("Failed to start server: "),e);};const validatePreInitServer=fn=>{try{if(!fn)throw new Error("preServerInit named function should be defined in server/index.js");if(typeof fn!=="function")throw new Error("preServerInit should be function present in server/index.js");return true;}catch(e){handleError(e);}};const validateMiddleware=fn=>{try{if(!fn)throw new Error("addMiddlewares named function not found in server/server.js");if(typeof fn!=="function")throw new Error("addMiddlewares should be function present in server/server.js");return true;}catch(e){handleError(e);}};const validateReducerFunction=fn=>{try{if(!fn)throw new Error("reducer not found in src/js/containers/App/reducer");if(typeof fn!=="function")throw new Error("reducer should present in src/js/containers/App/reducer");return true;}catch(e){handleError(e);}};const validateConfigFile=obj=>{try{if(!obj)throw new Error("config not found in config folder");if(typeof obj!=="object")throw new Error("config object should be exported from config folder inside your project root directory");if(typeof obj==="object"){const requiredConfigKeys={NODE_SERVER_HOSTNAME:"",NODE_SERVER_PORT:"",WEBPACK_DEV_SERVER_HOSTNAME:"",WEBPACK_DEV_SERVER_PORT:"",BUILD_OUTPUT_PATH:"",PUBLIC_STATIC_ASSET_PATH:"",PUBLIC_STATIC_ASSET_URL:"",CLIENT_ENV_VARIABLES:[],ANALYZE_BUNDLE:""};for(let key in requiredConfigKeys){if(!(key in obj))throw new Error(`${key} key not found inside config.json`);}}return true;}catch(e){handleError(e);}};const validatePackageJson=obj=>{try{if(!obj)throw new Error("package.json not found in the project");if(typeof obj!=="object")throw new Error("package.json should be defined in project root directory");return true;}catch(e){handleError(e);}};const validateModuleAlias=obj=>{try{if(!obj)throw new Error("moduleAliases not found in package.json file present in root directory.");if(typeof obj!=="object")throw new Error("moduleAliases named object should be exported from package.json");if(typeof obj==="object"){const requiredModuleAliases={"@api":"api.js","@containers":"src/js/containers","@server":"server","@config":"config","@css":"src/static/css","@routes":"src/js/routes/"};for(let key in requiredModuleAliases){if(!(key in obj))throw new Error(`${key} module alias not defined inside package.json`);}}return true;}catch(e){handleError(e);}};const validateConfigureStore=fn=>{try{if(!fn)throw new Error("configureStore not found in file src/js/store/index.js");if(typeof fn!=="function")throw new Error("configureStore should be function exported from src/js/store/index.js");return true;}catch(e){handleError(e);}};const validateGetRoutes=fn=>{try{if(!fn)throw new Error("getRoutes not found in file src/js/routes/utils.js");if(typeof fn!=="function")throw new Error("getRoutes should be function exported from src/js/routers/index.js");return true;}catch(e){handleError(e);}};const validateCustomDocument=fn=>{try{if(!fn)throw new Error("document not found in file server/document.js");if(typeof fn!=="function")throw new Error("document should be a react component exported from server/document.js");return true;}catch(e){handleError(e);}};module.exports={validateConfigFile,validateConfigureStore,validateCustomDocument,validateGetRoutes,validatePackageJson,validateReducerFunction,validateModuleAlias,validatePreInitServer,validateMiddleware};
1
+ "use strict";const pc=require("picocolors");const handleError=e=>{console.log(pc.red("Failed to start server: "),e);};const validatePreInitServer=fn=>{try{if(!fn)throw new Error("preServerInit named function should be defined in server/index.js");if(typeof fn!=="function")throw new Error("preServerInit should be function present in server/index.js");return true;}catch(e){handleError(e);}};const validateMiddleware=fn=>{try{if(!fn)throw new Error("addMiddlewares named function not found in server/server.js");if(typeof fn!=="function")throw new Error("addMiddlewares should be function present in server/server.js");return true;}catch(e){handleError(e);}};const validateReducerFunction=fn=>{try{if(!fn)throw new Error("reducer not found in src/js/containers/App/reducer");if(typeof fn!=="function")throw new Error("reducer should present in src/js/containers/App/reducer");return true;}catch(e){handleError(e);}};const validateConfigFile=obj=>{try{if(!obj)throw new Error("config not found in config folder");if(typeof obj!=="object")throw new Error("config object should be exported from config folder inside your project root directory");if(typeof obj==="object"){const requiredConfigKeys={NODE_SERVER_HOSTNAME:"",NODE_SERVER_PORT:"",WEBPACK_DEV_SERVER_HOSTNAME:"",WEBPACK_DEV_SERVER_PORT:"",BUILD_OUTPUT_PATH:"",PUBLIC_STATIC_ASSET_PATH:"",PUBLIC_STATIC_ASSET_URL:"",CLIENT_ENV_VARIABLES:[],ANALYZE_BUNDLE:""};for(let key in requiredConfigKeys){if(!(key in obj))throw new Error(`${key} key not found inside config.json`);}}return true;}catch(e){handleError(e);}};const validatePackageJson=obj=>{try{if(!obj)throw new Error("package.json not found in the project");if(typeof obj!=="object")throw new Error("package.json should be defined in project root directory");return true;}catch(e){handleError(e);}};const validateModuleAlias=obj=>{try{if(!obj)throw new Error("moduleAliases not found in package.json file present in root directory.");if(typeof obj!=="object")throw new Error("moduleAliases named object should be exported from package.json");if(typeof obj==="object"){const requiredModuleAliases={"@api":"api.js","@containers":"src/js/containers","@server":"server","@config":"config","@css":"src/static/css","@routes":"src/js/routes/"};for(let key in requiredModuleAliases){if(key.includes("catalyst"))throw new Error(`Catalyst keyword is restricted for defining aliases`);if(!(key in obj))throw new Error(`${key} module alias not defined inside package.json`);}}return true;}catch(e){handleError(e);}};const validateConfigureStore=fn=>{try{if(!fn)throw new Error("configureStore not found in file src/js/store/index.js");if(typeof fn!=="function")throw new Error("configureStore should be function exported from src/js/store/index.js");return true;}catch(e){handleError(e);}};const validateGetRoutes=fn=>{try{if(!fn)throw new Error("getRoutes not found in file src/js/routes/utils.js");if(typeof fn!=="function")throw new Error("getRoutes should be function exported from src/js/routers/index.js");return true;}catch(e){handleError(e);}};const validateCustomDocument=fn=>{try{if(!fn)throw new Error("document not found in file server/document.js");if(typeof fn!=="function")throw new Error("document should be a react component exported from server/document.js");return true;}catch(e){handleError(e);}};module.exports={validateConfigFile,validateConfigureStore,validateCustomDocument,validateGetRoutes,validatePackageJson,validateReducerFunction,validateModuleAlias,validatePreInitServer,validateMiddleware};
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _path=_interopRequireDefault(require("path"));var _express=_interopRequireDefault(require("express"));var _bodyParser=_interopRequireDefault(require("body-parser"));var _compression=_interopRequireDefault(require("compression"));var _cookieParser=_interopRequireDefault(require("cookie-parser"));var _expressStaticGzip=_interopRequireDefault(require("express-static-gzip"));var _renderer=_interopRequireDefault(require("./renderer"));var _server=require("@server/server.js");var _validator=require("./utils/validator");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const env=process.env.NODE_ENV||"development";const app=(0,_express.default)();// This middleware is being used to extract the body of the request
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _path=_interopRequireDefault(require("path"));var _express=_interopRequireDefault(require("express"));var _bodyParser=_interopRequireDefault(require("body-parser"));var _compression=_interopRequireDefault(require("compression"));var _cookieParser=_interopRequireDefault(require("cookie-parser"));var _expressStaticGzip=_interopRequireDefault(require("express-static-gzip"));var _renderer=_interopRequireDefault(require("@catalyst/server/renderer"));var _server=require("@catalyst/template/server/server.js");var _validator=require("@catalyst/server/utils/validator");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const env=process.env.NODE_ENV||"development";const app=(0,_express.default)();// This middleware is being used to extract the body of the request
2
2
  app.use(_bodyParser.default.json());// This middleware has been added to accommodate “byetstream array”
3
3
  app.use(_bodyParser.default.raw({type:"application/*"}));// This middleware is being used to parse cookies!
4
4
  app.use((0,_cookieParser.default)());// All the middlewares defined by the user will run here.
@@ -1,17 +1,17 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=_default;var _fs=_interopRequireDefault(require("fs"));var _path=_interopRequireDefault(require("path"));var _react=_interopRequireDefault(require("react"));var _render=_interopRequireDefault(require("./render"));var _App=_interopRequireDefault(require("@containers/App"));var _extract=_interopRequireDefault(require("./extract"));var _reactRedux=require("react-redux");var _document=require("./document");var _server=require("react-router-dom/server");var _ServerRouter=_interopRequireDefault(require("../../router/ServerRouter.js"));var _userAgentUtil=require("../utils/userAgentUtil");var _router=require("@tata1mg/router");var _server2=require("@loadable/server");var _server3=require("react-dom/server");var _validator=require("../utils/validator");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const{getRoutes}=require(`${process.env.src_path}/src/js/routes/utils.js`);const{default:CustomDocument}=require(`${process.env.src_path}/server/document.js`);const storePath=_path.default.resolve(`${process.env.src_path}/src/js/store/index.js`);let createStore;if(_fs.default.existsSync(storePath)){try{const{default:configureStore}=require(`${process.env.src_path}/src/js/store/index.js`);createStore=configureStore;}catch(error){createStore=()=>{return{getState:()=>{}};};}}else{createStore=()=>{return{getState:()=>{}};};}const isProduction=process.env.NODE_ENV==="production";// matches request route with routes defined in the application.
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=_default;var _fs=_interopRequireDefault(require("fs"));var _path=_interopRequireDefault(require("path"));var _react=_interopRequireDefault(require("react"));var _render=_interopRequireDefault(require("./render"));var _extract=_interopRequireDefault(require("./extract"));var _reactRedux=require("react-redux");var _document=require("./document");var _server=require("react-router-dom/server");var _ServerRouter=_interopRequireDefault(require("@catalyst/router/ServerRouter.js"));var _index=_interopRequireDefault(require("@catalyst/template/src/js/containers/App/index.js"));var _server2=require("@loadable/server");var _server3=require("react-dom/server");var _userAgentUtil=require("@catalyst/server/utils/userAgentUtil");var _router=require("@tata1mg/router");var _validator=require("@catalyst/server/utils/validator");var _document2=_interopRequireDefault(require("@catalyst/template/server/document.js"));var _utils=require("@catalyst/template/src/js/routes/utils.js");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const storePath=_path.default.resolve(`${process.env.src_path}/src/js/store/index.js`);let createStore;if(_fs.default.existsSync(storePath)){try{const{default:configureStore}=require(`${process.env.src_path}/src/js/store/index.js`);createStore=configureStore;}catch(error){createStore=()=>{return{getState:()=>{}};};}}else{createStore=()=>{return{getState:()=>{}};};}const isProduction=process.env.NODE_ENV==="production";// matches request route with routes defined in the application.
2
2
  const getMatchRoutes=(routes,req,res,store,context,fetcherData,basePath="",webExtractor)=>{return routes.reduce((matches,route)=>{const{path}=route;const match=(0,_router.matchPath)({path:`${basePath}/${path}`,caseSensitive:false,end:true},req.baseUrl||"/");if(match){if(isProduction&&!res.locals.pageCss&&!res.locals.pageJS&&!res.locals.routePath){(0,_extract.default)(res,route);}if(!res.locals.pageCss&&!res.locals.pageJS&&!res.locals.routePath){res.locals.routePath=path;//moving routing logic outside of the App and using ServerRoutes for creating routes on server instead
3
3
  (0,_server3.renderToString)(/*#__PURE__*/_react.default.createElement(_server2.ChunkExtractorManager,{extractor:webExtractor},/*#__PURE__*/_react.default.createElement(_reactRedux.Provider,{store:store},/*#__PURE__*/_react.default.createElement(_server.StaticRouter,{context:context,location:req.originalUrl},/*#__PURE__*/_react.default.createElement(_ServerRouter.default,{store:store,intialData:fetcherData})))));}const wc=route.component;matches.push({route,match,serverSideFunction:wc&&wc.serverSideFunction||(()=>Promise.resolve())});}if(!match&&route.children){// recursively try to match nested routes
4
4
  const nested=getMatchRoutes(route.children,req,res,store,context,fetcherData,`${basePath}/${path}`,webExtractor);if(nested.length){matches=matches.concat(nested);}}return matches;},[]);};// Preloads chunks required for rendering document
5
5
  const getComponent=(store,context,req,fetcherData)=>{return/*#__PURE__*/_react.default.createElement("div",{id:"app"},/*#__PURE__*/_react.default.createElement(_reactRedux.Provider,{store:store},/*#__PURE__*/_react.default.createElement(_server.StaticRouter,{context:context,location:req.originalUrl},/*#__PURE__*/_react.default.createElement(_ServerRouter.default,{store:store,intialData:fetcherData}))));};// sends document after rendering
6
6
  const renderMarkUp=async(errorCode,req,res,metaTags,fetcherData,store,matches,context,webExtractor)=>{const deviceDetails=(0,_userAgentUtil.getUserAgentDetails)(req.headers["user-agent"]||"");const isBot=deviceDetails.googleBot?true:false;// Transforms Head Props
7
7
  const shellStart=await _render.default.renderStart(res.locals.pageCss,res.locals.pageJS,metaTags,isBot,fetcherData);let state=store.getState();const jsx=webExtractor.collectChunks(getComponent(store,context,req,fetcherData));// Transforms Body Props
8
- const shellEnd=_render.default.renderEnd(webExtractor,state,res,jsx,errorCode,fetcherData);const finalProps={...shellStart,...shellEnd,jsx:jsx,req,res};let CompleteDocument=()=>{if((0,_validator.validateCustomDocument)(CustomDocument)){return CustomDocument(finalProps);}else{return/*#__PURE__*/_react.default.createElement("html",{lang:finalProps.lang},/*#__PURE__*/_react.default.createElement(_document.Head,{isBot:finalProps.isBot,pageJS:finalProps.pageJS,pageCss:finalProps.pageCss,fetcherData:finalProps.fetcherData,metaTags:finalProps.metaTags,publicAssetPath:finalProps.publicAssetPath}),/*#__PURE__*/_react.default.createElement(_document.Body,{initialState:finalProps.initialState,firstFoldCss:finalProps.firstFoldCss,firstFoldJS:finalProps.firstFoldJS,jsx:finalProps.jsx,statusCode:finalProps.statusCode,fetcherData:finalProps.fetcherData}));}};try{let status=matches.length&&matches[0].match.path==="*"?404:200;res.set({"content-type":"text/html; charset=utf-8"});res.status(status);const{pipe}=(0,_server3.renderToPipeableStream)(/*#__PURE__*/_react.default.createElement(CompleteDocument,null),{onShellReady(){res.setHeader("content-type","text/html");pipe(res);res.end();},onError(error){logger.error({message:`\n Error while renderToPipeableStream : ${error.toString()}`});}});}catch(error){logger.error("Error in rendering document on server:"+error);}};/**
8
+ const shellEnd=_render.default.renderEnd(webExtractor,state,res,jsx,errorCode,fetcherData);const finalProps={...shellStart,...shellEnd,jsx:jsx,req,res};let CompleteDocument=()=>{if((0,_validator.validateCustomDocument)(_document2.default)){return(0,_document2.default)(finalProps);}else{return/*#__PURE__*/_react.default.createElement("html",{lang:finalProps.lang},/*#__PURE__*/_react.default.createElement(_document.Head,{isBot:finalProps.isBot,pageJS:finalProps.pageJS,pageCss:finalProps.pageCss,fetcherData:finalProps.fetcherData,metaTags:finalProps.metaTags,publicAssetPath:finalProps.publicAssetPath}),/*#__PURE__*/_react.default.createElement(_document.Body,{initialState:finalProps.initialState,firstFoldCss:finalProps.firstFoldCss,firstFoldJS:finalProps.firstFoldJS,jsx:finalProps.jsx,statusCode:finalProps.statusCode,fetcherData:finalProps.fetcherData}));}};try{let status=matches.length&&matches[0].match.path==="*"?404:200;res.set({"content-type":"text/html; charset=utf-8"});res.status(status);const{pipe}=(0,_server3.renderToPipeableStream)(/*#__PURE__*/_react.default.createElement(CompleteDocument,null),{onShellReady(){res.setHeader("content-type","text/html");pipe(res);res.end();},onError(error){logger.error({message:`\n Error while renderToPipeableStream : ${error.toString()}`});}});}catch(error){logger.error("Error in rendering document on server:"+error);}};/**
9
9
  * middleware for document handling
10
10
  * @param {object} req - request object
11
11
  * @param {object} res - response object
12
- */async function _default(req,res){try{let context={};let fetcherData={};let webStats=_path.default.join(__dirname,"../..",`loadable-stats.json`);if(isProduction){webStats=_path.default.join(process.env.src_path,`${process.env.BUILD_OUTPUT_PATH}/public/loadable-stats.json`);}const webExtractor=new _server2.ChunkExtractor({statsFile:webStats,entrypoints:["app"]});// creates store
12
+ */async function _default(req,res){try{let context={};let fetcherData={};let webStats=_path.default.join(__dirname,"../../..",`loadable-stats.json`);if(isProduction){webStats=_path.default.join(process.env.src_path,`${process.env.BUILD_OUTPUT_PATH}/public/loadable-stats.json`);}const webExtractor=new _server2.ChunkExtractor({statsFile:webStats,entrypoints:["app"]});// creates store
13
13
  const store=(0,_validator.validateConfigureStore)(createStore)?createStore({},req):null;// user defined routes
14
- const routes=(0,_validator.validateGetRoutes)(getRoutes)?getRoutes():[];// Matches req url with routes
15
- const matches=getMatchRoutes(routes,req,res,store,context,fetcherData,undefined,webExtractor);const allMatches=(0,_router.matchRoutes)(getRoutes(),req.baseUrl);let allTags=[];// Executing app server side function
16
- _App.default.serverSideFunction({store,req,res})// Executing serverFetcher functions with serverDataFetcher provided by router and returning document
14
+ const routes=(0,_validator.validateGetRoutes)(_utils.getRoutes)?(0,_utils.getRoutes)():[];// Matches req url with routes
15
+ const matches=getMatchRoutes(routes,req,res,store,context,fetcherData,undefined,webExtractor);const allMatches=(0,_router.matchRoutes)((0,_utils.getRoutes)(),req.baseUrl);let allTags=[];// Executing app server side function
16
+ _index.default.serverSideFunction({store,req,res})// Executing serverFetcher functions with serverDataFetcher provided by router and returning document
17
17
  .then(()=>{(0,_router.serverDataFetcher)({routes:routes,req,res,url:req.originalUrl},{store}).then(res=>{fetcherData=res;allTags=(0,_router.getMetaData)(allMatches,fetcherData);}).then(async()=>await renderMarkUp(null,req,res,allTags,fetcherData,store,matches,context,webExtractor)).catch(async error=>{logger.error("Error in executing serverFetcher functions: "+error);await renderMarkUp(404,req,res,allTags,fetcherData,store,matches,context,webExtractor);});}).catch(error=>{logger.error("Error in executing serverSideFunction inside App: "+error);renderMarkUp(error.status_code,req,res,allTags,fetcherData,store,matches,context,webExtractor);});}catch(error){logger.error("Error in handling document request: "+error.toString());}}
@@ -0,0 +1,6 @@
1
+ "use strict";var _fs=_interopRequireDefault(require("fs"));var _path=_interopRequireDefault(require("path"));var _nodeUtil=_interopRequireDefault(require("node:util"));var _chokidar=_interopRequireDefault(require("chokidar"));var _picocolors=require("picocolors");var _index=require("@catalyst/template/server/index.js");var _validator=require("@catalyst/server/utils/validator.js");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const env=process.env.NODE_ENV||"development";// function defined by user which needs to run before server starts
2
+ if((0,_validator.validatePreInitServer)(_index.preServerInit))(0,_index.preServerInit)();process.on("uncaughtException",(err,origin)=>{console.log(process.stderr.fd);console.log(`Caught exception: ${err}\n`+`Exception origin: ${origin}`);});process.on("SIGINT",function(data){console.log("SIGINT");console.log(data);process.exit(0);});process.on("uncaughtExceptionMonitor",(err,origin)=>{console.log(err,origin);});process.on("message",function(msg){if(msg=="shutdown"){console.log("Closing all connections...");setTimeout(function(){console.log("Finished closing connections");process.exit(0);},1500);}});if(env==="development"){// Add better stack tracing for promises in dev mode
3
+ process.on("unhandledRejection",r=>console.debug(r));}const port=process.env.NODE_SERVER_PORT??3005;const host=process.env.NODE_SERVER_HOSTNAME??"localhost";let statsPath=_path.default.join(__dirname,`../../`,"loadable-stats.json");if(env==="production"){statsPath=_path.default.join(process.env.src_path,`${process.env.BUILD_OUTPUT_PATH}/public/loadable-stats.json`);}const watcher=_chokidar.default.watch(statsPath,{persistent:true});let serverInstance=null;const restartServer=()=>{const server=require("./expressServer.js").default;serverInstance=server.listen({port,host});};const startServer=()=>{const server=require("./expressServer.js").default;serverInstance=server.listen({port,host},error=>{const{APPLICATION,NODE_SERVER_HOSTNAME,NODE_SERVER_PORT}=process.env;if(error)console.log("An error occured while starting the Application server : ",error);if(env==="development")console.log((0,_picocolors.green)("Compiled successfully!"));console.log(`\nYou can now view ${APPLICATION} in the browser.\n`);console.log(_nodeUtil.default.format("\tLocal:".padEnd(8),(0,_picocolors.cyan)(`http://${NODE_SERVER_HOSTNAME}:${NODE_SERVER_PORT}`)));if(env==="development"){console.log("\nNote that the development build is not optimized.");console.log("To create a production build, use "+(0,_picocolors.cyan)("npm run build"));}console.log("\nFind out more about deployment here:");console.log((0,_picocolors.yellow)("\n https://catalyst.1mg.com/public_docs/content/deployment\n"));});};if(_fs.default.existsSync(statsPath)){// if loadable-stats.json exist this block will start the server in development environment. This happens in dev environment when loadable stats already exists and developer is making changes to the files. lodable-stats.json will be updated after every change.
4
+ watcher.on("change",()=>{watcher.close();if(serverInstance){serverInstance.close(()=>startServer());}else{startServer();}});// this block will start the server when your files have been compiled for production and lodable-stats.json exists.
5
+ watcher.on("add",()=>{if(env==="production"){watcher.close();startServer();}});}else{// this block will start the server in development environment for the first time when loadable-stats.json does not exists.
6
+ watcher.on("add",()=>{watcher.close();if(serverInstance){serverInstance.close(()=>startServer());}else{startServer();}});}if(_fs.default.existsSync(statsPath)){if(env==="development"){restartServer();}}
@@ -1 +1 @@
1
- "use strict";const pc=require("picocolors");const handleError=e=>{console.log(pc.red("Failed to start server: "),e);};const validatePreInitServer=fn=>{try{if(!fn)throw new Error("preServerInit named function should be defined in server/index.js");if(typeof fn!=="function")throw new Error("preServerInit should be function present in server/index.js");return true;}catch(e){handleError(e);}};const validateMiddleware=fn=>{try{if(!fn)throw new Error("addMiddlewares named function not found in server/server.js");if(typeof fn!=="function")throw new Error("addMiddlewares should be function present in server/server.js");return true;}catch(e){handleError(e);}};const validateReducerFunction=fn=>{try{if(!fn)throw new Error("reducer not found in src/js/containers/App/reducer");if(typeof fn!=="function")throw new Error("reducer should present in src/js/containers/App/reducer");return true;}catch(e){handleError(e);}};const validateConfigFile=obj=>{try{if(!obj)throw new Error("config not found in config folder");if(typeof obj!=="object")throw new Error("config object should be exported from config folder inside your project root directory");if(typeof obj==="object"){const requiredConfigKeys={NODE_SERVER_HOSTNAME:"",NODE_SERVER_PORT:"",WEBPACK_DEV_SERVER_HOSTNAME:"",WEBPACK_DEV_SERVER_PORT:"",BUILD_OUTPUT_PATH:"",PUBLIC_STATIC_ASSET_PATH:"",PUBLIC_STATIC_ASSET_URL:"",CLIENT_ENV_VARIABLES:[],ANALYZE_BUNDLE:""};for(let key in requiredConfigKeys){if(!(key in obj))throw new Error(`${key} key not found inside config.json`);}}return true;}catch(e){handleError(e);}};const validatePackageJson=obj=>{try{if(!obj)throw new Error("package.json not found in the project");if(typeof obj!=="object")throw new Error("package.json should be defined in project root directory");return true;}catch(e){handleError(e);}};const validateModuleAlias=obj=>{try{if(!obj)throw new Error("moduleAliases not found in package.json file present in root directory.");if(typeof obj!=="object")throw new Error("moduleAliases named object should be exported from package.json");if(typeof obj==="object"){const requiredModuleAliases={"@api":"api.js","@containers":"src/js/containers","@server":"server","@config":"config","@css":"src/static/css","@routes":"src/js/routes/"};for(let key in requiredModuleAliases){if(!(key in obj))throw new Error(`${key} module alias not defined inside package.json`);}}return true;}catch(e){handleError(e);}};const validateConfigureStore=fn=>{try{if(!fn)throw new Error("configureStore not found in file src/js/store/index.js");if(typeof fn!=="function")throw new Error("configureStore should be function exported from src/js/store/index.js");return true;}catch(e){handleError(e);}};const validateGetRoutes=fn=>{try{if(!fn)throw new Error("getRoutes not found in file src/js/routes/utils.js");if(typeof fn!=="function")throw new Error("getRoutes should be function exported from src/js/routers/index.js");return true;}catch(e){handleError(e);}};const validateCustomDocument=fn=>{try{if(!fn)throw new Error("document not found in file server/document.js");if(typeof fn!=="function")throw new Error("document should be a react component exported from server/document.js");return true;}catch(e){handleError(e);}};module.exports={validateConfigFile,validateConfigureStore,validateCustomDocument,validateGetRoutes,validatePackageJson,validateReducerFunction,validateModuleAlias,validatePreInitServer,validateMiddleware};
1
+ "use strict";const pc=require("picocolors");const handleError=e=>{console.log(pc.red("Failed to start server: "),e);};const validatePreInitServer=fn=>{try{if(!fn)throw new Error("preServerInit named function should be defined in server/index.js");if(typeof fn!=="function")throw new Error("preServerInit should be function present in server/index.js");return true;}catch(e){handleError(e);}};const validateMiddleware=fn=>{try{if(!fn)throw new Error("addMiddlewares named function not found in server/server.js");if(typeof fn!=="function")throw new Error("addMiddlewares should be function present in server/server.js");return true;}catch(e){handleError(e);}};const validateReducerFunction=fn=>{try{if(!fn)throw new Error("reducer not found in src/js/containers/App/reducer");if(typeof fn!=="function")throw new Error("reducer should present in src/js/containers/App/reducer");return true;}catch(e){handleError(e);}};const validateConfigFile=obj=>{try{if(!obj)throw new Error("config not found in config folder");if(typeof obj!=="object")throw new Error("config object should be exported from config folder inside your project root directory");if(typeof obj==="object"){const requiredConfigKeys={NODE_SERVER_HOSTNAME:"",NODE_SERVER_PORT:"",WEBPACK_DEV_SERVER_HOSTNAME:"",WEBPACK_DEV_SERVER_PORT:"",BUILD_OUTPUT_PATH:"",PUBLIC_STATIC_ASSET_PATH:"",PUBLIC_STATIC_ASSET_URL:"",CLIENT_ENV_VARIABLES:[],ANALYZE_BUNDLE:""};for(let key in requiredConfigKeys){if(!(key in obj))throw new Error(`${key} key not found inside config.json`);}}return true;}catch(e){handleError(e);}};const validatePackageJson=obj=>{try{if(!obj)throw new Error("package.json not found in the project");if(typeof obj!=="object")throw new Error("package.json should be defined in project root directory");return true;}catch(e){handleError(e);}};const validateModuleAlias=obj=>{try{if(!obj)throw new Error("moduleAliases not found in package.json file present in root directory.");if(typeof obj!=="object")throw new Error("moduleAliases named object should be exported from package.json");if(typeof obj==="object"){const requiredModuleAliases={"@api":"api.js","@containers":"src/js/containers","@server":"server","@config":"config","@css":"src/static/css","@routes":"src/js/routes/"};for(let key in requiredModuleAliases){if(key.includes("catalyst"))throw new Error(`Catalyst keyword is restricted for defining aliases`);if(!(key in obj))throw new Error(`${key} module alias not defined inside package.json`);}}return true;}catch(e){handleError(e);}};const validateConfigureStore=fn=>{try{if(!fn)throw new Error("configureStore not found in file src/js/store/index.js");if(typeof fn!=="function")throw new Error("configureStore should be function exported from src/js/store/index.js");return true;}catch(e){handleError(e);}};const validateGetRoutes=fn=>{try{if(!fn)throw new Error("getRoutes not found in file src/js/routes/utils.js");if(typeof fn!=="function")throw new Error("getRoutes should be function exported from src/js/routers/index.js");return true;}catch(e){handleError(e);}};const validateCustomDocument=fn=>{try{if(!fn)throw new Error("document not found in file server/document.js");if(typeof fn!=="function")throw new Error("document should be a react component exported from server/document.js");return true;}catch(e){handleError(e);}};module.exports={validateConfigFile,validateConfigureStore,validateCustomDocument,validateGetRoutes,validatePackageJson,validateReducerFunction,validateModuleAlias,validatePreInitServer,validateMiddleware};
@@ -0,0 +1,8 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.basePlugins=void 0;var _path=_interopRequireDefault(require("path"));var _webpack=_interopRequireDefault(require("webpack"));var _webpackPlugin=_interopRequireDefault(require("@loadable/webpack-plugin"));var _miniCssExtractPlugin=_interopRequireDefault(require("mini-css-extract-plugin"));var _webpackBundleAnalyzer=require("webpack-bundle-analyzer");var _config=_interopRequireDefault(require("@catalyst/root/config.json"));var _package=require("@catalyst/template/package.json");var _scssParams=require("@catalyst/webpack/scssParams");var _babelConfig=_interopRequireDefault(require("@catalyst/webpack/babel.config.ssr"));var _babelConfig2=_interopRequireDefault(require("@catalyst/webpack/babel.config.client"));var _loadEnvironmentVariables=_interopRequireDefault(require("@catalyst/scripts/loadEnvironmentVariables"));var _config2=require("@catalyst/template/config/config.json");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}(0,_loadEnvironmentVariables.default)();const isDev=process.env.NODE_ENV==="development";const isSSR=!!process.env.SSR||false;const basePlugins=exports.basePlugins=[new _webpackPlugin.default({filename:"loadable-stats.json",writeToDisk:{filename:_path.default.join(__dirname,"../..")}}),// **This loads process.env variable during webpack build process
2
+ new _webpack.default.DefinePlugin({"process.env":([..._config2.CLIENT_ENV_VARIABLES,...Object.keys(process.env)]||[]).reduce((clientEnvMap,env)=>{clientEnvMap[env]=JSON.stringify(process.env[env]);return clientEnvMap;},{})}),// ** This is used to analyze bundle size.
3
+ _config2.ANALYZE_BUNDLE&&new _webpackBundleAnalyzer.BundleAnalyzerPlugin({generateStatsFile:_config2.ANALYZE_BUNDLE}),new _webpack.default.IgnorePlugin({resourceRegExp:/^\.\/locale$/,contextRegExp:/moment$/})];const{IS_DEV_COMMAND,PUBLIC_STATIC_ASSET_URL,PUBLIC_STATIC_ASSET_PATH,WEBPACK_DEV_SERVER_HOSTNAME,WEBPACK_DEV_SERVER_PORT,NODE_SERVER_HOSTNAME,NODE_SERVER_PORT}=process.env;let publicPath=isDev?`http://${WEBPACK_DEV_SERVER_HOSTNAME}:${WEBPACK_DEV_SERVER_PORT}/`:`${PUBLIC_STATIC_ASSET_URL}${PUBLIC_STATIC_ASSET_PATH}`;// serves assets from local on running devBuild and devServe command
4
+ if(JSON.parse(IS_DEV_COMMAND)&&!isDev){publicPath=`http://${NODE_SERVER_HOSTNAME}:${NODE_SERVER_PORT}/assets/`;}var _default=exports.default={context:_path.default.resolve(process.env.src_path),mode:isDev?"development":"production",entry:{app:[_path.default.resolve(process.env.src_path,"./client/index.js")]},output:{path:_path.default.join(process.env.src_path,`${process.env.BUILD_OUTPUT_PATH}/public`),chunkFilename:process.env.NODE_ENV==="development"?_config.default.chunkFileNameDev:_config.default.chunkFileNameProd,publicPath:publicPath},resolve:{fallback:{url:require.resolve("url")},extensions:[".js",".jsx",".scss"],alias:Object.keys(_package._moduleAliases||{}).reduce((moduleEnvMap,alias)=>{moduleEnvMap[alias]=_path.default.join(process.env.src_path,..._package._moduleAliases[alias].split("/"));return moduleEnvMap;},{})},plugins:basePlugins,module:{rules:[{test:/\.jsx$|\.js$/,exclude:_path.default.resolve(process.env.src_path,"./node_modules"),use:{loader:"babel-loader",options:isSSR?_babelConfig.default:_babelConfig2.default}},{// This loader processes all the .scss files that should be modularized. This should exclude anything inside node_modules and everything inside src/css/base since they should be globally scoped.
5
+ test:/\.scss$/,exclude:[_path.default.resolve(process.env.src_path,"./node_modules"),_path.default.resolve(process.env.src_path,"./src/static/css/base")],use:[isDev&&"css-hot-loader",!isSSR&&_miniCssExtractPlugin.default.loader,{loader:"css-loader",options:{modules:{mode:"local",exportOnlyLocals:!isDev&&isSSR,localIdentName:isDev?_config.default.cssModulesIdentifierDev:_config.default.cssModulesIdentifierProd}}},{loader:"postcss-loader"},{loader:"sass-loader",options:{additionalData:"$font_url: "+(0,_scssParams.fontUrl)()+";"+"$url_for: "+(0,_scssParams.imageUrl)()+";"}},{loader:"sass-resources-loader",options:{resources:[_path.default.resolve(process.env.src_path,"./src/static/css/resources/*.scss")]}}]},{// In development mode, client request app.css ,which has all the css in node_modules and src/static/css/base, This is served by webpack-dev-server. However in prod this css is injected in the doc sent from the server and needs to be global, so we don't pass the files through css-loader to be modularized.
6
+ test:/\.scss$/,include:[_path.default.resolve(process.env.src_path,"./node_modules"),_path.default.resolve(process.env.src_path,"./src/static/css/base")],use:[isDev&&"css-hot-loader",!isSSR&&_miniCssExtractPlugin.default.loader,{loader:"css-loader"},{loader:"postcss-loader"},{loader:"sass-loader",options:{additionalData:"$font_url: "+(0,_scssParams.fontUrl)()+";"+"$url_for: "+(0,_scssParams.imageUrl)()+";"}},{loader:"sass-resources-loader",options:{resources:[_path.default.resolve(process.env.src_path,"./src/static/css/resources/*.scss")]}}]},{test:/\.css$/,use:[!isSSR&&_miniCssExtractPlugin.default.loader,"css-loader","postcss-loader"]},{test:/\.(png|jpg|gif|jpeg|ico?)$/,use:["url-loader?limit=10240","img-loader"]},{test:/\.svg$/i,issuer:/\.[jt]sx?$/,use:["@svgr/webpack","url-loader?limit=10240","img-loader"]},{// This loader loads fonts in src/static/fonts using file-loader
7
+ test:/\.(ttf|eot|woff2|json?)$/,use:[{loader:"url-loader",options:{limit:10240,outputPath:[_path.default.resolve(process.env.src_path,"./src/static/fonts/")]}},"file-loader"]},{// This loader loads html files
8
+ test:/\.html$/,use:[{loader:"html-loader",options:{minimize:{minifyJS:true,minifyCSS:true,removeComments:false,collapseWhitespace:true}}}]}]}};
@@ -0,0 +1,4 @@
1
+ "use strict";var _webpack=_interopRequireDefault(require("webpack"));var _webpackMerge=_interopRequireDefault(require("webpack-merge"));var _webpackDevServer=_interopRequireDefault(require("webpack-dev-server"));var _miniCssExtractPlugin=_interopRequireDefault(require("mini-css-extract-plugin"));var _reactRefreshWebpackPlugin=_interopRequireDefault(require("@pmmmwh/react-refresh-webpack-plugin"));var _config=_interopRequireDefault(require("@catalyst/root/config.json"));var _baseBabel=_interopRequireDefault(require("@catalyst/webpack/base.babel.js"));var _webpackConfig=_interopRequireDefault(require("@catalyst/template/webpackConfig.js"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const{WEBPACK_DEV_SERVER_PORT,WEBPACK_DEV_SERVER_HOSTNAME}=process.env;const webpackConfig=(0,_webpackMerge.default)(_baseBabel.default,{devtool:"inline-source-map",stats:"none",infrastructureLogging:{level:"none"},plugins:[new _reactRefreshWebpackPlugin.default({overlay:{entry:false}}),new _miniCssExtractPlugin.default({filename:_config.default.cssChunkFileName,ignoreOrder:true}),..._webpackConfig.default.developmentPlugins].filter(Boolean),optimization:{runtimeChunk:"single",moduleIds:"deterministic",splitChunks:{cacheGroups:{commonVendor:{test:/[\\/]node_modules[\\/](react|react-dom|react-redux|react-router|react-router-dom|redux|redux-thunk|axios|react-loadable-visibility|react-helmet-async|react-fast-compare|react-async-script|babel|@loadable\/component|catalyst)[\\/]/,name:"commonVendor",minSize:30000},utilityVendor:{maxInitialRequests:Infinity,chunks:"all",// minSize: 0, // Enable to replicate stand alone chunking for all packages
2
+ reuseExistingChunk:true,// Disable to replicate stand alone chunking for all packages
3
+ minRemainingSize:1000,// Disable to replicate stand alone chunking for all packages
4
+ test:/[\\/]node_modules[\\/]/,name(module){const moduleFileName=module.identifier().split("/").reduceRight(item=>item);return`npm.${moduleFileName}`;}}}}}});let devServer=new _webpackDevServer.default({port:WEBPACK_DEV_SERVER_PORT,host:WEBPACK_DEV_SERVER_HOSTNAME,static:{publicPath:webpackConfig.output.publicPath},hot:true,historyApiFallback:true,headers:{"Access-Control-Allow-Origin":"*"},client:{logging:"error",overlay:{errors:false,warnings:false,runtimeErrors:false},reconnect:true}},(0,_webpack.default)(webpackConfig));devServer.startCallback(()=>{console.log("Catalyst is compiling your files.");console.log("Please wait until bundling is finished.\n");});
@@ -0,0 +1,4 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _registerAliases2=_interopRequireWildcard(require("../scripts/registerAliases.js"));var _miniCssExtractPlugin=_interopRequireDefault(require("mini-css-extract-plugin"));var _webpackMerge=require("webpack-merge");var _base=_interopRequireDefault(require("@catalyst/webpack/base.babel"));var _config=_interopRequireDefault(require("@catalyst/root/config.json"));var _webpackConfig=_interopRequireDefault(require("@catalyst/template/webpackConfig.js"));var _package=require("@catalyst/root/package.json");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&Object.prototype.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n.default=e,t&&t.set(e,n),n;}/* eslint-disable */const clientConfig=(0,_webpackMerge.mergeWithCustomize)({customizeArray:(0,_webpackMerge.customizeArray)({entry:"prepend",plugins:"append",module:"prepend"}),customizeObject:(0,_webpackMerge.customizeObject)({entry:"prepend",plugins:"append",module:"prepend"})})(_base.default,{mode:"production",stats:"errors-only",resolve:{alias:_registerAliases2.catalystResultMap},optimization:{runtimeChunk:"single",moduleIds:"deterministic",splitChunks:{cacheGroups:{commonVendor:{chunks:"all",test:/[\\/]node_modules[\\/](react|react-dom|react-redux|react-router|react-router-dom|redux|redux-thunk|axios|react-loadable-visibility|react-helmet-async|react-fast-compare|react-async-script|babel|@loadable\/component|catalyst)[\\/]/,name:"commonVendor",minSize:400000,maxSize:400000},utilityVendor:{maxInitialRequests:Infinity,chunks:"all",// minSize: 0, // Enable to replicate stand alone chunking for all packages
2
+ reuseExistingChunk:true,// Disable to replicate stand alone chunking for all packages
3
+ minRemainingSize:1000,// Disable to replicate stand alone chunking for all packages
4
+ minSize:1000,maxSize:120000,test:/[\\/]node_modules[\\/]/,name(module){const moduleFileName=module.identifier().split("/").reverse().slice(0,3).reduce((item,current)=>{item=current+"."+item;return item;},[]);return`npm.${moduleFileName}`;}}},chunks:"all",name(module){const moduleFileName=module.identifier().split("/").reverse().slice(0,3).reduce((item,current)=>{item=current+"."+item;return item;},[]);return`npm.${moduleFileName}`;}}},plugins:[new _miniCssExtractPlugin.default({filename:_config.default.cssChunkFileName,ignoreOrder:true}),..._webpackConfig.default.clientPlugins]});var _default=exports.default=clientConfig;
@@ -0,0 +1,4 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _registerAliases2=_interopRequireWildcard(require("../scripts/registerAliases.js"));var _path=_interopRequireDefault(require("path"));var _webpackNodeExternals=_interopRequireDefault(require("webpack-node-externals"));var _appRootPath=_interopRequireDefault(require("app-root-path"));var _base=_interopRequireDefault(require("@catalyst/webpack/base.babel"));var _config=_interopRequireDefault(require("@catalyst/root/config.json"));var _webpackConfig=_interopRequireDefault(require("@catalyst/template/webpackConfig.js"));var _package=require("@catalyst/root/package.json");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _getRequireWildcardCache(e){if("function"!=typeof WeakMap)return null;var r=new WeakMap(),t=new WeakMap();return(_getRequireWildcardCache=function(e){return e?t:r;})(e);}function _interopRequireWildcard(e,r){if(!r&&e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache(r);if(t&&t.has(e))return t.get(e);var n={__proto__:null},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var u in e)if("default"!==u&&Object.prototype.hasOwnProperty.call(e,u)){var i=a?Object.getOwnPropertyDescriptor(e,u):null;i&&(i.get||i.set)?Object.defineProperty(n,u,i):n[u]=e[u];}return n.default=e,t&&t.set(e,n),n;}/* eslint-disable */const{mergeWithCustomize,customizeArray,customizeObject}=require("webpack-merge");const ssrConfig=mergeWithCustomize({customizeArray:customizeArray({entry:"replace",optimization:"replace",plugins:"prepend"}),customizeObject:customizeObject({entry:"replace",optimization:"replace",plugins:"prepend"})})(_base.default,{mode:"production",stats:"errors-only",optimization:{splitChunks:{chunks:"all",minSize:10000000,name:false}},resolve:{alias:_registerAliases2.catalystResultMap},plugins:[..._webpackConfig.default.ssrPlugins],target:"node",entry:{handler:_path.default.resolve(__dirname,"..","./server/renderer/handler.js")},externals:[// images are handled by isomorphic webpack.
2
+ // html files are required directly
3
+ /\.(html|png|gif|jpg)$/,// treat all node modules as external to keep this bundle small
4
+ (0,_webpackNodeExternals.default)({modulesDir:_path.default.resolve(process.env.src_path,"./node_modules")}),(0,_webpackNodeExternals.default)({modulesDir:_path.default.join(_appRootPath.default.path,"./node_modules")})],output:{path:_path.default.join(process.env.src_path,process.env.BUILD_OUTPUT_PATH,"/renderer"),chunkFilename:_config.default.chunkFileNameProd,filename:"handler.js",libraryTarget:"commonjs"}});var _default=exports.default=ssrConfig;
package/package.json CHANGED
@@ -1,17 +1,37 @@
1
1
  {
2
2
  "name": "catalyst-core-internal",
3
- "version": "0.0.1-beta.21",
3
+ "version": "0.0.1-beta.22",
4
4
  "main": "index.js",
5
5
  "description": "Web framework that provides great performance out of the box",
6
6
  "bin": {
7
7
  "catalyst": "bin/catalyst.js"
8
8
  },
9
+ "_moduleAliases": {
10
+ "@catalyst/template": ".",
11
+ "@catalyst/template/src": "src",
12
+ "@catalyst/template/routes": "src/js/routes",
13
+ "@catalyst/template/server": "server",
14
+ "@catalyst/template/store": "src/js/store",
15
+ "@catalyst/template/config": "config",
16
+ "@catalyst": ".",
17
+ "@catalyst/root": "../",
18
+ "@catalyst/router": "router",
19
+ "@catalyst/scripts": "scripts",
20
+ "@catalyst/server": "server",
21
+ "@catalyst/webpack": "webpack"
22
+ },
23
+ "exports": {
24
+ ".": "./dist/index.js",
25
+ "./logger": "./dist/logger.js",
26
+ "./caching": "./dist/caching.js",
27
+ "./router/ClientRouter": "./dist/router/ClientRouter.js"
28
+ },
9
29
  "scripts": {
10
- "prepare": "babel src --out-dir .",
11
- "prepublishOnly": "npm i && npm run prepare",
12
30
  "lint": "eslint .",
31
+ "lint-staged": "lint-staged",
13
32
  "prettify": "prettier . --write",
14
- "lint-staged": "lint-staged"
33
+ "prepare": "babel src --out-dir ./dist",
34
+ "prepublishOnly": "npm i && npm run prepare"
15
35
  },
16
36
  "license": "MIT",
17
37
  "dependencies": {
@@ -28,7 +48,7 @@
28
48
  "@loadable/webpack-plugin": "^5.15.2",
29
49
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
30
50
  "@svgr/webpack": "^8.1.0",
31
- "@tata1mg/router": "^0.0.1-beta.1",
51
+ "@tata1mg/router": "^0.0.2-test.1",
32
52
  "app-root-path": "^3.1.0",
33
53
  "babel-loader": "^9.1.3",
34
54
  "babel-plugin-transform-react-remove-prop-types": "^0.4.24",
package/.eslintignore DELETED
@@ -1,9 +0,0 @@
1
- node_modules/*
2
- router/*
3
- scripts/*
4
- server/*
5
- webpack/*
6
-
7
- caching.js
8
- index.js
9
- logger.js
package/.eslintrc DELETED
@@ -1,91 +0,0 @@
1
- {
2
- "parser": "@babel/eslint-parser",
3
- "rules": {
4
- "react/prop-types": 1,
5
- "react/display-name": [
6
- 0,
7
- {
8
- "ignoreTranspilerName": true
9
- }
10
- ],
11
- "react-hooks/exhaustive-deps": "error", // Checks effect dependencies
12
- "no-prototype-builtins": "off",
13
- "security/detect-possible-timing-attacks": "error",
14
- "security/detect-child-process": "error",
15
- "security/detect-eval-with-expression": "error",
16
- "security/detect-new-buffer": "error",
17
- "security/detect-no-csrf-before-method-override": "error",
18
- "risxss/catch-potential-xss-react": [
19
- "error",
20
- {
21
- "trustedLibraries": [
22
- "@commonUtils"
23
- ]
24
- }
25
- ],
26
- "react/jsx-no-target-blank": [
27
- 0,
28
- {
29
- "enforceDynamicLinks": "never"
30
- }
31
- ]
32
- },
33
- "env": {
34
- "browser": true,
35
- "es6": true,
36
- "jest": true,
37
- "node": true
38
- },
39
- "globals": {
40
- "expect": true,
41
- "__non_webpack_require__": true,
42
- "logger": "readonly",
43
- "AppCallbacks": "readonly"
44
- },
45
- "extends": [
46
- "eslint:recommended",
47
- "plugin:react/recommended"
48
- ],
49
- "parserOptions": {
50
- "sourceType": "module",
51
- "ecmaFeatures": {
52
- "experimentalObjectRestSpread": true,
53
- "jsx": true
54
- },
55
- "babelOptions": {
56
- "configFile": "./babel.config.json"
57
- },
58
- "ecmaVersion": 6
59
- },
60
- "plugins": [
61
- "babel",
62
- "react",
63
- "react-hooks",
64
- "security",
65
- "risxss"
66
- ],
67
- "settings": {
68
- "react": {
69
- "createClass": "createReactClass",
70
- "pragma": "React",
71
- "version": "detect"
72
- },
73
- "propWrapperFunctions": [
74
- "forbidExtraProps",
75
- {
76
- "property": "freeze",
77
- "object": "Object"
78
- },
79
- {
80
- "property": "myFavoriteWrapper"
81
- }
82
- ],
83
- "linkComponents": [
84
- "Hyperlink",
85
- {
86
- "name": "Link",
87
- "linkAttribute": "to"
88
- }
89
- ]
90
- }
91
- }
package/.husky/commit-msg DELETED
@@ -1 +0,0 @@
1
- npx --no -- commitlint --edit $1
package/.husky/pre-commit DELETED
@@ -1 +0,0 @@
1
- npm run lint-staged
@@ -1,11 +0,0 @@
1
- module.exports = {
2
- /*
3
- * Resolve and load @commitlint/config-conventional from node_modules.
4
- * Referenced packages must be installed
5
- */
6
- extends: ["@commitlint/config-conventional"],
7
- /*
8
- * Any rules defined here will override rules from @commitlint/config-conventional
9
- */
10
- rules: {},
11
- }
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _router=require("@tata1mg/router");var _utils=require("@routes/utils.js");const ServerRouter=reduxData=>{const{store,intialData}=reduxData;return(0,_router.useRoutes)((0,_utils.preparedRoutes)({store,routerInitialState:intialData}));};var _default=exports.default=ServerRouter;
@@ -1,5 +0,0 @@
1
- "use strict";var _cssModulesRequireHook=_interopRequireDefault(require("@dr.pogodin/css-modules-require-hook"));var _path=_interopRequireDefault(require("path"));var _moduleAlias=_interopRequireDefault(require("module-alias"));var _loadEnvironmentVariables=_interopRequireDefault(require("./loadEnvironmentVariables"));var _logger=require("../logger.js");var _validator=require("./validator.js");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const{cssModulesIdentifierDev}=require(`${__dirname}/../config.json`);const{_moduleAliases}=require(`${process.env.src_path}/package.json`);// stores your config keys in enviorments variables
2
- (0,_loadEnvironmentVariables.default)();// creates logger instance with provided config and stores them at global level.
3
- (0,_logger.configureLogger)({enableDebugLogs:process.env.ENABLE_DEBUG_LOGS,enableFileLogging:process.env.ENABLE_FILE_LOGGING,enableConsoleLogging:process.env.ENABLE_CONSOLE_LOGGING});// resolves module alias imports
4
- if((0,_validator.validateModuleAlias)(_moduleAliases)){_moduleAlias.default.addAliases(Object.keys(_moduleAliases||[]).reduce((resultMap,aliasName)=>{const aliasPath=_moduleAliases[aliasName];if(aliasPath.includes("server")){if(process.env.NODE_ENV!=="production"){resultMap[aliasName]=_path.default.join(process.env.src_path,aliasPath);}else{resultMap[aliasName]=_path.default.join(process.env.src_path,process.env.BUILD_OUTPUT_PATH);}}else resultMap[aliasName]=_path.default.join(process.env.src_path,aliasPath);return resultMap;},{}));}// compile css-variables in realtime in dev mode.
5
- if(process.env.NODE_ENV==="development")(0,_cssModulesRequireHook.default)({extensions:[".scss",".css"],generateScopedName:cssModulesIdentifierDev,devMode:true,ignore:_path.default.join(process.env.src_path,"/src/static/css/base/(?!.*.scss$).*")});
@@ -1,29 +0,0 @@
1
- import path from "path"
2
- import moduleAlias from "module-alias"
3
- import { _moduleAliases } from "../../package.json"
4
-
5
- export const getTemplatePath = (file) => {
6
- if (file) return path.resolve(__dirname, process.env.src_path, file)
7
- else return path.resolve(__dirname, process.env.src_path)
8
- }
9
-
10
- export const getCatalystPath = (file) => {
11
- if (file) return path.resolve(__dirname, "../", file)
12
- else return path.resolve(__dirname, "..")
13
- }
14
-
15
- moduleAlias.addAliases(
16
- Object.keys(_moduleAliases || []).reduce((resultMap, aliasName) => {
17
- const aliasPath = _moduleAliases[aliasName]
18
-
19
- if (aliasName.includes("@template")) {
20
- resultMap[aliasName] = path.join(__dirname, process.env.src_path, aliasPath)
21
- }
22
-
23
- if (aliasName.includes("@catalyst")) {
24
- resultMap[aliasName] = path.join(__dirname, "../", aliasPath)
25
- }
26
-
27
- return resultMap
28
- }, {})
29
- )
package/scripts/start.js DELETED
@@ -1,6 +0,0 @@
1
- "use strict";const path=require("path");const{spawnSync}=require("child_process");const{arrayToObject}=require("./scriptUtils");const{name}=require(`${process.env.PWD}/package.json`);/**
2
- * @description - starts webpack dev server and node server.
3
- */function start(){const commandLineArguments=process.argv.slice(2);const argumentsObject=arrayToObject(commandLineArguments);const dirname=path.resolve(__dirname,"../");const command=`
4
- node ./scripts/checkVersion
5
- npx babel-node -r ./scripts/loadScriptsBeforeServerStarts.js webpack/development.client.babel --no-warnings=ExperimentalWarning --no-warnings=BABEL & npx babel-node -r ./scripts/loadScriptsBeforeServerStarts.js ./server/startServer.js --watch-path=${process.env.PWD}/server --watch-path=${process.env.PWD}/src --ignore='__IGNORE__' --no-warnings=ExperimentalWarning --no-warnings=BABEL
6
- `;spawnSync(command,[],{cwd:dirname,stdio:"inherit",shell:true,env:{...process.env,src_path:process.env.PWD,NODE_ENV:"development",IS_DEV_COMMAND:false,APPLICATION:name||"catalyst_app",...argumentsObject}});}start();
@@ -1,6 +0,0 @@
1
- "use strict";var _fs=_interopRequireDefault(require("fs"));var _path=_interopRequireDefault(require("path"));var _nodeUtil=_interopRequireDefault(require("node:util"));var _chokidar=_interopRequireDefault(require("chokidar"));var _index=require("@server/index.js");var _picocolors=require("picocolors");var _validator=require("./utils/validator.js");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const env=process.env.NODE_ENV||"development";// function defined by user which needs to run before server starts
2
- if((0,_validator.validatePreInitServer)(_index.preServerInit))(0,_index.preServerInit)();process.on("uncaughtException",(err,origin)=>{console.log(process.stderr.fd);console.log(`Caught exception: ${err}\n`+`Exception origin: ${origin}`);});process.on("SIGINT",function(data){console.log("SIGINT");console.log(data);process.exit(0);});process.on("uncaughtExceptionMonitor",(err,origin)=>{console.log(err,origin);});process.on("message",function(msg){if(msg=="shutdown"){console.log("Closing all connections...");setTimeout(function(){console.log("Finished closing connections");process.exit(0);},1500);}});if(env==="development"){// Add better stack tracing for promises in dev mode
3
- process.on("unhandledRejection",r=>console.debug(r));}const port=process.env.NODE_SERVER_PORT??3005;const host=process.env.NODE_SERVER_HOSTNAME??"localhost";let statsPath=_path.default.join(__dirname,`../`,"loadable-stats.json");if(env==="production"){statsPath=_path.default.join(process.env.src_path,`${process.env.BUILD_OUTPUT_PATH}/public/loadable-stats.json`);}const watcher=_chokidar.default.watch(statsPath,{persistent:true});let serverInstance=null;const restartServer=()=>{const server=require("./expressServer.js").default;serverInstance=server.listen({port,host});};const startServer=()=>{const server=require("./expressServer.js").default;serverInstance=server.listen({port,host},error=>{const{APPLICATION,NODE_SERVER_HOSTNAME,NODE_SERVER_PORT}=process.env;if(error)console.log("An error occured while starting the Application server : ",error);if(env==="development")console.log((0,_picocolors.green)("Compiled successfully!"));console.log(`\nYou can now view ${APPLICATION} in the browser.\n`);console.log(_nodeUtil.default.format("\tLocal:".padEnd(8),(0,_picocolors.cyan)(`http://${NODE_SERVER_HOSTNAME}:${NODE_SERVER_PORT}`)));if(env==="development"){console.log("\nNote that the development build is not optimized.");console.log("To create a production build, use "+(0,_picocolors.cyan)("npm run build"));}console.log("\nFind out more about deployment here:");console.log((0,_picocolors.yellow)("\n https://catalyst.1mg.com/public_docs/content/deployment\n"));});};if(_fs.default.existsSync(statsPath)){// if loadable-stats.json exist this block will start the server in development environment. This happens in dev environment when loadable stats already exists and developer is making changes to the files. lodable-stats.json will be updated after every change.
4
- watcher.on("change",()=>{watcher.close();if(serverInstance){serverInstance.close(()=>startServer());}else{startServer();}});// this block will start the server when your files have been compiled for production and lodable-stats.json exists.
5
- watcher.on("add",()=>{if(env==="production"){watcher.close();startServer();}});}else{// this block will start the server in development environment for the first time when loadable-stats.json does not exists.
6
- watcher.on("add",()=>{watcher.close();if(serverInstance){serverInstance.close(()=>startServer());}else{startServer();}});}if(_fs.default.existsSync(statsPath)){if(env==="development"){restartServer();}}
package/tsconfig.json DELETED
@@ -1,110 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- /* Visit https://aka.ms/tsconfig to read more about this file */
4
-
5
- /* Projects */
6
- // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
- // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
- // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9
- // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
- // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
- // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
-
13
- /* Language and Environment */
14
- "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
15
- // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
- "jsx": "react" /* Specify what JSX code is generated. */,
17
- // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
18
- // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
- // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
20
- // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21
- // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
22
- // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
23
- // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
- // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
- // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26
-
27
- /* Modules */
28
- "module": "commonjs" /* Specify what module code is generated. */,
29
- // "rootDir": "./", /* Specify the root folder within your source files. */
30
- // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
31
- // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32
- // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
33
- // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
34
- // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
35
- // "types": [], /* Specify type package names to be included without being referenced in a source file. */
36
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
37
- // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38
- // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
39
- // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
40
- // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
41
- // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
42
- // "resolveJsonModule": true, /* Enable importing .json files. */
43
- // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
44
- // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
45
-
46
- /* JavaScript Support */
47
- "allowJs": true /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */,
48
- "checkJs": false /* Enable error reporting in type-checked JavaScript files. */,
49
- // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
50
-
51
- /* Emit */
52
- "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
53
- // "declarationMap": true, /* Create sourcemaps for d.ts files. */
54
- "emitDeclarationOnly": true /* Only output d.ts files and not JavaScript files. */,
55
- // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
56
- // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
57
- // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
58
- "outDir": "./types" /* Specify an output folder for all emitted files. */,
59
- // "removeComments": true, /* Disable emitting comments. */
60
- // "noEmit": true, /* Disable emitting files from a compilation. */
61
- // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
62
- // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
63
- // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
64
- // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
65
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
66
- // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
67
- // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
68
- // "newLine": "crlf", /* Set the newline character for emitting files. */
69
- // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
70
- // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
71
- // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
72
- // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
73
- // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
74
- // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
75
-
76
- /* Interop Constraints */
77
- // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
78
- // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
79
- // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
80
- "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
81
- // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
82
- "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
83
-
84
- /* Type Checking */
85
- "strict": true /* Enable all strict type-checking options. */,
86
- // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
87
- // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
88
- // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
89
- // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
90
- // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
91
- // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
92
- // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
93
- // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
94
- // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
95
- // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
96
- // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
97
- // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
98
- // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
99
- // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
100
- // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
101
- // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
102
- // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
103
- // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
104
-
105
- /* Completeness */
106
- // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
107
- "skipLibCheck": true /* Skip type checking all .d.ts files. */
108
- },
109
- "include": ["src"]
110
- }
@@ -1,8 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.basePlugins=void 0;var _path=_interopRequireDefault(require("path"));var _webpack=_interopRequireDefault(require("webpack"));var _miniCssExtractPlugin=_interopRequireDefault(require("mini-css-extract-plugin"));var _webpackBundleAnalyzer=require("webpack-bundle-analyzer");var _webpackPlugin=_interopRequireDefault(require("@loadable/webpack-plugin"));var _scssParams=require("./scssParams");var _babelConfig=_interopRequireDefault(require("./babel.config.client"));var _babelConfig2=_interopRequireDefault(require("./babel.config.ssr"));var _loadEnvironmentVariables=_interopRequireDefault(require("../scripts/loadEnvironmentVariables"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const catalystConfig=require(_path.default.resolve(__dirname,"..","config.json"));const{CLIENT_ENV_VARIABLES:clientEnv,ANALYZE_BUNDLE}=require(`${process.env.src_path}/config/config.json`);const{_moduleAliases}=require(`${process.env.src_path}/package.json`);(0,_loadEnvironmentVariables.default)();const isDev=process.env.NODE_ENV==="development";const isSSR=!!process.env.SSR||false;const basePlugins=exports.basePlugins=[new _webpackPlugin.default({filename:"loadable-stats.json",writeToDisk:{filename:_path.default.join(__dirname,"..")}}),// **This loads process.env variable during webpack build process
2
- new _webpack.default.DefinePlugin({"process.env":([...clientEnv,...Object.keys(process.env)]||[]).reduce((clientEnvMap,env)=>{clientEnvMap[env]=JSON.stringify(process.env[env]);return clientEnvMap;},{})}),// ** This is used to analyze bundle size.
3
- ANALYZE_BUNDLE&&new _webpackBundleAnalyzer.BundleAnalyzerPlugin({generateStatsFile:ANALYZE_BUNDLE}),new _webpack.default.IgnorePlugin({resourceRegExp:/^\.\/locale$/,contextRegExp:/moment$/})];const{IS_DEV_COMMAND,PUBLIC_STATIC_ASSET_URL,PUBLIC_STATIC_ASSET_PATH,WEBPACK_DEV_SERVER_HOSTNAME,WEBPACK_DEV_SERVER_PORT,NODE_SERVER_HOSTNAME,NODE_SERVER_PORT}=process.env;let publicPath=isDev?`http://${WEBPACK_DEV_SERVER_HOSTNAME}:${WEBPACK_DEV_SERVER_PORT}/`:`${PUBLIC_STATIC_ASSET_URL}${PUBLIC_STATIC_ASSET_PATH}`;// serves assets from local on running devBuild and devServe command
4
- if(JSON.parse(IS_DEV_COMMAND)&&!isDev){publicPath=`http://${NODE_SERVER_HOSTNAME}:${NODE_SERVER_PORT}/assets/`;}var _default=exports.default={context:_path.default.resolve(process.env.src_path),mode:isDev?"development":"production",entry:{app:[_path.default.resolve(process.env.src_path,"./client/index.js")]},output:{path:_path.default.join(process.env.src_path,`${process.env.BUILD_OUTPUT_PATH}/public`),chunkFilename:process.env.NODE_ENV==="development"?catalystConfig.chunkFileNameDev:catalystConfig.chunkFileNameProd,publicPath:publicPath},resolve:{fallback:{url:require.resolve("url")},extensions:[".js",".jsx",".scss"],alias:Object.keys(_moduleAliases||{}).reduce((moduleEnvMap,alias)=>{moduleEnvMap[alias]=_path.default.join(process.env.src_path,..._moduleAliases[alias].split("/"));return moduleEnvMap;},{})},plugins:basePlugins,module:{rules:[{test:/\.jsx$|\.js$/,exclude:_path.default.resolve(process.env.src_path,"./node_modules"),use:{loader:"babel-loader",options:isSSR?_babelConfig2.default:_babelConfig.default}},{// This loader processes all the .scss files that should be modularized. This should exclude anything inside node_modules and everything inside src/css/base since they should be globally scoped.
5
- test:/\.scss$/,exclude:[_path.default.resolve(process.env.src_path,"./node_modules"),_path.default.resolve(process.env.src_path,"./src/static/css/base")],use:[isDev&&"css-hot-loader",!isSSR&&_miniCssExtractPlugin.default.loader,{loader:"css-loader",options:{modules:{mode:"local",exportOnlyLocals:!isDev&&isSSR,localIdentName:isDev?catalystConfig.cssModulesIdentifierDev:catalystConfig.cssModulesIdentifierProd}}},{loader:"postcss-loader"},{loader:"sass-loader",options:{additionalData:"$font_url: "+(0,_scssParams.fontUrl)()+";"+"$url_for: "+(0,_scssParams.imageUrl)()+";"}},{loader:"sass-resources-loader",options:{resources:[_path.default.resolve(process.env.src_path,"./src/static/css/resources/*.scss")]}}]},{// In development mode, client request app.css ,which has all the css in node_modules and src/static/css/base, This is served by webpack-dev-server. However in prod this css is injected in the doc sent from the server and needs to be global, so we don't pass the files through css-loader to be modularized.
6
- test:/\.scss$/,include:[_path.default.resolve(process.env.src_path,"./node_modules"),_path.default.resolve(process.env.src_path,"./src/static/css/base")],use:[isDev&&"css-hot-loader",!isSSR&&_miniCssExtractPlugin.default.loader,{loader:"css-loader"},{loader:"postcss-loader"},{loader:"sass-loader",options:{additionalData:"$font_url: "+(0,_scssParams.fontUrl)()+";"+"$url_for: "+(0,_scssParams.imageUrl)()+";"}},{loader:"sass-resources-loader",options:{resources:[_path.default.resolve(process.env.src_path,"./src/static/css/resources/*.scss")]}}]},{test:/\.css$/,use:[!isSSR&&_miniCssExtractPlugin.default.loader,"css-loader","postcss-loader"]},{test:/\.(png|jpg|gif|jpeg|ico?)$/,use:["url-loader?limit=10240","img-loader"]},{test:/\.svg$/i,issuer:/\.[jt]sx?$/,use:["@svgr/webpack","url-loader?limit=10240","img-loader"]},{// This loader loads fonts in src/static/fonts using file-loader
7
- test:/\.(ttf|eot|woff2|json?)$/,use:[{loader:"url-loader",options:{limit:10240,outputPath:[_path.default.resolve(process.env.src_path,"./src/static/fonts/")]}},"file-loader"]},{// This loader loads html files
8
- test:/\.html$/,use:[{loader:"html-loader",options:{minimize:{minifyJS:true,minifyCSS:true,removeComments:false,collapseWhitespace:true}}}]}]}};
@@ -1,4 +0,0 @@
1
- "use strict";var _path=_interopRequireDefault(require("path"));var _webpack=_interopRequireDefault(require("webpack"));var _webpackMerge=_interopRequireDefault(require("webpack-merge"));var _baseBabel=_interopRequireDefault(require("./base.babel.js"));var _webpackDevServer=_interopRequireDefault(require("webpack-dev-server"));var _miniCssExtractPlugin=_interopRequireDefault(require("mini-css-extract-plugin"));var _reactRefreshWebpackPlugin=_interopRequireDefault(require("@pmmmwh/react-refresh-webpack-plugin"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const{WEBPACK_DEV_SERVER_PORT,WEBPACK_DEV_SERVER_HOSTNAME}=process.env;const catalystConfig=require(_path.default.resolve(__dirname,"..","config.json"));const plugins=require(_path.default.join(process.env.src_path,"webpackConfig.js"));const webpackConfig=(0,_webpackMerge.default)(_baseBabel.default,{devtool:"inline-source-map",stats:"none",infrastructureLogging:{level:"none"},plugins:[new _reactRefreshWebpackPlugin.default({overlay:{entry:false}}),new _miniCssExtractPlugin.default({filename:catalystConfig.cssChunkFileName,ignoreOrder:true}),...plugins.developmentPlugins].filter(Boolean),optimization:{runtimeChunk:"single",moduleIds:"deterministic",splitChunks:{cacheGroups:{commonVendor:{test:/[\\/]node_modules[\\/](react|react-dom|react-redux|react-router|react-router-dom|redux|redux-thunk|axios|react-loadable-visibility|react-helmet-async|react-fast-compare|react-async-script|babel|@loadable\/component|catalyst)[\\/]/,name:"commonVendor",minSize:30000},utilityVendor:{maxInitialRequests:Infinity,chunks:"all",// minSize: 0, // Enable to replicate stand alone chunking for all packages
2
- reuseExistingChunk:true,// Disable to replicate stand alone chunking for all packages
3
- minRemainingSize:1000,// Disable to replicate stand alone chunking for all packages
4
- test:/[\\/]node_modules[\\/]/,name(module){const moduleFileName=module.identifier().split("/").reduceRight(item=>item);return`npm.${moduleFileName}`;}}}}}});let devServer=new _webpackDevServer.default({port:WEBPACK_DEV_SERVER_PORT,host:WEBPACK_DEV_SERVER_HOSTNAME,static:{publicPath:webpackConfig.output.publicPath},hot:true,historyApiFallback:true,headers:{"Access-Control-Allow-Origin":"*"},client:{logging:"error",overlay:{errors:false,warnings:false,runtimeErrors:false},reconnect:true}},(0,_webpack.default)(webpackConfig));devServer.startCallback(()=>{console.log("Catalyst is compiling your files.");console.log("Please wait until bundling is finished.\n");});
@@ -1,4 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _base=_interopRequireDefault(require("./base.babel"));var _miniCssExtractPlugin=_interopRequireDefault(require("mini-css-extract-plugin"));var _path=_interopRequireDefault(require("path"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const{mergeWithCustomize,customizeArray,customizeObject}=require("webpack-merge");const plugins=require(_path.default.join(process.env.src_path,"webpackConfig.js"));const catalystConfig=require(_path.default.resolve(__dirname,"..","config.json"));const clientConfig=mergeWithCustomize({customizeArray:customizeArray({entry:"prepend",plugins:"append",module:"prepend"}),customizeObject:customizeObject({entry:"prepend",plugins:"append",module:"prepend"})})(_base.default,{mode:"production",stats:"errors-only",optimization:{runtimeChunk:"single",moduleIds:"deterministic",splitChunks:{cacheGroups:{commonVendor:{chunks:"all",test:/[\\/]node_modules[\\/](react|react-dom|react-redux|react-router|react-router-dom|redux|redux-thunk|axios|react-loadable-visibility|react-helmet-async|react-fast-compare|react-async-script|babel|@loadable\/component|catalyst)[\\/]/,name:"commonVendor",minSize:400000,maxSize:400000},utilityVendor:{maxInitialRequests:Infinity,chunks:"all",// minSize: 0, // Enable to replicate stand alone chunking for all packages
2
- reuseExistingChunk:true,// Disable to replicate stand alone chunking for all packages
3
- minRemainingSize:1000,// Disable to replicate stand alone chunking for all packages
4
- minSize:1000,maxSize:120000,test:/[\\/]node_modules[\\/]/,name(module){const moduleFileName=module.identifier().split("/").reverse().slice(0,3).reduce((item,current)=>{item=current+"."+item;return item;},[]);return`npm.${moduleFileName}`;}}},chunks:"all",name(module){const moduleFileName=module.identifier().split("/").reverse().slice(0,3).reduce((item,current)=>{item=current+"."+item;return item;},[]);return`npm.${moduleFileName}`;}}},plugins:[new _miniCssExtractPlugin.default({filename:catalystConfig.cssChunkFileName,ignoreOrder:true}),...plugins.clientPlugins]});var _default=exports.default=clientConfig;
@@ -1,4 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _webpackNodeExternals=_interopRequireDefault(require("webpack-node-externals"));var _path=_interopRequireDefault(require("path"));var _base=_interopRequireDefault(require("./base.babel"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}const{mergeWithCustomize,customizeArray,customizeObject}=require("webpack-merge");const rootWorkspacePath=require("app-root-path");const catalystConfig=require(_path.default.resolve(__dirname,"..","config.json"));const plugins=require(_path.default.join(process.env.src_path,"webpackConfig.js"));const ssrConfig=mergeWithCustomize({customizeArray:customizeArray({entry:"replace",optimization:"replace",plugins:"prepend"}),customizeObject:customizeObject({entry:"replace",optimization:"replace",plugins:"prepend"})})(_base.default,{mode:"production",stats:"errors-only",optimization:{splitChunks:{chunks:"all",minSize:10000000,name:false}},plugins:[...plugins.ssrPlugins],target:"node",entry:{handler:_path.default.resolve(__dirname,"..","./server/renderer/handler.js")},externals:[// images are handled by isomorphic webpack.
2
- // html files are required directly
3
- /\.(html|png|gif|jpg)$/,// treat all node modules as external to keep this bundle small
4
- (0,_webpackNodeExternals.default)({modulesDir:_path.default.resolve(process.env.src_path,"./node_modules")}),(0,_webpackNodeExternals.default)({modulesDir:_path.default.join(rootWorkspacePath.path,"./node_modules")})],output:{path:_path.default.join(process.env.src_path,process.env.BUILD_OUTPUT_PATH,"/renderer"),chunkFilename:catalystConfig.chunkFileNameProd,filename:"handler.js",libraryTarget:"commonjs"}});var _default=exports.default=ssrConfig;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes