@gfean/react-native-bundle-drop 0.1.35 → 0.1.36
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/CLIENT_README.md +16 -0
- package/README.md +16 -0
- package/lib/loadConfig.js +4 -9
- package/package.json +1 -1
package/CLIENT_README.md
CHANGED
|
@@ -14,6 +14,22 @@ Add the Android bootstrap side-effect import (resolver patches):
|
|
|
14
14
|
import '@gfean/react-native-bundle-drop/bootstrap';
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
### Metro config (resolve bundle.drop.config.js from node_modules)
|
|
18
|
+
If Metro can’t find `bundle.drop.config.js` when a package requires it, add an alias:
|
|
19
|
+
```js
|
|
20
|
+
// metro.config.js
|
|
21
|
+
const path = require('path');
|
|
22
|
+
|
|
23
|
+
module.exports = {
|
|
24
|
+
resolver: {
|
|
25
|
+
extraNodeModules: {
|
|
26
|
+
// Lets packages do: require('bundle-drop-config')
|
|
27
|
+
'bundle-drop-config': path.resolve(__dirname, 'bundle.drop.config.js'),
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
```
|
|
32
|
+
|
|
17
33
|
## 2) App config
|
|
18
34
|
Add `bundle.drop.config.js` to your project root:
|
|
19
35
|
```js
|
package/README.md
CHANGED
|
@@ -14,6 +14,22 @@ Add the Android bootstrap side-effect import once (images resolver patch):
|
|
|
14
14
|
import '@gfean/react-native-bundle-drop/bootstrap';
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
### Metro config (to resolve bundle.drop.config.js from node_modules)
|
|
18
|
+
If Metro cannot resolve `bundle.drop.config.js` from within `node_modules`, add an alias in `metro.config.js`:
|
|
19
|
+
```js
|
|
20
|
+
// metro.config.js
|
|
21
|
+
const path = require('path');
|
|
22
|
+
|
|
23
|
+
module.exports = {
|
|
24
|
+
resolver: {
|
|
25
|
+
extraNodeModules: {
|
|
26
|
+
// Allows packages to do: require('bundle-drop-config')
|
|
27
|
+
'bundle-drop-config': path.resolve(__dirname, 'bundle.drop.config.js'),
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
```
|
|
32
|
+
|
|
17
33
|
## Prerequisites
|
|
18
34
|
- `bundle.drop.config.js` in your app root:
|
|
19
35
|
```js
|
package/lib/loadConfig.js
CHANGED
|
@@ -2,19 +2,15 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.loadConfig = loadConfig;
|
|
4
4
|
const react_native_1 = require("react-native");
|
|
5
|
-
// Simpler, fixed path load to match the prior behavior.
|
|
6
5
|
function loadConfig() {
|
|
7
6
|
try {
|
|
8
|
-
//
|
|
9
|
-
// node_modules/@gfean/react-native-bundle-drop/lib/loadConfig.js
|
|
10
|
-
// so we walk four levels up to the app root.
|
|
7
|
+
// ✅ Resolved via Metro alias in the host app (extraNodeModules)
|
|
11
8
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
12
|
-
const cfg = require('
|
|
9
|
+
const cfg = require('bundle-drop-config');
|
|
13
10
|
if (!cfg?.serverUrl || !cfg?.project?.slug || !cfg?.org?.slug) {
|
|
14
11
|
throw new Error('bundle.drop.config.js missing serverUrl, org.slug or project.slug');
|
|
15
12
|
}
|
|
16
|
-
|
|
17
|
-
if (debugLocal) {
|
|
13
|
+
if (cfg.debugLocal === true) {
|
|
18
14
|
return {
|
|
19
15
|
...cfg,
|
|
20
16
|
serverUrl: react_native_1.Platform.OS === 'android' ? 'http://10.0.2.2:4000' : 'http://localhost:4000',
|
|
@@ -24,8 +20,7 @@ function loadConfig() {
|
|
|
24
20
|
return cfg;
|
|
25
21
|
}
|
|
26
22
|
catch (e) {
|
|
27
|
-
console.log(e);
|
|
28
|
-
// In production this should fail fast; for now return localhost defaults.
|
|
23
|
+
console.log('[BundleDrop] loadConfig failed:', e);
|
|
29
24
|
return {
|
|
30
25
|
serverUrl: 'http://localhost:4000',
|
|
31
26
|
org: { slug: 'default-org' },
|