-
Notifications
You must be signed in to change notification settings - Fork 29
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
refactor(config): load the config as a JS module instead of parsing it as JSON #2599
Conversation
🦋 Changeset detectedLatest commit: 73b28db The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
const result = get(moduleExport, 'default', moduleExport); | ||
|
||
// Write the application config to `stdout`so that the main program can read it. | ||
process.stdout.write(JSON.stringify(result)); |
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.
Before this was executed as a Node script. The config was then printed to stdout and parsed from the child process.
}); | ||
|
||
// Require the module. It's expected that the module exports the application config | ||
const moduleExport = require(filePath); |
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.
Now we simply require
the JS module, no JSON serialization.
This allows to define and preserve JS functions into the application config (useful for example for dev server plugins)
8fff87e
to
59929db
Compare
4b7d889
to
73b28db
Compare
So this is not going anywhere, as I don't like any of the approaches I tried. The main driver for this was to be able to define functions within the config and be able to use them. For example, for Vite to pass extra plugins and use them when starting the dev server. I'm opting now for a different approach, to have plugins defined in a separate file and simply reference the file path in the custom app config. Small downside is that there would be another file but I think it's a reasonable tradeoff. |
Closing as there would be a different approach. |
Basic work for continuing with #2577