catalyst-core-internal 0.0.1-beta.1 → 0.0.1-beta.10

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 (79) hide show
  1. package/.eslintignore +9 -0
  2. package/.eslintrc +92 -0
  3. package/README.md +45 -43
  4. package/babel.config.json +1 -5
  5. package/bin/catalyst.js +35 -34
  6. package/config.json +1 -1
  7. package/license +10 -0
  8. package/logger.js +3 -0
  9. package/package.json +87 -82
  10. package/scripts/build.js +21 -8
  11. package/scripts/devBuild.js +42 -0
  12. package/scripts/devServe.js +43 -0
  13. package/scripts/loadScriptsBeforeServerStarts.js +1 -1
  14. package/scripts/serve.js +21 -8
  15. package/scripts/start.js +17 -8
  16. package/scripts/validator.js +1 -4
  17. package/server/renderer/document/Head.js +2 -2
  18. package/server/renderer/handler.js +42 -46
  19. package/server/renderer/render.js +14 -3
  20. package/server/startServer.js +2 -1
  21. package/server/utils/metaTags.js +13 -0
  22. package/server/utils/userAgentUtil.js +3 -7
  23. package/server/utils/validator.js +1 -4
  24. package/webpack/babel.config.client.js +1 -1
  25. package/webpack/babel.config.ssr.js +1 -1
  26. package/webpack/base.babel.js +12 -2
  27. package/webpack/development.client.babel.js +6 -3
  28. package/webpack/production.ssr.babel.js +1 -1
  29. package/webpack/scssParams.js +18 -2
  30. package/packages/create-framework-app/templates/redux-js/node_modules/@babel/core/lib/config/caching.js +0 -261
  31. package/packages/create-framework-app/templates/redux-js/node_modules/@remix-run/router/dist/router.js +0 -4327
  32. package/packages/create-framework-app/templates/redux-js/node_modules/catalyst/router.js +0 -15
  33. package/packages/create-framework-app/templates/redux-js/node_modules/catalyst/src/router.js +0 -1
  34. package/packages/create-framework-app/templates/redux-js/node_modules/http-proxy-middleware/dist/router.js +0 -46
  35. package/types/caching.d.ts +0 -1
  36. package/types/config/config.d.ts +0 -19
  37. package/types/index.d.ts +0 -1
  38. package/types/logger/index.d.ts +0 -14
  39. package/types/reducer/index.d.ts +0 -22
  40. package/types/reducer/loadableConfigReducer.d.ts +0 -9
  41. package/types/router/ClientRouter.d.ts +0 -5
  42. package/types/router/ServerRouter.d.ts +0 -7
  43. package/types/router/index.d.ts +0 -8
  44. package/types/router.d.ts +0 -1
  45. package/types/scripts/build.d.ts +0 -1
  46. package/types/scripts/loadEnvironmentVariables.d.ts +0 -5
  47. package/types/scripts/loadScriptsBeforeServerStarts.d.ts +0 -1
  48. package/types/scripts/prepare.d.ts +0 -1
  49. package/types/scripts/registerAliases.d.ts +0 -1
  50. package/types/scripts/serve.d.ts +0 -1
  51. package/types/scripts/start.d.ts +0 -1
  52. package/types/scripts/validator.d.ts +0 -9
  53. package/types/scripts/verifyConfig.d.ts +0 -1
  54. package/types/server/mainIndex.d.ts +0 -1
  55. package/types/server/mainServer.d.ts +0 -2
  56. package/types/server/renderer/document/Body.d.ts +0 -11
  57. package/types/server/renderer/document/Head.d.ts +0 -11
  58. package/types/server/renderer/document/index.d.ts +0 -2
  59. package/types/server/renderer/extract.d.ts +0 -18
  60. package/types/server/renderer/handler.d.ts +0 -6
  61. package/types/server/renderer/index.d.ts +0 -2
  62. package/types/server/renderer/render.d.ts +0 -38
  63. package/types/server/renderer/userAgentUtil.d.ts +0 -1
  64. package/types/store/index.d.ts +0 -11
  65. package/types/store/index.dev.d.ts +0 -8
  66. package/types/store/index.prod.d.ts +0 -8
  67. package/types/webpack/babel-plugins/remove-client.plugin.d.ts +0 -10
  68. package/types/webpack/babel-plugins/remove-ssr.plugin.d.ts +0 -10
  69. package/types/webpack/babel.config.client.d.ts +0 -21
  70. package/types/webpack/babel.config.d.ts +0 -16
  71. package/types/webpack/babel.config.ssr.d.ts +0 -21
  72. package/types/webpack/base.babel.d.ts +0 -184
  73. package/types/webpack/development.client.babel.d.ts +0 -1
  74. package/types/webpack/plugins/mime-types.d.ts +0 -78
  75. package/types/webpack/plugins/route-manifest-plugin.d.ts +0 -1
  76. package/types/webpack/plugins/upload-assets-plugin.d.ts +0 -1
  77. package/types/webpack/production.client.babel.d.ts +0 -174
  78. package/types/webpack/production.ssr.babel.d.ts +0 -2
  79. package/types/webpack/scssParams.d.ts +0 -2
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ const {
4
+ spawnSync
5
+ } = require("child_process");
6
+ const path = require("path");
7
+ const {
8
+ name
9
+ } = require(`${process.env.PWD}/package.json`);
10
+ const {
11
+ BUILD_OUTPUT_PATH
12
+ } = require(`${process.env.PWD}/config/config.json`);
13
+ function arrayToObject(array) {
14
+ const obj = {};
15
+ array.forEach(item => {
16
+ const [key, value] = item.split("=");
17
+ if (value) obj[key] = value;
18
+ });
19
+ return obj;
20
+ }
21
+
22
+ /**
23
+ * @description - creates a production build of the application.
24
+ */
25
+ function start() {
26
+ const commandLineArguments = process.argv.slice(2);
27
+ const argumentsObject = arrayToObject(commandLineArguments);
28
+ const dirname = path.resolve(__dirname, "../");
29
+ spawnSync("npm", ["run", "build", `--src_path=${process.env.PWD}`, `--app_name=${name || "catalyst_app"}`], {
30
+ cwd: dirname,
31
+ stdio: "inherit",
32
+ env: {
33
+ ...process.env,
34
+ src_path: process.env.PWD,
35
+ build_output_path: BUILD_OUTPUT_PATH,
36
+ NODE_ENV: "production",
37
+ IS_DEV_COMMAND: true,
38
+ ...argumentsObject
39
+ }
40
+ });
41
+ }
42
+ start();
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ const {
4
+ spawnSync
5
+ } = require("child_process");
6
+ const path = require("path");
7
+ const {
8
+ name
9
+ } = require(`${process.env.PWD}/package.json`);
10
+ const {
11
+ BUILD_OUTPUT_PATH
12
+ } = require(`${process.env.PWD}/config/config.json`);
13
+ function arrayToObject(array) {
14
+ const obj = {};
15
+ array.forEach(item => {
16
+ const [key, value] = item.split("=");
17
+ if (value) obj[key] = value;
18
+ });
19
+ return obj;
20
+ }
21
+
22
+ /**
23
+ * @description - Serves production build of the application.
24
+ */
25
+
26
+ function start() {
27
+ const commandLineArguments = process.argv.slice(2);
28
+ const argumentsObject = arrayToObject(commandLineArguments);
29
+ const dirname = path.resolve(__dirname, "../");
30
+ spawnSync("npm", ["run", "serve", `--src_path=${process.env.PWD}`, `--app_name=${name || "catalyst_app"}`], {
31
+ cwd: dirname,
32
+ stdio: "inherit",
33
+ env: {
34
+ ...process.env,
35
+ src_path: process.env.PWD,
36
+ build_output_path: BUILD_OUTPUT_PATH,
37
+ NODE_ENV: "production",
38
+ IS_DEV_COMMAND: true,
39
+ ...argumentsObject
40
+ }
41
+ });
42
+ }
43
+ start();
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _cssModulesRequireHook = _interopRequireDefault(require("css-modules-require-hook"));
3
+ var _cssModulesRequireHook = _interopRequireDefault(require("@dr.pogodin/css-modules-require-hook"));
4
4
  var _path = _interopRequireDefault(require("path"));
