I was a bit too quick to ask for help. I found the solution here: Sage 9 - external Js not defined
So, my solution for anyone else who stumbles upon this page with the same error:
I moved imports and everything from main.js to routes/common.js, and now my common.js looks like this:
// import rellax.js
import Rellax from 'rellax/rellax.min';
export default {
init() {
// JavaScript to be fired on all pages
var rellax = new Rellax('.rellax');
rellax;
},
finalize() {
// JavaScript to be fired on all pages, after page specific JS is fired
},
};