Hacker News new | past | comments | ask | show | jobs | submit login
Set Next.js public environment variables without rebuilds (phase.dev)
2 points by nimishk on Jan 24, 2024 | hide | past | favorite | 3 comments



Wouldn't source maps be broken by changing characters around in the built code?


In source maps, the mapping is done between the transformed code (like minified or bundled JavaScript) and the original source code. As long as the transformations are consistent and predictable, source maps remain effective. When you replace a unique placeholder with an actual value, you're essentially making a very targeted change that shouldn't alter the overall structure or flow of the code. This means the source maps should still accurately reflect the relationship between the source code and the transformed code, except for the parts where the placeholders were replaced.


There is a small chance of that, but as long as the variable names are unique enough, and the values being changed aren't excessively long it is unlikely to cause any issues. Of course any time you manipulate built code like this it could break something (which we mentioned in the post as something to consider) but we have been using this method in our builds for a long time now without issue.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: