ionic-team / stencil

A toolchain for building scalable, enterprise-ready component systems on top of TypeScript and Web Component standards. Stencil components can be distributed natively to React, Angular, Vue, and traditional web developers from a single, framework-agnostic codebase.
https://stenciljs.com
Other
12.6k stars 790 forks source link

bug: unable to compile using angular's standalone mode (2) #5810

Closed Loic57 closed 5 months ago

Loic57 commented 5 months ago

Prerequisites

Stencil Version

4.16

Current Behavior

This ticket is a duplicate of : https://github.com/ionic-team/stencil/issues/5118

I would like to reopen this ticket because my issue has not been solved and I need a solution

In angular 16.2 and 17 I tried to use standalone mode with stencil but It doesn't work.

I followed this doc : https://stenciljs.com/docs/angular#angular-with-standalone-components but it doesn't work

You can see a reproduction repo here : https://github.com/Loic57/stencil-angular17

Long story short : My stencil.config.ts is configured with outputTarget: 'standalone' and when I'm trying to use these wrapped components into angular I have many error messages, for example this one in angular-workspace/projects/components-library/src/lib/stencil-generated/components.ts :

"import { defineCustomElement as defineComponentName } from 'LIBRARY_EXAMPLE_NAME/components/component-name.js';

Another one in angular-workspace/projects/components-library/src/lib/post-web-components-angular.module.ts :

"STENCIL_FOLDER_EXAMPLE/loader/index.d.ts" is not a module - when I hover the line import {defineCustomElements} from STENCIL_COMPONENTS/loader';

Expected Behavior

Be able to use stencil standalone components into angular 16 / 17 / 18

System Info

System: node 19.9
    Platform: windows (10.0.19045)
   CPU Model: 11th Gen Intel(R) Core(TM) i5-11600K @ 3.90GHz (12 cpus)
    Compiler: D:\Documents\web\projets\agile-partner\starter-web-components\node_modules\@stencil\core\compiler\stencil.js
       Build: 1699286313
     Stencil: 4.7.1
  TypeScript: 5.2.2
      Rollup: 2.42.3
      Parse5: 7.1.2
      Sizzle: 2.42.3
      Terser: 5.24.0

Steps to Reproduce

  1. clone the repo
  2. npm i (you need lerna 8.0.2 to install the dependances of all projects)
  3. Go to angular-workspace/projects/my-app/src/app/app.component.ts, this is where I import my wrapped angular 17 components
  4. don't forget to run : npx -p @angular/cli ng build component-library to build the wrapped components lib
  5. ng serve to start the app and you should see "test" and that's it. If you inspect the markup with your console you'll see two components: and . These two components are empty so they don't display on screen

Code Reproduction URL

https://github.com/Loic57/stencil-angular17

Additional Information

No response

christian-bromann commented 5 months ago

@Loic57 I am sorry, #5118 was not suppose to be closed. I will re-open it.