rebuiltron 6.0.2 → 6.1.0
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/configurations/base.js +2 -2
- package/configurations/main.js +2 -1
- package/configurations/preloads.js +2 -1
- package/configurations/renderers.js +9 -8
- package/eslint.config.js +9 -0
- package/helpers/constants.js +16 -0
- package/helpers/paths.js +1 -0
- package/helpers/utils.js +86 -10
- package/loaders/javascript.js +13 -1
- package/loaders/style.js +1 -1
- package/package.json +12 -11
- package/scripts/build.js +10 -4
- package/scripts/start.js +3 -5
- package/tasks/buildApp.js +38 -42
- package/tasks/checkSetup.js +2 -1
- package/tasks/compileMain.js +42 -22
- package/tasks/startDevServer.js +52 -12
- package/tasks/startElectron.js +6 -4
- package/tasks/watchPreloads.js +57 -48
- package/webpack.config.js +2 -2
- package/webpackDevServer.config.js +4 -0
- package/helpers/logger.js +0 -55
package/configurations/base.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const { createHash } = require("crypto");
|
|
2
2
|
|
|
3
3
|
const CaseSensitivePathsPlugin = require("case-sensitive-paths-webpack-plugin");
|
|
4
|
-
const TerserPlugin = require("terser-webpack-plugin");
|
|
5
4
|
const ModuleNotFoundPlugin = require("react-dev-utils/ModuleNotFoundPlugin");
|
|
5
|
+
const TerserPlugin = require("terser-webpack-plugin");
|
|
6
6
|
|
|
7
|
-
const paths = require("../helpers/paths");
|
|
8
7
|
const { isEnvDevelopment, isEnvProduction } = require("../helpers/environment");
|
|
8
|
+
const paths = require("../helpers/paths");
|
|
9
9
|
const { emptyOr } = require("../helpers/utils");
|
|
10
10
|
|
|
11
11
|
|
package/configurations/main.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
const paths = require("../helpers/paths");
|
|
2
|
+
const javascriptLoaders = require("../loaders/javascript");
|
|
2
3
|
const rebuiltronConfig = require("../rebuiltronConfig");
|
|
4
|
+
|
|
3
5
|
const baseConfig = require("./base");
|
|
4
|
-
const javascriptLoaders = require("../loaders/javascript");
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
const { main } = require(paths.appConfig);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
const { mapKeys } = require("lodash");
|
|
2
2
|
|
|
3
3
|
const paths = require("../helpers/paths");
|
|
4
|
+
const javascriptLoaders = require("../loaders/javascript");
|
|
4
5
|
const rebuiltronConfig = require("../rebuiltronConfig");
|
|
6
|
+
|
|
5
7
|
const baseConfig = require("./base");
|
|
6
|
-
const javascriptLoaders = require("../loaders/javascript");
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
const { preloads } = require(paths.appConfig);
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
const path = require("path");
|
|
2
2
|
|
|
3
|
-
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
4
|
-
const CopyPlugin = require("copy-webpack-plugin");
|
|
5
|
-
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
6
|
-
const InlineChunkHtmlPlugin = require("react-dev-utils/InlineChunkHtmlPlugin");
|
|
7
3
|
const ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin");
|
|
4
|
+
const CopyPlugin = require("copy-webpack-plugin");
|
|
8
5
|
const CssMinimizerPlugin = require("css-minimizer-webpack-plugin");
|
|
6
|
+
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
9
7
|
const { keys } = require("lodash");
|
|
8
|
+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
9
|
+
const InlineChunkHtmlPlugin = require("react-dev-utils/InlineChunkHtmlPlugin");
|
|
10
10
|
|
|
11
|
-
const paths = require("../helpers/paths");
|
|
12
11
|
const { isEnvProduction, isEnvDevelopment, shouldUseSourceMap } = require("../helpers/environment");
|
|
12
|
+
const paths = require("../helpers/paths");
|
|
13
13
|
const { emptyOr } = require("../helpers/utils");
|
|
14
|
-
const rebuiltronConfig = require("../rebuiltronConfig");
|
|
15
|
-
const baseConfig = require("./base");
|
|
16
14
|
const imageLoaders = require("../loaders/images");
|
|
17
|
-
const styleLoaders = require("../loaders/style");
|
|
18
15
|
const javascriptLoaders = require("../loaders/javascript");
|
|
16
|
+
const styleLoaders = require("../loaders/style");
|
|
17
|
+
const rebuiltronConfig = require("../rebuiltronConfig");
|
|
18
|
+
|
|
19
|
+
const baseConfig = require("./base");
|
|
19
20
|
|
|
20
21
|
|
|
21
22
|
const { renderers } = require(paths.appConfig);
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const COMPILATION_ASSETS = Object.freeze({
|
|
2
|
+
PRELOAD: "Preload",
|
|
3
|
+
MAIN: "Main",
|
|
4
|
+
RENDERER: "Renderer"
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
const COMPILATION_STATES = Object.freeze({
|
|
8
|
+
PENDING: "pending",
|
|
9
|
+
FATAL_ERROR: "fatalError",
|
|
10
|
+
ERROR: "error",
|
|
11
|
+
WARNING: "warning",
|
|
12
|
+
SUCCESS: "success"
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
module.exports = { COMPILATION_ASSETS, COMPILATION_STATES };
|
package/helpers/paths.js
CHANGED
package/helpers/utils.js
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable jsdoc/valid-types, jsdoc/match-description */
|
|
2
|
+
|
|
2
3
|
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
3
5
|
|
|
6
|
+
const { bold, red, green, yellow } = require("chalk");
|
|
4
7
|
const { isArray } = require("lodash");
|
|
5
8
|
|
|
6
|
-
const
|
|
9
|
+
const { COMPILATION_STATES } = require("./constants");
|
|
7
10
|
const spinnies = require("./spinnies");
|
|
8
11
|
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
/**
|
|
14
|
+
* @import { Stats } from "webpack"
|
|
15
|
+
* @import { COMPILATION_ASSETS } from "./constants"
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Path of the app directory.
|
|
20
|
+
*/
|
|
11
21
|
|
|
22
|
+
const _appDirectory = fs.realpathSync(process.cwd());
|
|
12
23
|
|
|
13
24
|
/**
|
|
14
25
|
* Resolves a path relative to the app directory.
|
|
@@ -19,15 +30,15 @@ const _appDirectory = fs.realpathSync(process.cwd());
|
|
|
19
30
|
const resolveApp = (relativePath) => path.resolve(_appDirectory, relativePath);
|
|
20
31
|
|
|
21
32
|
/**
|
|
22
|
-
* Logs error message
|
|
23
|
-
* @param {
|
|
33
|
+
* Logs error message (if provided) and exits the running process.
|
|
34
|
+
* @param {Error} [error] - Error to log
|
|
24
35
|
*/
|
|
25
36
|
|
|
26
37
|
const exitProcessWithError = (error) => {
|
|
27
38
|
spinnies.stopAll("fail");
|
|
28
39
|
|
|
29
|
-
|
|
30
|
-
|
|
40
|
+
if (!error) return;
|
|
41
|
+
console.log(red(`\n${error?.message || error}\n`));
|
|
31
42
|
|
|
32
43
|
process.exit(1);
|
|
33
44
|
};
|
|
@@ -35,8 +46,8 @@ const exitProcessWithError = (error) => {
|
|
|
35
46
|
/**
|
|
36
47
|
* Returns the given value when the condition is truthy, otherwise an empty element of the same type.
|
|
37
48
|
* @param {any} condition - Condition determining if the value should be returned
|
|
38
|
-
* @param {(object|Array)} value - Value to return
|
|
39
|
-
* @returns {(object|Array)} Value or empty element
|
|
49
|
+
* @param {(object | Array)} value - Value to return
|
|
50
|
+
* @returns {(object | Array)} Value or empty element
|
|
40
51
|
*/
|
|
41
52
|
|
|
42
53
|
const emptyOr = (condition, value) => {
|
|
@@ -44,5 +55,70 @@ const emptyOr = (condition, value) => {
|
|
|
44
55
|
return condition ? value : empty;
|
|
45
56
|
};
|
|
46
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Clears the console.
|
|
60
|
+
*/
|
|
61
|
+
|
|
62
|
+
const clearConsole = () => {
|
|
63
|
+
process.stdout.write(
|
|
64
|
+
process.platform === "win32" ? "\x1B[2J\x1B[0f" : "\x1B[2J\x1B[3J\x1B[H"
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Logs stats.
|
|
70
|
+
* @param {Stats} stats - Stats to log
|
|
71
|
+
*/
|
|
72
|
+
|
|
73
|
+
const logStats = (stats) => {
|
|
74
|
+
console.log();
|
|
75
|
+
|
|
76
|
+
console.log(stats.toString({
|
|
77
|
+
colors: true,
|
|
78
|
+
all: false,
|
|
79
|
+
warnings: true,
|
|
80
|
+
errors: true,
|
|
81
|
+
errorDetails: false
|
|
82
|
+
}));
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @typedef CompilationData
|
|
87
|
+
* @property {COMPILATION_ASSETS[keyof COMPILATION_ASSETS]} [asset] - Type of the compiled asset
|
|
88
|
+
* @property {COMPILATION_STATES[keyof COMPILATION_STATES]} state - Compilation state
|
|
89
|
+
* @property {Stats} [stats] - Compilation stats
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Constructs the text to display for the given compilation state.
|
|
94
|
+
* @param {CompilationData} data - Compilation data
|
|
95
|
+
* @returns {string} Compilation text
|
|
96
|
+
*/
|
|
97
|
+
|
|
98
|
+
const getCompilationText = ({ asset, state, stats }) => {
|
|
99
|
+
let prefix = asset ? bold(`${asset}: `) : "";
|
|
100
|
+
|
|
101
|
+
if (state === COMPILATION_STATES.PENDING) return prefix + `${asset ? "c" : "C"}ompiling...`;
|
|
102
|
+
if (state === COMPILATION_STATES.FATAL_ERROR) return prefix + bold(`${asset ? "f" : "F"}ailed`) + " to compile";
|
|
103
|
+
|
|
104
|
+
prefix += `${asset ? "c" : "C"}ompiled `;
|
|
105
|
+
|
|
106
|
+
if (state === COMPILATION_STATES.SUCCESS) return prefix + green(bold("successfully"));
|
|
107
|
+
|
|
108
|
+
const isError = state === COMPILATION_STATES.ERROR;
|
|
109
|
+
|
|
110
|
+
const count = stats.toJson()[isError ? "errorsCount" : "warningsCount"];
|
|
111
|
+
const color = isError ? red : yellow;
|
|
112
|
+
|
|
113
|
+
return prefix + "with " + bold(color(`${count} ${state}${count > 1 ? "s" : ""}`));
|
|
114
|
+
};
|
|
115
|
+
|
|
47
116
|
|
|
48
|
-
module.exports = {
|
|
117
|
+
module.exports = {
|
|
118
|
+
resolveApp,
|
|
119
|
+
exitProcessWithError,
|
|
120
|
+
emptyOr,
|
|
121
|
+
logStats,
|
|
122
|
+
clearConsole,
|
|
123
|
+
getCompilationText
|
|
124
|
+
};
|
package/loaders/javascript.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
const
|
|
1
|
+
const path = require("path");
|
|
2
|
+
|
|
2
3
|
const { shouldUseSourceMap, isEnvProduction } = require("../helpers/environment");
|
|
4
|
+
const paths = require("../helpers/paths");
|
|
3
5
|
|
|
4
6
|
|
|
5
7
|
module.exports = [
|
|
@@ -10,6 +12,16 @@ module.exports = [
|
|
|
10
12
|
loader: require.resolve("swc-loader"),
|
|
11
13
|
options: {
|
|
12
14
|
jsc: {
|
|
15
|
+
experimental: {
|
|
16
|
+
plugins: [
|
|
17
|
+
["@swc/plugin-transform-imports", {
|
|
18
|
+
lodash: {
|
|
19
|
+
transform: "lodash/{{member}}"
|
|
20
|
+
}
|
|
21
|
+
}]
|
|
22
|
+
],
|
|
23
|
+
cacheRoot: path.join(paths.appWebpackCache, "swc")
|
|
24
|
+
},
|
|
13
25
|
parser: {
|
|
14
26
|
syntax: "ecmascript",
|
|
15
27
|
jsx: true,
|
package/loaders/style.js
CHANGED
|
@@ -2,8 +2,8 @@ const path = require("path");
|
|
|
2
2
|
|
|
3
3
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
4
4
|
|
|
5
|
-
const paths = require("../helpers/paths");
|
|
6
5
|
const { shouldUseSourceMap, isEnvDevelopment, isEnvProduction } = require("../helpers/environment");
|
|
6
|
+
const paths = require("../helpers/paths");
|
|
7
7
|
const { emptyOr } = require("../helpers/utils");
|
|
8
8
|
const rebuiltronConfig = require("../rebuiltronConfig");
|
|
9
9
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rebuiltron",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"author": "Arkellys",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bin": {
|
|
@@ -10,38 +10,39 @@
|
|
|
10
10
|
"lint": "eslint ."
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
|
-
"eslint": "^
|
|
14
|
-
"eslint-config-arklint": "^
|
|
13
|
+
"eslint": "^9.14.0",
|
|
14
|
+
"eslint-config-arklint": "^3.3.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
|
|
18
18
|
"@svgr/webpack": "^8.1.0",
|
|
19
|
-
"@swc/core": "^1.7.
|
|
20
|
-
"
|
|
19
|
+
"@swc/core": "^1.7.42",
|
|
20
|
+
"@swc/plugin-transform-imports": "^4.0.0",
|
|
21
|
+
"browserslist": "^4.24.2",
|
|
21
22
|
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|
|
22
23
|
"copy-webpack-plugin": "^12.0.2",
|
|
23
24
|
"css-loader": "^7.1.2",
|
|
24
25
|
"css-minimizer-webpack-plugin": "^7.0.0",
|
|
25
26
|
"detect-port": "^1.6.1",
|
|
26
27
|
"fs-extra": "^11.2.0",
|
|
27
|
-
"html-webpack-plugin": "^5.6.
|
|
28
|
+
"html-webpack-plugin": "^5.6.3",
|
|
28
29
|
"lodash": "^4.17.21",
|
|
29
|
-
"mini-css-extract-plugin": "^2.9.
|
|
30
|
+
"mini-css-extract-plugin": "^2.9.2",
|
|
30
31
|
"postcss": "^8.4.47",
|
|
31
32
|
"postcss-flexbugs-fixes": "^5.0.2",
|
|
32
33
|
"postcss-loader": "^8.1.1",
|
|
33
|
-
"postcss-normalize": "^13.0.
|
|
34
|
-
"postcss-preset-env": "^10.0.
|
|
34
|
+
"postcss-normalize": "^13.0.1",
|
|
35
|
+
"postcss-preset-env": "^10.0.9",
|
|
35
36
|
"react-dev-utils": "^12.0.1",
|
|
36
37
|
"react-refresh": "^0.14.2",
|
|
37
38
|
"resolve-url-loader": "^5.0.0",
|
|
38
|
-
"sass-loader": "^16.0.
|
|
39
|
+
"sass-loader": "^16.0.3",
|
|
39
40
|
"source-map-loader": "^5.0.0",
|
|
40
41
|
"spinnies": "^0.5.1",
|
|
41
42
|
"style-loader": "^4.0.0",
|
|
42
43
|
"swc-loader": "^0.2.6",
|
|
43
44
|
"terser-webpack-plugin": "^5.3.10",
|
|
44
|
-
"webpack": "^5.
|
|
45
|
+
"webpack": "^5.96.1",
|
|
45
46
|
"webpack-dev-server": "^5.1.0"
|
|
46
47
|
},
|
|
47
48
|
"peerDependencies": {
|
package/scripts/build.js
CHANGED
|
@@ -2,12 +2,13 @@ process.env.BABEL_ENV = "production";
|
|
|
2
2
|
process.env.NODE_ENV = "production";
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
const fsExtra = require("fs-extra");
|
|
5
6
|
const { measureFileSizesBeforeBuild, printFileSizesAfterBuild } = require("react-dev-utils/FileSizeReporter");
|
|
6
7
|
|
|
7
|
-
const buildApp = require("../tasks/buildApp");
|
|
8
|
-
const checkSetup = require("../tasks/checkSetup");
|
|
9
8
|
const paths = require("../helpers/paths");
|
|
10
9
|
const { exitProcessWithError } = require("../helpers/utils");
|
|
10
|
+
const buildApp = require("../tasks/buildApp");
|
|
11
|
+
const checkSetup = require("../tasks/checkSetup");
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
process.on("unhandledRejection", exitProcessWithError);
|
|
@@ -16,8 +17,13 @@ const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
|
|
16
17
|
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
|
17
18
|
|
|
18
19
|
checkSetup
|
|
19
|
-
.then(() =>
|
|
20
|
-
|
|
20
|
+
.then(() => (
|
|
21
|
+
measureFileSizesBeforeBuild(paths.appBuild)
|
|
22
|
+
))
|
|
23
|
+
.then((previousFileSizes) => {
|
|
24
|
+
fsExtra.emptyDirSync(paths.appBuild);
|
|
25
|
+
return buildApp(previousFileSizes);
|
|
26
|
+
})
|
|
21
27
|
.then(({ stats, previousFileSizes }) => {
|
|
22
28
|
console.log("\nFile sizes after gzip:\n");
|
|
23
29
|
|
package/scripts/start.js
CHANGED
|
@@ -2,14 +2,12 @@ process.env.BABEL_ENV = "development";
|
|
|
2
2
|
process.env.NODE_ENV = "development";
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
const clearConsole = require("
|
|
6
|
-
|
|
5
|
+
const { exitProcessWithError, clearConsole } = require("../helpers/utils");
|
|
7
6
|
const checkSetup = require("../tasks/checkSetup");
|
|
8
|
-
const startDevServer = require("../tasks/startDevServer");
|
|
9
7
|
const compileMain = require("../tasks/compileMain");
|
|
10
|
-
const
|
|
8
|
+
const startDevServer = require("../tasks/startDevServer");
|
|
11
9
|
const startElectron = require("../tasks/startElectron");
|
|
12
|
-
const
|
|
10
|
+
const watchPreloads = require("../tasks/watchPreloads");
|
|
13
11
|
|
|
14
12
|
|
|
15
13
|
process.on("unhandledRejection", exitProcessWithError);
|
package/tasks/buildApp.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
const fsExtra = require("fs-extra");
|
|
2
1
|
const webpack = require("webpack");
|
|
3
|
-
const clearConsole = require("react-dev-utils/clearConsole");
|
|
4
|
-
const formatWebpackMessages = require("react-dev-utils/formatWebpackMessages");
|
|
5
|
-
const { bold, green, yellow } = require("chalk");
|
|
6
2
|
|
|
7
|
-
const
|
|
8
|
-
const webpackConfig = require("../webpack.config");
|
|
3
|
+
const { COMPILATION_STATES } = require("../helpers/constants");
|
|
9
4
|
const spinnies = require("../helpers/spinnies");
|
|
10
|
-
const
|
|
5
|
+
const { logStats, getCompilationText, clearConsole } = require("../helpers/utils");
|
|
6
|
+
const webpackConfig = require("../webpack.config");
|
|
11
7
|
|
|
12
8
|
|
|
13
9
|
/**
|
|
@@ -16,50 +12,50 @@ const log = require("../helpers/logger");
|
|
|
16
12
|
* @returns {Promise<{ stats: webpack.Stats | undefined, previousFileSizes: any }>} Result of the build
|
|
17
13
|
*/
|
|
18
14
|
|
|
19
|
-
module.exports = (previousFileSizes) => {
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
module.exports = (previousFileSizes) => new Promise((resolve, reject) => {
|
|
16
|
+
clearConsole();
|
|
17
|
+
spinnies.add("build", { text: "Creating the production build" });
|
|
22
18
|
|
|
23
|
-
|
|
19
|
+
webpack(webpackConfig.production, (error, stats) => {
|
|
24
20
|
clearConsole();
|
|
25
|
-
spinnies.add("build", { text: "Creating the production build" });
|
|
26
|
-
|
|
27
|
-
compiler.run((error, stats) => {
|
|
28
|
-
if (!error) {
|
|
29
|
-
return resolve({
|
|
30
|
-
stats,
|
|
31
|
-
previousFileSizes
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
21
|
|
|
22
|
+
if (error || stats.hasErrors()) {
|
|
35
23
|
spinnies.fail("build", {
|
|
36
|
-
text:
|
|
24
|
+
text: getCompilationText({
|
|
25
|
+
state: COMPILATION_STATES.FATAL_ERROR
|
|
26
|
+
})
|
|
37
27
|
});
|
|
38
28
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
if (stats) logStats(stats);
|
|
30
|
+
return reject(error);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (stats.hasWarnings()) {
|
|
34
|
+
spinnies.update("build", {
|
|
35
|
+
text: getCompilationText({
|
|
36
|
+
state: COMPILATION_STATES.WARNING
|
|
37
|
+
}),
|
|
38
|
+
status: "stopped",
|
|
39
|
+
color: "white"
|
|
40
|
+
});
|
|
47
41
|
|
|
48
|
-
|
|
42
|
+
logStats(stats);
|
|
49
43
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
});
|
|
44
|
+
return resolve({
|
|
45
|
+
stats,
|
|
46
|
+
previousFileSizes
|
|
47
|
+
});
|
|
48
|
+
}
|
|
56
49
|
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
spinnies.succeed("build", {
|
|
51
|
+
text: getCompilationText({
|
|
52
|
+
state: COMPILATION_STATES.SUCCESS
|
|
53
|
+
})
|
|
54
|
+
});
|
|
59
55
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
return resolve({
|
|
57
|
+
stats,
|
|
58
|
+
previousFileSizes
|
|
63
59
|
});
|
|
64
60
|
});
|
|
65
|
-
};
|
|
61
|
+
});
|
package/tasks/checkSetup.js
CHANGED
|
@@ -3,8 +3,9 @@ const fs = require("fs");
|
|
|
3
3
|
const detect = require("detect-port");
|
|
4
4
|
|
|
5
5
|
const { isEnvProduction } = require("../helpers/environment");
|
|
6
|
-
const rebuiltronConfig = require("../rebuiltronConfig");
|
|
7
6
|
const { resolveApp } = require("../helpers/utils");
|
|
7
|
+
const rebuiltronConfig = require("../rebuiltronConfig");
|
|
8
|
+
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* @type {Promise<number>}
|
package/tasks/compileMain.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const webpack = require("webpack");
|
|
2
|
-
const { bold, green } = require("chalk");
|
|
3
|
-
const formatWebpackMessages = require("react-dev-utils/formatWebpackMessages");
|
|
4
2
|
|
|
5
|
-
const
|
|
3
|
+
const { COMPILATION_ASSETS, COMPILATION_STATES } = require("../helpers/constants");
|
|
6
4
|
const spinnies = require("../helpers/spinnies");
|
|
5
|
+
const { getCompilationText, logStats } = require("../helpers/utils");
|
|
6
|
+
const webpackConfig = require("../webpack.config");
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -11,31 +11,51 @@ const spinnies = require("../helpers/spinnies");
|
|
|
11
11
|
* @returns {Promise<void>} Promise resolving when compilation is successful
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
module.exports = () => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
return new Promise((resolve, reject) => {
|
|
18
|
-
spinnies.add("compile-main", { text: "Compiling main file..." });
|
|
14
|
+
module.exports = () => new Promise((resolve, reject) => {
|
|
15
|
+
const asset = COMPILATION_ASSETS.MAIN;
|
|
19
16
|
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
spinnies.add("compile-main", {
|
|
18
|
+
text: getCompilationText({
|
|
19
|
+
asset,
|
|
20
|
+
state: COMPILATION_STATES.PENDING
|
|
21
|
+
})
|
|
22
|
+
});
|
|
22
23
|
|
|
24
|
+
webpack(webpackConfig.development.main, (error, stats) => {
|
|
25
|
+
if (error || stats.hasErrors()) {
|
|
23
26
|
spinnies.fail("compile-main", {
|
|
24
|
-
text:
|
|
27
|
+
text: getCompilationText({
|
|
28
|
+
asset,
|
|
29
|
+
state: COMPILATION_STATES.FATAL_ERROR
|
|
30
|
+
})
|
|
25
31
|
});
|
|
26
32
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
if (stats) logStats(stats);
|
|
34
|
+
return reject(error);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (stats.hasWarnings()) {
|
|
38
|
+
spinnies.update("compile-main", {
|
|
39
|
+
text: getCompilationText({
|
|
40
|
+
asset,
|
|
41
|
+
state: COMPILATION_STATES.WARNING,
|
|
42
|
+
stats
|
|
43
|
+
}),
|
|
44
|
+
status: "stopped",
|
|
45
|
+
color: "white"
|
|
46
|
+
});
|
|
33
47
|
|
|
34
|
-
|
|
48
|
+
logStats(stats);
|
|
49
|
+
return resolve();
|
|
50
|
+
}
|
|
35
51
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
52
|
+
spinnies.succeed("compile-main", {
|
|
53
|
+
text: getCompilationText({
|
|
54
|
+
asset,
|
|
55
|
+
state: COMPILATION_STATES.SUCCESS
|
|
56
|
+
})
|
|
39
57
|
});
|
|
58
|
+
|
|
59
|
+
return resolve();
|
|
40
60
|
});
|
|
41
|
-
};
|
|
61
|
+
});
|
package/tasks/startDevServer.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
const { bold } = require("chalk");
|
|
1
2
|
const webpack = require("webpack");
|
|
2
3
|
const WebpackDevServer = require("webpack-dev-server");
|
|
3
|
-
const clearConsole = require("react-dev-utils/clearConsole");
|
|
4
|
-
const { bold } = require("chalk");
|
|
5
4
|
|
|
5
|
+
const { COMPILATION_ASSETS, COMPILATION_STATES } = require("../helpers/constants");
|
|
6
|
+
const spinnies = require("../helpers/spinnies");
|
|
7
|
+
const { getCompilationText, logStats, clearConsole } = require("../helpers/utils");
|
|
6
8
|
const webpackConfig = require("../webpack.config");
|
|
7
9
|
const devServerConfig = require("../webpackDevServer.config");
|
|
8
|
-
|
|
10
|
+
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Starts the development server.
|
|
@@ -18,28 +20,66 @@ module.exports = (port) => (
|
|
|
18
20
|
let devServer;
|
|
19
21
|
let isFirstRun = true;
|
|
20
22
|
|
|
21
|
-
const
|
|
23
|
+
const asset = COMPILATION_ASSETS.RENDERER;
|
|
24
|
+
const compiler = webpack(webpackConfig.development.renderers);
|
|
22
25
|
|
|
23
26
|
spinnies.add("devServer", { text: "Starting the development server" });
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
clearConsole();
|
|
27
|
-
|
|
28
|
+
compiler.hooks.compile.tap("compile", () => {
|
|
29
|
+
if (!isFirstRun) clearConsole();
|
|
30
|
+
|
|
31
|
+
spinnies.add("compile", {
|
|
32
|
+
text: getCompilationText({
|
|
33
|
+
asset,
|
|
34
|
+
state: COMPILATION_STATES.PENDING
|
|
35
|
+
})
|
|
36
|
+
});
|
|
28
37
|
});
|
|
29
38
|
|
|
30
|
-
|
|
39
|
+
compiler.hooks.done.tap("done", (stats) => {
|
|
31
40
|
if (isFirstRun) {
|
|
32
41
|
isFirstRun = false;
|
|
33
42
|
|
|
34
43
|
spinnies.succeed("devServer", { text: `Development server running on port ${bold(port)}` });
|
|
35
|
-
|
|
44
|
+
resolve(devServer);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (stats.hasErrors()) {
|
|
48
|
+
spinnies.fail("compile", {
|
|
49
|
+
text: getCompilationText({
|
|
50
|
+
asset,
|
|
51
|
+
state: COMPILATION_STATES.ERROR,
|
|
52
|
+
stats
|
|
53
|
+
}),
|
|
54
|
+
failColor: "white"
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return logStats(stats);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (stats.hasWarnings()) {
|
|
61
|
+
spinnies.update("compile", {
|
|
62
|
+
text: getCompilationText({
|
|
63
|
+
asset,
|
|
64
|
+
state: COMPILATION_STATES.WARNING,
|
|
65
|
+
stats
|
|
66
|
+
}),
|
|
67
|
+
status: "stopped",
|
|
68
|
+
color: "white"
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
return logStats(stats);
|
|
36
72
|
}
|
|
37
73
|
|
|
38
|
-
|
|
39
|
-
|
|
74
|
+
spinnies.succeed("compile", {
|
|
75
|
+
text: getCompilationText({
|
|
76
|
+
asset,
|
|
77
|
+
state: COMPILATION_STATES.SUCCESS
|
|
78
|
+
})
|
|
79
|
+
});
|
|
40
80
|
});
|
|
41
81
|
|
|
42
|
-
devServer = new WebpackDevServer({ ...devServerConfig, port },
|
|
82
|
+
devServer = new WebpackDevServer({ ...devServerConfig, port }, compiler);
|
|
43
83
|
await devServer.start();
|
|
44
84
|
})
|
|
45
85
|
);
|
package/tasks/startElectron.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const { spawn } = require("child_process");
|
|
2
|
-
const path = require("path");
|
|
3
2
|
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
const { bold } = require("chalk");
|
|
4
6
|
|
|
5
7
|
const spinnies = require("../helpers/spinnies");
|
|
6
8
|
|
|
@@ -13,7 +15,7 @@ const spinnies = require("../helpers/spinnies");
|
|
|
13
15
|
|
|
14
16
|
module.exports = (port) => (
|
|
15
17
|
new Promise((resolve, reject) => {
|
|
16
|
-
spinnies.add("electron", { text:
|
|
18
|
+
spinnies.add("electron", { text: `Starting ${bold("Electron")}` });
|
|
17
19
|
|
|
18
20
|
try {
|
|
19
21
|
const electronPath = require.resolve("electron");
|
|
@@ -30,11 +32,11 @@ module.exports = (port) => (
|
|
|
30
32
|
}
|
|
31
33
|
}).on("close", process.exit);
|
|
32
34
|
|
|
33
|
-
spinnies.succeed("electron", { text: "Electron started
|
|
35
|
+
spinnies.succeed("electron", { text: `${bold("Electron")} started` });
|
|
34
36
|
resolve();
|
|
35
37
|
|
|
36
38
|
} catch (error) {
|
|
37
|
-
spinnies.fail("electron", { text: "Failed to start Electron
|
|
39
|
+
spinnies.fail("electron", { text: `${bold("Failed")} to start Electron` });
|
|
38
40
|
reject(error);
|
|
39
41
|
}
|
|
40
42
|
})
|
package/tasks/watchPreloads.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
const webpack = require("webpack");
|
|
2
|
-
const { red, bold, green, yellow } = require("chalk");
|
|
3
|
-
const formatWebpackMessages = require("react-dev-utils/formatWebpackMessages");
|
|
4
|
-
const clearConsole = require("react-dev-utils/clearConsole");
|
|
5
2
|
|
|
6
|
-
const
|
|
3
|
+
const { COMPILATION_ASSETS, COMPILATION_STATES } = require("../helpers/constants");
|
|
7
4
|
const spinnies = require("../helpers/spinnies");
|
|
8
|
-
const
|
|
5
|
+
const { logStats, getCompilationText, clearConsole } = require("../helpers/utils");
|
|
6
|
+
const webpackConfig = require("../webpack.config");
|
|
9
7
|
|
|
10
8
|
|
|
11
9
|
/**
|
|
@@ -13,61 +11,72 @@ const log = require("../helpers/logger");
|
|
|
13
11
|
* @returns {Promise<void>} Promise resolving when compilation is successful
|
|
14
12
|
*/
|
|
15
13
|
|
|
16
|
-
module.exports = () => {
|
|
17
|
-
|
|
14
|
+
module.exports = () => new Promise((resolve, reject) => {
|
|
15
|
+
let isFirstWatch = true;
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
const asset = COMPILATION_ASSETS.PRELOAD;
|
|
18
|
+
const compiler = webpack(webpackConfig.development.preloads);
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
isFirstWatch = false;
|
|
20
|
+
compiler.hooks.compile.tap("compile", () => {
|
|
21
|
+
if (!isFirstWatch) clearConsole();
|
|
25
22
|
|
|
26
|
-
|
|
23
|
+
spinnies.add("watch", {
|
|
24
|
+
text: getCompilationText({
|
|
25
|
+
asset,
|
|
26
|
+
state: COMPILATION_STATES.PENDING
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
});
|
|
27
30
|
|
|
31
|
+
compiler.watch({}, (error, stats) => {
|
|
32
|
+
if (error) {
|
|
28
33
|
spinnies.fail("watch", {
|
|
29
|
-
text:
|
|
34
|
+
text: getCompilationText({
|
|
35
|
+
asset,
|
|
36
|
+
state: COMPILATION_STATES.FATAL_ERROR
|
|
37
|
+
})
|
|
30
38
|
});
|
|
31
39
|
|
|
32
|
-
reject(error);
|
|
33
|
-
}
|
|
40
|
+
return reject(error);
|
|
41
|
+
}
|
|
34
42
|
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
if (isFirstWatch) {
|
|
44
|
+
isFirstWatch = false;
|
|
45
|
+
resolve();
|
|
46
|
+
}
|
|
37
47
|
|
|
38
|
-
|
|
39
|
-
|
|
48
|
+
if (stats.hasErrors()) {
|
|
49
|
+
spinnies.fail("watch", {
|
|
50
|
+
text: getCompilationText({
|
|
51
|
+
asset,
|
|
52
|
+
state: COMPILATION_STATES.ERROR,
|
|
53
|
+
stats
|
|
54
|
+
}),
|
|
55
|
+
failColor: "white"
|
|
40
56
|
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
preloadCompiler.hooks.done.tap("done", (stats) => {
|
|
44
|
-
const statsData = stats.toJson({ all: false, warnings: true, errors: true });
|
|
45
|
-
const { errors, warnings } = formatWebpackMessages(statsData);
|
|
46
|
-
|
|
47
|
-
if (stats.hasErrors()) {
|
|
48
|
-
if (isFirstWatch) throw new Error(errors); // Stops the process
|
|
49
|
-
|
|
50
|
-
spinnies.fail("watch", {
|
|
51
|
-
text: `Preload file(s) compiled ${red(bold("with errors"))}`,
|
|
52
|
-
failColor: "white"
|
|
53
|
-
});
|
|
54
57
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
return logStats(stats);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (stats.hasWarnings()) {
|
|
62
|
+
spinnies.update("watch", {
|
|
63
|
+
text: getCompilationText({
|
|
64
|
+
asset,
|
|
65
|
+
state: COMPILATION_STATES.WARNING,
|
|
66
|
+
stats
|
|
67
|
+
}),
|
|
68
|
+
status: "stopped",
|
|
69
|
+
color: "white"
|
|
70
|
+
});
|
|
64
71
|
|
|
65
|
-
|
|
66
|
-
|
|
72
|
+
return logStats(stats);
|
|
73
|
+
}
|
|
67
74
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
75
|
+
spinnies.succeed("watch", {
|
|
76
|
+
text: getCompilationText({
|
|
77
|
+
asset,
|
|
78
|
+
state: COMPILATION_STATES.SUCCESS
|
|
79
|
+
})
|
|
71
80
|
});
|
|
72
81
|
});
|
|
73
|
-
};
|
|
82
|
+
});
|
package/webpack.config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const rendererConfig = require("./configurations/renderers");
|
|
2
|
-
const preloadConfig = require("./configurations/preloads");
|
|
3
1
|
const mainConfig = require("./configurations/main");
|
|
2
|
+
const preloadConfig = require("./configurations/preloads");
|
|
3
|
+
const rendererConfig = require("./configurations/renderers");
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
@@ -15,11 +15,15 @@ module.exports = {
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
client: {
|
|
18
|
+
progress: true,
|
|
18
19
|
overlay: {
|
|
19
20
|
errors: true,
|
|
20
21
|
warnings: false
|
|
21
22
|
}
|
|
22
23
|
},
|
|
24
|
+
devMiddleware: {
|
|
25
|
+
stats: "none" // Already handled manually
|
|
26
|
+
},
|
|
23
27
|
historyApiFallback: {
|
|
24
28
|
disableDotRule: true, // Supports route with dots
|
|
25
29
|
index: paths.basePath
|
package/helpers/logger.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
const { red, green, yellow, black } = require("chalk");
|
|
2
|
-
const { isString } = require("lodash");
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* @typedef {(string|string[])} LogMessage
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Formats a message into a single string.
|
|
11
|
-
* @param {LogMessage} message - Message to format
|
|
12
|
-
* @returns {string} Formatted message
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
const _formatMessage = (message) => {
|
|
16
|
-
if (isString(message)) return message;
|
|
17
|
-
return message.join("\n");
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Logs a message in red.
|
|
23
|
-
* @param {LogMessage} message - Message to log
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
const logError = (message) => console.log(red(`\n${_formatMessage(message)}\n`));
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Logs a message in green.
|
|
30
|
-
* @param {LogMessage} message - Message to log
|
|
31
|
-
*/
|
|
32
|
-
|
|
33
|
-
const logSuccess = (message) => console.log(green(`\n${_formatMessage(message)}\n`));
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Logs a message in yellow.
|
|
37
|
-
* @param {LogMessage} message - Message to log
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
const logWarning = (message) => console.log(yellow(`\n${_formatMessage(message)}\n`));
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Logs a message in black.
|
|
44
|
-
* @param {string} message - Message to log
|
|
45
|
-
*/
|
|
46
|
-
|
|
47
|
-
const logInfo = (message) => console.log(black(`${message}\n`));
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
module.exports = {
|
|
51
|
-
error: logError,
|
|
52
|
-
success: logSuccess,
|
|
53
|
-
warning: logWarning,
|
|
54
|
-
info: logInfo
|
|
55
|
-
};
|