How do I include an arbitrary module/file in my stenciljs build?

Viewed 243

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?

1 Answers

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

Related