Melody arises from the natural intonation and rhythm of the text — literal setting of speech to music.
Write the text, then read it aloud with emphasis. Watch where the voice naturally rises and falls. Use that curve as melody.
Text-first preserves naturalness. The melody copies speech — not 'forcibly imposed on text.'
Leonard Cohen, Bob Dylan — lyrics work as poems even without music.