@sleeperhq/mini-core 4.0.2 → 4.0.3
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/bin/build_mini.js +28 -9
- package/mini_packages.json +1 -1
- package/package.json +1 -1
- package/rspack.config.js +1 -7
package/bin/build_mini.js
CHANGED
|
@@ -5,10 +5,11 @@ const os = require('os');
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const readLine = require('readline');
|
|
7
7
|
const fs = require('fs');
|
|
8
|
+
const yargs = require('yargs');
|
|
8
9
|
|
|
9
10
|
const isWindows = os.platform() === 'win32';
|
|
10
11
|
|
|
11
|
-
const getCommands = (projectName) => {
|
|
12
|
+
const getCommands = (projectName, useWebpack = false) => {
|
|
12
13
|
// Pathing
|
|
13
14
|
const distPath = path.join('dist', projectName);
|
|
14
15
|
const zipFilePath = `${distPath}.zip`;
|
|
@@ -26,6 +27,9 @@ const getCommands = (projectName) => {
|
|
|
26
27
|
};
|
|
27
28
|
const reactNativeCliPath = path.join('node_modules', 'react-native', 'cli.js');
|
|
28
29
|
|
|
30
|
+
// Choose config file based on useWebpack flag
|
|
31
|
+
const configFile = useWebpack ? 'webpack.config.js' : 'rspack.config.js';
|
|
32
|
+
|
|
29
33
|
// Commands
|
|
30
34
|
const removeDir = (isWindows ? 'rmdir /s /q ' : 'rm -rf ');
|
|
31
35
|
// TODO (Windows): double check this zip command.
|
|
@@ -47,7 +51,7 @@ const getCommands = (projectName) => {
|
|
|
47
51
|
--sourcemap-output "${sourcemapOutputPath[platform]}" \
|
|
48
52
|
--minify true \
|
|
49
53
|
--assets-dest "${assetsDestPath[platform]}" \
|
|
50
|
-
--webpackConfig ./node_modules/@sleeperhq/mini-core
|
|
54
|
+
--webpackConfig ./node_modules/@sleeperhq/mini-core/${configFile}`;
|
|
51
55
|
};
|
|
52
56
|
|
|
53
57
|
// Exposed
|
|
@@ -88,15 +92,15 @@ const spawnProcess = (command, errorMessage) => {
|
|
|
88
92
|
};
|
|
89
93
|
|
|
90
94
|
const printError = (error) => {
|
|
91
|
-
console.error("\n\
|
|
95
|
+
console.error("\n\x1b[91m" + error + "\x1b[0m");
|
|
92
96
|
};
|
|
93
97
|
|
|
94
98
|
const printInfo = (message) => {
|
|
95
|
-
console.log("\n\
|
|
99
|
+
console.log("\n\x1b[96m" + message + "\x1b[0m");
|
|
96
100
|
};
|
|
97
101
|
|
|
98
102
|
const printComplete = (message) => {
|
|
99
|
-
console.log("\
|
|
103
|
+
console.log("\x1b[92m" + message + "\x1b[0m");
|
|
100
104
|
};
|
|
101
105
|
|
|
102
106
|
const getInput = (message, fallback) => {
|
|
@@ -106,7 +110,7 @@ const getInput = (message, fallback) => {
|
|
|
106
110
|
});
|
|
107
111
|
|
|
108
112
|
return new Promise((resolve) => {
|
|
109
|
-
interface.question("\n\
|
|
113
|
+
interface.question("\n\x1b[96m[current: " + fallback + "]\x1b[0m " + message, (name) => {
|
|
110
114
|
const result = name.trim();
|
|
111
115
|
if (!result) {
|
|
112
116
|
resolve(fallback);
|
|
@@ -136,7 +140,11 @@ const validateProjectName = (name) => {
|
|
|
136
140
|
return regex.test(name);
|
|
137
141
|
}
|
|
138
142
|
|
|
139
|
-
const main = async () => {
|
|
143
|
+
const main = async (useWebpack = false) => {
|
|
144
|
+
// Print configuration info
|
|
145
|
+
const configType = useWebpack ? 'webpack' : 'rspack';
|
|
146
|
+
printInfo(`Using ${configType} configuration`);
|
|
147
|
+
|
|
140
148
|
// Enter project name.
|
|
141
149
|
const fallback = getProjectName();
|
|
142
150
|
const projectName = await getInput("Enter project name (return to skip): ", fallback);
|
|
@@ -150,7 +158,7 @@ const main = async () => {
|
|
|
150
158
|
setProjectName(projectName);
|
|
151
159
|
}
|
|
152
160
|
|
|
153
|
-
const commands = getCommands(projectName);
|
|
161
|
+
const commands = getCommands(projectName, useWebpack);
|
|
154
162
|
|
|
155
163
|
const shouldClean = await getInput("Clean and rebuild project? (y/n): ", 'y');
|
|
156
164
|
if (shouldClean === 'y') {
|
|
@@ -186,4 +194,15 @@ const main = async () => {
|
|
|
186
194
|
process.exit(0);
|
|
187
195
|
};
|
|
188
196
|
|
|
189
|
-
|
|
197
|
+
// Set up command line arguments
|
|
198
|
+
const argv = yargs(process.argv.slice(2))
|
|
199
|
+
.option('webpack', {
|
|
200
|
+
alias: 'w',
|
|
201
|
+
type: 'boolean',
|
|
202
|
+
description: 'Use webpack configuration instead of rspack',
|
|
203
|
+
default: false,
|
|
204
|
+
})
|
|
205
|
+
.help()
|
|
206
|
+
.alias('help', 'h').argv;
|
|
207
|
+
|
|
208
|
+
main(argv.webpack).catch(console.error);
|
package/mini_packages.json
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@react-navigation/native": "6.1.17",
|
|
20
20
|
"@react-navigation/stack": "6.4.0",
|
|
21
21
|
"@shopify/flash-list": "1.7.6",
|
|
22
|
-
"@sleeperhq/mini-core": "4.0.
|
|
22
|
+
"@sleeperhq/mini-core": "4.0.3",
|
|
23
23
|
"amazon-cognito-identity-js": "6.3.2",
|
|
24
24
|
"crypto-js": "3.3.0",
|
|
25
25
|
"decimal.js-light": "2.5.1",
|
package/package.json
CHANGED
package/rspack.config.js
CHANGED
|
@@ -45,13 +45,7 @@ module.exports = env => {
|
|
|
45
45
|
const dev = mode === 'development';
|
|
46
46
|
|
|
47
47
|
const sharedDeps = Object.keys(dependencies).reduce((acc, key) => {
|
|
48
|
-
acc[key] = {
|
|
49
|
-
requiredVersion: dependencies[key],
|
|
50
|
-
// Only set eager for development to prevent sync loading issues in production
|
|
51
|
-
eager: dev && (key === 'react' || key === 'react-native'),
|
|
52
|
-
// Only set singleton for critical packages
|
|
53
|
-
...(key === 'react' || key === 'react-native' ? { singleton: true } : {})
|
|
54
|
-
};
|
|
48
|
+
acc[key] = { eager: dev, requiredVersion: dependencies[key] };
|
|
55
49
|
return acc;
|
|
56
50
|
}, {});
|
|
57
51
|
|