catalyst-core 0.0.1-beta.5 → 0.0.1-beta.7
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.
- package/README.md +15 -121
- package/bin/catalyst.js +1 -1
- package/changelog.md +5 -8
- package/dist/caching.js +1 -0
- package/dist/index.js +1 -0
- package/dist/logger.js +10 -0
- package/{router → dist/router}/ClientRouter.js +2 -2
- package/dist/router/ServerRouter.js +1 -0
- package/dist/router.js +1 -0
- package/{scripts → dist/scripts}/build.js +7 -7
- package/{scripts → dist/scripts}/devBuild.js +7 -7
- package/{scripts → dist/scripts}/devServe.js +3 -3
- package/{scripts → dist/scripts}/loadEnvironmentVariables.js +1 -1
- package/dist/scripts/loadScriptsBeforeServerStarts.js +4 -0
- package/dist/scripts/registerAliases.js +2 -0
- package/{scripts → dist/scripts}/serve.js +3 -3
- package/dist/scripts/start.js +6 -0
- package/{scripts → dist/scripts}/validator.js +1 -1
- package/{server → dist/server}/expressServer.js +1 -1
- package/{server → dist/server}/renderer/document/Body.js +2 -5
- package/dist/server/renderer/document/Head.js +9 -0
- package/dist/server/renderer/extract.js +27 -0
- package/dist/server/renderer/handler.js +16 -0
- package/dist/server/startServer.js +6 -0
- package/{server → dist/server}/utils/validator.js +1 -1
- package/{webpack → dist/webpack}/babel-plugins/remove-ssr.plugin.js +1 -1
- package/dist/webpack/base.babel.js +8 -0
- package/dist/webpack/development.client.babel.js +4 -0
- package/dist/webpack/production.client.babel.js +4 -0
- package/dist/webpack/production.ssr.babel.js +4 -0
- package/package.json +27 -6
- package/.eslintignore +0 -9
- package/.eslintrc +0 -91
- package/.husky/commit-msg +0 -1
- package/.husky/pre-commit +0 -1
- package/commitlint.config.js +0 -11
- package/router/ServerRouter.js +0 -1
- package/scripts/loadScriptsBeforeServerStarts.js +0 -5
- package/scripts/resiterAliases.js +0 -29
- package/scripts/start.js +0 -6
- package/server/renderer/document/Head.js +0 -9
- package/server/renderer/extract.js +0 -21
- package/server/renderer/handler.js +0 -17
- package/server/renderer/render.js +0 -21
- package/server/startServer.js +0 -6
- package/tsconfig.json +0 -110
- package/webpack/base.babel.js +0 -8
- package/webpack/development.client.babel.js +0 -4
- package/webpack/production.client.babel.js +0 -4
- package/webpack/production.ssr.babel.js +0 -4
- /package/{scripts → dist/scripts}/checkVersion.js +0 -0
- /package/{scripts → dist/scripts}/scriptUtils.js +0 -0
- /package/{server → dist/server}/renderer/document/index.js +0 -0
- /package/{server → dist/server}/renderer/index.js +0 -0
- /package/{server → dist/server}/utils/userAgentUtil.js +0 -0
- /package/{webpack → dist/webpack}/babel-plugins/remove-client.plugin.js +0 -0
- /package/{webpack → dist/webpack}/babel.config.client.js +0 -0
- /package/{webpack → dist/webpack}/babel.config.ssr.js +0 -0
- /package/{webpack → dist/webpack}/scssParams.js +0 -0
package/README.md
CHANGED
|
@@ -1,146 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<picture>
|
|
3
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://onemg.gumlet.io/staging/7ee66dfb-b5fb-4fbe-8dea-789685e45f7a.svg">
|
|
4
|
+
<img alt="Catalyst logo" src="https://onemg.gumlet.io/staging/2fdb0975-8f51-4fd1-bd7d-6375d793f581.svg" height="128">
|
|
5
|
+
</picture>
|
|
6
|
+
</div>
|
|
4
7
|
|
|
5
8
|
## Table of Contents
|
|
6
9
|
|
|
7
10
|
- Overview
|
|
8
11
|
- Installation
|
|
9
|
-
|
|
10
|
-
- serverFetcher
|
|
11
|
-
- clientFetcher
|
|
12
|
-
- refetch (for data revalidation)
|
|
13
|
-
- State Management
|
|
14
|
-
|
|
12
|
+
|
|
15
13
|
## Overview
|
|
16
14
|
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
Catalyst offers a comprehensive suite of features designed for modern web development. It includes isomorphic rendering for optimal performance, an extendable server with full-stack capabilities, and configurable state management. The framework employs smart prefetching of data and chunks, allows easy configuration of global styles and layouts, and provides SEO optimization at both global and page levels.
|
|
19
16
|
## Installation
|
|
20
17
|
|
|
21
18
|
**System Requirements**
|
|
22
19
|
|
|
23
20
|
- Node version 20.4.0 or later
|
|
24
|
-
- macOS and Linux
|
|
21
|
+
- Compatible with **macOS** and **Linux**
|
|
25
22
|
|
|
26
23
|
**Automatic Installation**
|
|
27
24
|
|
|
28
|
-
|
|
25
|
+
Run the following commands in the directory where you want to set up the Catalyst app:
|
|
29
26
|
|
|
30
|
-
```
|
|
27
|
+
```bash
|
|
31
28
|
npx create-catalyst-app@latest
|
|
32
29
|
```
|
|
33
30
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
- Enter the name of your Catalyst application.
|
|
37
|
-
- Choose state management.
|
|
38
|
-
- Once packages are installed,start the development server by running the following command.
|
|
39
|
-
|
|
40
|
-
```js
|
|
41
|
-
cd project-name && npm run start
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
- Navigate to http://localhost:3005
|
|
45
|
-
|
|
46
|
-
The dev server should be running now.
|
|
47
|
-
|
|
48
|
-
Visit our official documentation:
|
|
49
|
-
https://catalyst.1mg.com/public_docs/content/installation
|
|
50
|
-
|
|
51
|
-
## Data Fetching with Catalyst
|
|
52
|
-
|
|
53
|
-
we have serverFetcher function for fetching with SSR and clientFetcher function for fetching during client side rendering and navigations.
|
|
54
|
-
|
|
55
|
-
**serverFetcher**
|
|
56
|
-
|
|
57
|
-
server fetcher will get request, request params, search params and store (if project is setup with redux or rtk) as arguments. We can declare it as an async function and use await for fetching or use then chaining for data fetching.
|
|
58
|
-
|
|
59
|
-
if server fetcher is called for a route then client fetcher will not be called for that route, unless called with refetch.
|
|
60
|
-
|
|
61
|
-
```js
|
|
62
|
-
Home.serverFetcher = async ({ req, params, searchParams }, { store }) => {
|
|
63
|
-
store.dispatch(someAction())
|
|
64
|
-
const res = await fetch("some_url")
|
|
65
|
-
const json = await res.json()
|
|
66
|
-
return json
|
|
67
|
-
}
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
data returned from fetcher function will be accessible through useCurrentRouteData() hook provided by router.
|
|
71
|
-
|
|
72
|
-
```js
|
|
73
|
-
const [data, error, isFetched] = useCurrentRouteData()
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
error and loading state would be handled by router.
|
|
77
|
-
|
|
78
|
-
**clientFetcher**
|
|
79
|
-
|
|
80
|
-
client fetcher would be called on client side rendering and client side navigations. `store` would be available as a param in client side for dispatching redux/rtk actions.
|
|
81
|
-
|
|
82
|
-
```js
|
|
83
|
-
Home.clientFetcher = async ({ route, location, params, searchParams, navigate }, { store }) => {
|
|
84
|
-
store.dispatch(someAction())
|
|
85
|
-
const res = await fetch("some_url")
|
|
86
|
-
const json = await res.json()
|
|
87
|
-
return json
|
|
88
|
-
}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
data returned from client fetcher function will be accessible through useCurrentRouteData() hook provided by router (hook for data access through client is same).
|
|
92
|
-
|
|
93
|
-
```js
|
|
94
|
-
const [data, error, isFetched] = useCurrentRouteData()
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
**refetch (for data revalidation)**
|
|
98
|
-
|
|
99
|
-
refetch function can be used were we need to execute clientFetcher based on some condition(such as for infinite scroll or some state change inside container or onClick.)
|
|
100
|
-
|
|
101
|
-
We can pass arguments in refetch function which would
|
|
102
|
-
|
|
103
|
-
```js
|
|
104
|
-
const [data,error,isFetched,refetch] = useCurrentRouteData()
|
|
105
|
-
|
|
106
|
-
useEffect(()=>{
|
|
107
|
-
refetch({refetchArgument:some_value})
|
|
108
|
-
},[arg])
|
|
109
|
-
|
|
110
|
-
clientFetcher = ({},{refetchArgument}) => {
|
|
111
|
-
|
|
112
|
-
const res = await api_call // refetchArg can be used as a param in api call
|
|
113
|
-
return res
|
|
114
|
-
}
|
|
31
|
+
You will see some prompts to configure your application.
|
|
115
32
|
|
|
33
|
+
```bash
|
|
34
|
+
cd <name-of-your-project> && npm run start
|
|
116
35
|
```
|
|
117
36
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
state management wrappers are defined in stateProvider.js file
|
|
121
|
-
|
|
122
|
-
store can be configured by manipulating store/index.js as per user requirements (custom middlewares etc can be added in this way.
|
|
123
|
-
|
|
124
|
-
initial state and request object would be provided in createStore function which will be called on server and client, we use the params to add additional arguments and middlewares in redux store.
|
|
125
|
-
|
|
126
|
-
```js
|
|
127
|
-
const configureStore = (initialState, cookies, requestObj, customHeaders) => {
|
|
128
|
-
const api = fetchInstance
|
|
129
|
-
const store = createStore({
|
|
130
|
-
reducer: rootReducer,
|
|
131
|
-
middleware: (getDefaultMiddleware) =>
|
|
132
|
-
getDefaultMiddleware({
|
|
133
|
-
thunk: {
|
|
134
|
-
extraArgument: { api },
|
|
135
|
-
},
|
|
136
|
-
}),
|
|
137
|
-
preloadedState: initialState,
|
|
138
|
-
})
|
|
139
|
-
return store
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export default configureStore
|
|
143
|
-
```
|
|
37
|
+
The development server will start at ```http://localhost:3005```
|
|
144
38
|
|
|
145
39
|
## Documentation
|
|
146
40
|
|
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) {
|
package/changelog.md
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## [0.0.1-beta.
|
|
3
|
+
## [0.0.1-beta.7] - 19-10-2024
|
|
4
4
|
|
|
5
|
-
###
|
|
5
|
+
### Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
### Fixed
|
|
11
|
-
|
|
12
|
-
- Fixed logs folder creation in project directory.
|
|
7
|
+
- Added postcss-scss parser to parse scss in dev mode.
|
|
8
|
+
- Removed default meta tags if the user chooses to setup their own document.
|
|
9
|
+
- Fix assets being injected in the documnet sent from the server.
|
package/dist/caching.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _apiCaching=require("@tata1mg/api-caching");Object.keys(_apiCaching).forEach(function(key){if(key==="default"||key==="__esModule")return;if(key in exports&&exports[key]===_apiCaching[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function(){return _apiCaching[key];}});});
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _index=require("./server/renderer/document/index");Object.keys(_index).forEach(function(key){if(key==="default"||key==="__esModule")return;if(key in exports&&exports[key]===_index[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function(){return _index[key];}});});
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";const pc=require("picocolors");const winston=require("winston");const DailyRotateFile=require("winston-daily-rotate-file");const{createLogger,format,transports}=winston;/**
|
|
2
|
+
* @description Logger library with rotational strategy. Creates a logs folder in root.
|
|
3
|
+
* With debug, error and info log directories with their respective log files.
|
|
4
|
+
*
|
|
5
|
+
* @format Logstash with timestamp
|
|
6
|
+
* @param config { @enableDebugLogs: Bool // default: true }
|
|
7
|
+
* @returns loggerInstance
|
|
8
|
+
*
|
|
9
|
+
*/const configureLogger=(config={})=>{const{enableDebugLogs=true,enableFileLogging=true,enableConsoleLogging=true}=config;const consoleTransport=new transports.Console({level:"debug"});const fileTransport=(type="info")=>{return new DailyRotateFile({filename:`${process.env.src_path}/logs/${type}/%DATE%.${type}.log`,datePattern:"YYYY-MM-DD",maxFiles:"3d",// Logs will be removed after 2days,
|
|
10
|
+
loglevel:type,level:type});};const infoLogger=createLogger({format:format.combine(format.timestamp({format:"YYYY-MM-DD HH:mm:ss"}),format.json()),defaultMeta:{loglevel:"info"}});const debugLogger=createLogger({format:format.combine(format.timestamp({format:"YYYY-MM-DD HH:mm:ss"}),format.json()),defaultMeta:{loglevel:"debug"}});const errorLogger=createLogger({format:format.combine(format.timestamp({format:"YYYY-MM-DD HH:mm:ss"}),format.json()),defaultMeta:{loglevel:"error"}});if(enableConsoleLogging&&JSON.parse(enableConsoleLogging)){infoLogger.add(consoleTransport);debugLogger.add(consoleTransport);errorLogger.add(consoleTransport);}if(enableFileLogging&&JSON.parse(enableFileLogging)){infoLogger.add(fileTransport("info"));debugLogger.add(fileTransport("debug"));errorLogger.add(fileTransport("error"));}const Logger={debug:()=>{},error:msg=>{console.log(pc.red(pc.bold("ERROR: "+JSON.stringify(msg))));errorLogger.error(msg);},info:msg=>{console.log(pc.green(pc.bold("INFO: "+JSON.stringify(msg))));infoLogger.info(msg);}};if(enableDebugLogs&&JSON.parse(enableDebugLogs)){Logger.debug=msg=>{console.log(pc.yellow(pc.bold("DEBUG: "+JSON.stringify(msg))));debugLogger.debug(msg);};}if(global)global.logger=Logger;return Logger;};module.exports={configureLogger};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _router=require("@tata1mg/router");
|
|
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)(
|
|
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;
|
package/dist/router.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});var _router=require("@tata1mg/router");Object.keys(_router).forEach(function(key){if(key==="default"||key==="__esModule")return;if(key in exports&&exports[key]===_router[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function(){return _router[key];}});});
|
|
@@ -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,"
|
|
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,
|
|
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();
|
|
@@ -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,"
|
|
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,
|
|
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,"
|
|
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,
|
|
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(
|
|
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 _postcssScss=_interopRequireDefault(require("postcss-scss"));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"],processorOpts:{parser:_postcssScss.default.parse},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,"
|
|
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,
|
|
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("
|
|
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,14 +1,11 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.Body=Body;var _react=_interopRequireDefault(require("react"));var _propTypes=_interopRequireDefault(require("prop-types"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}/**
|
|
2
2
|
* Body component which will be used in page component
|
|
3
3
|
* @param {object} jsx - page jsx code
|
|
4
|
-
* @param {object} statusCode - document request status code
|
|
5
4
|
* @param {object} initialState - initial state object for redux store
|
|
6
5
|
* @param {object} firstFoldCss - style elements extracted for initial page load
|
|
7
|
-
* @param {object} firstFoldJS - javascript elements extracted for initial page load
|
|
8
6
|
* @param {object} fetcherData - contains data from executing serverFetcher function
|
|
9
7
|
* @param {object} children - contains any child elements defined within the component
|
|
10
|
-
*/function Body(props){const{jsx="",
|
|
8
|
+
*/function Body(props){const{jsx="",initialState={},fetcherData={},children}=props;return/*#__PURE__*/_react.default.createElement("body",null,jsx,/*#__PURE__*/_react.default.createElement("script",{/* eslint-disable */dangerouslySetInnerHTML:{__html:`
|
|
11
9
|
window.__INITIAL_STATE__ = ${JSON.stringify(initialState)}
|
|
12
|
-
window.__STATUS_CODE__ = ${statusCode}
|
|
13
10
|
window.__ROUTER_INITIAL_DATA__ = ${JSON.stringify(fetcherData)}
|
|
14
|
-
`}}),children);}Body.propTypes={initialState:_propTypes.default.object,
|
|
11
|
+
`}}),children);}Body.propTypes={initialState:_propTypes.default.object,jsx:_propTypes.default.any,fetcherData:_propTypes.default.object,children:_propTypes.default.node};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.Head=Head;var _react=_interopRequireDefault(require("react"));var _propTypes=_interopRequireDefault(require("prop-types"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}/**
|
|
2
|
+
* Head component which will be used in page rendering
|
|
3
|
+
* @param {boolean} isBot - checks if request is made by bot
|
|
4
|
+
* @param {string} pageCss - includes all styles for page css
|
|
5
|
+
* @param {object} preloadJSLinks - async scripts for loading chunks
|
|
6
|
+
* @param {array} metaTags - user defined function which returns meta tags in array
|
|
7
|
+
* @param {string} publicAssetPath - public asset path for assets
|
|
8
|
+
* @param {object} children - contains any child elements defined within the component
|
|
9
|
+
*/function Head(props){const{pageCss,preloadJSLinks,metaTags,isBot,publicAssetPath,children}=props;if(children){return/*#__PURE__*/_react.default.createElement("head",null,children,metaTags&&metaTags,!isBot&&pageCss&&/*#__PURE__*/_react.default.createElement("style",{dangerouslySetInnerHTML:{__html:pageCss}}),!isBot&&preloadJSLinks);}return/*#__PURE__*/_react.default.createElement("head",null,/*#__PURE__*/_react.default.createElement("meta",{charSet:"utf-8"}),/*#__PURE__*/_react.default.createElement("meta",{name:"viewport",content:"width=device-width, initial-scale=1"}),publicAssetPath&&/*#__PURE__*/_react.default.createElement("link",{rel:"preconnect",href:publicAssetPath}),publicAssetPath&&/*#__PURE__*/_react.default.createElement("link",{rel:"dns-prefetch",href:publicAssetPath}),metaTags&&metaTags,!isBot&&pageCss&&/*#__PURE__*/_react.default.createElement("style",{dangerouslySetInnerHTML:{__html:pageCss}}),!isBot&&preloadJSLinks);}Head.propTypes={isBot:_propTypes.default.bool,preloadJSLinks:_propTypes.default.object,pageCss:_propTypes.default.string,metaTags:_propTypes.default.array,publicAssetPath:_propTypes.default.string,children:_propTypes.default.node};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.cacheAndFetchAssets=void 0;exports.cacheCSS=cacheCSS;exports.cachePreloadJSLinks=cachePreloadJSLinks;exports.default=_default;var _path=_interopRequireDefault(require("path"));var _fs=_interopRequireDefault(require("fs"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function cachePreloadJSLinks(key,data){if(!process.preloadJSLinkCache){process.preloadJSLinkCache={};}let preloadJSLinks=[];if(Array.isArray(data)){try{preloadJSLinks=data.filter(asset=>asset?.props?.as==="script");}catch(error){}}process.preloadJSLinkCache[key]=preloadJSLinks;}/**
|
|
2
|
+
* Stores css chunks styles into cache in string format
|
|
3
|
+
* @param {string} key - router path
|
|
4
|
+
* @param {object} data - css elements array extracted through loadable chunk extracter
|
|
5
|
+
*/function cacheCSS(key,data){if(!process.cssCache){process.cssCache={};}let pageCss="";let listOfCachedAssets={};if(Array.isArray(data)){try{if(process.env.NODE_ENV==="production"){data.map(assetChunk=>{const assetPathArr=assetChunk.key.split("/");const assetName=assetPathArr[assetPathArr.length-1];const ext=_path.default.extname(assetName);if(ext===".css"){// if css file has not already been cached, add the content of this CSS file in pageCSS
|
|
6
|
+
if(!listOfCachedAssets[assetName]&&!process.cssCache?.[key]?.listOfCachedAssets?.[assetName]){pageCss+=_fs.default.readFileSync(_path.default.resolve(process.env.src_path,`${process.env.BUILD_OUTPUT_PATH}/public`,assetName));listOfCachedAssets[assetName]=true;}}});}}catch(error){}}// if css cache exists for a route and there are some uncached css, add that css to the cache
|
|
7
|
+
// this will run on subsequent hits and will add css of uncached widgets to the cache
|
|
8
|
+
if(process.cssCache[key]){if(pageCss!==""){let existingListOfCachedAssets=process.cssCache[key].listOfCachedAssets;const newPageCSS=process.cssCache[key].pageCss+pageCss;let newListOfCachedAssets={...existingListOfCachedAssets,...listOfCachedAssets};process.cssCache[key]={pageCss:newPageCSS,listOfCachedAssets:newListOfCachedAssets};}}else{// create css cache for a page. This will run on the first hit.
|
|
9
|
+
process.cssCache[key]={pageCss,listOfCachedAssets};}return pageCss;}/**
|
|
10
|
+
* returns cached css
|
|
11
|
+
* @param {string} key - router path
|
|
12
|
+
* @return {string} - cached css
|
|
13
|
+
*/function fetchCachedCSS(key){return process.cssCache&&process.cssCache[key]?process.cssCache[key].pageCss:"";}function fetchPreloadJSLinkCache(key){return process.preloadJSLinkCache&&process.preloadJSLinkCache[key]?process.preloadJSLinkCache[key]:null;}/**
|
|
14
|
+
* stores css and js in cache
|
|
15
|
+
* @param {object} res - response object
|
|
16
|
+
* @param {string} route - route path
|
|
17
|
+
*/function _default(res,route){try{const requestPath=route.path;const cachedCss=fetchCachedCSS(requestPath);const cachedPreloadJSLinks=fetchPreloadJSLinkCache(requestPath);if(cachedCss||cachedPreloadJSLinks){res.locals.pageCss=cachedCss;res.locals.preloadJSLinks=cachedPreloadJSLinks;return;}}catch(error){}}const cacheAndFetchAssets=({webExtractor,res,isBot})=>{// For bot first fold css and js would become complete page css and js
|
|
18
|
+
let firstFoldCss="";let firstFoldJS="";const isProd=process.env.NODE_ENV==="production";const{routePath,preloadJSLinks}=res.locals;const linkElements=webExtractor.getLinkElements();// We want to cache/or check for update css on every call
|
|
19
|
+
// We want to extract script tags for every call that will get added to body.
|
|
20
|
+
// Their corresponding preloaded link script tags are already present in head.
|
|
21
|
+
if(routePath){if(!isBot){if(isProd){firstFoldCss=cacheCSS(routePath,linkElements);firstFoldCss=`<style>${firstFoldCss}</style>`;}else{cacheCSS(routePath,linkElements);firstFoldCss=webExtractor.getStyleTags();}}// firstFoldJS = webExtractor.getScriptTags({ nonce: cspNonce })
|
|
22
|
+
firstFoldJS=webExtractor.getScriptTags();}// This block will run for the first time and cache preloaded JS Links for second render
|
|
23
|
+
// firstFoldJS ->scripts gets inject in body
|
|
24
|
+
// firstFoldCss -> Inline css gets injected in body only for the first render
|
|
25
|
+
if(!isProd||isBot||routePath&&!preloadJSLinks){// For production, we inject link tags with preload/prefetch using getLinkElements and inlining them via file reads
|
|
26
|
+
// For local, given we have assets in memory we dont read from file rather directly inject via link elements returned without preload/prefetch
|
|
27
|
+
!isBot&&cachePreloadJSLinks(routePath,linkElements);}return{firstFoldCss,firstFoldJS};};exports.cacheAndFetchAssets=cacheAndFetchAssets;
|
|
@@ -0,0 +1,16 @@
|
|
|
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 _extract=_interopRequireWildcard(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 _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;}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
|
+
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(!res.locals.pageCss&&!res.locals.preloadJSLinks&&!res.locals.routePath){res.locals.routePath=path;(0,_extract.default)(res,route);}if(!res.locals.pageCss&&!res.locals.preloadJSLinks){//moving routing logic outside of the App and using ServerRoutes for creating routes on server instead
|
|
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
|
+
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
|
+
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
|
+
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;let state=store.getState();const jsx=webExtractor.collectChunks(getComponent(store,context,req,fetcherData));const{IS_DEV_COMMAND,WEBPACK_DEV_SERVER_HOSTNAME,WEBPACK_DEV_SERVER_PORT}=process.env;let publicAssetPath=`${process.env.PUBLIC_STATIC_ASSET_URL}${process.env.PUBLIC_STATIC_ASSET_PATH}`;// serves assets from localhost on running devBuild and devServe command
|
|
7
|
+
if(JSON.parse(IS_DEV_COMMAND)){publicAssetPath=`http://${WEBPACK_DEV_SERVER_HOSTNAME}:${WEBPACK_DEV_SERVER_PORT}/assets/`;}const finalProps={req,res,lang:"en",pageCss:res.locals.pageCss,preloadJSLinks:res.locals.preloadJSLinks,metaTags,isBot,publicAssetPath,jsx,initialState:state,fetcherData};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,pageCss:finalProps.pageCss,metaTags:finalProps.metaTags,preloadJSLinks:finalProps.preloadJSLinks,publicAssetPath:finalProps.publicAssetPath}),/*#__PURE__*/_react.default.createElement(_document.Body,{jsx:finalProps.jsx,fetcherData:finalProps.fetcherData,initialState:finalProps.initialState}));}};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);},onAllReady(){const{firstFoldCss,firstFoldJS}=(0,_extract.cacheAndFetchAssets)({webExtractor,res,isBot});res.write(firstFoldCss);res.write(firstFoldJS);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
|
+
* middleware for document handling
|
|
9
|
+
* @param {object} req - request object
|
|
10
|
+
* @param {object} res - response object
|
|
11
|
+
*/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
|
+
const store=(0,_validator.validateConfigureStore)(createStore)?createStore({},req,res):null;// user defined routes
|
|
13
|
+
const routes=(0,_validator.validateGetRoutes)(_utils.getRoutes)?(0,_utils.getRoutes)():[];// Matches req url with routes
|
|
14
|
+
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
|
|
15
|
+
_index.default.serverSideFunction({store,req,res})// Executing serverFetcher functions with serverDataFetcher provided by router and returning document
|
|
16
|
+
.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};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* @description babel plugin used to remove unwanted code from the build.
|
|
3
3
|
* @return babel plugin object
|
|
4
4
|
*/function _default(){return{name:"ast-transform",// not required
|
|
5
|
-
visitor:{ImportDefaultSpecifier(path){path.parentPath.parent.body=path.parentPath.parent.body.filter(val=>val?.expression?.left?.property?.name!=="serverSideFunction");}}};}
|
|
5
|
+
visitor:{ImportDefaultSpecifier(path){path.parentPath.parent.body=path.parentPath.parent.body.filter(val=>val?.expression?.left?.property?.name!=="serverSideFunction"&&val?.expression?.left?.property?.name!=="serverFetcher");}}};}
|
|
@@ -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",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.7",
|
|
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
|
-
"
|
|
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": "
|
|
51
|
+
"@tata1mg/router": "0.0.1-beta.2",
|
|
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",
|
|
@@ -47,6 +67,7 @@
|
|
|
47
67
|
"module-alias": "^2.2.3",
|
|
48
68
|
"picocolors": "^1.0.0",
|
|
49
69
|
"postcss-loader": "^7.3.3",
|
|
70
|
+
"postcss-scss": "^4.0.9",
|
|
50
71
|
"react": "^18.2.0",
|
|
51
72
|
"react-dom": "^18.2.0",
|
|
52
73
|
"react-redux": "^8.1.3",
|
|
@@ -88,4 +109,4 @@
|
|
|
88
109
|
"prettier . --write"
|
|
89
110
|
]
|
|
90
111
|
}
|
|
91
|
-
}
|
|
112
|
+
}
|
package/.eslintignore
DELETED
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
|
package/commitlint.config.js
DELETED
|
@@ -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
|
-
}
|
package/router/ServerRouter.js
DELETED
|
@@ -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,9 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.Head=Head;var _react=_interopRequireDefault(require("react"));var _propTypes=_interopRequireDefault(require("prop-types"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}/**
|
|
2
|
-
* Head component which will be used in page rendering
|
|
3
|
-
* @param {boolean} isBot - checks if request is made by bot
|
|
4
|
-
* @param {string} pageCss - includes all styles for page css
|
|
5
|
-
* @param {object} pageJS - async scripts for loading chunks
|
|
6
|
-
* @param {array} metaTags - user defined function which returns meta tags in array
|
|
7
|
-
* @param {string} publicAssetPath - public asset path for assets
|
|
8
|
-
* @param {object} children - contains any child elements defined within the component
|
|
9
|
-
*/function Head(props){const{pageCss,pageJS,metaTags,isBot,publicAssetPath,children}=props;return/*#__PURE__*/_react.default.createElement("head",null,/*#__PURE__*/_react.default.createElement("meta",{charSet:"utf-8"}),/*#__PURE__*/_react.default.createElement("meta",{name:"viewport",content:"width=device-width, initial-scale=1"}),publicAssetPath&&/*#__PURE__*/_react.default.createElement("link",{rel:"preconnect",href:publicAssetPath}),publicAssetPath&&/*#__PURE__*/_react.default.createElement("link",{rel:"dns-prefetch",href:publicAssetPath}),metaTags&&metaTags,!isBot&&pageJS,!isBot&&pageCss&&/*#__PURE__*/_react.default.createElement("style",{dangerouslySetInnerHTML:{__html:pageCss}}),children);}Head.propTypes={isBot:_propTypes.default.bool,pageJS:_propTypes.default.object,pageCss:_propTypes.default.string,metaTags:_propTypes.default.array,publicAssetPath:_propTypes.default.string,children:_propTypes.default.node};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.cacheCSS=cacheCSS;exports.cacheJS=cacheJS;exports.default=_default;var _path=_interopRequireDefault(require("path"));var _fs=_interopRequireDefault(require("fs"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}/**
|
|
2
|
-
* Stores css chunks styles into cache in string format
|
|
3
|
-
* @param {string} key - router path
|
|
4
|
-
* @param {object} data - css elements array extracted through loadable chunk extracter
|
|
5
|
-
*/function cacheCSS(key,data){if(!process.cssCache){process.cssCache={};}let pageCss="";if(Array.isArray(data)){try{data.map(assetChunk=>{const assetPathArr=assetChunk.key.split("/");const assetName=assetPathArr[assetPathArr.length-1];const ext=_path.default.extname(assetName);if(ext===".css")pageCss+=_fs.default.readFileSync(_path.default.resolve(process.env.src_path,`${process.env.BUILD_OUTPUT_PATH}/public`,assetName));});}catch(error){if(process.env.NODE_ENV=="development"){console.log("Error While Extracting The Chunk: ",_path.default.resolve(process.env.src_path,`${process.env.BUILD_OUTPUT_PATH}/public`));}}}process.cssCache[key]=pageCss;}/**
|
|
6
|
-
* Stores javascript into cache
|
|
7
|
-
* @param {string} key - router path
|
|
8
|
-
* @param {object} data - js elements array extracted through loadable chunk extracter
|
|
9
|
-
*/function cacheJS(key,data){if(!process.jsCache){process.jsCache={};}process.jsCache[key]=data;}/**
|
|
10
|
-
* returns cached css
|
|
11
|
-
* @param {string} key - router path
|
|
12
|
-
* @return {string} - cached css
|
|
13
|
-
*/function fetchCachedCSS(key){return process.cssCache&&process.cssCache[key]?process.cssCache[key]:null;}/**
|
|
14
|
-
* returns cached js
|
|
15
|
-
* @param {string} key - router path
|
|
16
|
-
* @return {string} - cached js
|
|
17
|
-
*/function fetchCachedJS(key){return process.jsCache&&process.jsCache[key]?process.jsCache[key]:null;}/**
|
|
18
|
-
* stores css and js in cache
|
|
19
|
-
* @param {object} res - response object
|
|
20
|
-
* @param {string} route - route path
|
|
21
|
-
*/function _default(res,route){try{const requestPath=route.path;const cachedCss=fetchCachedCSS(requestPath);const cachedJS=fetchCachedJS(requestPath);if(cachedCss||cachedJS){res.locals.pageJS=cachedJS;res.locals.pageCss=cachedCss;return;}}catch(error){console.log("Error while caching your assets.");}}
|
|
@@ -1,17 +0,0 @@
|
|
|
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.
|
|
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
|
-
(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
|
-
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
|
-
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
|
-
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
|
-
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);}};/**
|
|
9
|
-
* middleware for document handling
|
|
10
|
-
* @param {object} req - request object
|
|
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
|
|
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
|
|
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());}}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _extract=require("./extract");/**
|
|
2
|
-
* returns data which will be used in Head component for page rendering
|
|
3
|
-
* @param {string} pageCss - cached styles for page
|
|
4
|
-
* @param {string} pageJS - cached javscript elements for page
|
|
5
|
-
* @param {function} metaTagFunction - user defined function which returns meta tags in array
|
|
6
|
-
* @param {boolean} isBot - checks if request is made by bot
|
|
7
|
-
* @param {object} fetcherData - router fetched data
|
|
8
|
-
*/const renderStart=(pageCss,pageJS,metaTags,isBot,fetcherData)=>{const{IS_DEV_COMMAND,WEBPACK_DEV_SERVER_HOSTNAME,WEBPACK_DEV_SERVER_PORT}=process.env;let publicAssetPath=`${process.env.PUBLIC_STATIC_ASSET_URL}${process.env.PUBLIC_STATIC_ASSET_PATH}`;// serves assets from localhost on running devBuild and devServe command
|
|
9
|
-
if(JSON.parse(IS_DEV_COMMAND)){publicAssetPath=`http://${WEBPACK_DEV_SERVER_HOSTNAME}:${WEBPACK_DEV_SERVER_PORT}/assets/`;}return{pageCss,pageJS,metaTags,isBot,publicAssetPath,fetcherData};};/**
|
|
10
|
-
* returns data which will be used in body component for page rendering
|
|
11
|
-
* @param {object} webExtractor - loadable object which holds chunking function
|
|
12
|
-
* @param {string} initialState - reducer initial state
|
|
13
|
-
* @param {function} res - response object
|
|
14
|
-
* @param {boolean} jsx - jsx which needs to be render on server side
|
|
15
|
-
* @param {string|number|null} errorCode - error code
|
|
16
|
-
* @param {object} fetcherData - router fetched data
|
|
17
|
-
*/const renderEnd=(webExtractor,initialState={},res,jsx,errorCode,fetcherData)=>{// For bot first fold css and js would become complete page css and js
|
|
18
|
-
let firstFoldCss="";let firstFoldJS="";const isProd=process.env.NODE_ENV==="production";const{routePath,pageCss,pageJS}=res.locals;// Development: Extracts styles and javascript elements for injecting in Body Component.
|
|
19
|
-
// NOTE: Caching of styles and javascript is not enabled in development.
|
|
20
|
-
if(!isProd){firstFoldCss=webExtractor.getStyleElements();firstFoldJS=webExtractor.getScriptElements();}// Production: Extract styles and javscript elements if they are not found in cache and stores them in cache.
|
|
21
|
-
if(isProd&&routePath&&(!pageCss||!pageJS)){firstFoldCss=webExtractor.getStyleElements();firstFoldJS=webExtractor.getScriptElements();(0,_extract.cacheCSS)(routePath,webExtractor.getLinkElements());(0,_extract.cacheJS)(routePath,webExtractor.getScriptElements());}return{initialState,firstFoldCss,firstFoldJS,jsx,errorCode,fetcherData};};var _default=exports.default={renderStart,renderEnd};
|
package/server/startServer.js
DELETED
|
@@ -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
|
-
}
|
package/webpack/base.babel.js
DELETED
|
@@ -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
|