5
5
  var _moduleAlias = _interopRequireDefault(require("module-alias"));
6
6
  var _loadEnvironmentVariables = _interopRequireDefault(require("./loadEnvironmentVariables"));
package/scripts/serve.js CHANGED
@@ -1,10 +1,5 @@
1
1
  "use strict";
2
2
 
3
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
7
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
3
  const {
9
4
  spawnSync
10
5
  } = require("child_process");
@@ -12,19 +7,37 @@ const path = require("path");
12
7
  const {
13
8
  name
14
9
  } = require(`${process.env.PWD}/package.json`);
10
+ const {
11
+ BUILD_OUTPUT_PATH
12
+ } = require(`${process.env.PWD}/config/config.json`);
13
+ function arrayToObject(array) {
14
+ const obj = {};
15
+ array.forEach(item => {
16
+ const [key, value] = item.split("=");
17
+ if (value) obj[key] = value;
18
+ });
19
+ return obj;
20
+ }
15
21
 
16
22
  /**
17
23
  * @description - Serves production build of the application.
18
24
  */
19
25
 
20
26
  function start() {
27
+ const commandLineArguments = process.argv.slice(2);
28
+ const argumentsObject = arrayToObject(commandLineArguments);
21
29
  const dirname = path.resolve(__dirname, "../");
22
30
  spawnSync("npm", ["run", "serve", `--src_path=${process.env.PWD}`, `--app_name=${name || "catalyst_app"}`], {
23
31
  cwd: dirname,
24
32
  stdio: "inherit",
25
- env: _objectSpread(_objectSpread({}, process.env), {}, {
26
- src_path: process.env.PWD
27
- })
33
+ env: {
34
+ ...process.env,
35
+ src_path: process.env.PWD,
36
+ build_output_path: BUILD_OUTPUT_PATH,
37
+ NODE_ENV: "production",
38
+ IS_DEV_COMMAND: false,
39
+ ...argumentsObject
40
+ }
28
41
  });
29
42
  }
