Skip to content

bug: All stencil components are imported in Angular even if only one is called #5952

@Loic57

Description

@Loic57

Prerequisites

Stencil Version

4.20

Current Behavior

I followed this documentationt to build a monorepo with stencil and angular : https://stenciljs.com/docs/angular
Nothing less, nothing more.

When running my angular app I can see in the network tab in my console that my two stencil components are loaded whereas I only need one.
image

In my app.component.ts (angular 18.2 in standalone mode) I call only "my-component" but my two components are called in the console.

import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { MyComponent } from 'component-library';

@Component({
  selector: 'app-root',
  standalone: true,
  imports: [RouterOutlet, MyComponent],
  templateUrl: './app.component.html',
  styleUrl: './app.component.scss'
})
export class AppComponent {
  title = 'my-app';
}

Expected Behavior

I would like to load only the right component, not everything at once.

System Info

System: node 20.15.1
    Platform: windows (10.0.19045)
   CPU Model: 11th Gen Intel(R) Core(TM) i5-11600K @ 3.90GHz (12 cpus)
    Compiler:  [HIDDEN]\@stencil\core\compiler\stencil.js
       Build: 1722623140
     Stencil: 4.20.0
  TypeScript: 5.5.3
      Rollup: 2.56.3
      Parse5: 7.1.2
      jQuery: 4.0.0-pre
      Terser: 5.31.1

Steps to Reproduce

git clone https://github.com/Loic57/stencil-angular-18
npm i (be sure to have lerna installed)
go to packages/stencil-library and run : npm run build
go to packages/angular-workspace and run : npx -p @angular/cli ng build component-library
go to packages/angular-workspace/projects/my-app and run : npm run start

The browser should open on localhost:4200 and you should see "Hell, i'm a test" which is shipped by default with stencil.

But if you inspect the network tab in the console you should see another component name created by myself but which is not called in app.component.ts

Code Reproduction URL

https://github.com/Loic57/stencil-angular-18

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug: ValidatedThis PR or Issue is verified to be a bug within StencilHelp Wanted

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions