@sleeperhq/mini-core 4.0.0 → 4.0.2

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
@@ -47,7 +47,7 @@ const getCommands = (projectName) => {
47
47
  --sourcemap-output "${sourcemapOutputPath[platform]}" \
48
48
  --minify true \
49
49
  --assets-dest "${assetsDestPath[platform]}" \
50
- --webpackConfig ./node_modules/@sleeperhq/mini-core/webpack.config.js`;
50
+ --webpackConfig ./node_modules/@sleeperhq/mini-core/rspack.config.js`;
51
51
  };
52
52
 
53
53
  // Exposed
@@ -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.0",
22
+ "@sleeperhq/mini-core": "4.0.1",
23
23
  "amazon-cognito-identity-js": "6.3.2",
24
24
  "crypto-js": "3.3.0",
25
25
  "decimal.js-light": "2.5.1",
@@ -52,7 +52,6 @@
52
52
  "react-native-image-pan-zoom": "2.1.12",
53
53
  "react-native-image-picker": "4.10.3",
54
54
  "react-native-image-resizer": "1.4.5",
55
- "react-native-interactable": "2.0.1",
56
55
  "react-native-iphone-x-helper": "1.3.1",
57
56
  "react-native-json-tree": "1.3.0",
58
57
  "react-native-keep-awake": "4.0.0",
@@ -96,7 +95,7 @@
96
95
  "rn-prompt": "1.0.4"
97
96
  },
