I’m getting ready to build a new custom web component that is:
- Built using the Stencil library/toolkit
- Designed to be used solely within Ionic apps and/or PWAs
- Based on other modal components, e.g.
ion-action-sheet
orion-modal
ion-action-sheet
and ion-modal
both make use of common framework utilities, e.g. overlays, which in turn depend upon other components like ion-animation-controller
.
I see several possible courses of action:
-
Copy the required modules/resources into my project:
The obvious problem with this is that it makes it difficult to update my component to take advantage of changes/upgrades in the @ionic libraries. I’d have to watch the repo for changes in specific files and incorporate those manually when they occur. -
Fork ionic-team/ionic and implement alongside the other ionic components:
The problem is I don’t immediately see how I could compile just my custom component and distribute/publish it separately from the rest of the entire ionic framework. At least at the level of the rootpackage.json
, there do not seem to be any build scripts designed just for exporting components. -
Put ionic-angular in my Stencil project’s
devDependencies
:
This seems like it might be the best option. Then I could justimport
the code I need to make my component work. However, if I just donpm i -D ionic-angular
I get the distributed version of the framework and not all of the source. It doesn’t include everything that I need, e.g. it doesn’t haveOverlayInterface
which I’d like to implement in my component class.
Update: I think I figured it out…
Instead of ionic-angular
you should add @ionic/core
to your devDependencies
as follows:
$ npm i -D @ionic/core
Then you can import things like OverlayInterface
using:
import { OverlayInterface } from "@ionic/core/dist/collection/utils/overlays";
If I’ve got this wrong, or if someone knows of a better way to do this, please let me know!
Thanks!!!