catalyst-core 0.0.1-beta.4 → 0.0.1-beta.6
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/babel.config.json +1 -0
- package/bin/catalyst.js +2 -5
- package/changelog.md +14 -22
- package/dist/caching.js +1 -0
- package/dist/index.js +1 -0
- package/dist/logger.js +10 -0
- package/dist/router/ClientRouter.js +3 -0
- package/dist/router/ServerRouter.js +1 -0
- package/dist/router.js +1 -0
- package/dist/scripts/build.js +10 -0
- package/dist/scripts/centralImport.js +1 -0
- package/dist/scripts/checkVersion.js +1 -0
- package/dist/scripts/devBuild.js +10 -0
- package/dist/scripts/devServe.js +5 -0
- package/dist/scripts/loadEnvironmentVariables.js +5 -0
- package/dist/scripts/loadScriptsBeforeServerStarts.js +4 -0
- package/dist/scripts/registerAliases.js +2 -0
- package/dist/scripts/scriptUtils.js +2 -0
- package/dist/scripts/serve.js +5 -0
- package/dist/scripts/start.js +6 -0
- package/dist/scripts/validator.js +1 -0
- package/dist/server/expressServer.js +9 -0
- package/dist/server/renderer/document/Body.js +14 -0
- package/dist/server/renderer/document/Head.js +9 -0
- package/dist/server/renderer/document/index.js +1 -0
- package/dist/server/renderer/extract.js +21 -0
- package/dist/server/renderer/handler.js +17 -0
- package/dist/server/renderer/index.js +1 -0
- package/dist/server/renderer/render.js +21 -0
- package/dist/server/startServer.js +6 -0
- package/dist/server/utils/userAgentUtil.js +9 -0
- package/dist/server/utils/validator.js +1 -0
- package/dist/webpack/babel-plugins/remove-client.plugin.js +5 -0
- package/dist/webpack/babel-plugins/remove-ssr.plugin.js +5 -0
- package/dist/webpack/babel.config.client.js +1 -0
- package/dist/webpack/babel.config.ssr.js +1 -0
- 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/dist/webpack/scssParams.js +9 -0
- package/package.json +109 -87
- package/.eslintignore +0 -9
- package/.eslintrc +0 -92
- package/caching.js +0 -16
- package/index.js +0 -16
- package/logger.js +0 -99
- package/router/ClientRouter.js +0 -19
- package/router/ServerRouter.js +0 -19
- package/router/index.js +0 -32
- package/router.js +0 -16
- package/scripts/build.js +0 -42
- package/scripts/checkVersion.js +0 -5
- package/scripts/devBuild.js +0 -42
- package/scripts/devServe.js +0 -43
- package/scripts/loadEnvironmentVariables.js +0 -24
- package/scripts/loadScriptsBeforeServerStarts.js +0 -47
- package/scripts/prepare.js +0 -19
- package/scripts/registerAliases.js +0 -30
- package/scripts/serve.js +0 -43
- package/scripts/start.js +0 -35
- package/scripts/validator.js +0 -127
- package/server/expressServer.js +0 -50
- package/server/mainIndex.js +0 -65
- package/server/mainServer.js +0 -70
- package/server/renderer/document/Body.js +0 -36
- package/server/renderer/document/Head.js +0 -43
- package/server/renderer/document/index.js +0 -27
- package/server/renderer/extract.js +0 -87
- package/server/renderer/handler.js +0 -240
- package/server/renderer/index.js +0 -12
- package/server/renderer/render.js +0 -84
- package/server/renderer/userAgentUtil.js +0 -55
- package/server/startServer.js +0 -66
- package/server/utils/metaTags.js +0 -13
- package/server/utils/userAgentUtil.js +0 -51
- package/server/utils/validator.js +0 -127
- package/tsconfig.json +0 -110
- package/webpack/babel-plugins/remove-client.plugin.js +0 -31
- package/webpack/babel-plugins/remove-ssr.plugin.js +0 -21
- package/webpack/babel.config.client.js +0 -24
- package/webpack/babel.config.js +0 -20
- package/webpack/babel.config.ssr.js +0 -24
- package/webpack/base.babel.js +0 -175
- package/webpack/development.client.babel.js +0 -85
- package/webpack/plugins/mime-types.js +0 -82
- package/webpack/plugins/route-manifest-copy.js +0 -122
- package/webpack/plugins/route-manifest-plugin.js +0 -122
- package/webpack/plugins/upload-assets-plugin.js +0 -181
- package/webpack/production.client.babel.js +0 -78
- package/webpack/production.ssr.babel.js +0 -61
- package/webpack/scssParams.js +0 -51
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const pc = require("picocolors");
|
|
4
|
-
const handleError = e => {
|
|
5
|
-
console.log(pc.red("Failed to start server: "), e);
|
|
6
|
-
};
|
|
7
|
-
const validatePreInitServer = fn => {
|
|
8
|
-
try {
|
|
9
|
-
if (!fn) throw new Error("preServerInit named function should be defined in server/index.js");
|
|
10
|
-
if (typeof fn !== "function") throw new Error("preServerInit should be function present in server/index.js");
|
|
11
|
-
return true;
|
|
12
|
-
} catch (e) {
|
|
13
|
-
handleError(e);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
const validateMiddleware = fn => {
|
|
17
|
-
try {
|
|
18
|
-
if (!fn) throw new Error("addMiddlewares named function not found in server/server.js");
|
|
19
|
-
if (typeof fn !== "function") throw new Error("addMiddlewares should be function present in server/server.js");
|
|
20
|
-
return true;
|
|
21
|
-
} catch (e) {
|
|
22
|
-
handleError(e);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
const validateReducerFunction = fn => {
|
|
26
|
-
try {
|
|
27
|
-
if (!fn) throw new Error("reducer not found in src/js/containers/App/reducer");
|
|
28
|
-
if (typeof fn !== "function") throw new Error("reducer should present in src/js/containers/App/reducer");
|
|
29
|
-
return true;
|
|
30
|
-
} catch (e) {
|
|
31
|
-
handleError(e);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
const validateConfigFile = obj => {
|
|
35
|
-
try {
|
|
36
|
-
if (!obj) throw new Error("config not found in config folder");
|
|
37
|
-
if (typeof obj !== "object") throw new Error("config object should be exported from config folder inside your project root directory");
|
|
38
|
-
if (typeof obj === "object") {
|
|
39
|
-
const requiredConfigKeys = {
|
|
40
|
-
NODE_SERVER_HOSTNAME: "",
|
|
41
|
-
NODE_SERVER_PORT: "",
|
|
42
|
-
WEBPACK_DEV_SERVER_HOSTNAME: "",
|
|
43
|
-
WEBPACK_DEV_SERVER_PORT: "",
|
|
44
|
-
BUILD_OUTPUT_PATH: "",
|
|
45
|
-
PUBLIC_STATIC_ASSET_PATH: "",
|
|
46
|
-
PUBLIC_STATIC_ASSET_URL: "",
|
|
47
|
-
CLIENT_ENV_VARIABLES: [],
|
|
48
|
-
ANALYZE_BUNDLE: ""
|
|
49
|
-
};
|
|
50
|
-
for (let key in requiredConfigKeys) {
|
|
51
|
-
if (!(key in obj)) throw new Error(`${key} key not found inside config.json`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return true;
|
|
55
|
-
} catch (e) {
|
|
56
|
-
handleError(e);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
const validatePackageJson = obj => {
|
|
60
|
-
try {
|
|
61
|
-
if (!obj) throw new Error("package.json not found in the project");
|
|
62
|
-
if (typeof obj !== "object") throw new Error("package.json should be defined in project root directory");
|
|
63
|
-
return true;
|
|
64
|
-
} catch (e) {
|
|
65
|
-
handleError(e);
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
const validateModuleAlias = obj => {
|
|
69
|
-
try {
|
|
70
|
-
if (!obj) throw new Error("moduleAliases not found in package.json file present in root directory.");
|
|
71
|
-
if (typeof obj !== "object") throw new Error("moduleAliases named object should be exported from package.json");
|
|
72
|
-
if (typeof obj === "object") {
|
|
73
|
-
const requiredModuleAliases = {
|
|
74
|
-
"@api": "api.js",
|
|
75
|
-
"@containers": "src/js/containers",
|
|
76
|
-
"@server": "server",
|
|
77
|
-
"@config": "config",
|
|
78
|
-
"@css": "src/static/css",
|
|
79
|
-
"@routes": "src/js/routes/"
|
|
80
|
-
};
|
|
81
|
-
for (let key in requiredModuleAliases) {
|
|
82
|
-
if (!(key in obj)) throw new Error(`${key} module alias not defined inside package.json`);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return true;
|
|
86
|
-
} catch (e) {
|
|
87
|
-
handleError(e);
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
const validateConfigureStore = fn => {
|
|
91
|
-
try {
|
|
92
|
-
if (!fn) throw new Error("configureStore not found in file src/js/store/index.js");
|
|
93
|
-
if (typeof fn !== "function") throw new Error("configureStore should be function exported from src/js/store/index.js");
|
|
94
|
-
return true;
|
|
95
|
-
} catch (e) {
|
|
96
|
-
handleError(e);
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
const validateGetRoutes = fn => {
|
|
100
|
-
try {
|
|
101
|
-
if (!fn) throw new Error("getRoutes not found in file src/js/routes/utils.js");
|
|
102
|
-
if (typeof fn !== "function") throw new Error("getRoutes should be function exported from src/js/routers/index.js");
|
|
103
|
-
return true;
|
|
104
|
-
} catch (e) {
|
|
105
|
-
handleError(e);
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
const validateCustomDocument = fn => {
|
|
109
|
-
try {
|
|
110
|
-
if (!fn) throw new Error("document not found in file server/document.js");
|
|
111
|
-
if (typeof fn !== "function") throw new Error("document should be a react component exported from server/document.js");
|
|
112
|
-
return true;
|
|
113
|
-
} catch (e) {
|
|
114
|
-
handleError(e);
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
module.exports = {
|
|
118
|
-
validateConfigFile,
|
|
119
|
-
validateConfigureStore,
|
|
120
|
-
validateCustomDocument,
|
|
121
|
-
validateGetRoutes,
|
|
122
|
-
validatePackageJson,
|
|
123
|
-
validateReducerFunction,
|
|
124
|
-
validateModuleAlias,
|
|
125
|
-
validatePreInitServer,
|
|
126
|
-
validateMiddleware
|
|
127
|
-
};
|
package/tsconfig.json
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
-
|
|
5
|
-
/* Projects */
|
|
6
|
-
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
7
|
-
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
-
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
9
|
-
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
10
|
-
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
-
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
-
|
|
13
|
-
/* Language and Environment */
|
|
14
|
-
"target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
|
15
|
-
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
|
-
"jsx": "react" /* Specify what JSX code is generated. */,
|
|
17
|
-
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
|
18
|
-
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
19
|
-
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
20
|
-
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
21
|
-
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
22
|
-
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
23
|
-
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
24
|
-
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
25
|
-
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
26
|
-
|
|
27
|
-
/* Modules */
|
|
28
|
-
"module": "commonjs" /* Specify what module code is generated. */,
|
|
29
|
-
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
30
|
-
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
31
|
-
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
32
|
-
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
33
|
-
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
34
|
-
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
35
|
-
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
36
|
-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
37
|
-
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
38
|
-
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
39
|
-
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
40
|
-
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
41
|
-
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
42
|
-
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
43
|
-
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
|
44
|
-
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
45
|
-
|
|
46
|
-
/* JavaScript Support */
|
|
47
|
-
"allowJs": true /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */,
|
|
48
|
-
"checkJs": false /* Enable error reporting in type-checked JavaScript files. */,
|
|
49
|
-
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
50
|
-
|
|
51
|
-
/* Emit */
|
|
52
|
-
"declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */,
|
|
53
|
-
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
54
|
-
"emitDeclarationOnly": true /* Only output d.ts files and not JavaScript files. */,
|
|
55
|
-
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
56
|
-
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
57
|
-
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
58
|
-
"outDir": "./types" /* Specify an output folder for all emitted files. */,
|
|
59
|
-
// "removeComments": true, /* Disable emitting comments. */
|
|
60
|
-
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
61
|
-
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
62
|
-
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
|
63
|
-
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
64
|
-
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
65
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
66
|
-
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
67
|
-
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
68
|
-
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
69
|
-
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
70
|
-
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
71
|
-
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
72
|
-
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
73
|
-
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
74
|
-
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
75
|
-
|
|
76
|
-
/* Interop Constraints */
|
|
77
|
-
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
78
|
-
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
79
|
-
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
80
|
-
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
|
81
|
-
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
82
|
-
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
83
|
-
|
|
84
|
-
/* Type Checking */
|
|
85
|
-
"strict": true /* Enable all strict type-checking options. */,
|
|
86
|
-
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
87
|
-
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
88
|
-
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
89
|
-
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
90
|
-
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
91
|
-
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
92
|
-
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
93
|
-
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
94
|
-
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
95
|
-
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
96
|
-
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
97
|
-
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
98
|
-
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
99
|
-
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
100
|
-
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
101
|
-
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
102
|
-
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
103
|
-
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
104
|
-
|
|
105
|
-
/* Completeness */
|
|
106
|
-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
107
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
108
|
-
},
|
|
109
|
-
"include": ["src"]
|
|
110
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = _default;
|
|
7
|
-
/**
|
|
8
|
-
* @description babel plugin used to remove unwanted code from the build.
|
|
9
|
-
* @return babel plugin object
|
|
10
|
-
*/
|
|
11
|
-
function _default() {
|
|
12
|
-
return {
|
|
13
|
-
name: "ast-transform",
|
|
14
|
-
// not required
|
|
15
|
-
visitor: {
|
|
16
|
-
ImportDefaultSpecifier(path) {
|
|
17
|
-
path.parentPath.parent.body = path.parentPath.parent.body.map(astStructure => {
|
|
18
|
-
if (astStructure.type === "VariableDeclaration") {
|
|
19
|
-
if (astStructure.declarations[0]?.init?.type === "ArrowFunctionExpression" && astStructure.declarations[0]?.init?.body?.body?.length > 0) {
|
|
20
|
-
astStructure.declarations[0].init.body.body = astStructure.declarations[0].init.body.body.filter(node => !(node?.type === "ExpressionStatement" && node?.expression?.callee?.name === "useEffect"));
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
if (astStructure?.type === "FunctionDeclaration" && astStructure?.body?.body?.length > 0) {
|
|
24
|
-
astStructure.body.body = astStructure.body.body.filter(node => !(node?.type === "ExpressionStatement" && node?.expression?.callee?.name === "useEffect"));
|
|
25
|
-
}
|
|
26
|
-
return astStructure;
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = _default;
|
|
7
|
-
/**
|
|
8
|
-
* @description babel plugin used to remove unwanted code from the build.
|
|
9
|
-
* @return babel plugin object
|
|
10
|
-
*/
|
|
11
|
-
function _default() {
|
|
12
|
-
return {
|
|
13
|
-
name: "ast-transform",
|
|
14
|
-
// not required
|
|
15
|
-
visitor: {
|
|
16
|
-
ImportDefaultSpecifier(path) {
|
|
17
|
-
path.parentPath.parent.body = path.parentPath.parent.body.filter(val => val?.expression?.left?.property?.name !== "serverSideFunction");
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _default = exports.default = {
|
|
8
|
-
babelrc: false,
|
|
9
|
-
presets: [["@babel/preset-env", {
|
|
10
|
-
targets: {
|
|
11
|
-
browsers: "last 2 versions"
|
|
12
|
-
}
|
|
13
|
-
}], "@babel/preset-react"],
|
|
14
|
-
plugins: ["@loadable/babel-plugin"],
|
|
15
|
-
env: {
|
|
16
|
-
production: {
|
|
17
|
-
plugins: [require("./babel-plugins/remove-ssr.plugin").default, "transform-react-remove-prop-types"]
|
|
18
|
-
},
|
|
19
|
-
test: {
|
|
20
|
-
presets: ["@babel/preset-react"]
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
ignore: ["__TEST__"]
|
|
24
|
-
};
|
package/webpack/babel.config.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _default = exports.default = {
|
|
8
|
-
"presets": [["@babel/preset-env", {
|
|
9
|
-
"targets": {
|
|
10
|
-
"node": "current"
|
|
11
|
-
}
|
|
12
|
-
}], "@babel/preset-react"],
|
|
13
|
-
"plugins": ["@babel/plugin-proposal-object-rest-spread", "transform-class-properties", "dynamic-import-node", "@loadable/babel-plugin"],
|
|
14
|
-
"env": {
|
|
15
|
-
"test": {
|
|
16
|
-
"presets": ["@babel/preset-react"]
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
"ignore": ["__TEST__"]
|
|
20
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _default = exports.default = {
|
|
8
|
-
babelrc: false,
|
|
9
|
-
presets: [["@babel/preset-env", {
|
|
10
|
-
targets: {
|
|
11
|
-
node: "current"
|
|
12
|
-
}
|
|
13
|
-
}], "@babel/preset-react"],
|
|
14
|
-
plugins: ["@loadable/babel-plugin"],
|
|
15
|
-
env: {
|
|
16
|
-
development: {
|
|
17
|
-
plugins: ["react-refresh/babel"]
|
|
18
|
-
},
|
|
19
|
-
production: {
|
|
20
|
-
plugins: [require("./babel-plugins/remove-client.plugin").default, "transform-react-remove-prop-types"]
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
ignore: ["__TEST__"]
|
|
24
|
-
};
|
package/webpack/base.babel.js
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.basePlugins = void 0;
|
|
7
|
-
var _path = _interopRequireDefault(require("path"));
|
|
8
|
-
var _webpack = _interopRequireDefault(require("webpack"));
|
|
9
|
-
var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plugin"));
|
|
10
|
-
var _webpackBundleAnalyzer = require("webpack-bundle-analyzer");
|
|
11
|
-
var _webpackPlugin = _interopRequireDefault(require("@loadable/webpack-plugin"));
|
|
12
|
-
var _scssParams = require("./scssParams");
|
|
13
|
-
var _babelConfig = _interopRequireDefault(require("./babel.config.client"));
|
|
14
|
-
var _babelConfig2 = _interopRequireDefault(require("./babel.config.ssr"));
|
|
15
|
-
var _loadEnvironmentVariables = _interopRequireDefault(require("../scripts/loadEnvironmentVariables"));
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
const catalystConfig = require(_path.default.resolve(__dirname, "..", "config.json"));
|
|
18
|
-
const {
|
|
19
|
-
CLIENT_ENV_VARIABLES: clientEnv,
|
|
20
|
-
ANALYZE_BUNDLE
|
|
21
|
-
} = require(`${process.env.src_path}/config/config.json`);
|
|
22
|
-
const {
|
|
23
|
-
_moduleAliases
|
|
24
|
-
} = require(`${process.env.src_path}/package.json`);
|
|
25
|
-
(0, _loadEnvironmentVariables.default)();
|
|
26
|
-
const isDev = process.env.NODE_ENV === "development";
|
|
27
|
-
const isSSR = !!process.env.SSR || false;
|
|
28
|
-
const basePlugins = exports.basePlugins = [new _webpackPlugin.default({
|
|
29
|
-
filename: "loadable-stats.json",
|
|
30
|
-
writeToDisk: {
|
|
31
|
-
filename: _path.default.join(__dirname, "..")
|
|
32
|
-
}
|
|
33
|
-
}),
|
|
34
|
-
// **This loads process.env variable during webpack build process
|
|
35
|
-
new _webpack.default.DefinePlugin({
|
|
36
|
-
"process.env": ([...clientEnv, ...Object.keys(process.env)] || []).reduce((clientEnvMap, env) => {
|
|
37
|
-
clientEnvMap[env] = JSON.stringify(process.env[env]);
|
|
38
|
-
return clientEnvMap;
|
|
39
|
-
}, {})
|
|
40
|
-
}),
|
|
41
|
-
// ** This is used to analyze bundle size.
|
|
42
|
-
ANALYZE_BUNDLE && new _webpackBundleAnalyzer.BundleAnalyzerPlugin({
|
|
43
|
-
generateStatsFile: ANALYZE_BUNDLE
|
|
44
|
-
}), new _webpack.default.IgnorePlugin({
|
|
45
|
-
resourceRegExp: /^\.\/locale$/,
|
|
46
|
-
contextRegExp: /moment$/
|
|
47
|
-
})];
|
|
48
|
-
const {
|
|
49
|
-
IS_DEV_COMMAND,
|
|
50
|
-
PUBLIC_STATIC_ASSET_URL,
|
|
51
|
-
PUBLIC_STATIC_ASSET_PATH,
|
|
52
|
-
WEBPACK_DEV_SERVER_HOSTNAME,
|
|
53
|
-
WEBPACK_DEV_SERVER_PORT,
|
|
54
|
-
NODE_SERVER_HOSTNAME,
|
|
55
|
-
NODE_SERVER_PORT
|
|
56
|
-
} = process.env;
|
|
57
|
-
let publicPath = isDev ? `http://${WEBPACK_DEV_SERVER_HOSTNAME}:${WEBPACK_DEV_SERVER_PORT}/` : `${PUBLIC_STATIC_ASSET_URL}${PUBLIC_STATIC_ASSET_PATH}`;
|
|
58
|
-
|
|
59
|
-
// serves assets from local on running devBuild and devServe command
|
|
60
|
-
if (JSON.parse(IS_DEV_COMMAND) && !isDev) {
|
|
61
|
-
publicPath = `http://${NODE_SERVER_HOSTNAME}:${NODE_SERVER_PORT}/assets/`;
|
|
62
|
-
}
|
|
63
|
-
var _default = exports.default = {
|
|
64
|
-
context: _path.default.resolve(process.env.src_path),
|
|
65
|
-
mode: isDev ? "development" : "production",
|
|
66
|
-
entry: {
|
|
67
|
-
app: [_path.default.resolve(process.env.src_path, "./client/index.js")]
|
|
68
|
-
},
|
|
69
|
-
output: {
|
|
70
|
-
path: _path.default.join(process.env.src_path, `${process.env.BUILD_OUTPUT_PATH}/public`),
|
|
71
|
-
chunkFilename: process.env.NODE_ENV === "development" ? catalystConfig.chunkFileNameDev : catalystConfig.chunkFileNameProd,
|
|
72
|
-
publicPath: publicPath,
|
|
73
|
-
chunkFilename: process.env.NODE_ENV === "development" ? catalystConfig.chunkFileNameDev : catalystConfig.chunkFileNameProd
|
|
74
|
-
},
|
|
75
|
-
resolve: {
|
|
76
|
-
fallback: {
|
|
77
|
-
url: require.resolve("url")
|
|
78
|
-
},
|
|
79
|
-
extensions: [".js", ".jsx", ".scss"],
|
|
80
|
-
alias: Object.keys(_moduleAliases || {}).reduce((moduleEnvMap, alias) => {
|
|
81
|
-
moduleEnvMap[alias] = _path.default.join(process.env.src_path, ..._moduleAliases[alias].split("/"));
|
|
82
|
-
return moduleEnvMap;
|
|
83
|
-
}, {})
|
|
84
|
-
},
|
|
85
|
-
plugins: basePlugins,
|
|
86
|
-
module: {
|
|
87
|
-
rules: [{
|
|
88
|
-
test: /\.jsx$|\.js$/,
|
|
89
|
-
exclude: _path.default.resolve(process.env.src_path, "./node_modules"),
|
|
90
|
-
use: {
|
|
91
|
-
loader: "babel-loader",
|
|
92
|
-
options: isSSR ? _babelConfig2.default : _babelConfig.default
|
|
93
|
-
}
|
|
94
|
-
}, {
|
|
95
|
-
// 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.
|
|
96
|
-
test: /\.scss$/,
|
|
97
|
-
exclude: [_path.default.resolve(process.env.src_path, "./node_modules"), _path.default.resolve(process.env.src_path, "./src/static/css/base")],
|
|
98
|
-
use: [isDev && "css-hot-loader", !isSSR && _miniCssExtractPlugin.default.loader, {
|
|
99
|
-
loader: "css-loader",
|
|
100
|
-
options: {
|
|
101
|
-
modules: {
|
|
102
|
-
mode: "local",
|
|
103
|
-
exportOnlyLocals: !isDev && isSSR,
|
|
104
|
-
localIdentName: isDev ? catalystConfig.cssModulesIdentifierDev : catalystConfig.cssModulesIdentifierProd
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}, {
|
|
108
|
-
loader: "postcss-loader"
|
|
109
|
-
}, {
|
|
110
|
-
loader: "sass-loader",
|
|
111
|
-
options: {
|
|
112
|
-
additionalData: "$font_url: " + (0, _scssParams.fontUrl)() + ";" + "$url_for: " + (0, _scssParams.imageUrl)() + ";"
|
|
113
|
-
}
|
|
114
|
-
}, {
|
|
115
|
-
loader: "sass-resources-loader",
|
|
116
|
-
options: {
|
|
117
|
-
resources: [_path.default.resolve(process.env.src_path, "./src/static/css/resources/*.scss")]
|
|
118
|
-
}
|
|
119
|
-
}]
|
|
120
|
-
}, {
|
|
121
|
-
// 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.
|
|
122
|
-
test: /\.scss$/,
|
|
123
|
-
include: [_path.default.resolve(process.env.src_path, "./node_modules"), _path.default.resolve(process.env.src_path, "./src/static/css/base")],
|
|
124
|
-
use: [isDev && "css-hot-loader", !isSSR && _miniCssExtractPlugin.default.loader, {
|
|
125
|
-
loader: "css-loader"
|
|
126
|
-
}, {
|
|
127
|
-
loader: "postcss-loader"
|
|
128
|
-
}, {
|
|
129
|
-
loader: "sass-loader",
|
|
130
|
-
options: {
|
|
131
|
-
additionalData: "$font_url: " + (0, _scssParams.fontUrl)() + ";" + "$url_for: " + (0, _scssParams.imageUrl)() + ";"
|
|
132
|
-
}
|
|
133
|
-
}, {
|
|
134
|
-
loader: "sass-resources-loader",
|
|
135
|
-
options: {
|
|
136
|
-
resources: [_path.default.resolve(process.env.src_path, "./src/static/css/resources/*.scss")]
|
|
137
|
-
}
|
|
138
|
-
}]
|
|
139
|
-
}, {
|
|
140
|
-
test: /\.css$/,
|
|
141
|
-
use: [!isSSR && _miniCssExtractPlugin.default.loader, "css-loader", "postcss-loader"]
|
|
142
|
-
}, {
|
|
143
|
-
test: /\.(png|jpg|gif|jpeg|ico?)$/,
|
|
144
|
-
use: ["url-loader?limit=10240", "img-loader"]
|
|
145
|
-
}, {
|
|
146
|
-
test: /\.svg$/i,
|
|
147
|
-
issuer: /\.[jt]sx?$/,
|
|
148
|
-
use: ["@svgr/webpack", "url-loader?limit=10240", "img-loader"]
|
|
149
|
-
}, {
|
|
150
|
-
// This loader loads fonts in src/static/fonts using file-loader
|
|
151
|
-
test: /\.(ttf|eot|woff2|json?)$/,
|
|
152
|
-
use: [{
|
|
153
|
-
loader: "url-loader",
|
|
154
|
-
options: {
|
|
155
|
-
limit: 10240,
|
|
156
|
-
outputPath: [_path.default.resolve(process.env.src_path, "./src/static/fonts/")]
|
|
157
|
-
}
|
|
158
|
-
}, "file-loader"]
|
|
159
|
-
}, {
|
|
160
|
-
// This loader loads html files
|
|
161
|
-
test: /\.html$/,
|
|
162
|
-
use: [{
|
|
163
|
-
loader: "html-loader",
|
|
164
|
-
options: {
|
|
165
|
-
minimize: {
|
|
166
|
-
minifyJS: true,
|
|
167
|
-
minifyCSS: true,
|
|
168
|
-
removeComments: false,
|
|
169
|
-
collapseWhitespace: true
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}]
|
|
173
|
-
}]
|
|
174
|
-
}
|
|
175
|
-
};
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _path = _interopRequireDefault(require("path"));
|
|
4
|
-
var _webpackDevServer = _interopRequireDefault(require("webpack-dev-server"));
|
|
5
|
-
var _webpack = _interopRequireDefault(require("webpack"));
|
|
6
|
-
var _webpackMerge = _interopRequireDefault(require("webpack-merge"));
|
|
7
|
-
var _baseBabel = _interopRequireDefault(require("./base.babel.js"));
|
|
8
|
-
var _reactRefreshWebpackPlugin = _interopRequireDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
|
|
9
|
-
var _miniCssExtractPlugin = _interopRequireDefault(require("mini-css-extract-plugin"));
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
/* eslint-disable no-console */
|
|
12
|
-
|
|
13
|
-
const {
|
|
14
|
-
WEBPACK_DEV_SERVER_PORT,
|
|
15
|
-
WEBPACK_DEV_SERVER_HOSTNAME,
|
|
16
|
-
NODE_SERVER_PORT,
|
|
17
|
-
NODE_SERVER_HOSTNAME
|
|
18
|
-
} = process.env;
|
|
19
|
-
const catalystConfig = require(_path.default.resolve(__dirname, "..", "config.json"));
|
|
20
|
-
const plugins = require(_path.default.join(process.env.src_path, "webpackConfig.js"));
|
|
21
|
-
const webpackConfig = (0, _webpackMerge.default)(_baseBabel.default, {
|
|
22
|
-
devtool: "inline-source-map",
|
|
23
|
-
stats: "minimal",
|
|
24
|
-
plugins: [new _reactRefreshWebpackPlugin.default({
|
|
25
|
-
overlay: {
|
|
26
|
-
entry: false
|
|
27
|
-
}
|
|
28
|
-
}), new _miniCssExtractPlugin.default({
|
|
29
|
-
filename: catalystConfig.cssChunkFileName,
|
|
30
|
-
ignoreOrder: true
|
|
31
|
-
}), ...plugins.developmentPlugins].filter(Boolean),
|
|
32
|
-
optimization: {
|
|
33
|
-
runtimeChunk: "single",
|
|
34
|
-
moduleIds: "deterministic",
|
|
35
|
-
splitChunks: {
|
|
36
|
-
cacheGroups: {
|
|
37
|
-
commonVendor: {
|
|
38
|
-
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)[\\/]/,
|
|
39
|
-
name: "commonVendor",
|
|
40
|
-
minSize: 30000
|
|
41
|
-
},
|
|
42
|
-
utilityVendor: {
|
|
43
|
-
maxInitialRequests: Infinity,
|
|
44
|
-
chunks: "all",
|
|
45
|
-
// minSize: 0, // Enable to replicate stand alone chunking for all packages
|
|
46
|
-
reuseExistingChunk: true,
|
|
47
|
-
// Disable to replicate stand alone chunking for all packages
|
|
48
|
-
minRemainingSize: 1000,
|
|
49
|
-
// Disable to replicate stand alone chunking for all packages
|
|
50
|
-
test: /[\\/]node_modules[\\/]/,
|
|
51
|
-
name(module) {
|
|
52
|
-
const moduleFileName = module.identifier().split("/").reduceRight(item => item);
|
|
53
|
-
return `npm.${moduleFileName}`;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
console.info("Firing up catalyst dev server...\n");
|
|
61
|
-
let devServer = new _webpackDevServer.default({
|
|
62
|
-
port: WEBPACK_DEV_SERVER_PORT,
|
|
63
|
-
host: WEBPACK_DEV_SERVER_HOSTNAME,
|
|
64
|
-
static: {
|
|
65
|
-
publicPath: webpackConfig.output.publicPath
|
|
66
|
-
},
|
|
67
|
-
hot: true,
|
|
68
|
-
historyApiFallback: true,
|
|
69
|
-
open: [`http://${NODE_SERVER_HOSTNAME}:${NODE_SERVER_PORT}`],
|
|
70
|
-
headers: {
|
|
71
|
-
"Access-Control-Allow-Origin": "*"
|
|
72
|
-
},
|
|
73
|
-
client: {
|
|
74
|
-
logging: "error",
|
|
75
|
-
overlay: {
|
|
76
|
-
errors: false,
|
|
77
|
-
warnings: false,
|
|
78
|
-
runtimeErrors: false
|
|
79
|
-
},
|
|
80
|
-
reconnect: true
|
|
81
|
-
}
|
|
82
|
-
}, (0, _webpack.default)(webpackConfig));
|
|
83
|
-
devServer.startCallback(() => {
|
|
84
|
-
console.info(`Webpack dev server mounted at http://${WEBPACK_DEV_SERVER_HOSTNAME}:${WEBPACK_DEV_SERVER_PORT}.`);
|
|
85
|
-
});
|