Non-gravitating scalars and spacetime compactification