Esp8266 and battery 18650 (or 13350)

Example 1 is no good because the ams1117 will drop too many volts.

Example 2 is good, this is how I power many of my D1 mini circuits.

However, you need to protect the 18650 otherwise it will be damaged by over-discharging. Once is it damaged, when you try to recharge it, it can get hot, explode or catch fire.

I use 1800mAh Li-po packs with my D1 mini circuits. These packs contain a protection circuit which cuts the power when the voltage gets low, so that over-discharging does not occur. These circuits last 10~12 weeks before a recharge is needed, because the D1 mini is in deep sleep for 15 minutes, then wakes, connects to WiFi, reads sensors, transmits the data to a server and goes back into deep sleep in around 10 seconds.

Usually, 18650 batteries do not contain protection circuits, but some do have them. If you do not know, your battery probably does not have protection. You can add a protection circuit between the battery and the D1 mini.