4

I'm creating a component library with a tooltip component. I want to provide users of my package with the ability to import a service that I've created. Basically I want the API to look something like this:

import { defineCustomElements, tooltipService } from 'my-cool-tooltip-lib';
// tooltipService is a module that I've created that isn't a component

How do I do that?

ccnokes
  • 6,885
  • 5
  • 47
  • 54

1 Answers1

0

You don't.

The defineCustomElements has to be imported from the stencil loader. So your import has to look like this:

import { defineCustomElements, tooltipService } from 'my-cool-tooltip-lib/dist/loader';

Inside the /loader folder is another package.json that resolves all the different ES-Flavours to it's correct loader entry.

See also: https://github.com/ionic-team/stencil/issues/1840

Schadenn
  • 854
  • 1
  • 9
  • 20