Or just make it easy and in your open source project put placeholder values for d1 in your wrangler config, eg "<your d1 db id here">, update your readme, and move on to building your features.
There are a lot of good reasons not to use .env, largely related to the fact that these are edge runners without OS access + security concerns. I think if this is a hill worth dying on for you, you should consider another platform OR again, just source control a wrangler config with placeholders. I wish you the best of luck
Following on from #1929 —it's probably worthwhile having a discussion about the future of configuration for Wrangler, pulling together the various discussions there have been at different point...