Rebased Raynos's lightweight RCSS

CC: @Raynos @chenglou

We should do an NPM publish after this is merged.