@codemoreira/esad 1.4.6-14 ā 1.4.6-16
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/README.md +82 -96
- package/bin/esad.js +88 -114
- package/package.json +9 -13
- package/src/cli/commands/build.js +2 -9
- package/src/cli/commands/createCdn.js +44 -45
- package/src/cli/commands/deploy.js +112 -118
- package/src/cli/commands/dev.js +42 -83
- package/src/cli/commands/host.js +10 -14
- package/src/cli/utils/config.js +11 -37
- package/src/cli/utils/process.js +20 -21
- package/src/cli/utils/scaffold.js +96 -112
- package/src/client/index.js +69 -82
- package/src/plugin/index.js +54 -49
- package/src/plugin/config-plugin.js +0 -45
|
@@ -1,112 +1,96 @@
|
|
|
1
|
-
const { runProcess } = require('./process');
|
|
2
|
-
const fs = require('fs-extra');
|
|
3
|
-
const path = require('path');
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Clones a template repository and cleans up the .git folder
|
|
7
|
-
*/
|
|
8
|
-
async function cloneTemplate(url, dest) {
|
|
9
|
-
console.log(`\nš„ Cloning template: ${url}...`);
|
|
10
|
-
await runProcess('git', ['clone', url, dest]);
|
|
11
|
-
|
|
12
|
-
const gitDir = path.join(dest, '.git');
|
|
13
|
-
if (fs.existsSync(gitDir)) {
|
|
14
|
-
await fs.remove(gitDir);
|
|
15
|
-
console.log(`ā
Detached from template repository.`);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Renames the project in package.json and app.json
|
|
21
|
-
*/
|
|
22
|
-
async function renameProject(targetDir, newName) {
|
|
23
|
-
const pkgPath = path.join(targetDir, 'package.json');
|
|
24
|
-
const appJsonPath = path.join(targetDir, 'app.json');
|
|
25
|
-
|
|
26
|
-
if (fs.existsSync(pkgPath)) {
|
|
27
|
-
const pkg = await fs.readJson(pkgPath);
|
|
28
|
-
pkg.name = newName;
|
|
29
|
-
await fs.writeJson(pkgPath, pkg, { spaces: 2 });
|
|
30
|
-
console.log(`ā
Updated package.json name: ${newName}`);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (fs.existsSync(appJsonPath)) {
|
|
34
|
-
const appJson = await fs.readJson(appJsonPath);
|
|
35
|
-
if (appJson.expo) {
|
|
36
|
-
appJson.expo.name = newName;
|
|
37
|
-
appJson.expo.slug = newName;
|
|
38
|
-
appJson.expo.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
// 3. Create react-native.config.js if missing
|
|
100
|
-
const rnConfigPath = path.join(cwd, 'react-native.config.js');
|
|
101
|
-
if (!fs.existsSync(rnConfigPath)) {
|
|
102
|
-
const content = `module.exports = {\n commands: require('@callstack/repack/commands/rspack'),\n};\n`;
|
|
103
|
-
await fs.writeFile(rnConfigPath, content);
|
|
104
|
-
console.log(`ā
Generated react-native.config.js.`);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
module.exports = {
|
|
109
|
-
cloneTemplate,
|
|
110
|
-
renameProject,
|
|
111
|
-
prepareNative
|
|
112
|
-
};
|
|
1
|
+
const { runProcess } = require('./process');
|
|
2
|
+
const fs = require('fs-extra');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Clones a template repository and cleans up the .git folder
|
|
7
|
+
*/
|
|
8
|
+
async function cloneTemplate(url, dest) {
|
|
9
|
+
console.log(`\nš„ Cloning template: ${url}...`);
|
|
10
|
+
await runProcess('git', ['clone', url, dest]);
|
|
11
|
+
|
|
12
|
+
const gitDir = path.join(dest, '.git');
|
|
13
|
+
if (fs.existsSync(gitDir)) {
|
|
14
|
+
await fs.remove(gitDir);
|
|
15
|
+
console.log(`ā
Detached from template repository.`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Renames the project in package.json and app.json
|
|
21
|
+
*/
|
|
22
|
+
async function renameProject(targetDir, newName) {
|
|
23
|
+
const pkgPath = path.join(targetDir, 'package.json');
|
|
24
|
+
const appJsonPath = path.join(targetDir, 'app.json');
|
|
25
|
+
|
|
26
|
+
if (fs.existsSync(pkgPath)) {
|
|
27
|
+
const pkg = await fs.readJson(pkgPath);
|
|
28
|
+
pkg.name = newName;
|
|
29
|
+
await fs.writeJson(pkgPath, pkg, { spaces: 2 });
|
|
30
|
+
console.log(`ā
Updated package.json name: ${newName}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (fs.existsSync(appJsonPath)) {
|
|
34
|
+
const appJson = await fs.readJson(appJsonPath);
|
|
35
|
+
if (appJson.expo) {
|
|
36
|
+
appJson.expo.name = newName;
|
|
37
|
+
appJson.expo.slug = newName;
|
|
38
|
+
if (appJson.expo.android) {
|
|
39
|
+
appJson.expo.android.package = `com.anonymous.${newName.replace(/[^a-zA-Z0-9]/g, '')}`;
|
|
40
|
+
}
|
|
41
|
+
} else {
|
|
42
|
+
appJson.name = newName;
|
|
43
|
+
appJson.slug = newName;
|
|
44
|
+
}
|
|
45
|
+
await fs.writeJson(appJsonPath, appJson, { spaces: 2 });
|
|
46
|
+
console.log(`ā
Updated app.json name/slug/package.`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// 3. Update Rspack Config if exists
|
|
50
|
+
const rspackPath = path.join(targetDir, 'rspack.config.mjs');
|
|
51
|
+
if (fs.existsSync(rspackPath)) {
|
|
52
|
+
let content = await fs.readFile(rspackPath, 'utf8');
|
|
53
|
+
const regex = /id:\s*['"][^'"]+['"]/;
|
|
54
|
+
if (regex.test(content)) {
|
|
55
|
+
content = content.replace(regex, `id: '${newName}'`);
|
|
56
|
+
await fs.writeFile(rspackPath, content);
|
|
57
|
+
console.log(`ā
Updated rspack.config.mjs id: ${newName}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Prepares the native folders and applies Re.Pack patches
|
|
64
|
+
*/
|
|
65
|
+
async function prepareNative(cwd, platform = 'android') {
|
|
66
|
+
if (!fs.existsSync(path.join(cwd, 'android')) && (platform === 'android' || platform === 'all')) {
|
|
67
|
+
console.log(`š¦ Native folder not found. Running expo prebuild...`);
|
|
68
|
+
await runProcess('npx', ['expo', 'prebuild', '--platform', 'android'], cwd);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Apply Gradle Patch (Android)
|
|
72
|
+
const buildGradlePath = path.join(cwd, 'android/app/build.gradle');
|
|
73
|
+
if (fs.existsSync(buildGradlePath)) {
|
|
74
|
+
let content = await fs.readFile(buildGradlePath, 'utf8');
|
|
75
|
+
if (!content.includes('project.ext.react')) {
|
|
76
|
+
const patch = `\nproject.ext.react = [\n bundleCommand: "repack-bundle",\n bundleConfig: "rspack.config.mjs"\n]\n\n`;
|
|
77
|
+
content = content.replace(/react \{/, `${patch}react {`);
|
|
78
|
+
await fs.writeFile(buildGradlePath, content);
|
|
79
|
+
console.log(`ā
Patched android/app/build.gradle for Re.Pack.`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Create react-native.config.js if missing
|
|
84
|
+
const rnConfigPath = path.join(cwd, 'react-native.config.js');
|
|
85
|
+
if (!fs.existsSync(rnConfigPath)) {
|
|
86
|
+
const content = `module.exports = {\n commands: require('@callstack/repack/commands/rspack'),\n};\n`;
|
|
87
|
+
await fs.writeFile(rnConfigPath, content);
|
|
88
|
+
console.log(`ā
Generated react-native.config.js.`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
module.exports = {
|
|
93
|
+
cloneTemplate,
|
|
94
|
+
renameProject,
|
|
95
|
+
prepareNative
|
|
96
|
+
};
|
package/src/client/index.js
CHANGED
|
@@ -1,82 +1,69 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ESAD Global Event Manager
|
|
5
|
-
* This class runs as a true Singleton across the Host and all Federated Modules,
|
|
6
|
-
* allowing instant variable sharing without tight coupling.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
setVal(newVal);
|
|
71
|
-
});
|
|
72
|
-
return unsubscribe;
|
|
73
|
-
}, [key]);
|
|
74
|
-
|
|
75
|
-
const setter = (newVal) => {
|
|
76
|
-
ESADState.set(key, newVal);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
return [val, setter];
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export { ESADState };
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ESAD Global Event Manager
|
|
5
|
+
* This class runs as a true Singleton across the Host and all Federated Modules,
|
|
6
|
+
* allowing instant variable sharing without tight coupling.
|
|
7
|
+
*/
|
|
8
|
+
class ESADEventEmitter {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.state = {};
|
|
11
|
+
this.listeners = {};
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
set(key, value) {
|
|
15
|
+
this.state[key] = value;
|
|
16
|
+
if (this.listeners[key]) {
|
|
17
|
+
this.listeners[key].forEach(callback => callback(value));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get(key) {
|
|
22
|
+
return this.state[key];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
subscribe(key, callback) {
|
|
26
|
+
if (!this.listeners[key]) this.listeners[key] = [];
|
|
27
|
+
this.listeners[key].push(callback);
|
|
28
|
+
return () => {
|
|
29
|
+
this.listeners[key] = this.listeners[key].filter(cb => cb !== callback);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Because this package is marked as a ModuleFederation Singleton,
|
|
35
|
+
// this instance will be shared identically across all chunks!
|
|
36
|
+
const ESADState = new ESADEventEmitter();
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* React Hook for subscribing to Global State Changes
|
|
40
|
+
* @param {string} key Unique identifier for the state slice (e.g. 'auth_token', 'theme')
|
|
41
|
+
* @param {any} initialValue Optional initial state fallback
|
|
42
|
+
*/
|
|
43
|
+
export function useESADState(key, initialValue) {
|
|
44
|
+
const [val, setVal] = useState(() => {
|
|
45
|
+
const existing = ESADState.get(key);
|
|
46
|
+
if (existing !== undefined) return existing;
|
|
47
|
+
if (initialValue !== undefined) {
|
|
48
|
+
ESADState.set(key, initialValue);
|
|
49
|
+
return initialValue;
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
// Whenever ESADState.set is called matching this key, this component will re-render
|
|
56
|
+
const unsubscribe = ESADState.subscribe(key, (newVal) => {
|
|
57
|
+
setVal(newVal);
|
|
58
|
+
});
|
|
59
|
+
return unsubscribe;
|
|
60
|
+
}, [key]);
|
|
61
|
+
|
|
62
|
+
const setter = (newVal) => {
|
|
63
|
+
ESADState.set(key, newVal);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
return [val, setter];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export { ESADState };
|
package/src/plugin/index.js
CHANGED
|
@@ -3,7 +3,6 @@ const fs = require('node:fs');
|
|
|
3
3
|
const Repack = require('@callstack/repack');
|
|
4
4
|
const { ExpoModulesPlugin } = require('@callstack/repack-plugin-expo-modules');
|
|
5
5
|
const { ProvidePlugin, DefinePlugin } = require('@rspack/core');
|
|
6
|
-
const { ReanimatedPlugin } = require('@callstack/repack-plugin-reanimated');
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* ESAD Re.Pack Plugin Wrapper
|
|
@@ -32,51 +31,47 @@ function withESAD(env, options) {
|
|
|
32
31
|
const config = {
|
|
33
32
|
mode: isDev ? 'development' : 'production',
|
|
34
33
|
context: dirname,
|
|
35
|
-
entry:
|
|
36
|
-
index: './index.js',
|
|
37
|
-
},
|
|
34
|
+
entry: options.entry || './index.js',
|
|
38
35
|
output: {
|
|
39
36
|
path: path.resolve(dirname, 'build', platform),
|
|
40
37
|
filename: 'index.bundle',
|
|
41
|
-
|
|
42
|
-
publicPath: Repack.getPublicPath({ platform, dev: isDev }),
|
|
38
|
+
clean: true,
|
|
43
39
|
},
|
|
44
|
-
...((options.type === 'host' && dev !== false) ? {
|
|
45
|
-
devServer: {
|
|
46
|
-
hot: true,
|
|
47
|
-
port: 8081,
|
|
48
|
-
historyApiFallback: true,
|
|
49
|
-
proxy: [
|
|
50
|
-
{
|
|
51
|
-
context: ['/.expo/.virtual-metro-entry'],
|
|
52
|
-
pathRewrite: { '^/.expo/.virtual-metro-entry': '/index' },
|
|
53
|
-
},
|
|
54
|
-
],
|
|
55
|
-
},
|
|
56
|
-
} : {}),
|
|
57
40
|
resolve: {
|
|
58
|
-
...Repack.getResolveOptions(
|
|
59
|
-
fullySpecified: false,
|
|
41
|
+
...Repack.getResolveOptions(),
|
|
60
42
|
alias: {
|
|
61
|
-
'
|
|
62
|
-
|
|
63
|
-
'@module-federation/runtime/helpers': path.resolve(dirname, 'node_modules/@module-federation/runtime/dist/helpers.
|
|
43
|
+
'@': path.resolve(dirname, '.'),
|
|
44
|
+
// Internal MFv2 & Re.Pack Aliases (Magic)
|
|
45
|
+
'@module-federation/runtime/helpers': path.resolve(dirname, 'node_modules/@module-federation/runtime/dist/helpers.js'),
|
|
64
46
|
'@module-federation/error-codes/browser': path.resolve(dirname, 'node_modules/@module-federation/error-codes/dist/browser.cjs'),
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
47
|
+
'@module-federation/sdk': path.resolve(dirname, 'node_modules/@module-federation/sdk'),
|
|
48
|
+
|
|
49
|
+
...Repack.getResolveOptions().alias,
|
|
50
|
+
...(options.alias || {}),
|
|
51
|
+
}
|
|
68
52
|
},
|
|
69
53
|
module: {
|
|
70
54
|
rules: [
|
|
71
55
|
{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
56
|
+
oneOf: [
|
|
57
|
+
{
|
|
58
|
+
test: /\.[cm]?[jt]sx?$/,
|
|
59
|
+
include: [
|
|
60
|
+
/node_modules[\\/]react-native/,
|
|
61
|
+
/node_modules[\\/]@react-native/,
|
|
62
|
+
],
|
|
63
|
+
type: 'javascript/auto',
|
|
64
|
+
use: {
|
|
65
|
+
loader: '@callstack/repack/babel-swc-loader',
|
|
66
|
+
options: {
|
|
67
|
+
sourceMaps: true,
|
|
68
|
+
parallel: true,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
...Repack.getJsTransformRules(),
|
|
73
|
+
]
|
|
78
74
|
},
|
|
79
|
-
...Repack.getJsTransformRules(),
|
|
80
75
|
...Repack.getAssetTransformRules(),
|
|
81
76
|
],
|
|
82
77
|
},
|
|
@@ -87,16 +82,9 @@ function withESAD(env, options) {
|
|
|
87
82
|
new DefinePlugin({
|
|
88
83
|
'process.env.NODE_ENV': JSON.stringify(isDev ? 'development' : 'production'),
|
|
89
84
|
'__DEV__': JSON.stringify(isDev),
|
|
90
|
-
'process.env.EXPO_BASE_URL': JSON.stringify(''),
|
|
91
|
-
'process.env.EXPO_OS': JSON.stringify(platform),
|
|
92
|
-
'process.env.EXPO_PROJECT_ROOT': JSON.stringify(dirname),
|
|
93
|
-
'process.env.EXPO_ROUTER_ABS_APP_ROOT': JSON.stringify(path.resolve(dirname, 'app')),
|
|
94
|
-
'process.env.EXPO_ROUTER_APP_ROOT': JSON.stringify('~/app'),
|
|
95
|
-
'process.env.EXPO_ROUTER_IMPORT_MODE': JSON.stringify('sync'),
|
|
96
85
|
}),
|
|
97
86
|
new ExpoModulesPlugin(),
|
|
98
87
|
new Repack.RepackPlugin(),
|
|
99
|
-
new ReanimatedPlugin(),
|
|
100
88
|
new Repack.plugins.ModuleFederationPluginV2({
|
|
101
89
|
name: id,
|
|
102
90
|
filename: `${id}.container.js.bundle`,
|
|
@@ -109,14 +97,10 @@ function withESAD(env, options) {
|
|
|
109
97
|
'react/jsx-runtime': { singleton: true, eager: true, requiredVersion: pkg.dependencies.react },
|
|
110
98
|
'react-native': { singleton: true, eager: true, requiredVersion: pkg.dependencies['react-native'] },
|
|
111
99
|
'react-native-safe-area-context': { singleton: true, eager: true, requiredVersion: pkg.dependencies['react-native-safe-area-context'] },
|
|
112
|
-
'
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
'@codemoreira/esad/client': {
|
|
117
|
-
singleton: true,
|
|
118
|
-
eager: options.type === 'host',
|
|
119
|
-
import: clientPath
|
|
100
|
+
'@codemoreira/esad/client': {
|
|
101
|
+
singleton: true,
|
|
102
|
+
eager: options.type === 'host', // Only eager in host to ensure it's available
|
|
103
|
+
import: clientPath
|
|
120
104
|
},
|
|
121
105
|
...(options.shared || {})
|
|
122
106
|
}
|
|
@@ -124,6 +108,27 @@ function withESAD(env, options) {
|
|
|
124
108
|
],
|
|
125
109
|
};
|
|
126
110
|
|
|
111
|
+
// Add Host-specific DevServer magic for Expo
|
|
112
|
+
if (options.type === 'host') {
|
|
113
|
+
config.devServer = {
|
|
114
|
+
setupMiddlewares: (middlewares) => {
|
|
115
|
+
middlewares.unshift((req, res, next) => {
|
|
116
|
+
if (req.url.startsWith('/.expo/.virtual-metro-entry.bundle')) {
|
|
117
|
+
const query = req.url.split('?')[1];
|
|
118
|
+
const isMap = req.url.includes('.map');
|
|
119
|
+
const target = isMap ? '/index.bundle.map' : '/index.bundle';
|
|
120
|
+
const location = query ? `${target}?${query}` : target;
|
|
121
|
+
res.writeHead(302, { Location: location });
|
|
122
|
+
res.end();
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
next();
|
|
126
|
+
});
|
|
127
|
+
return middlewares;
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
127
132
|
return config;
|
|
128
133
|
}
|
|
129
134
|
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
const { withAppBuildGradle, withXcodeProject } = require('expo/config-plugins');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* ESAD Re.Pack Config Plugin
|
|
5
|
-
*
|
|
6
|
-
* Automates the native patching required for Re.Pack/Rspack to work with Expo.
|
|
7
|
-
* Replaces manual patching in ESAD CLI.
|
|
8
|
-
*/
|
|
9
|
-
module.exports = (config) => {
|
|
10
|
-
// --- iOS Patching ---
|
|
11
|
-
config = withXcodeProject(config, (configuration) => {
|
|
12
|
-
const xcodeProject = configuration.modResults;
|
|
13
|
-
const bundleReactNativeCodeAndImagesBuildPhase = xcodeProject.buildPhaseObject(
|
|
14
|
-
'PBXShellScriptBuildPhase',
|
|
15
|
-
'Bundle React Native code and images'
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
if (bundleReactNativeCodeAndImagesBuildPhase) {
|
|
19
|
-
const script = JSON.parse(bundleReactNativeCodeAndImagesBuildPhase.shellScript);
|
|
20
|
-
const patched = script
|
|
21
|
-
.replace(
|
|
22
|
-
/if \[\[ -z "\$CLI_PATH" \]\]; then[\s\S]*?fi\n?/g,
|
|
23
|
-
`export CLI_PATH="$("$NODE_BINARY" --print "require('path').dirname(require.resolve('@react-native-community/cli/package.json')) + '/build/bin.js'")"`
|
|
24
|
-
)
|
|
25
|
-
.replace(/if \[\[ -z "\$BUNDLE_COMMAND" \]\]; then[\s\S]*?fi\n?/g, '');
|
|
26
|
-
|
|
27
|
-
bundleReactNativeCodeAndImagesBuildPhase.shellScript = JSON.stringify(patched);
|
|
28
|
-
}
|
|
29
|
-
return configuration;
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// --- Android Patching ---
|
|
33
|
-
config = withAppBuildGradle(config, (configuration) => {
|
|
34
|
-
const buildGradle = configuration.modResults.contents;
|
|
35
|
-
// Ensure Re.Pack bundle command is used
|
|
36
|
-
const patched = buildGradle
|
|
37
|
-
.replace(/cliFile.*/, '')
|
|
38
|
-
.replace(/bundleCommand.*/, 'bundleCommand = "bundle"');
|
|
39
|
-
|
|
40
|
-
configuration.modResults.contents = patched;
|
|
41
|
-
return configuration;
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
return config;
|
|
45
|
-
};
|