30
43
  start();
package/scripts/start.js CHANGED
@@ -1,26 +1,35 @@
1
1
  "use strict";
2
2
 
3
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
7
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
3
  const {
9
4
  spawnSync
10
5
  } = require("child_process");
11
6
  const path = require("path");
7
+ function arrayToObject(array) {
8
+ const obj = {};
9
+ array.forEach(item => {
10
+ const [key, value] = item.split("=");
11
+ if (value) obj[key] = value;
12
+ });
13
+ return obj;
14
+ }
12
15
 
13
16
  /**
14
17
  * @description - starts webpack dev server and node server.
15
18
  */
16
19
  function start() {
20
+ const commandLineArguments = process.argv.slice(2);
21
+ const argumentsObject = arrayToObject(commandLineArguments);
17
22
  const dirname = path.resolve(__dirname, "../");
18
23
  spawnSync("npm", ["run", "start", `--src_path=${process.env.PWD}`], {
19
24
  cwd: dirname,
20
25
  stdio: "inherit",
21
- env: _objectSpread(_objectSpread({}, process.env), {}, {
22
- src_path: process.env.PWD
23
- })
26
+ env: {
27
+ ...process.env,
28
+ src_path: process.env.PWD,
29
+ NODE_ENV: "development",
30
+ IS_DEV_COMMAND: false,
31
+ ...argumentsObject
32
+ }
24
33
  });
25
34
  }
26
35
  start();
@@ -44,8 +44,6 @@ const validateConfigFile = obj => {
44
44
  BUILD_OUTPUT_PATH: "",
45
45
  PUBLIC_STATIC_ASSET_PATH: "",
46
46
  PUBLIC_STATIC_ASSET_URL: "",
47
- NODE_ENV: "",
48
- BUILD_ENV: "",
49
47
  CLIENT_ENV_VARIABLES: [],
50
48
  ANALYZE_BUNDLE: ""
51
49
  };
