-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Provide an optional argument for loadConfigFromFile()
to avoid leaving temporary file in user workspace
#15441
Comments
loadConfigFromFile()
to avoid leaving cached temporary file in user workspaceloadConfigFromFile()
to avoid leaving temporary file in user workspace
We cannot just write to a different directory otherwise the relative/bare imports will be resolved to a different file. |
Thanks for the information! BTW, may I ask about the rationale of bundling user config? That is, if user config is also |
It is to collect the dependency information (#5779). |
Description
Although current implementation is already invulnerable to exceptions from the imported userConfig (using finally statememt), it can still leave the temporary file undeleted when user hits CTRL-C on server start (this happens randomly)
See this issue: vuejs/vitepress#3382
Suggested solution
Provide an additional optional parameter to specify where to save the temporary file so downstream frameworks can save temp file to their cache folder.
Example:
Alternative
Instead of writing the file to disk and then importing it back dynamically, transform the code into an IIFE and use
eval()
to run it.Mask SIGINT before import and unmask it in the
finally
block.Additional context
As discussed in the issue (link above), moving bundled file to a different path could mess up relative imports (or requires).
However, it seems like the bundling process always produces a monolithic file without any external dependency (as it is supposed to). My theory is, as long as the process's current working directory doesn't change, nothing should break.
Validations
The text was updated successfully, but these errors were encountered: