-
Notifications
You must be signed in to change notification settings - Fork 2.3k
fix(expo): VS code extension not picking up expo support via metadata in package.json #8980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -75,5 +75,8 @@ | |
| "eslintIgnore": [ | ||
| "node_modules/", | ||
| "dist/" | ||
| ] | ||
| ], | ||
| "expo": { | ||
| "plugin": "./app.plugin.js" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,5 +73,8 @@ | |
| "eslintIgnore": [ | ||
| "node_modules/", | ||
| "dist/" | ||
| ] | ||
| ], | ||
| "expo": { | ||
| "plugin": "./app.plugin.js" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,5 +71,8 @@ | |
| "eslintIgnore": [ | ||
| "node_modules/", | ||
| "dist/" | ||
| ] | ||
| ], | ||
| "expo": { | ||
| "plugin": "./app.plugin.js" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -144,5 +144,8 @@ | |
| "eslintIgnore": [ | ||
| "node_modules/", | ||
| "dist/" | ||
| ] | ||
| ], | ||
| "expo": { | ||
| "plugin": "./app.plugin.js" | ||
| } | ||
| } | ||
| 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; | ||||||||||||||||||
|
|
||||||||||||||||||
| const repoRoot = path.resolve(__dirname, '../../../../'); | ||||||||||||||||||
|
|
||||||||||||||||||
| interface ExpoPluginPackageJson { | ||||||||||||||||||
| expo?: { | ||||||||||||||||||
| plugin?: string; | ||||||||||||||||||
| }; | ||||||||||||||||||
| exports?: Record<string, string>; | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| 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'); | ||||||||||||||||||
| } | ||||||||||||||||||
| }); | ||||||||||||||||||
| }); | ||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,5 +42,8 @@ | |
| "publishConfig": { | ||
| "access": "public", | ||
| "provenance": true | ||
| }, | ||
| "expo": { | ||
| "plugin": "./app.plugin.js" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,5 +76,8 @@ | |
| } | ||
| ] | ||
| ] | ||
| }, | ||
| "expo": { | ||
| "plugin": "./app.plugin.js" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,5 +72,8 @@ | |
| "eslintIgnore": [ | ||
| "node_modules/", | ||
| "dist/" | ||
| ] | ||
| ], | ||
| "expo": { | ||
| "plugin": "./app.plugin.js" | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,5 +43,8 @@ | |
| "publishConfig": { | ||
| "access": "public", | ||
| "provenance": true | ||
| }, | ||
| "expo": { | ||
| "plugin": "./app.plugin.js" | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 anapp.plugin.jsfile.