improve interweaving of js source for #355
when stitching in js sources, share declarations #355