98
97
  "overrides": {
99
- "@callstack/repack": "5.0.7-c",
98
+ "@callstack/repack": "5.0.9",
100
99
  "@react-native-async-storage/async-storage": "2.2.0",
101
100
  "@react-native-community/audio-toolkit": "2.0.3",
102
101
  "react-native-chart-kit": "6.7.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sleeperhq/mini-core",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "Core library frameworks for developing Sleeper Mini Apps.",
5
5
  "main": "index.ts",
6
6
  "types": "index.d.ts",
@@ -36,17 +36,21 @@
36
36
  "dependencies": {
37
37
  "@babel/plugin-transform-runtime": "7.25.9",
38
38
  "@babel/runtime": "7.26.0",
39
- "@callstack/repack": "blitzstudios/repack.git#callstack-repack-v5.0.7-c-gitpkg",
39
+ "@callstack/repack": "blitzstudios/repack.git#callstack-repack-v5.0.9-gitpkg",
40
+ "@callstack/repack-plugin-reanimated": "5.1.1",
40
41
  "@react-native-community/cli": "15.0.1",
41
42
  "@react-native-community/cli-platform-android": "15.0.1",
42
43
  "@react-native-community/cli-platform-apple": "15.0.1",
43
44
  "@react-native-community/cli-platform-ios": "15.0.1",
44
45
  "@react-native-community/netinfo": "11.3.2",
46
+ "@rspack/core": "1.3.15",
45
47
  "@rspack/plugin-react-refresh": "1.0.0",
48
+ "@swc/helpers": "0.5.17",
46
49
  "axios": "0.15.3",
47
50
  "babel-loader": "9.1.3",
48
51
  "react-native-fast-image": "https://github.com/blitzstudios/react-native-fast-image.git#release/1.4",
49
52
  "react-native-linear-gradient": "2.8.3",
53
+ "react-native-reanimated": "3.17.1",
50
54
  "react-native-rename": "blitzstudios/react-native-rename.git#react-native-rename-v3.2.17-gitpkg",
51
55
  "react-native-turbo-image": "1.22.3",
52
56
  "regenerator-runtime": "0.13.11",
@@ -0,0 +1,279 @@
1
+ const path = require('path');
2
+ const Repack = require('../../../node_modules/@callstack/repack');
3
+ const config = require('../../../app.json');
4
+ const { dependencies } = require('../../../package.json');
5
+ const { RebuildNotifyPlugin } = require('./src/plugins/rebuildNotifyPlugin');
6
+ const { ReanimatedPlugin } = require('@callstack/repack-plugin-reanimated');
7
+
8
+ const { samples, selectedSample } = config;
9
+ const sampleClassPath = `../../../src/${samples[selectedSample]}`;
10
+ const sampleClassPathLocal = `./src/${samples[selectedSample]}`
11
+
12
+ /**
13
+ * More documentation, installation, usage, motivation and differences with Metro is available at:
14
+ * https://github.com/callstack/repack/blob/main/README.md
15
+ *
16
+ * The API documentation for the functions and plugins used in this file is available at:
17
+ * https://re-pack.netlify.app/
18
+ */
19
+
20
+ /**
21
+ * Webpack configuration.
22
+ * You can also export a static object or a function returning a Promise.
23
+ *
24
+ * @param env Environment options passed from either Webpack CLI or React Native CLI
25
+ * when running with `react-native start/bundle`.
26
+ */
27
+ module.exports = env => {
28
+ const {
29
+ mode = 'development',
30
+ context = path.resolve(__dirname, '..', '..', '..'),
31
+ entry = './node_modules/@sleeperhq/mini-core/start.tsx',
32
+ platform,
33
+ minimize = mode === 'production',
34
+ devServer = undefined,
35
+ bundleFilename = undefined,
36
+ sourceMapFilename = undefined,
37
+ assetsPath = undefined,
38
+ reactNativePath = require.resolve('react-native'),
39
+ } = env;
40
+
41
+ if (!platform) {
42
+ throw new Error('Missing platform');
43
+ }
44
+
45
+ const dev = mode === 'development';
46
+
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
+ };
55
+ return acc;
56
+ }, {});
57
+
58
+ /**
59
+ * Using Module Federation might require disabling hmr.
60
+ * Uncomment below to set `devServer.hmr` to `false`.
61
+ *
62
+ * Keep in mind that `devServer` object is not available
63
+ * when running `webpack-bundle` command. Be sure
64
+ * to check its value to avoid accessing undefined value,
65
+ * otherwise an error might occur.
66
+ */
67
+ // if (devServer) {
68
+ // devServer.hmr = false;
69
+ // }
70
+
71
+ /**
72
+ * Depending on your Babel configuration you might want to keep it.
73
+ * If you don't use `env` in your Babel config, you can remove it.
74
+ *
75
+ * Keep in mind that if you remove it you should set `BABEL_ENV` or `NODE_ENV`
76
+ * to `development` or `production`. Otherwise your production code might be compiled with
77
+ * in development mode by Babel.
78
+ */
79
+ process.env.BABEL_ENV = mode;
80
+
81
+ return {
82
+ mode,
83
+ /**
84
+ * This should be always `false`, since the Source Map configuration is done
85
+ * by `SourceMapDevToolPlugin`.
86
+ */
87
+ devtool: 'source-map',
88
+ context,
89
+ entry,
90
+ resolve: {
91
+ /**
92
+ * `getResolveOptions` returns additional resolution configuration for React Native.
93
+ * If it's removed, you won't be able to use `<file>.<platform>.<ext>` (eg: `file.ios.js`)
94
+ * convention and some 3rd-party libraries that specify `react-native` field
95
+ * in their `package.json` might not work correctly.
96
+ */
97
+ ...Repack.getResolveOptions(platform),
98
+
99
+ /**
100
+ * Uncomment this to ensure all `react-native*` imports will resolve to the same React Native
101
+ * dependency. You might need it when using workspaces/monorepos or unconventional project
102
+ * structure. For simple/typical project you won't need it.
103
+ */
104
+ // alias: {
105
+ // 'react-native': reactNativePath,
106
+ // },
107
+ alias: {
108
+ app: path.resolve(__dirname, sampleClassPath),
109
+ root: path.resolve(__dirname, '..', '..', '..'),
110
+ },
111
+ },
112
+ /**
113
+ * Configures output.
114
+ * It's recommended to leave it as it is unless you know what you're doing.
115
+ * By default Webpack will emit files into the directory specified under `path`. In order for the
116
+ * React Native app use them when bundling the `.ipa`/`.apk`, they need to be copied over with
117
+ * `Repack.OutputPlugin`, which is configured by default inside `Repack.RepackPlugin`.
118
+ */
119
+ output: {
120
+ clean: true,
121
+ path: path.join(__dirname, '..', '..', '..', 'build', platform),
122
+ filename: dev
123
+ ? 'index.bundle'
124
+ : platform === 'android'
125
+ ? 'index.android.bundle'
126
+ : 'index.ios.bundle',
127
+ chunkFilename: '[name].chunk.bundle',
128
+ uniqueName: config.name,
129
+ },
130
+ /**
131
+ * Configures optimization of the built bundle.
132
+ */
133
+ optimization: {
134
+ /** Enables minification based on values passed from React Native CLI or from fallback. */
135
+ minimize,
136
+ chunkIds: 'named',
137
+ },
138
+ /**
139
+ * We turn on polling so file updates can be recognized when used with Docker.
140
+ */
141
+ watchOptions: {
142
+ poll: true,
143
+ aggregateTimeout: 600,
144
+ ignored: '**/node_modules',
145
+ },
146
+ module: {
147
+ /**
148
+ * This rule will process all React Native related dependencies with Babel.
149
+ * If you have a 3rd-party dependency that you need to transpile, you can add it to the
150
+ * `include` list.
151
+ *
152
+ * You can also enable persistent caching with `cacheDirectory` - please refer to:
153
+ * https://github.com/babel/babel-loader#options
154
+ */
155
+ rules: [
156
+ ...Repack.getJsTransformRules(),
157
+ {
158
+ test: /\.jsx?$/,
159
+ type: 'javascript/auto',
160
+ exclude: /node_modules/,
161
+ use: {
162
+ loader: '@callstack/repack/flow-loader',
163
+ options: { all: true },
164
+ },
165
+ },
166
+ {
167
+ test: /\.jsx?$/,
168
+ include: Repack.getModulePaths([
169
+ 'react-native-sms',
170
+ '@react-native-masked-view/masked-view',
171
+ 'react-native-keyboard-aware-scroll-view',
172
+ 'react-native-modal-datetime-picker',
173
+ '@react-native-community/art',
174
+ '@react-native-community/audio-toolkit',
175
+ 'react-native-appsflyer',
176
+ 'react-native-emoji-rain',
177
+ 'react-native-keep-awake',
178
+ 'react-native-sms',
179
+ ]),
180
+ use: {
181
+ loader: '@callstack/repack/flow-loader',
182
+ options: { all: true },
183
+ },
184
+ type: 'javascript/auto',
185
+ },
186
+ /**
187
+ * This loader handles all static assets (images, video, audio and others), so that you can
188
+ * use (reference) them inside your application.
189
+ *
190
+ * If you wan to handle specific asset type manually, filter out the extension
191
+ * from `ASSET_EXTENSIONS`, for example:
192
+ * ```
193
+ * Repack.ASSET_EXTENSIONS.filter((ext) => ext !== 'svg')
194
+ * ```
195
+ */
196
+ {
197
+ test: Repack.getAssetExtensionsRegExp(Repack.SCALABLE_ASSETS),
198
+ use: {
199
+ loader: '@callstack/repack/assets-loader',
200
+ options: {
201
+ // In order to support single file bundle uploads through our submission process,
202
+ // we need to encode image dependencies directly into the main bundle file as base64.
203
+ inline: true,
204
+ platform,
205
+ devServerEnabled: Boolean(devServer),
206
+ scalableAssetExtensions: Repack.SCALABLE_ASSETS,
207
+ },
208
+ },
209
+ },
210
+ {
211
+ test: Repack.getAssetExtensionsRegExp(Repack.NON_SCALABLE_ASSETS),
212
+ use: {
213
+ loader: '@callstack/repack/assets-loader',
214
+ options: {
215
+ inline: false, // all other assets must be uploaded separately, as they cannot be inlined.
216
+ platform,
217
+ devServerEnabled: Boolean(devServer),
218
+ scalableAssetExtensions: Repack.SCALABLE_ASSETS,
219
+ },
220
+ },
221
+ },
222
+ ].filter(Boolean),
223
+ },
224
+ plugins: [
225
+ /**
226
+ * Configure other required and additional plugins to make the bundle
227
+ * work in React Native and provide good development experience with
228
+ * sensible defaults.
229
+ *
230
+ * `Repack.RepackPlugin` provides some degree of customization, but if you
231
+ * need more control, you can replace `Repack.RepackPlugin` with plugins
232
+ * from `Repack.plugins`.
233
+ */
234
+ new Repack.RepackPlugin({
235
+ context,
236
+ mode,
237
+ platform,
238
+ devServer,
239
+ output: {
240
+ bundleFilename,
241
+ sourceMapFilename,
242
+ assetsPath,
243
+ },
244
+ extraChunks: [
245
+ {
246
+ include: new RegExp('.*'),
247
+ type: 'remote',
248
+ outputPath: path.join(__dirname, '..', '..', '..', 'dist', config.name, platform),
249
+ },
250
+ ],
251
+ listenerIP: config.remoteIP,
252
+ }),
253
+ new ReanimatedPlugin(),
254
+ new Repack.plugins.ModuleFederationPlugin({
255
+ name: config.name,
256
+ exposes: {
257
+ app: sampleClassPathLocal,
258
+ },
259
+ shared: {
260
+ // Adding this here fixes the named chunks problem.
261
+ // It also makes sure any third party javascript packages are included in the container,
262
+ // not exported to a separate chunk.
263
+ // The only separate chunk is the exposed stuff.
264
+ ...sharedDeps,
265
+ // if we don't do the above, then instead each package that is not included in this list will
266
+ // split off into a seperate chunk, and named chunks will break (assume that's a bug that we can fix).
267
+ },
268
+ }),
269
+
270
+ new RebuildNotifyPlugin(config),
271
+
272
+ // new Repack.plugins.ChunksToHermesBytecodePlugin({
273
+ // enabled: !dev,
274
+ // test: /\.(js)?bundle$/,
275
+ // exclude: /index\.bundle$/,
276
+ // }),
277
+ ],
278
+ };
279
+ };
package/webpack.config.js CHANGED
@@ -78,7 +78,7 @@ module.exports = env => {
78
78
  * This should be always `false`, since the Source Map configuration is done
79
79
  * by `SourceMapDevToolPlugin`.
80
80
  */
81
- devtool: false,
81
+ devtool: 'source-map',
82
82
  context,
83
83
  entry,
84
84
  resolve: {
@@ -322,4 +322,4 @@ module.exports = env => {
322
322
  // }),
323
323
  ],
324
324
  };
325
- };
325
+ };