@@ -78,8 +76,7 @@ const validateModuleAlias = obj => {
78
76
  "@server": "server",
79
77
  "@config": "config",
80
78
  "@css": "src/static/css",
81
- "@routes": "src/js/routes/",
82
- "@store": "src/js/store/index.js"
79
+ "@routes": "src/js/routes/"
83
80
  };
84
81
  for (let key in requiredModuleAliases) {
85
82
  if (!(key in obj)) throw new Error(`${key} module alias not defined inside package.json`);
@@ -19,7 +19,7 @@ function Head(props) {
19
19
  const {
20
20
  pageCss,
21
21
  pageJS,
22
- metaTagFunction,
22
+ metaTags,
23
23
  isBot,
24
24
  publicAssetPath,
25
25
  fetcherData
@@ -35,7 +35,7 @@ function Head(props) {
35
35
  }), publicAssetPath && /*#__PURE__*/_react.default.createElement("link", {
36
36
  rel: "dns-prefetch",
37
37
  href: publicAssetPath
38
- }), metaTagFunction && metaTagFunction(fetcherData), !isBot && pageJS, !isBot && /*#__PURE__*/_react.default.createElement("style", {
38
+ }), metaTags && metaTags, !isBot && pageJS, !isBot && /*#__PURE__*/_react.default.createElement("style", {
39
39
  dangerouslySetInnerHTML: {
40
40
  __html: pageCss
41
41
  }
@@ -20,24 +20,27 @@ var _server2 = require("@loadable/server");
20
20
  var _server3 = require("react-dom/server");
21
21
  var _validator = require("../utils/validator");
22
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
24
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
25
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
26
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
27
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
28
23
  const {
29
24
  getRoutes
30
25
  } = require(`${process.env.src_path}/src/js/routes/utils.js`);
31
26
  const {
32
27
  default: CustomDocument
33
28
  } = require(`${process.env.src_path}/server/document.js`);
34
- const storePath = `${process.env.src_path}/src/js/store/index.js`;
29
+ const storePath = _path.default.resolve(`${process.env.src_path}/src/js/store/index.js`);
35
30
  let createStore;
36
31
  if (_fs.default.existsSync(storePath)) {
37
- const {
38
- default: configureStore
39
- } = require(storePath);
40
- createStore = configureStore;
32
+ try {
33
+ const {
34
+ default: configureStore
35
+ } = require(`${process.env.src_path}/src/js/store/index.js`);
36
+ createStore = configureStore;
37
+ } catch (error) {
38
+ createStore = () => {
39
+ return {
40
+ getState: () => {}
41
+ };
42
+ };
43
+ }
41
44
  } else {
42
45
  createStore = () => {
43
46
  return {
@@ -89,9 +92,7 @@ const getMatchRoutes = (routes, req, res, store, context, fetcherData) => {
89
92
  matches.push({
90
93
  route,
91
94
  match,
92
- serverSideFunction: wc && wc.serverSideFunction || (() => Promise.resolve()),
93
- metaTagFunction: wc && wc.metaTagFunction || null,
94
- serverFetcher: wc && wc.serverFetcher || (() => Promise.resolve())
95
+ serverSideFunction: wc && wc.serverSideFunction || (() => Promise.resolve())
95
96
  });
96
97
  }
97
98
  if (!match && route.routes) {
@@ -119,24 +120,25 @@ const getComponent = (store, context, req, fetcherData) => {
119
120
  intialData: fetcherData
120
121
  }))));
121
122
  };
122
-
123
123
  // sends document after rendering
124
- const renderMarkUp = async (errorCode, req, res, metaTagFunction, fetcherData, store, matches, context) => {
124
+ const renderMarkUp = async (errorCode, req, res, metaTags, fetcherData, store, matches, context) => {
125
125
  const deviceDetails = (0, _userAgentUtil.getUserAgentDetails)(req.headers["user-agent"] || "");
126
126
  const isBot = deviceDetails.googleBot ? true : false;
127
127
 
128
128
  // Transforms Head Props
129
- const shellStart = await _render.default.renderStart(res.locals.pageCss, res.locals.pageJS, metaTagFunction, isBot, fetcherData);
129
+ const shellStart = await _render.default.renderStart(res.locals.pageCss, res.locals.pageJS, metaTags, isBot, fetcherData);
130
130
  let state = store.getState();
131
131
  const jsx = webExtractor.collectChunks(getComponent(store, context, req, fetcherData));
132
132
 
133
133
  // Transforms Body Props
134
134
  const shellEnd = _render.default.renderEnd(webExtractor, state, res, jsx, errorCode, fetcherData);
135
- const finalProps = _objectSpread(_objectSpread(_objectSpread({}, shellStart), shellEnd), {}, {
135
+ const finalProps = {
136
+ ...shellStart,
137
+ ...shellEnd,
136
138
  jsx: jsx,
137
139
  req,
138
140
  res
139
- });
141
+ };
140
142
  let CompleteDocument = () => {
141
143
  if ((0, _validator.validateCustomDocument)(CustomDocument)) {
142
144
  return CustomDocument(finalProps);
@@ -148,7 +150,7 @@ const renderMarkUp = async (errorCode, req, res, metaTagFunction, fetcherData, s
148
150
  pageJS: finalProps.pageJS,
149
151
  pageCss: finalProps.pageCss,
150
152
  fetcherData: finalProps.fetcherData,
151
- metaTagFunction: finalProps.metaTagFunction,
153
+ metaTags: finalProps.metaTags,
152
154
  publicAssetPath: finalProps.publicAssetPath
153
155
  }), /*#__PURE__*/_react.default.createElement(_document.Body, {
154
156
  initialState: finalProps.initialState,
@@ -194,7 +196,6 @@ async function _default(req, res) {
194
196
  try {
195
197
  let context = {};
196
198
  let fetcherData = {};
197
- let metaTagFunction = null;
198
199
 
199
200
  // creates store
200
201
  const store = (0, _validator.validateConfigureStore)(createStore) ? createStore({}, req) : null;
@@ -204,39 +205,34 @@ async function _default(req, res) {
204
205
 
205
206
  // Matches req url with routes
206
207
  const matches = getMatchRoutes(routes, req, res, store, context, fetcherData);
208
+ const allMatches = (0, _router.matchRoutes)(getRoutes(), req.baseUrl);
209
+ let allTags = [];
207
210
 
208
211
  // Executing app server side function
209
212
  _App.default.serverSideFunction({
210
213
  store,
211
- req
212
- }).then(() => {
213
- const serverSideFunction = matches.map(match => {
214
- if (match?.metaTagFunction) {
215
- metaTagFunction = match.metaTagFunction;
216
- }
217
- return match.serverSideFunction({
218
- store
219
- });
220
- });
221
-
222
- // Executing serverFetcher functions with serverDataFetcher provided by router and returning document
223
- Promise.all(serverSideFunction).then(() => {
224
- (0, _router.serverDataFetcher)({
225
- routes: routes,
226
- req,
227
- url: req.originalUrl
228
- }, {
229
- store
230
- }).then(res => {
231
- fetcherData = res;
232
- }).then(async () => await renderMarkUp(null, req, res, metaTagFunction, fetcherData, store, matches, context)).catch(async error => {
233
- logger.error("Error in executting serverFetcher functions: " + error);
234
- await renderMarkUp(404, req, res, metaTagFunction, fetcherData, store, matches, context);
235
- });
214
+ req,
215
+ res
216
+ })
217
+ // Executing serverFetcher functions with serverDataFetcher provided by router and returning document
218
+ .then(() => {
219
+ (0, _router.serverDataFetcher)({
220
+ routes: routes,
221
+ req,
222
+ res,
223
+ url: req.originalUrl
224
+ }, {
225
+ store
226
+ }).then(res => {
227
+ fetcherData = res;
228
+ allTags = (0, _router.getMetaData)(allMatches, fetcherData);
229
+ }).then(async () => await renderMarkUp(null, req, res, allTags, fetcherData, store, matches, context)).catch(async error => {
230
+ logger.error("Error in executing serverFetcher functions: " + error);
231
+ await renderMarkUp(404, req, res, allTags, fetcherData, store, matches, context);
236
232
  });
237
233
  }).catch(error => {
238
234
  logger.error("Error in executing serverSideFunction inside App: " + error);
239
- renderMarkUp(error.status_code, req, res, metaTagFunction, fetcherData, store, matches, context);
235
+ renderMarkUp(error.status_code, req, res, allTags, fetcherData, store, matches, context);
240
236
  });
241
237
  } catch (error) {
242
238
  logger.error("Error in handling document request: " + error.toString());
@@ -13,13 +13,24 @@ var _extract = require("./extract");
13
13
  * @param {boolean} isBot - checks if request is made by bot
14
14
  * @param {object} fetcherData - router fetched data
15
15
  */
16
- const renderStart = (pageCss, pageJS, metaTagFunction, isBot, fetcherData) => {
16
+ const renderStart = (pageCss, pageJS, metaTags, isBot, fetcherData) => {
17
+ const {
18
+ IS_DEV_COMMAND,
19
+ WEBPACK_DEV_SERVER_HOSTNAME,
20
+ WEBPACK_DEV_SERVER_PORT
21
+ } = process.env;
22
+ let publicAssetPath = `${process.env.PUBLIC_STATIC_ASSET_URL}${process.env.PUBLIC_STATIC_ASSET_PATH}`;
23
+
24
+ // serves assets from localhost on running devBuild and devServe command
25
+ if (JSON.parse(IS_DEV_COMMAND)) {
26
+ publicAssetPath = `http://${WEBPACK_DEV_SERVER_HOSTNAME}:${WEBPACK_DEV_SERVER_PORT}/assets/`;
27
+ }
17
28
  return {
18
29
  pageCss,
19
30
  pageJS,
20
- metaTagFunction,
31
+ metaTags,
21
32
  isBot,
22
- publicAssetPath: `${process.env.PUBLIC_STATIC_ASSET_URL}${process.env.PUBLIC_STATIC_ASSET_PATH}`,
33
+ publicAssetPath,
23
34
  fetcherData
24
35
  };
25
36
  };
@@ -5,6 +5,7 @@ var _chokidar = _interopRequireDefault(require("chokidar"));
5
5
  var _path = _interopRequireDefault(require("path"));
6
6
  var _index = require("@server/index.js");
7
7
  var _validator = require("./utils/validator.js");
8
+ var _picocolors = _interopRequireDefault(require("picocolors"));
8
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
10
  const env = process.env.NODE_ENV || "development";
10
11
 
@@ -58,7 +59,7 @@ watcher.on("all", (event, path) => {
58
59
  if (error) {
59
60
  console.log("An error occured while starting the Application server : ", error);
60
61
  } else {
61
- console.log(`Application server is mounted on http://${host}:${port}.`);
62
+ console.log(_picocolors.default.cyan(_picocolors.default.bold(`Application server is mounted on ${_picocolors.default.yellow(`http://${host}:${port}`)}.`)));
62
63
  }
63
64
  });
64
65
  }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.mergeMetaTags = void 0;
7
+ const mergeMetaTags = (parentTags, childTags) => {};
8
+ exports.mergeMetaTags = mergeMetaTags;
9
+ const typesOfMeta = {};
10
+
11
+ // type
12
+ // props
13
+ // children
@@ -6,11 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getUserAgentDetails = void 0;
7
7
  var _uaParserJs = _interopRequireDefault(require("ua-parser-js"));
8
8
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
10
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
- function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
12
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
13
- function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
14
9
  const googleBots = {
15
10
  "APIs-Google": "APIs-Google",
16
11
  AdSense: "Mediapartners-Google",
@@ -48,8 +43,9 @@ const getGoogleBot = ua => {
48
43
  const getUserAgentDetails = ua => {
49
44
  const agentDetails = (0, _uaParserJs.default)(ua);
50
45
  const googleBot = getGoogleBot(ua);
51
- return _objectSpread(_objectSpread({}, agentDetails), {}, {
46
+ return {
47
+ ...agentDetails,
52
48
  googleBot
53
- });
49
+ };
54
50
  };
55
51
  exports.getUserAgentDetails = getUserAgentDetails;
@@ -44,8 +44,6 @@ const validateConfigFile = obj => {
44
44
  BUILD_OUTPUT_PATH: "",
45
45
  PUBLIC_STATIC_ASSET_PATH: "",
46
46
  PUBLIC_STATIC_ASSET_URL: "",
47
- NODE_ENV: "",
48
- BUILD_ENV: "",
49
47
  CLIENT_ENV_VARIABLES: [],
50
48
  ANALYZE_BUNDLE: ""
51
49
  };
@@ -78,8 +76,7 @@ const validateModuleAlias = obj => {
78
76
  "@server": "server",
79
77
  "@config": "config",
80
78
  "@css": "src/static/css",
81
- "@routes": "src/js/routes/",
82
- "@store": "src/js/store/index.js"
79
+ "@routes": "src/js/routes/"
83
80
  };
84
81
  for (let key in requiredModuleAliases) {
85
82
  if (!(key in obj)) throw new Error(`${key} module alias not defined inside package.json`);
@@ -11,7 +11,7 @@ var _default = exports.default = {
11
11
  browsers: "last 2 versions"
12
12
  }
13
13
  }], "@babel/preset-react"],
14
- plugins: ["@babel/plugin-proposal-object-rest-spread", "@babel/plugin-transform-react-jsx", "transform-class-properties", "transform-export-extensions", "syntax-dynamic-import", "@loadable/babel-plugin"],
14
+ plugins: ["@loadable/babel-plugin"],
15
15
  env: {
16
16
  production: {
17
17
  plugins: [require("./babel-plugins/remove-ssr.plugin").default, "transform-react-remove-prop-types"]
@@ -11,7 +11,7 @@ var _default = exports.default = {
11
11
  node: "current"
12
12
  }
13
13
  }], "@babel/preset-react"],
14
- plugins: ["@babel/plugin-proposal-object-rest-spread", "@babel/plugin-transform-react-jsx", "transform-class-properties", "transform-export-extensions", "syntax-dynamic-import", "@loadable/babel-plugin"],
14
+ plugins: ["@loadable/babel-plugin"],
15
15
  env: {
16
16
  development: {
17
17
  plugins: ["react-refresh/babel"]
@@ -46,10 +46,20 @@ ANALYZE_BUNDLE && new _webpackBundleAnalyzer.BundleAnalyzerPlugin({
46
46
  contextRegExp: /moment$/
47
47
  })];
48
48
  const {
49
+ IS_DEV_COMMAND,
49
50
  PUBLIC_STATIC_ASSET_URL,
50
- PUBLIC_STATIC_ASSET_PATH
51
+ PUBLIC_STATIC_ASSET_PATH,
52
+ WEBPACK_DEV_SERVER_HOSTNAME,
53
+ WEBPACK_DEV_SERVER_PORT,
54
+ NODE_SERVER_HOSTNAME,
55
+ NODE_SERVER_PORT
51
56
  } = process.env;
52
- let publicPath = `${PUBLIC_STATIC_ASSET_URL}${PUBLIC_STATIC_ASSET_PATH}`;
57
+ let publicPath = isDev ? `http://${WEBPACK_DEV_SERVER_HOSTNAME}:${WEBPACK_DEV_SERVER_PORT}/` : `${PUBLIC_STATIC_ASSET_URL}${PUBLIC_STATIC_ASSET_PATH}`;
58
+
59
+ // serves assets from local on running devBuild and devServe command
60
+ if (JSON.parse(IS_DEV_COMMAND) && !isDev) {
61
+ publicPath = `http://${NODE_SERVER_HOSTNAME}:${NODE_SERVER_PORT}/assets/`;
62
+ }
53
63
  var _default = exports.default = {
54
64
  context: _path.default.resolve(process.env.src_path),
55
65
  mode: isDev ? "development" : "production",
@@ -12,7 +12,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
12
12
 
13
13
  const {
14
14
  WEBPACK_DEV_SERVER_PORT,
15
- WEBPACK_DEV_SERVER_HOSTNAME
15
+ WEBPACK_DEV_SERVER_HOSTNAME,
16
+ NODE_SERVER_PORT,
17
+ NODE_SERVER_HOSTNAME
16
18
  } = process.env;
17
19
  const catalystConfig = require(_path.default.resolve(__dirname, "..", "config.json"));
18
20
  const plugins = require(_path.default.join(process.env.src_path, "webpackConfig.js"));
@@ -57,13 +59,14 @@ const webpackConfig = (0, _webpackMerge.default)(_baseBabel.default, {
57
59
  });
58
60
  console.info("Firing up catalyst dev server...\n");
59
61
  let devServer = new _webpackDevServer.default({
60
- port: process.env.WEBPACK_DEV_SERVER_PORT,
61
- host: process.env.WEBPACK_DEV_SERVER_HOSTNAME,
62
+ port: WEBPACK_DEV_SERVER_PORT,
63
+ host: WEBPACK_DEV_SERVER_HOSTNAME,
62
64
  static: {
63
65
  publicPath: webpackConfig.output.publicPath
64
66
  },
65
67
  hot: true,
66
68
  historyApiFallback: true,
69
+ open: [`http://${NODE_SERVER_HOSTNAME}:${NODE_SERVER_PORT}`],
67
70
  headers: {
68
71
  "Access-Control-Allow-Origin": "*"
69
72
  },
@@ -36,7 +36,7 @@ const ssrConfig = mergeWithCustomize({
36
36
  name: false
37
37
  }
38
38
  },
39
- plugins: [...plugins.ssrPrugins],
39
+ plugins: [...plugins.ssrPlugins],
40
40
  target: "node",
41
41
  entry: {
42
42
  handler: _path.default.resolve(__dirname, "..", "./server/renderer/handler.js")
@@ -11,9 +11,17 @@ exports.imageUrl = exports.fontUrl = void 0;
11
11
  const imageUrl = () => {
12
12
  const {
13
13
  PUBLIC_STATIC_ASSET_URL,
14
- PUBLIC_STATIC_ASSET_PATH
14
+ PUBLIC_STATIC_ASSET_PATH,
15
+ IS_DEV_COMMAND,
16
+ NODE_SERVER_HOSTNAME,
17
+ NODE_SERVER_PORT
15
18
  } = process.env;
16
19
  let publicPath = `${PUBLIC_STATIC_ASSET_URL}${PUBLIC_STATIC_ASSET_PATH}`;
20
+
21
+ // serves assets from localhost on running devBuild and devServe command
22
+ if (JSON.parse(IS_DEV_COMMAND)) {
23
+ publicPath = `http://${NODE_SERVER_HOSTNAME}:${NODE_SERVER_PORT}/${PUBLIC_STATIC_ASSET_PATH}`;
24
+ }
17
25
  const imagePath = JSON.stringify(`${publicPath}images/`);
18
26
  return imagePath;
19
27
  };
@@ -26,9 +34,17 @@ exports.imageUrl = imageUrl;
26
34
  const fontUrl = () => {
27
35
  const {
28
36
  PUBLIC_STATIC_ASSET_URL,
29
- PUBLIC_STATIC_ASSET_PATH
37
+ PUBLIC_STATIC_ASSET_PATH,
38
+ IS_DEV_COMMAND,
39
+ NODE_SERVER_HOSTNAME,
40
+ NODE_SERVER_PORT
30
41
  } = process.env;
31
42
  let publicPath = `${PUBLIC_STATIC_ASSET_URL}${PUBLIC_STATIC_ASSET_PATH}`;
43
+
44
+ // serves assets from localhost on running devBuild and devServe command
45
+ if (JSON.parse(IS_DEV_COMMAND)) {
46
+ publicPath = `http://${NODE_SERVER_HOSTNAME}:${NODE_SERVER_PORT}/${PUBLIC_STATIC_ASSET_PATH}`;
47
+ }
32
48
  const fontPath = JSON.stringify(`${publicPath}fonts/`);
33
49
  return fontPath;
34
50
  };