-
Notifications
You must be signed in to change notification settings - Fork 1k
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
feat(cli): allow async in capacitor config file #4299
Conversation
This allows users to generate their config asynchronously.
Would be better if instead of exporting a Promise as default it's allowed to export function and async function ?
|
Another, possibly more standard / intuitive, option is using top-level // capacitor.config.ts
import type { CapacitorConfig } from '@capacitor/cli';
const appId = await determineAppId();
const config: CapacitorConfig = {
appId,
appName: 'My Capacitor App',
// ...
};
export default config; |
while working on a "whitelabel" project using Ionic 6 with Angular 14 and Capacitor 4, I ran into an issue with trying to retrieve the IP address of the current dev machine's primary network interface.. the only NPM packages that I found with enough "business logic" to sufficiently retrieve and inspect the network interfaces all work with Promises, whereas those with pure synchronous logic simply don't get sufficient information. this async support would have solved that issue for me in a heartbeat. I see this PR has been open and untouched for a long time now, so just to check: is there any update on this idea? or do we simply need to find (or make) another plan for cases like mine? |
@@ -136,7 +138,7 @@ async function loadExtConfigJS( | |||
extConfigType: 'js', | |||
extConfigName, | |||
extConfigFilePath: extConfigFilePath, | |||
extConfig: require(extConfigFilePath), | |||
extConfig: await require(extConfigFilePath), |
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.
is this await needed?
seems to work fine without it.
Is there a case where it would be needed?
@giralte-ionic @theproducer @markemer @dallastjames |
I mean, it seems harmless enough to me with a useful feature addition. |
capacitor.config.{ts,js}
This allows users to generate their config asynchronously.