Ship an NPM package for base class
# package-development
m
Question: I have a couple of extension points in my package and to make it easy for anyone to use them I would like to ship base classes (basically a base class for a LitElement) as an NPM package. I've managed to create the NPM package with base classes and types but the problem is the importmaps. When someone uses these base classes in their code the resulting javascript looks like: import {TheBaseClass} from '@my-package/backoffice/ui'; The browser does not know what to do with
@my-package/backoffice/ui
so I guess I need importmaps for this. BUT. Since Vite just outputs a lot of files during my build I'm not sure how to configure the import maps in my
umbraco-package.json
? If I were only to distribute types this would not be a problem since they are stripped during ts-compilation but since I would like to distribute the base classes as well I need to find a way to make this work. Has anyone done something similar or does anyone have any pointers?
w
Isn’t this what @Matt Brailsford (HQ) did recently in his post I assume for Vendr having extension points
m
Thanks man! You're right, https://dev.to/mattbrailsford/deploying-typescript-type-definitions-for-umbraco-v14-packages-5eg4 as far as I understand, the approach he took will only export types (not any code) so not sure it works for my use case as I need to export the base class. Trying to read up on this but I can't find any other examples except for the core-stuff.
w
Yeh hopefully someone from HQ see's this - but the joys of Summer holiday season its quiet