Comments (4)
Yes, I would do the example with Rollup as the build system for the React library. I think it is the most commonly used. And the react app using the react library I would do it with Vite. I think a bit the same, today is used a lot.
Oh, and I would differentiate the targets with one full example for each target. Why I would use one target and not the other? those explanations would be lovely. I know you have a targets section but wasn't clear enough for me. The examples would help.
Lastly in the react integration would be super nice to explain how is configured the package.json
exports.
from stencil-site.
Hi, I manage to ship a StencilJS component and a react wrapper
The component is a iframe
wrapper that syncs fields between the react app and the iframe
Here is the live demo:
https://latitude-embed.vercel.app/embedding
The code is here
This is the config
// ./packages/client/webcomponents/stencil.config.ts
import { Config } from '@stencil/core'
import { reactOutputTarget } from '@stencil/react-output-target'
// NOTE: `externalRuntime: false` why?
// Docs: https://stenciljs.com/docs/custom-elements#externalruntime
// This compile in this package `@stencil/core`. Other option would be
// to do it in `@latitude-data/react` by requiring as dependency `@stencil/core`
// But for now because we only have one component I think is fine to ship it here.
// so it has the runtime
export const config: Config = {
namespace: 'webcomponents',
outputTargets: [
{ type: 'docs-readme' },
{ type: 'dist' },
{
type: 'dist-custom-elements',
customElementsExportBehavior: 'single-export-module',
generateTypeDeclarations: true,
externalRuntime: false,
},
reactOutputTarget({
componentCorePackage: '@latitude-data/webcomponents',
proxiesFile: '../react/src/webcomponents/index.ts',
customElementsDir: 'dist/components',
includeImportCustomElements: true,
}),
],
testing: {
browserHeadless: 'new',
},
}
And very important the config for packages/client/webcomponents/package.json
"main": "./dist/index.cjs.js",
"module": "./dist/index.js",
"collection": "dist/collection/collection-manifest.json",
"collection:main": "dist/collection/index.js",
"unpkg": "dist/webcomponents/webcomponents.esm.js",
"types": "./dist/components/index.d.ts",
"exports": {
"./dist/loader": {
"import": "./dist/loader/index.js",
"types": "./dist/loader/index.d.ts"
},
"./dist/components": {
"import": "./dist/components/index.js",
"types": "./dist/components/index.d.ts"
},
"./dist/components/latitude-embed.js": {
"import": "./dist/components/latitude-embed.js",
"types": "./dist/types/components.d.ts"
}
},
"files": [
"dist/"
],
I hope this can help
from stencil-site.
Hi, thank you for your comment!
I managed to make it work differently too, but I think the documentation should contain a working example so that it could be used as a reference for everyone :)
from stencil-site.
@andresgutgon is there anything you believe we can improve in our docs to be more clear on shipping StencilJS components with React wrappers?
from stencil-site.
Related Issues (20)
- Clock example no longer works HOT 1
- Doc v3 : componentDidUnload missing HOT 3
- Docs: Missing space in code comment for https://stenciljs.com/docs/reactive-data HOT 1
- Redux docs page should be updated to use Redux Toolkit examples HOT 2
- The document home page has a bug HOT 2
- forceUpdate in documentation HOT 1
- Dependency Dashboard
- bug: Issue consuming components in an Angular 16 Project HOT 5
- bug: Documentation for array loops is wrong HOT 1
- `@Watch()` could have an example using a `@State()` in the documentation HOT 3
- Missing content in styleUrls docs HOT 2
- Docs: stencil-library reference HOT 1
- missing documentation for Angular 17's standalone mode HOT 1
- test bug HOT 1
- NextJS Integration Example with app router HOT 1
- testing automation - needs doc
- testing automation
- Docs should show @stencil/react-output-target is a dev dependency
- Youtube guide to use stencil with React and Angular doesn't work HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stencil-site.