Stencil: (bug) Missing file stencil.core.ts in the build.

Created on 28 Sep 2019  路  6Comments  路  Source: ionic-team/stencil

Stencil version:

 @stencil/[email protected]

I'm submitting a:
bug report

Current behavior:
The file component.d.ts refer to a non existing file ./stencil.core.ts. With this problem I can't use it in Angular (8.2.8) without having errors on the build console. (ng serve).

image

Expected behavior:
The Stencil compiler should remove the reference or provide this file.

Steps to reproduce:
I did nothing special, just:

  1. Create a Stencil project.
  2. Create your componten/s.
  3. Build (npm run build and in my case publish to npm).
  4. Install the npm to a new Angular project.
  5. Follow the docs to integrate the web-component to Angular.
  6. Get annoyed about the errors.
ERROR in node_modules/state-stepper/dist/types/components.d.ts:8:45 - error TS2307: Cannot find module './stencil.core'.

Related code:

https://github.com/domske/state-stepper
https://www.npmjs.com/package/state-stepper

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { FormsModule } from '@angular/forms';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule, FormsModule],
  providers: [],
  bootstrap: [AppComponent],
  schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppModule {}

main.ts

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 'state-stepper/loader';

if (environment.production) {
  enableProdMode();
}

platformBrowserDynamic()
  .bootstrapModule(AppModule)
  .catch(err => console.error(err));

defineCustomElements(window);
triage

Most helpful comment

Building stencil for the first time (empty dist-folder) does not create the stencel.core.d.ts. Building stencil for the second time (existing dist-folder) does create the stencil.core.d.ts. Looks like a build order problem.

All 6 comments

Building stencil for the first time (empty dist-folder) does not create the stencel.core.d.ts. Building stencil for the second time (existing dist-folder) does create the stencil.core.d.ts. Looks like a build order problem.

We have noticed the same thing (building twice fixes it).

To work around this, we actually run the build twice in our pipelines. Not ideal, obviously.

Confirmed. Thanks guys. But sometimes the stencil.core.ts exists on first build (fresh clone git repo). The bug is not 100% reproducible. I'm not sure if a second build workarounds the problem. Maybe multiple builds. That's not good, if it's so uncertain.

@manucorporat Can you confirm this and add a bug label please?
Maybe it has to do with rollup.

See https://github.com/ionic-team/stencil/issues/1705#issuecomment-528923433.

The solution is to make sure your package.json defines "types": "dist/types/components.d.ts".

Closed as duplicate of #1705.

Still having this problem even more severe. The stencil.core.d.ts is not copied at all to my dist/types-folder. I use Jenkins to build my package so there is always an empty dist-folder.
Now the stencil.core.d.ts fails to exist in the dist/types-folder, even building it twice.

Was this page helpful?
0 / 5 - 0 ratings