refactor request: avoid useless calls to `NestConfigurationLoader#load` on 'build' (and 'start') commands
micalevisk opened this issue · 1 comments
Is there an existing issue that is already proposing this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe it
while investigating how to reduce the time spent on build
command just for the cli bootstrapping, I notice that NestConfigurationLoader#load
method was called twice for the same input:
nest-cli/lib/configuration/nest-configuration.loader.ts
Lines 9 to 37 in 802a73c
name
is always undefined
for those calls.
Describe the solution you'd like
somehow refactor the code so that NestConfigurationLoader#load
will be invoked only once.
What is the motivation / use case for changing the behavior?
that method is using fs.readFile
+JSON.parse
. I'd like to avoid this for performance reasons (although minimal, I guess) and to improve the codebase (ie., as a refactor since that seems to be something missed from the legacy version)
Would you like to create a PR for this? If there's no easy way to refactor the code to just call the method once, we can just cache the invocation result and grab it from memory for subsequent calls.