Open kartikwatwani opened 2 months ago
@kartikwatwani Thanks for reporting! I transferred this issue to our framework output targets repo as it's an issue with our Angular output target, but did confirm something is not quite right here!
As a temporary workaround, you can apply
this patch which eliminates the build errors. In there, I also changed the customElementsExportBehavior
for the dist-custom-elements
output target as that needs to be set to a specific value when using the standalone
option (docs here).
Thanks, the patch worked. But will single-export-module
export behavior result in whole module being loaded when I import even one component in my angular app?
If someone wants a stencil starter with angular included by default, they can give try this repo which includes a way to rename the library name and set origin using gulp task.
I have realized 'auto-define-custom-elements' works for outputTarget:'dist-custom-elements', if we provide exports
in package.json
of stencil core components in the below fashion i.e. for each of the component below it is "my-component" we wish to export from the library we need to specify it in exports along with ".","loader","./standalone". Can we do something so that this exports for each component is not required in package.json?
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs.js",
"types": "./dist/types/index.d.ts"
},
"./standalone": {
"import": "./dist/index.js",
"types": "./dist/types/index.d.ts"
},
"./standalone/my-component.js": {
"import": "./standalone/my-component.js",
"types": "./standalone/my-component.d.ts"
},
"./loader": {
"import": "./loader/index.js",
"require": "./loader/index.cjs",
"types": "./loader/index.d.ts"
}
},
For anyone who still needs it. I don't know if it causes any other problems, but it seems to be an easy workaround if you simply change the value of "componentCorePackage" to "stencil-library/dist" (or similar, the point is to add /dist at the end). It solved my problem for now.
@balazssoltesz That fixes the majority of the compile issues in my project, however the type import for Components still fails.
import type { Components } from 'stencil-library/dist/components';
Changing it to import type { Components } from 'stencil-library/dist/types';
fixes the compile issues.
Prerequisites
Stencil Version
4.21.0
Current Behavior
I started with Stencil yesterday. Went through the documentation to integrate angular but I am unable to import the web components generated via stencil in
component.ts
ofangular-workspace/projects/(some-more-paths)/stencil-generated/component.ts
, therefore I am unable to runnpm run build
in angular-workspace. It was mentioned in Angular Integration documentation that we don't need to usenpm link
if we are using lerna monorepo but I still tried it because it was giving errors. But still no help. I tried adding paths intsconfig.json
but still no help. So, I felt maybe something with IDE so I tried it on IDX but still errors were present. I then checked with public stencil projects like revogrid and that was also configured like mine so I am not able to find what is causing this. My repo is available here.Expected Behavior
I should be able to run
npm run build
in angular-workspace without import errors instencil-generated/component.ts
.System Info
Steps to Reproduce
I have reproduced in my repo.
Code Reproduction URL
https://github.com/kartikwatwani/inner-growth
Additional Information
No response