Error: export 'defineCustomElements' (imported as 'defineCustomElements') was not found

stencil/core: 2.13.0
angular/core: 15.0.0
ionic/angular: 6.1.9

I have build some custom components with stencil and added them to my ionic angular app. They were working yesterday but today I updated them a little and I get an error when building the ionic app.

My workflow is as follows:

In stencil:

  • Change the version number in the package.json
  • npm run build to build it
  • Run npm link in the root of the stencil folder to link the stencil package to the local installation of npm
  • Check the package is linked with npm ls -g --depth=0 --link=true
  • Run npm link xxx in the root of the ionic folder to install the package ‘xxx’ to the ionic app.
  • In main.ts:
    – Add import { defineCustomElements } from '../node_modules/xxx/loader/'; at the top
    – Add defineCustomElements(window); at the bottom

So main.ts in the ionic app looks like this:

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';

import { defineCustomElements } from '../node_modules/xxx/loader/';

if (environment.production) {

  .catch(err => console.log(err));


If I follow the import { defineCustomElements } from '../node_modules/xxx/loader/'; with F12 in VSCode it does take me to the index.d.ts file with the export:

export declare function defineCustomElements(win?: Window, opts?: CustomElementsDefineOptions): Promise<void>;

When I run ionic build --prod or ionic build I get the following error and I can see the library package in the node_modules folder:

./src/main.ts:10:0-20 - Error: export 'defineCustomElements' (imported as 'defineCustomElements') was not found in '../node_modules/xxx/loader/' (module has no exports)

It built without error before.

I can’t find anything on Google. Any ideas please?

Update: Interestingly if I build with --verbose it builds without error???