catalyst-core 0.0.1-beta.3 → 0.0.1-beta.4

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 (77) hide show
  1. package/.eslintignore +9 -0
  2. package/.eslintrc +92 -0
  3. package/README.md +44 -42
  4. package/babel.config.json +1 -5
  5. package/bin/catalyst.js +35 -34
  6. package/changelog.md +26 -0
  7. package/config.json +1 -1
  8. package/logger.js +3 -0
  9. package/package.json +87 -83
  10. package/scripts/build.js +17 -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 +17 -8
  15. package/scripts/start.js +17 -8
  16. package/scripts/validator.js +0 -1
  17. package/server/renderer/document/Head.js +2 -2
  18. package/server/renderer/handler.js +33 -45
  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 +0 -1
  24. package/webpack/babel.config.client.js +1 -1
  25. package/webpack/babel.config.ssr.js +1 -1
  26. package/webpack/base.babel.js +9 -1
  27. package/webpack/scssParams.js +18 -2
  28. package/packages/create-framework-app/templates/redux-js/node_modules/@babel/core/lib/config/caching.js +0 -261
  29. package/packages/create-framework-app/templates/redux-js/node_modules/@remix-run/router/dist/router.js +0 -4327
  30. package/packages/create-framework-app/templates/redux-js/node_modules/catalyst/router.js +0 -15
  31. package/packages/create-framework-app/templates/redux-js/node_modules/catalyst/src/router.js +0 -1
  32. package/packages/create-framework-app/templates/redux-js/node_modules/http-proxy-middleware/dist/router.js +0 -46
  33. package/types/caching.d.ts +0 -1
  34. package/types/config/config.d.ts +0 -19
  35. package/types/index.d.ts +0 -1
  36. package/types/logger/index.d.ts +0 -14
  37. package/types/reducer/index.d.ts +0 -22
  38. package/types/reducer/loadableConfigReducer.d.ts +0 -9
  39. package/types/router/ClientRouter.d.ts +0 -5
  40. package/types/router/ServerRouter.d.ts +0 -7
  41. package/types/router/index.d.ts +0 -8
  42. package/types/router.d.ts +0 -1
  43. package/types/scripts/build.d.ts +0 -1
  44. package/types/scripts/loadEnvironmentVariables.d.ts +0 -5
  45. package/types/scripts/loadScriptsBeforeServerStarts.d.ts +0 -1
  46. package/types/scripts/prepare.d.ts +0 -1
  47. package/types/scripts/registerAliases.d.ts +0 -1
  48. package/types/scripts/serve.d.ts +0 -1
  49. package/types/scripts/start.d.ts +0 -1
  50. package/types/scripts/validator.d.ts +0 -9
  51. package/types/scripts/verifyConfig.d.ts +0 -1
  52. package/types/server/mainIndex.d.ts +0 -1
  53. package/types/server/mainServer.d.ts +0 -2
  54. package/types/server/renderer/document/Body.d.ts +0 -11
  55. package/types/server/renderer/document/Head.d.ts +0 -11
  56. package/types/server/renderer/document/index.d.ts +0 -2
  57. package/types/server/renderer/extract.d.ts +0 -18
  58. package/types/server/renderer/handler.d.ts +0 -6
  59. package/types/server/renderer/index.d.ts +0 -2
  60. package/types/server/renderer/render.d.ts +0 -38
  61. package/types/server/renderer/userAgentUtil.d.ts +0 -1
  62. package/types/store/index.d.ts +0 -11
  63. package/types/store/index.dev.d.ts +0 -8
  64. package/types/store/index.prod.d.ts +0 -8
  65. package/types/webpack/babel-plugins/remove-client.plugin.d.ts +0 -10
  66. package/types/webpack/babel-plugins/remove-ssr.plugin.d.ts +0 -10
  67. package/types/webpack/babel.config.client.d.ts +0 -21
  68. package/types/webpack/babel.config.d.ts +0 -16
  69. package/types/webpack/babel.config.ssr.d.ts +0 -21
  70. package/types/webpack/base.babel.d.ts +0 -184
  71. package/types/webpack/development.client.babel.d.ts +0 -1
  72. package/types/webpack/plugins/mime-types.d.ts +0 -78
  73. package/types/webpack/plugins/route-manifest-plugin.d.ts +0 -1
  74. package/types/webpack/plugins/upload-assets-plugin.d.ts +0 -1
  75. package/types/webpack/production.client.babel.d.ts +0 -174
  76. package/types/webpack/production.ssr.babel.d.ts +0 -2
  77. package/types/webpack/scssParams.d.ts +0 -2
