@sleeperhq/mini-core 4.0.2 → 4.0.4-a

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 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/rspack.config.js`;
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\033[91m" + error + "\033[0m");
95
+ console.error("\n\x1b[91m" + error + "\x1b[0m");
92
96
  };
93
97
 
94
98
  const printInfo = (message) => {
95
- console.log("\n\033[96m" + message + "\033[0m");
99
+ console.log("\n\x1b[96m" + message + "\x1b[0m");
96
100
  };
97
101
 
98
102
  const printComplete = (message) => {
99
- console.log("\033[92m" + message + "\033[0m");
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\033[96m[current: " + fallback + "]\033[0m " + message, (name) => {
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
- main();
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);
@@ -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.1",
22
+ "@sleeperhq/mini-core": "4.0.4-a",
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sleeperhq/mini-core",
3
- "version": "4.0.2",
3
+ "version": "4.0.4-a",
4
4
  "description": "Core library frameworks for developing Sleeper Mini Apps.",
5
5
  "main": "index.ts",
6
6
  "types": "index.d.ts",
@@ -38,6 +38,7 @@
38
38
  "@babel/runtime": "7.26.0",
39
39
  "@callstack/repack": "blitzstudios/repack.git#callstack-repack-v5.0.9-gitpkg",
40
40
  "@callstack/repack-plugin-reanimated": "5.1.1",
41
+ "@module-federation/enhanced": "0.14.3",
41
42
  "@react-native-community/cli": "15.0.1",
42
43
  "@react-native-community/cli-platform-android": "15.0.1",
43
44
  "@react-native-community/cli-platform-apple": "15.0.1",
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
 
@@ -243,7 +237,7 @@ module.exports = env => {
243
237
  },
244
238
  extraChunks: [
245
239
  {
246
- include: new RegExp('.*'),
240
+ include: /.*/,
247
241
  type: 'remote',
248
242
  outputPath: path.join(__dirname, '..', '..', '..', 'dist', config.name, platform),
249
243
  },
@@ -251,8 +245,9 @@ module.exports = env => {
251
245
  listenerIP: config.remoteIP,
252
246
  }),
253
247
  new ReanimatedPlugin(),
254
- new Repack.plugins.ModuleFederationPlugin({
248
+ new Repack.plugins.ModuleFederationPluginV2({
255
249
  name: config.name,
250
+ filename: `${config.name}.container.bundle`,
256
251
  exposes: {
257
252
  app: sampleClassPathLocal,
258
253
  },
package/webpack.config.js CHANGED
@@ -119,7 +119,6 @@ module.exports = env => {
119
119
  ? 'index.android.bundle'
120
120
  : 'index.ios.bundle',
121
121
  chunkFilename: '[name].chunk.bundle',
122
- publicPath: Repack.getPublicPath({platform, devServer}),
123
122
  uniqueName: config.name,
124
123
  },
125
124
  /**
@@ -289,7 +288,7 @@ module.exports = env => {
289
288
  },
290
289
  extraChunks: [
291
290
  {
292
- include: new RegExp('.*'),
291
+ include: /.*/,
293
292
  type: 'remote',
294
293
  outputPath: path.join(__dirname, '..', '..', '..', 'dist', config.name, platform),
295
294
  },
@@ -297,8 +296,9 @@ module.exports = env => {
297
296
  listenerIP: config.remoteIP,
298
297
  }),
299
298
 
300
- new Repack.plugins.ModuleFederationPlugin({
299
+ new Repack.plugins.ModuleFederationPluginV2({
301
300
  name: config.name,
301
+ filename: `${config.name}.container.bundle`,
302
302
  exposes: {
303
303
  app: sampleClassPathLocal,
304
304
  },