expo-targets 0.1.1 → 0.2.1
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withTargetsMetro.d.ts","sourceRoot":"","sources":["../../../metro/src/withTargetsMetro.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"withTargetsMetro.d.ts","sourceRoot":"","sources":["../../../metro/src/withTargetsMetro.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AA2ChD,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GACjC,WAAW,CAwBb"}
|
|
@@ -27,144 +27,51 @@ exports.withTargetsMetro = void 0;
|
|
|
27
27
|
const fs = __importStar(require("fs"));
|
|
28
28
|
const path = __importStar(require("path"));
|
|
29
29
|
function scanTargetsDirectory(projectRoot) {
|
|
30
|
-
console.log(`[expo-targets-metro] 🔍 Scanning targets directory...`);
|
|
31
|
-
console.log(`[expo-targets-metro] Project root: ${projectRoot}`);
|
|
32
30
|
const targetsDir = path.join(projectRoot, 'targets');
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
const targetDirs = fs.readdirSync(targetsDir, { withFileTypes: true });
|
|
40
|
-
console.log(`[expo-targets-metro] Found ${targetDirs.length} items in targets directory`);
|
|
41
|
-
for (const dir of targetDirs) {
|
|
42
|
-
if (!dir.isDirectory()) {
|
|
43
|
-
console.log(`[expo-targets-metro] ⏭ Skipping non-directory: ${dir.name}`);
|
|
31
|
+
const entryMap = new Map();
|
|
32
|
+
if (!fs.existsSync(targetsDir))
|
|
33
|
+
return entryMap;
|
|
34
|
+
for (const dir of fs.readdirSync(targetsDir, { withFileTypes: true })) {
|
|
35
|
+
if (!dir.isDirectory())
|
|
44
36
|
continue;
|
|
45
|
-
}
|
|
46
|
-
console.log(`[expo-targets-metro] 📁 Checking target: ${dir.name}`);
|
|
47
37
|
const configPath = path.join(targetsDir, dir.name, 'expo-target.config.json');
|
|
48
|
-
if (!fs.existsSync(configPath))
|
|
49
|
-
console.log(`[expo-targets-metro] ⚠️ No config found at: ${configPath}`);
|
|
38
|
+
if (!fs.existsSync(configPath))
|
|
50
39
|
continue;
|
|
51
|
-
}
|
|
52
40
|
try {
|
|
53
|
-
const
|
|
54
|
-
const config = JSON.parse(configContent);
|
|
55
|
-
console.log(`[expo-targets-metro] ✅ Config loaded: name="${config.name}", entry="${config.entry}"`);
|
|
56
|
-
// Check if config has entry field
|
|
41
|
+
const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
|
|
57
42
|
if (config.entry) {
|
|
58
43
|
const entryPath = path.resolve(projectRoot, config.entry);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
entryPath,
|
|
64
|
-
excludedPackages: config.excludedPackages,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
console.log(`[expo-targets-metro] ⏭ No entry field in config`);
|
|
44
|
+
const bundleRoot = config.entry
|
|
45
|
+
.replace(/^\.\//, '')
|
|
46
|
+
.replace(/\.(tsx?|jsx?)$/, '');
|
|
47
|
+
entryMap.set(bundleRoot, entryPath);
|
|
69
48
|
}
|
|
70
49
|
}
|
|
71
|
-
catch
|
|
72
|
-
|
|
50
|
+
catch {
|
|
51
|
+
// Skip invalid configs
|
|
73
52
|
}
|
|
74
53
|
}
|
|
75
|
-
|
|
76
|
-
return entryPoints;
|
|
54
|
+
return entryMap;
|
|
77
55
|
}
|
|
78
56
|
function withTargetsMetro(metroConfig, options) {
|
|
79
|
-
console.log(`\n[expo-targets-metro] 🚀 Initializing Metro configuration...`);
|
|
80
57
|
const projectRoot = options?.projectRoot || process.cwd();
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
console.log(`\n[expo-targets-metro] ✅ Found ${targetEntryPoints.length} target(s) with React Native entry points:`);
|
|
85
|
-
targetEntryPoints.forEach((t) => {
|
|
86
|
-
console.log(` - ${t.targetName}: ${t.entryPath}`);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
console.log(`\n[expo-targets-metro] ⚠️ No targets with React Native entry points found`);
|
|
58
|
+
const entryMap = scanTargetsDirectory(projectRoot);
|
|
59
|
+
if (entryMap.size > 0) {
|
|
60
|
+
console.log(`[expo-targets] Found ${entryMap.size} target entry point(s)`);
|
|
91
61
|
}
|
|
92
|
-
// Create a map for quick lookup of target names to bundle roots and entry paths
|
|
93
|
-
const targetMap = new Map();
|
|
94
|
-
targetEntryPoints.forEach((target) => {
|
|
95
|
-
// Calculate the bundle root that would be used in ReactNativeViewController
|
|
96
|
-
// e.g., "./targets/rn-share/index.tsx" -> "targets/rn-share/index"
|
|
97
|
-
const relativeEntry = path.relative(projectRoot, target.entryPath);
|
|
98
|
-
const bundleRoot = relativeEntry.replace(/\.(tsx?|jsx?)$/, '');
|
|
99
|
-
targetMap.set(target.targetName, {
|
|
100
|
-
bundleRoot,
|
|
101
|
-
entryPath: target.entryPath,
|
|
102
|
-
});
|
|
103
|
-
console.log(`[expo-targets-metro] 📌 Registered: ${target.targetName} -> "${bundleRoot}"`);
|
|
104
|
-
});
|
|
105
|
-
const originalGetTransformOptions = metroConfig.transformer?.getTransformOptions;
|
|
106
|
-
const originalRewriteRequestUrl = metroConfig.server?.rewriteRequestUrl;
|
|
107
|
-
console.log(`[expo-targets-metro] 🔧 Setting up URL rewriting for target entry points...`);
|
|
108
62
|
return {
|
|
109
63
|
...metroConfig,
|
|
110
64
|
resolver: {
|
|
111
65
|
...metroConfig.resolver,
|
|
112
|
-
// Keep custom resolver for initial module resolution
|
|
113
66
|
resolveRequest: (context, moduleName, platform) => {
|
|
114
|
-
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
normalizedModuleName.startsWith(bundleRoot)) {
|
|
119
|
-
console.log(`[expo-targets-metro] ✅ Resolved "${moduleName}" -> "${entryPath}"`);
|
|
120
|
-
return {
|
|
121
|
-
type: 'sourceFile',
|
|
122
|
-
filePath: entryPath,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
67
|
+
const normalized = moduleName.replace(/^\.\//, '');
|
|
68
|
+
const entryPath = entryMap.get(normalized);
|
|
69
|
+
if (entryPath) {
|
|
70
|
+
return { type: 'sourceFile', filePath: entryPath };
|
|
125
71
|
}
|
|
126
|
-
// Fall back to default resolver
|
|
127
72
|
return context.resolveRequest(context, moduleName, platform);
|
|
128
73
|
},
|
|
129
74
|
},
|
|
130
|
-
server: {
|
|
131
|
-
...metroConfig.server,
|
|
132
|
-
rewriteRequestUrl: (url) => {
|
|
133
|
-
// Apply original URL rewrite first
|
|
134
|
-
const rewrittenUrl = originalRewriteRequestUrl
|
|
135
|
-
? originalRewriteRequestUrl(url)
|
|
136
|
-
: url;
|
|
137
|
-
// Check for target query parameter
|
|
138
|
-
const targetMatch = rewrittenUrl.match(/[?&]target=([^&]+)/);
|
|
139
|
-
if (targetMatch) {
|
|
140
|
-
const targetName = targetMatch[1];
|
|
141
|
-
const targetInfo = targetMap.get(targetName);
|
|
142
|
-
if (targetInfo) {
|
|
143
|
-
console.log(`[expo-targets-metro] 🔄 Rewriting URL for target: ${targetName}`);
|
|
144
|
-
// Keep the bundle root in the URL but flag it as a target bundle
|
|
145
|
-
return rewrittenUrl.replace('index.bundle', `index.${targetName}.bundle`);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return rewrittenUrl;
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
transformer: {
|
|
152
|
-
...metroConfig.transformer,
|
|
153
|
-
getTransformOptions: async (entryPoints, options, getDependenciesOf) => {
|
|
154
|
-
console.log(`[expo-targets-metro] 🔄 Transform requested for entry points:`, entryPoints);
|
|
155
|
-
const transformOptions = originalGetTransformOptions
|
|
156
|
-
? await originalGetTransformOptions(entryPoints, options, getDependenciesOf)
|
|
157
|
-
: {};
|
|
158
|
-
return {
|
|
159
|
-
...transformOptions,
|
|
160
|
-
transform: {
|
|
161
|
-
...transformOptions.transform,
|
|
162
|
-
experimentalImportSupport: false,
|
|
163
|
-
inlineRequires: true,
|
|
164
|
-
},
|
|
165
|
-
};
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
75
|
};
|
|
169
76
|
}
|
|
170
77
|
exports.withTargetsMetro = withTargetsMetro;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withTargetsMetro.js","sourceRoot":"","sources":["../../../metro/src/withTargetsMetro.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,2CAA6B;
|
|
1
|
+
{"version":3,"file":"withTargetsMetro.js","sourceRoot":"","sources":["../../../metro/src/withTargetsMetro.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AAEzB,2CAA6B;AAO7B,SAAS,oBAAoB,CAAC,WAAmB;IAC/C,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACrD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE3C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;QAAE,OAAO,QAAQ,CAAC;IAEhD,KAAK,MAAM,GAAG,IAAI,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QACtE,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE;YAAE,SAAS;QAEjC,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAC1B,UAAU,EACV,GAAG,CAAC,IAAI,EACR,yBAAyB,CAC1B,CAAC;QACF,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;YAAE,SAAS;QAEzC,IAAI,CAAC;YACH,MAAM,MAAM,GAAiB,IAAI,CAAC,KAAK,CACrC,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CACrC,CAAC;YACF,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;gBACjB,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC1D,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK;qBAC5B,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;qBACpB,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;gBACjC,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,uBAAuB;QACzB,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAgB,gBAAgB,CAC9B,WAAwB,EACxB,OAAkC;IAElC,MAAM,WAAW,GAAG,OAAO,EAAE,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAC1D,MAAM,QAAQ,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAC;IAEnD,IAAI,QAAQ,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,CAAC,wBAAwB,QAAQ,CAAC,IAAI,wBAAwB,CAAC,CAAC;IAC7E,CAAC;IAED,OAAO;QACL,GAAG,WAAW;QACd,QAAQ,EAAE;YACR,GAAG,WAAW,CAAC,QAAQ;YACvB,cAAc,EAAE,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE;gBAChD,MAAM,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;gBACnD,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;gBAE3C,IAAI,SAAS,EAAE,CAAC;oBACd,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;gBACrD,CAAC;gBAED,OAAO,OAAO,CAAC,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;YAC/D,CAAC;SACF;KACF,CAAC;AACJ,CAAC;AA3BD,4CA2BC"}
|
|
@@ -4,244 +4,69 @@ import * as path from 'path';
|
|
|
4
4
|
|
|
5
5
|
interface TargetConfig {
|
|
6
6
|
name: string;
|
|
7
|
-
type?: string;
|
|
8
|
-
platforms?: string[];
|
|
9
7
|
entry?: string;
|
|
10
|
-
excludedPackages?: string[];
|
|
11
|
-
ios?: Record<string, any>;
|
|
12
8
|
}
|
|
13
9
|
|
|
14
|
-
|
|
15
|
-
targetName: string;
|
|
16
|
-
entryPath: string;
|
|
17
|
-
excludedPackages?: string[];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function scanTargetsDirectory(projectRoot: string): TargetEntryPoint[] {
|
|
21
|
-
console.log(`[expo-targets-metro] 🔍 Scanning targets directory...`);
|
|
22
|
-
console.log(`[expo-targets-metro] Project root: ${projectRoot}`);
|
|
23
|
-
|
|
10
|
+
function scanTargetsDirectory(projectRoot: string): Map<string, string> {
|
|
24
11
|
const targetsDir = path.join(projectRoot, 'targets');
|
|
25
|
-
|
|
12
|
+
const entryMap = new Map<string, string>();
|
|
26
13
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (!fs.existsSync(targetsDir)) {
|
|
30
|
-
console.log(`[expo-targets-metro] ⚠️ Targets directory does not exist`);
|
|
31
|
-
return entryPoints;
|
|
32
|
-
}
|
|
14
|
+
if (!fs.existsSync(targetsDir)) return entryMap;
|
|
33
15
|
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
`[expo-targets-metro] Found ${targetDirs.length} items in targets directory`
|
|
37
|
-
);
|
|
16
|
+
for (const dir of fs.readdirSync(targetsDir, { withFileTypes: true })) {
|
|
17
|
+
if (!dir.isDirectory()) continue;
|
|
38
18
|
|
|
39
|
-
for (const dir of targetDirs) {
|
|
40
|
-
if (!dir.isDirectory()) {
|
|
41
|
-
console.log(
|
|
42
|
-
`[expo-targets-metro] ⏭ Skipping non-directory: ${dir.name}`
|
|
43
|
-
);
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
console.log(`[expo-targets-metro] 📁 Checking target: ${dir.name}`);
|
|
48
19
|
const configPath = path.join(
|
|
49
20
|
targetsDir,
|
|
50
21
|
dir.name,
|
|
51
22
|
'expo-target.config.json'
|
|
52
23
|
);
|
|
53
|
-
|
|
54
|
-
if (!fs.existsSync(configPath)) {
|
|
55
|
-
console.log(
|
|
56
|
-
`[expo-targets-metro] ⚠️ No config found at: ${configPath}`
|
|
57
|
-
);
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
24
|
+
if (!fs.existsSync(configPath)) continue;
|
|
60
25
|
|
|
61
26
|
try {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
console.log(
|
|
65
|
-
`[expo-targets-metro] ✅ Config loaded: name="${config.name}", entry="${config.entry}"`
|
|
27
|
+
const config: TargetConfig = JSON.parse(
|
|
28
|
+
fs.readFileSync(configPath, 'utf-8')
|
|
66
29
|
);
|
|
67
|
-
|
|
68
|
-
// Check if config has entry field
|
|
69
30
|
if (config.entry) {
|
|
70
31
|
const entryPath = path.resolve(projectRoot, config.entry);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
`[expo-targets-metro] 📝 Entry exists: ${fs.existsSync(entryPath)}`
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
entryPoints.push({
|
|
79
|
-
targetName: config.name || dir.name,
|
|
80
|
-
entryPath,
|
|
81
|
-
excludedPackages: config.excludedPackages,
|
|
82
|
-
});
|
|
83
|
-
} else {
|
|
84
|
-
console.log(`[expo-targets-metro] ⏭ No entry field in config`);
|
|
32
|
+
const bundleRoot = config.entry
|
|
33
|
+
.replace(/^\.\//, '')
|
|
34
|
+
.replace(/\.(tsx?|jsx?)$/, '');
|
|
35
|
+
entryMap.set(bundleRoot, entryPath);
|
|
85
36
|
}
|
|
86
|
-
} catch
|
|
87
|
-
|
|
88
|
-
`[expo-targets-metro] Failed to parse config for ${dir.name}:`,
|
|
89
|
-
error
|
|
90
|
-
);
|
|
37
|
+
} catch {
|
|
38
|
+
// Skip invalid configs
|
|
91
39
|
}
|
|
92
40
|
}
|
|
93
41
|
|
|
94
|
-
|
|
95
|
-
`[expo-targets-metro] 📊 Total entry points found: ${entryPoints.length}`
|
|
96
|
-
);
|
|
97
|
-
return entryPoints;
|
|
42
|
+
return entryMap;
|
|
98
43
|
}
|
|
99
44
|
|
|
100
45
|
export function withTargetsMetro(
|
|
101
46
|
metroConfig: MetroConfig,
|
|
102
|
-
options?: {
|
|
103
|
-
projectRoot?: string;
|
|
104
|
-
targets?: string[];
|
|
105
|
-
}
|
|
47
|
+
options?: { projectRoot?: string }
|
|
106
48
|
): MetroConfig {
|
|
107
|
-
console.log(`\n[expo-targets-metro] 🚀 Initializing Metro configuration...`);
|
|
108
49
|
const projectRoot = options?.projectRoot || process.cwd();
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const targetEntryPoints = scanTargetsDirectory(projectRoot);
|
|
50
|
+
const entryMap = scanTargetsDirectory(projectRoot);
|
|
112
51
|
|
|
113
|
-
if (
|
|
114
|
-
console.log(
|
|
115
|
-
`\n[expo-targets-metro] ✅ Found ${targetEntryPoints.length} target(s) with React Native entry points:`
|
|
116
|
-
);
|
|
117
|
-
targetEntryPoints.forEach((t) => {
|
|
118
|
-
console.log(` - ${t.targetName}: ${t.entryPath}`);
|
|
119
|
-
});
|
|
120
|
-
} else {
|
|
121
|
-
console.log(
|
|
122
|
-
`\n[expo-targets-metro] ⚠️ No targets with React Native entry points found`
|
|
123
|
-
);
|
|
52
|
+
if (entryMap.size > 0) {
|
|
53
|
+
console.log(`[expo-targets] Found ${entryMap.size} target entry point(s)`);
|
|
124
54
|
}
|
|
125
55
|
|
|
126
|
-
// Create a map for quick lookup of target names to bundle roots and entry paths
|
|
127
|
-
const targetMap = new Map<
|
|
128
|
-
string,
|
|
129
|
-
{ bundleRoot: string; entryPath: string }
|
|
130
|
-
>();
|
|
131
|
-
targetEntryPoints.forEach((target) => {
|
|
132
|
-
// Calculate the bundle root that would be used in ReactNativeViewController
|
|
133
|
-
// e.g., "./targets/rn-share/index.tsx" -> "targets/rn-share/index"
|
|
134
|
-
const relativeEntry = path.relative(projectRoot, target.entryPath);
|
|
135
|
-
const bundleRoot = relativeEntry.replace(/\.(tsx?|jsx?)$/, '');
|
|
136
|
-
|
|
137
|
-
targetMap.set(target.targetName, {
|
|
138
|
-
bundleRoot,
|
|
139
|
-
entryPath: target.entryPath,
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
console.log(
|
|
143
|
-
`[expo-targets-metro] 📌 Registered: ${target.targetName} -> "${bundleRoot}"`
|
|
144
|
-
);
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
const originalGetTransformOptions =
|
|
148
|
-
metroConfig.transformer?.getTransformOptions;
|
|
149
|
-
const originalRewriteRequestUrl = metroConfig.server?.rewriteRequestUrl;
|
|
150
|
-
|
|
151
|
-
console.log(
|
|
152
|
-
`[expo-targets-metro] 🔧 Setting up URL rewriting for target entry points...`
|
|
153
|
-
);
|
|
154
|
-
|
|
155
56
|
return {
|
|
156
57
|
...metroConfig,
|
|
157
58
|
resolver: {
|
|
158
59
|
...metroConfig.resolver,
|
|
159
|
-
// Keep custom resolver for initial module resolution
|
|
160
60
|
resolveRequest: (context, moduleName, platform) => {
|
|
161
|
-
|
|
162
|
-
const
|
|
61
|
+
const normalized = moduleName.replace(/^\.\//, '');
|
|
62
|
+
const entryPath = entryMap.get(normalized);
|
|
163
63
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
{ bundleRoot, entryPath },
|
|
167
|
-
] of targetMap.entries()) {
|
|
168
|
-
if (
|
|
169
|
-
normalizedModuleName === bundleRoot ||
|
|
170
|
-
normalizedModuleName.startsWith(bundleRoot)
|
|
171
|
-
) {
|
|
172
|
-
console.log(
|
|
173
|
-
`[expo-targets-metro] ✅ Resolved "${moduleName}" -> "${entryPath}"`
|
|
174
|
-
);
|
|
175
|
-
return {
|
|
176
|
-
type: 'sourceFile',
|
|
177
|
-
filePath: entryPath,
|
|
178
|
-
};
|
|
179
|
-
}
|
|
64
|
+
if (entryPath) {
|
|
65
|
+
return { type: 'sourceFile', filePath: entryPath };
|
|
180
66
|
}
|
|
181
67
|
|
|
182
|
-
// Fall back to default resolver
|
|
183
68
|
return context.resolveRequest(context, moduleName, platform);
|
|
184
69
|
},
|
|
185
70
|
},
|
|
186
|
-
server: {
|
|
187
|
-
...metroConfig.server,
|
|
188
|
-
rewriteRequestUrl: (url: string) => {
|
|
189
|
-
// Apply original URL rewrite first
|
|
190
|
-
const rewrittenUrl = originalRewriteRequestUrl
|
|
191
|
-
? originalRewriteRequestUrl(url)
|
|
192
|
-
: url;
|
|
193
|
-
|
|
194
|
-
// Check for target query parameter
|
|
195
|
-
const targetMatch = rewrittenUrl.match(/[?&]target=([^&]+)/);
|
|
196
|
-
|
|
197
|
-
if (targetMatch) {
|
|
198
|
-
const targetName = targetMatch[1];
|
|
199
|
-
const targetInfo = targetMap.get(targetName);
|
|
200
|
-
|
|
201
|
-
if (targetInfo) {
|
|
202
|
-
console.log(
|
|
203
|
-
`[expo-targets-metro] 🔄 Rewriting URL for target: ${targetName}`
|
|
204
|
-
);
|
|
205
|
-
// Keep the bundle root in the URL but flag it as a target bundle
|
|
206
|
-
return rewrittenUrl.replace(
|
|
207
|
-
'index.bundle',
|
|
208
|
-
`index.${targetName}.bundle`
|
|
209
|
-
);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
return rewrittenUrl;
|
|
214
|
-
},
|
|
215
|
-
},
|
|
216
|
-
transformer: {
|
|
217
|
-
...metroConfig.transformer,
|
|
218
|
-
getTransformOptions: async (
|
|
219
|
-
entryPoints: readonly string[],
|
|
220
|
-
options: any,
|
|
221
|
-
getDependenciesOf: any
|
|
222
|
-
) => {
|
|
223
|
-
console.log(
|
|
224
|
-
`[expo-targets-metro] 🔄 Transform requested for entry points:`,
|
|
225
|
-
entryPoints
|
|
226
|
-
);
|
|
227
|
-
|
|
228
|
-
const transformOptions = originalGetTransformOptions
|
|
229
|
-
? await originalGetTransformOptions(
|
|
230
|
-
entryPoints,
|
|
231
|
-
options,
|
|
232
|
-
getDependenciesOf
|
|
233
|
-
)
|
|
234
|
-
: {};
|
|
235
|
-
|
|
236
|
-
return {
|
|
237
|
-
...transformOptions,
|
|
238
|
-
transform: {
|
|
239
|
-
...transformOptions.transform,
|
|
240
|
-
experimentalImportSupport: false,
|
|
241
|
-
inlineRequires: true,
|
|
242
|
-
},
|
|
243
|
-
};
|
|
244
|
-
},
|
|
245
|
-
},
|
|
246
71
|
};
|
|
247
72
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-targets",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Expo config plugin for Apple targets and Android app extensions",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"types": "build/src/index.d.ts",
|
|
@@ -58,11 +58,51 @@
|
|
|
58
58
|
"keywords": [
|
|
59
59
|
"expo",
|
|
60
60
|
"expo-plugin",
|
|
61
|
+
"expo-config-plugin",
|
|
62
|
+
"config-plugin",
|
|
63
|
+
"react-native",
|
|
64
|
+
"react-native-widget",
|
|
61
65
|
"ios",
|
|
66
|
+
"android",
|
|
67
|
+
"swift",
|
|
68
|
+
"swiftui",
|
|
69
|
+
"kotlin",
|
|
62
70
|
"widget",
|
|
71
|
+
"widgets",
|
|
72
|
+
"home-screen-widget",
|
|
73
|
+
"widgetkit",
|
|
74
|
+
"glance",
|
|
75
|
+
"jetpack-compose",
|
|
63
76
|
"app-clip",
|
|
77
|
+
"app-clips",
|
|
78
|
+
"appclip",
|
|
79
|
+
"instant-app",
|
|
80
|
+
"share-extension",
|
|
81
|
+
"share",
|
|
82
|
+
"action-extension",
|
|
83
|
+
"action",
|
|
64
84
|
"imessage",
|
|
65
|
-
"
|
|
85
|
+
"imessage-stickers",
|
|
86
|
+
"stickers",
|
|
87
|
+
"sticker-pack",
|
|
88
|
+
"messages",
|
|
89
|
+
"messages-extension",
|
|
90
|
+
"safari-extension",
|
|
91
|
+
"notification-extension",
|
|
92
|
+
"notification-content",
|
|
93
|
+
"notification-service",
|
|
94
|
+
"siri",
|
|
95
|
+
"siri-intents",
|
|
96
|
+
"app-intents",
|
|
97
|
+
"apple-targets",
|
|
98
|
+
"app-extension",
|
|
99
|
+
"ios-extension",
|
|
100
|
+
"native-module",
|
|
101
|
+
"app-groups",
|
|
102
|
+
"userdefaults",
|
|
103
|
+
"shared-preferences",
|
|
104
|
+
"data-sharing",
|
|
105
|
+
"cross-process"
|
|
66
106
|
],
|
|
67
107
|
"repository": {
|
|
68
108
|
"type": "git",
|