-
Notifications
You must be signed in to change notification settings - Fork 479
[config] Create dynamic config "app.config.js" #1342
Conversation
one tradeoff worth noting here is that we won't be able to automate updating config for people after this, at least not with the so when we run re: sdk version, honestly we should move the source of truth for this to package.json anyways, and just use whatever sdk version corresponds to the expo package. that might be something we want to do before landing this. are there any other tradeoffs you can think of? |
Currently we do read the sdkVersion from the expo/package.json. sdkVersion is only used for locking down a version or using UNVERSIONED. Having a js config opens up room for plugins so we could potentially migrate scripts to dynamic classes that you add in the config. |
oh i did not realize we had made that change, nice! |
Don't worry about the semantic release, it wasn't using Expo components anyways. I'll rework that library. If other automation tools are using the proper packages, like Also, the |
this is pretty big so i don't think i'll deploy it until the new year. will review it then as well :) |
Maybe we should also add expo icon to VSCode for |
Added a method to ensure the config is always serialized before being read. |
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.
This is very good I think.
I made a few comments regarding the developer experience – let's make sure the new format is easily debuggable and errors very clear from the beginning.
|
||
const configPath = options.configPath || customConfigPaths[projectRoot]; | ||
|
||
// If the app.json exists, we'll read it and pass it to the app.config.js for further modification |
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.
Maybe we want to get rid of this capability, and make the JSON/JS configurations mutually exclusive, for a few reasons:
- Having the configuration split across two files is more confusing for new users or anyone coming across a project that does this. Now you must know two ways to do the same thing. Now you need to check two files to confirm what configuration value is used.
- When responding to issues the common question "please show us your app.config.js" becomes "please show us your app.config.js and app.json (and package.json)"
- JS can include JSON inside it. It can also import configuration from an arbitrary JSON file, if a static format is desired for some values.
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.
Having the configuration split across two files
We support this functionality for values that are generated by Expo CLI like bundleIdentifier
. I'm totally open to better ideas though. I imagine a new project's config would look something like:
module.exports = function({ config }) {
return {
...config,
icon: 'assets/icon.png',
/* etc... */
}
}
The spread of another config is somewhat unpleasant.
responding to issues
We can add a mechanism for printing out the serialized config after it's been returned from app.config.js
.
if a static format is desired for some values.
I imagine eventually app.json
will be the static location for generated values.
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.
When responding to issues the common question "please show us your app.config.js" becomes "please show us your app.config.js and app.json (and package.json)"
maybe we could add this to expo diagnostics
? and we could automatically filter out any potentially sensitive fields
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.
all we'd have to do to support this is switch the method used to read the config file.
Why
Problems with the existing solution:
app.json
How
If a project has an
app.config.js
, that will take priority over anapp.json
. You can use theapp.config.js
to modify yourapp.json
using environment variables or custom JS plugins. Here is how you might modify your project'sapp.json
using the newapp.config.js
:Also add support for the following config types:
app.config.js
app.config.json
- disabled via @ide requestapp.config.json5
Added but disabled:
app.config.ts
app.config.yml
app.config.yaml
app.config.toml
I'm somewhat against the idea of having multiple different languages for the config. At the very least we could just add them later after
app.config.js
has migrated.Only allow sync configs to maintain usability with Next.js.
Test Plan
app.config
has higher priority thanapp.json
app.config.js
method is passed theapp.json
and amode
optionapp
files don't get read (likeapp.yml
,app.json5
)