Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-expo-config-typescript-resolution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'eas-cli': patch
---

Handle Expo config resolution for TypeScript-based project configuration files.
6 changes: 3 additions & 3 deletions packages/eas-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"dependencies": {
"@expo/apple-utils": "2.2.1",
"@expo/code-signing-certificates": "0.0.5",
"@expo/config": "55.0.10",
"@expo/config-plugins": "55.0.7",
"@expo/config": "56.0.14",
"@expo/config-plugins": "56.0.16",
"@expo/eas-build-job": "27.0.0",
"@expo/eas-json": "27.0.0",
"@expo/env": "^1.0.0",
Expand All @@ -61,7 +61,7 @@
"@expo/plist": "0.3.5",
"@expo/plugin-help": "5.1.23",
"@expo/plugin-warn-if-update-available": "2.5.1",
"@expo/prebuild-config": "9.0.12",
"@expo/prebuild-config": "56.0.23",
"@expo/results": "1.0.0",
"@expo/rudder-sdk-node": "1.1.1",
"@expo/spawn-async": "1.7.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/eas-cli/src/build/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async function validateAndroidPNGsAsync(ctx: CommonContext<Platform.ANDROID>): P
},
{
configPath: 'exp.splash.image',
pngPath: ctx.exp.splash?.image,
pngPath: (ctx.exp as Record<string, any>).splash?.image,
},
{
configPath: 'exp.notification.icon',
Expand Down
6 changes: 1 addition & 5 deletions packages/eas-cli/src/commands/update/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Workflow } from '@expo/eas-build-job';
import { EasJson, EasJsonAccessor, EasJsonUtils } from '@expo/eas-json';
import { Errors, Flags } from '@oclif/core';
import chalk from 'chalk';
Expand Down Expand Up @@ -500,10 +499,7 @@ export default class UpdatePublish extends EasCommand {
exp,
platforms: realizedPlatforms,
projectDir,
workflows: {
...workflows,
web: Workflow.UNKNOWN,
},
workflows,
env: maybeServerEnv,
});
const runtimeToPlatformsAndFingerprintInfoMapping =
Expand Down
55 changes: 55 additions & 0 deletions packages/eas-cli/src/project/__tests__/bundledExpoConfig-test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import fs from 'fs';
import os from 'os';
import path from 'path';
import { createRequire } from 'module';

import { getConfig } from '@expo/config';

// Regression for #4205: EAS CLI's direct and prebuild config readers must
// both handle TypeScript app.config.ts with the currently bundled dependencies.
describe('bundled Expo config can load TypeScript app.config.ts', () => {
function withConfigFile(content: string, check: (directory: string) => void): void {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'eas-config-ts-'));
try {
fs.writeFileSync(
path.join(dir, 'package.json'),
JSON.stringify({ name: 'minimal', version: '1.2.3' })
);
fs.writeFileSync(path.join(dir, 'app.config.ts'), content);
check(dir);
} finally {
fs.rmSync(dir, { recursive: true, force: true });
}
}

it('loads an ordinary TypeScript config through the EAS CLI config dependency', () => {
withConfigFile(
"export default ({ config }: { config: Record<string, unknown> }) => ({ ...config, name: 'Minimal', slug: 'minimal' });",
dir => {
const { exp } = getConfig(dir, { skipSDKVersionRequirement: true });
expect(exp.name).toBe('Minimal');
}
);
});

it('loads import.meta through the config dependency resolved by prebuild-config', () => {
const fromPrebuild = createRequire(require.resolve('@expo/prebuild-config/package.json'));
const { getConfig: getPrebuildConfig } = fromPrebuild(
'@expo/config'
) as typeof import('@expo/config');

withConfigFile(
`import { createRequire } from 'node:module';
const load = createRequire(import.meta.url ?? __filename);
const { version } = load('./package.json');
export default ({ config }: { config: Record<string, unknown> }) => ({
...config, name: 'Minimal', slug: 'minimal', version,
});`,
dir => {
const { exp } = getPrebuildConfig(dir, { skipSDKVersionRequirement: true });
expect(exp.name).toBe('Minimal');
expect(exp.version).toBe('1.2.3');
}
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,31 @@ jest.mock('@expo/require-utils', () => {
const actual = jest.requireActual('@expo/require-utils');
return {
...actual,
resolveFrom: (
fromDirectory: string,
moduleId: string,
options?: { extensions?: string[] }
): string | null => {
if (!moduleId.startsWith('./')) {
return actual.resolveFrom(fromDirectory, moduleId, options);
}

const fs = require('fs');
const path = require('path');
const basePath = path.resolve(fromDirectory, moduleId);
const candidates = options?.extensions?.length
? options.extensions.map((extension: string) => `${basePath}${extension}`)
: [basePath];

for (const candidate of candidates) {
try {
if (fs.statSync(candidate).isFile()) {
return candidate;
}
} catch {}
}
return null;
},
loadModuleSync: (filename: string) => {
const fs = require('fs');
const content = fs.readFileSync(filename, 'utf-8');
Expand Down
2 changes: 1 addition & 1 deletion packages/eas-cli/src/project/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,7 @@ export async function getRuntimeVersionInfoObjectsAsync({
}: {
exp: ExpoConfig;
platforms: UpdatePublishPlatform[];
workflows: Record<ExpoConfigPlatform, Workflow>;
workflows: Record<UpdatePublishPlatform, Workflow>;
projectDir: string;
env: Env | undefined;
}): Promise<
Expand Down
Loading
Loading