Compare commits

...
2 changed files with 61 additions and 5 deletions

No files matched your search

+2
View File
@@ -14,6 +14,8 @@ This is the log of notable changes to EAS CLI and related packages.
### 🐛 Bug fixes
- Add missing sourcemap normalization to EAS Hosting worker deployment uploads. ([#3004](https://github.com/expo/eas-cli/pull/3004) by [@kitten](https://github.com/kitten))
### 🧹 Chores
## [16.3.3](https://github.com/expo/eas-cli/releases/tag/v16.3.3) - 2025-04-24
+59 -5
View File
@@ -141,6 +141,53 @@ export async function createManifestAsync(
return { conflictingVariableNames, manifest };
}
interface RawSourceMap {
version: number;
sources: string[];
names: string[];
sourceRoot?: string;
sourcesContent?: string[];
mappings: string;
file: string;
}
const sourceMapExtensionRe = /\.map$/;
async function normalizeSourceMapAsync(
file: RecursiveFileEntry
): Promise<WorkerFileEntry | undefined> {
// This logic normalizes source maps like Wrangler does
// See: https://github.com/cloudflare/workers-sdk/blob/508a1a3/packages/wrangler/src/deployment-bundle/source-maps.ts#L31-L63
const data = await fs.promises.readFile(file.path, 'utf-8');
try {
const map = JSON.parse(data) as RawSourceMap;
if (typeof map !== 'object' || !map) {
return undefined;
}
let sources = map.sources || [];
if (Array.isArray(map.sources)) {
// Remote null-byte prefixes from virtual file names
sources = map.sources.map(sourceName =>
sourceName.charCodeAt(0) === 0 ? sourceName.slice(1) : sourceName
);
}
return {
normalizedPath: file.normalizedPath,
path: file.path,
data: JSON.stringify({
version: 3,
file: file.normalizedPath.replace(sourceMapExtensionRe, ''),
sourcesContent: sources.map(() => null),
sources,
names: map.names,
mappings: map.mappings,
}),
};
} catch {
return undefined;
}
}
interface WorkerFileEntry {
normalizedPath: string;
path: string;
@@ -150,11 +197,18 @@ interface WorkerFileEntry {
/** Reads worker files while normalizing sourcemaps and providing normalized paths */
async function* listWorkerFilesAsync(workerPath: string): AsyncGenerator<WorkerFileEntry> {
for await (const file of listFilesRecursively(workerPath)) {
yield {
normalizedPath: file.normalizedPath,
path: file.path,
data: await fs.promises.readFile(file.path),
};
if (file.normalizedPath.endsWith('.map')) {
const normalizedSourceMap = await normalizeSourceMapAsync(file);
if (normalizedSourceMap) {
yield normalizedSourceMap;
}
} else {
yield {
normalizedPath: file.normalizedPath,
path: file.path,
data: await fs.promises.readFile(file.path),
};
}
}
}