All widgets do the same pattern including the core widgets, pythreejs, ipyleaflet, bqplot, etc.
Write the core widget once. Then there's a small shim that registers the widget in lab, and another small shim that makes it available as an nbextension
Pattern in the cookiecutter.
Part that packages up an nbextension.
Part that tells lab where to look for the lab shim.