Commit 4fc3a64
Fix Dynamic Import Path Resolution for Internal Utils
Summary:
## Problem
* Dynamic import of `./utils/fb/internal_utils` failed with 404 errors due to incorrect path resolution
* `checkFbDirectoryExists()` returned `true` but subsequent import failed because of double `utils` in resolved URL
## Root Causes
1. **Path Context Issue**: `safeImport.ts` in `utils/` directory resolved `./utils/fb/internal_utils` as `utils/utils/fb/internal_utils`
2. **Detection Logic Issue**: Checked non-existent `fb/exists` file, got HTML fallback instead of actual file
## Changes Made
------------
### 1. Fixed `safeImport.ts`
`// Added path adjustment for utils/ context let adjustedPath = modulePath; if (modulePath.startsWith('./utils/')) { adjustedPath = './' + modulePath.substring('./utils/'.length); }`
### 2. Fixed `**fbDetection.ts**`
```
// Check actual file instead of non-existent marker - const response = await fetch('./fb/exists', { method: 'HEAD' }); + const response = await fetch('./fb/internal_utils.ts', { method: 'HEAD' }); // Detect HTML fallback vs real file const contentType = response.headers.get('content-type') || ''; const isHtmlFallback = contentType.includes('text/html'); return response.ok && !isHtmlFallback;
```
Reviewed By: Sibylau
Differential Revision: D77977718
fbshipit-source-id: 8b017a0af417e8bdc27ddc997b665cdd928cb0a51 parent 6ef4072 commit 4fc3a64
2 files changed
+27
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
9 | | - | |
10 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
11 | 18 | | |
12 | 19 | | |
13 | 20 | | |
14 | 21 | | |
15 | | - | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
16 | 24 | | |
17 | 25 | | |
18 | 26 | | |
19 | 27 | | |
20 | 28 | | |
21 | | - | |
| 29 | + | |
0 commit comments