Democrats and Republicans largely thought alike about immigration until after around 2010. A widening gap grew not only over immigration, but also over other issues such as over race and racial justice. Democrats have moved much more left since about 2010.
From an article in Vox