package/scripts/build.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");
@@ -15,19 +10,33 @@ const {
15
10
  const {
16
11
  BUILD_OUTPUT_PATH
17
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
+ }
18
21
 
19
22
  /**
20
23
  * @description - creates a production build of the application.
21
24
  */
22
25
  function start() {
26
+ const commandLineArguments = process.argv.slice(2);
27
+ const argumentsObject = arrayToObject(commandLineArguments);
23
28
  const dirname = path.resolve(__dirname, "../");
24
29
  spawnSync("npm", ["run", "build", `--src_path=${process.env.PWD}`, `--app_name=${name || "catalyst_app"}`], {
25
30
  cwd: dirname,
26
31
  stdio: "inherit",
27
- env: _objectSpread(_objectSpread({}, process.env), {}, {
32
+ env: {
33
+ ...process.env,
28
34
  src_path: process.env.PWD,
29
- build_output_path: BUILD_OUTPUT_PATH
30
- })
35
+ build_output_path: BUILD_OUTPUT_PATH,
36
+ NODE_ENV: "production",
37
+ IS_DEV_COMMAND: false,
38
+ ...argumentsObject
39
+ }
31
40
  });
32
41
  }
33
42
  start();
@@ -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");
@@ -15,20 +10,34 @@ const {
15
10
  const {
16
11
  BUILD_OUTPUT_PATH
17
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
+ }
18
21
 
19
22
  /**
20
23
  * @description - Serves production build of the application.
21
24
  */
22
25
 
23
26
  function start() {
27
+ const commandLineArguments = process.argv.slice(2);
28
+ const argumentsObject = arrayToObject(commandLineArguments);
24
29
  const dirname = path.resolve(__dirname, "../");
25
30
  spawnSync("npm", ["run", "serve", `--src_path=${process.env.PWD}`, `--app_name=${name || "catalyst_app"}`], {
26
31
  cwd: dirname,
27
32
  stdio: "inherit",
28
- env: _objectSpread(_objectSpread({}, process.env), {}, {
33
+ env: {
34
+ ...process.env,
29
35
  src_path: process.env.PWD,
30
- build_output_path: BUILD_OUTPUT_PATH
31
- })
36
+ build_output_path: BUILD_OUTPUT_PATH,
37
+ NODE_ENV: "production",
38
+ IS_DEV_COMMAND: false,
39
+ ...argumentsObject
40
+ }
32
41
  });
33
42
  }
34
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,7 +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
47
  CLIENT_ENV_VARIABLES: [],
49
48
  ANALYZE_BUNDLE: ""
50
49
  };
@@ -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,11 +20,6 @@ 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`);
@@ -64,13 +59,13 @@ const webExtractor = new _server2.ChunkExtractor({
64
59
  });
65
60
 
66
61
  // matches request route with routes defined in the application.
67
- const getMatchRoutes = (routes, req, res, store, context, fetcherData) => {
62
+ const getMatchRoutes = (routes, req, res, store, context, fetcherData, basePath = "") => {
68
63
  return routes.reduce((matches, route) => {
69
64
  const {
70
65
  path
71
66
  } = route;
72
67
  const match = (0, _router.matchPath)({
73
- path,
68
+ path: `${basePath}/${path}`,
74
69
  caseSensitive: false,
75
70
  end: true
76
71
  }, req.baseUrl || "/");
@@ -97,14 +92,12 @@ const getMatchRoutes = (routes, req, res, store, context, fetcherData) => {
97
92
  matches.push({
98
93
  route,
99
94
  match,
100
- serverSideFunction: wc && wc.serverSideFunction || (() => Promise.resolve()),
101
- metaTagFunction: wc && wc.metaTagFunction || null,
102
- serverFetcher: wc && wc.serverFetcher || (() => Promise.resolve())
95
+ serverSideFunction: wc && wc.serverSideFunction || (() => Promise.resolve())
103
96
  });
104
97
  }
105
- if (!match && route.routes) {
98
+ if (!match && route.children) {
106
99
  // recursively try to match nested routes
107
- const nested = getMatchRoutes(route.routes, req, res, store, context, fetcherData);
100
+ const nested = getMatchRoutes(route.children, req, res, store, context, fetcherData, `${basePath}/${path}`);
108
101
  if (nested.length) {
109
102
  matches = matches.concat(nested);
110
103
  }
@@ -127,24 +120,25 @@ const getComponent = (store, context, req, fetcherData) => {
127
120
  intialData: fetcherData
128
121
  }))));
129
122
  };
130
-
131
123
  // sends document after rendering
132
- const renderMarkUp = async (errorCode, req, res, metaTagFunction, fetcherData, store, matches, context) => {
124
+ const renderMarkUp = async (errorCode, req, res, metaTags, fetcherData, store, matches, context) => {
133
125
  const deviceDetails = (0, _userAgentUtil.getUserAgentDetails)(req.headers["user-agent"] || "");
134
126
  const isBot = deviceDetails.googleBot ? true : false;
135
127
 
136
128
  // Transforms Head Props
137
- 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);
138
130
  let state = store.getState();
139
131
  const jsx = webExtractor.collectChunks(getComponent(store, context, req, fetcherData));
140
132
 
141
133
  // Transforms Body Props
142
134
  const shellEnd = _render.default.renderEnd(webExtractor, state, res, jsx, errorCode, fetcherData);
143
- const finalProps = _objectSpread(_objectSpread(_objectSpread({}, shellStart), shellEnd), {}, {
135
+ const finalProps = {
136
+ ...shellStart,
137
+ ...shellEnd,
144
138
  jsx: jsx,
145
139
  req,
146
140
  res
147
- });
141
+ };
148
142
  let CompleteDocument = () => {
149
143
  if ((0, _validator.validateCustomDocument)(CustomDocument)) {
150
144
  return CustomDocument(finalProps);
@@ -156,7 +150,7 @@ const renderMarkUp = async (errorCode, req, res, metaTagFunction, fetcherData, s
156
150
  pageJS: finalProps.pageJS,
157
151
  pageCss: finalProps.pageCss,
158
152
  fetcherData: finalProps.fetcherData,
159
- metaTagFunction: finalProps.metaTagFunction,
153
+ metaTags: finalProps.metaTags,
160
154
  publicAssetPath: finalProps.publicAssetPath
161
155
  }), /*#__PURE__*/_react.default.createElement(_document.Body, {
162
156
  initialState: finalProps.initialState,
@@ -202,7 +196,6 @@ async function _default(req, res) {
202
196
  try {
203
197
  let context = {};
204
198
  let fetcherData = {};
205
- let metaTagFunction = null;
206
199
 
207
200
  // creates store
208
201
  const store = (0, _validator.validateConfigureStore)(createStore) ? createStore({}, req) : null;
@@ -212,39 +205,34 @@ async function _default(req, res) {
212
205
 
213
206
  // Matches req url with routes
214
207
  const matches = getMatchRoutes(routes, req, res, store, context, fetcherData);
208
+ const allMatches = (0, _router.matchRoutes)(getRoutes(), req.baseUrl);
209
+ let allTags = [];
215
210
 
216
211
  // Executing app server side function
217
212
  _App.default.serverSideFunction({
218
213
  store,
219
- req
220
- }).then(() => {
221
- const serverSideFunction = matches.map(match => {
222
- if (match?.metaTagFunction) {
223
- metaTagFunction = match.metaTagFunction;
224
- }
225
- return match.serverSideFunction({
226
- store
227
- });
228
- });
229
-
230
- // Executing serverFetcher functions with serverDataFetcher provided by router and returning document
231
- Promise.all(serverSideFunction).then(() => {
232
- (0, _router.serverDataFetcher)({
233
- routes: routes,
234
- req,
235
- url: req.originalUrl
236
- }, {
237
- store
238
- }).then(res => {
239
- fetcherData = res;
240
- }).then(async () => await renderMarkUp(null, req, res, metaTagFunction, fetcherData, store, matches, context)).catch(async error => {
241
- logger.error("Error in executting serverFetcher functions: " + error);
242
- await renderMarkUp(404, req, res, metaTagFunction, fetcherData, store, matches, context);
243
- });
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);
244
232
  });
245
233
  }).catch(error => {
246
234
  logger.error("Error in executing serverSideFunction inside App: " + error);
247
- renderMarkUp(error.status_code, req, res, metaTagFunction, fetcherData, store, matches, context);
235
+ renderMarkUp(error.status_code, req, res, allTags, fetcherData, store, matches, context);
248
236
  });
249
237
  } catch (error) {
250
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,7 +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
47
  CLIENT_ENV_VARIABLES: [],
49
48
  ANALYZE_BUNDLE: ""
50
49
  };
@@ -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,12 +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
51
  PUBLIC_STATIC_ASSET_PATH,
51
52
  WEBPACK_DEV_SERVER_HOSTNAME,
52
- WEBPACK_DEV_SERVER_PORT
53
+ WEBPACK_DEV_SERVER_PORT,
54
+ NODE_SERVER_HOSTNAME,
55
+ NODE_SERVER_PORT
53
56
  } = process.env;
54
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
+ }
55
63
  var _default = exports.default = {
56
64
  context: _path.default.resolve(process.env.src_path),
57
65
  mode: isDev ? "development" : "production",
@@ -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
  };