Skip to content
Draft
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: 4 additions & 1 deletion packages/analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,8 @@
"eslintIgnore": [
"node_modules/",
"dist/"
]
],
"expo": {
"plugin": "./app.plugin.js"
}
}
5 changes: 4 additions & 1 deletion packages/app-check/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,8 @@
"eslintIgnore": [
"node_modules/",
"dist/"
]
],
"expo": {
"plugin": "./app.plugin.js"
}
}
5 changes: 4 additions & 1 deletion packages/app-distribution/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,8 @@
"eslintIgnore": [
"node_modules/",
"dist/"
]
],
"expo": {
"plugin": "./app.plugin.js"
}
}
5 changes: 4 additions & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,8 @@
"eslintIgnore": [
"node_modules/",
"dist/"
]
],
"expo": {
"plugin": "./app.plugin.js"
}
}
55 changes: 55 additions & 0 deletions packages/app/plugin/__tests__/packageManifest.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import fs from 'fs';
import path from 'path';
import { describe, expect, it } from '@jest/globals';

const pluginPackages = [
'analytics',
'app',
'app-check',
'app-distribution',
'auth',
'crashlytics',
'messaging',
'perf',
] as const;
Comment on lines +5 to +14
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The list of packages is currently hardcoded. To make this regression test more robust and ensure it automatically covers any future packages that might include an Expo plugin, consider dynamically discovering the packages by scanning the packages/ directory for the presence of an app.plugin.js file.


const repoRoot = path.resolve(__dirname, '../../../../');

interface ExpoPluginPackageJson {
expo?: {
plugin?: string;
};
exports?: Record<string, string>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The exports field in package.json can contain nested objects for conditional exports (e.g., import, require, default), not just strings. The current type definition is too restrictive and technically incorrect for packages like @react-native-firebase/app which use an object for the . export.

Suggested change
exports?: Record<string, string>;
exports?: Record<string, string | Record<string, unknown>>;

}

function readPackageJson(pkg: (typeof pluginPackages)[number]): ExpoPluginPackageJson {
const packageJsonPath = path.resolve(repoRoot, 'packages', pkg, 'package.json');

try {
return JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')) as ExpoPluginPackageJson;
} catch (error) {
throw new Error(`Failed to read ${pkg}/package.json: ${String(error)}`);
}
}

describe('Expo config plugin package manifests', function () {
it.each(pluginPackages)('%s declares app.plugin.js for Expo tooling', function (pkg) {
const packageJsonPath = path.resolve(repoRoot, 'packages', pkg, 'package.json');
const pluginEntryPath = path.resolve(repoRoot, 'packages', pkg, 'app.plugin.js');

expect(fs.existsSync(packageJsonPath)).toBe(true);
expect(fs.existsSync(pluginEntryPath)).toBe(true);
Comment on lines +37 to +41
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The packageJsonPath is already constructed and used inside the readPackageJson function. You can simplify this test by removing the redundant path calculation and the explicit existsSync check for the manifest, as readPackageJson handles file reading and error reporting internally.

Suggested change
const packageJsonPath = path.resolve(repoRoot, 'packages', pkg, 'package.json');
const pluginEntryPath = path.resolve(repoRoot, 'packages', pkg, 'app.plugin.js');
expect(fs.existsSync(packageJsonPath)).toBe(true);
expect(fs.existsSync(pluginEntryPath)).toBe(true);
const pluginEntryPath = path.resolve(repoRoot, 'packages', pkg, 'app.plugin.js');
expect(fs.existsSync(pluginEntryPath)).toBe(true);


const manifest = readPackageJson(pkg);

expect(manifest.expo).toMatchObject({
plugin: './app.plugin.js',
});

// Older JS packages do not declare an exports map yet, but any package that does
// must keep the config plugin subpath available for Expo's resolver.
if (manifest.exports) {
expect(manifest.exports['./app.plugin.js']).toBe('./app.plugin.js');
}
});
});
3 changes: 3 additions & 0 deletions packages/auth/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,8 @@
"publishConfig": {
"access": "public",
"provenance": true
},
"expo": {
"plugin": "./app.plugin.js"
}
}
3 changes: 3 additions & 0 deletions packages/crashlytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,8 @@
}
]
]
},
"expo": {
"plugin": "./app.plugin.js"
}
}
5 changes: 4 additions & 1 deletion packages/messaging/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,8 @@
"eslintIgnore": [
"node_modules/",
"dist/"
]
],
"expo": {
"plugin": "./app.plugin.js"
}
}
3 changes: 3 additions & 0 deletions packages/perf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,8 @@
"publishConfig": {
"access": "public",
"provenance": true
},
"expo": {
"plugin": "./app.plugin.js"
}
}
Loading