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
suggestion: deprecate std/dotenv
's load()
#4019
Comments
I agree 100% with OP. Users will still be able to use
Personally I only need To me, autodiscovering files - even a Thanks for tagging me, and sorry for not replying earlier. I did read all the comments in the PR carefully. |
Can you elaborate? Autodiscovery of |
I think autodiscovery in general is not aligned with Deno's philosophy of being explicit. Deno doesn't autoload import maps for example. There's no explicit connection between the |
Deno autoloads I generally agree that Deno prefers explicit over implicit, but it also allows auto-discovery of things when practicality wins.
I think I find this pattern more often in modern tools. Some examples are |
Regarding the trend of In terms of practicality, the difference would be that the user would have to add deno run --env=.env main.ts Or possibly use {
"env": ".env"
} I believe the extra effort is worth it. That way the only magical untraceable step is the Merry Christmas! 🎄 |
We have
|
Sounds interesting idea to me, worth pursuing in Deno CLI repo.
dotenv load is used in many place across ecosystem. (ref. https://github.com/search?q=std%2Fdotenv%2Fload&type=code ) Deno core team also internally uses it in many places including |
Also I haven't seen people having migrated from |
+1
Fresh can use
Deprecating
I believe my previous points and suggestions address the concerns regarding the differences in functionality. |
Furthermore, removing |
I personally think if we deprecate |
I've rarely used |
I use |
Can you give the example usage of this pattern? @andrewthauer Can you elaborate on your usage pattern? Do you read text from .env file? |
@kt3k - I have 2 cases where parse specifically is useful.
As for |
@kt3k Calling the |
PTAL at #4578, where I suggest we simplify |
Preface
#3604 was for discussing the deprecation of the whole
std/dotenv
sub-module.parse()
andstringify()
seem worth keeping. This issue specifically discusses the deprecation and removal ofstd/dotenv
'sload()
.I'll aim to be concise. Those with feedback, please also aim to do the same so we can finally reach a desirable conclusion.
Problem
The solutions that
load()
provides are more complicated and opinionated than necessary. These solutions also overlap with current and possible future solutions, which are simpler and more robust. These solutions come at a cost (see references below).load()
mostly does the following:.env
file into the current process. This overlaps with the runtime's new--env
feature..env.example
(or similar) file. Using a.env
file to define this configuration is magic and seems unfitting for a Standard Library..env.defaults
(or similar) file. Again, using a.env
file to define this configuration is magic and seems unfitting for a Standard Library.Suggested solution
Offer simpler, smaller and more robust alternatives:
load()
for removal in v1 of the Standard Library in favour of the--env
flag. Independently, a third-party module could host this functionality.std/env
withassertEnvSet()
andsetEnvDefault()
#3874 was one possible way to do this.References
std/env
withassertEnvSet()
andsetEnvDefault()
#3874load.ts
andmod.ts
when used together withrun --watch=
#2490CC @timreichen, @jsejcksn, @cknight, @andrewthauer and @Leokuma
The text was updated successfully, but these errors were encountered: