Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Update react.md to include a fix for imports not being resolved. #1498

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DanyaalMajid
Copy link

Add additional instructions to properly export the dist directory to fix build issues in the react-library later on.

Add additional instructions to properly export the dist directory to fix build issues in the react-library later on.
@DanyaalMajid DanyaalMajid requested a review from a team as a code owner December 10, 2024 07:56
@DanyaalMajid DanyaalMajid requested review from christian-bromann and gnbm and removed request for a team December 10, 2024 07:56
Copy link

vercel bot commented Dec 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
stencil-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 10, 2024 7:59am

@DanyaalMajid DanyaalMajid changed the title Update react.md docs: Update react.md to include a fix for imports not being resolved. Dec 10, 2024
@christian-bromann
Copy link
Member

@DanyaalMajid thanks for the contributions!

Could you describe a little bit more the problem this documentation tries to address?

@DanyaalMajid
Copy link
Author

In the current versions of both stencil and the stencil/react-output-target packages, exporting react wrappers of components causes an issue whereby the import statement does not resolve, and the react-library fails to build due to unresolved modules.

This requires modifying the package.json for the stencil-library to include the proper export of the dist directory.

Also exporting each component manually is a redundant task, so i also added an export for all components generated in the components directory.

Ideally this change should be made in the stencil template repository which is used to create the stencil components project, feel free to include this there, meanwhile the updated docs should help.

The full error in the react-library when the dist folder is not exported properly:

lib/components/stencil-generated/components.ts:14:93 - error TS2307: Cannot find module 'stencil-library/dist/components/my-component.js' or its corresponding type declarations.

import { MyComponent as MyComponentElement, defineCustomElement as defineMyComponent } from "stencil-library/dist/components/my-component.js";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants