Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
@stencil/react-output-target
Advanced tools
React output target for @stencil/core components.
Automate the creation of React component wrappers for your Stencil web components.
This package includes an output target for code generation that allows developers to generate a React component wrapper for each Stencil component and a minimal runtime package built around @lit/react that is required to use the generated React components in your React library or application.
Install the @stencil/react-output-target
package in your Stencil project as a development dependency:
npm install @stencil/react-output-target --save-dev
Configure the output target in your stencil.config.ts
file:
import { Config } from '@stencil/core';
import { reactOutputTarget } from '@stencil/react-output-target';
export const config: Config = {
outputTargets: [
reactOutputTarget({
// Relative path to where the React components will be generated
outDir: '../path-to-react-library-or-app/src/',
}),
// dist-custom-elements output target is required for the React output target
{ type: 'dist-custom-elements' },
],
};
Build your Stencil project to generate the React component wrappers:
npm run build
The component wrappers will be generated in the specified output directory.
Install the @stencil/react-output-target
runtime package in your React project:
npm install @stencil/react-output-target
Note: The
@stencil/react-output-target
runtime package is required to use the generated React component wrappers. This package must be a dependency in your React project.
Verify or update your tsconfig.json
file to include the following settings:
{
"compilerOptions": {
"module": "esnext",
"moduleResolution": "bundler"
}
}
moduleResolution": "bundler"
is required to resolve the secondary entry points in the@stencil/react-output-target
runtime package. You can learn more about this setting in the TypeScript documentation.
Verify or install Typescript v5.0 or later in your project:
npm install typescript@5 --save-dev
That's it! You can now import and use your Stencil components as React components in your React application or library.
Property | Description |
---|---|
outDir (required) | The directory where the React components will be generated. |
esModule | If true , the output target will generate a separate ES module for each React component wrapper. Defaults to false . |
stencilPackageName | The name of the package that exports the Stencil components. Defaults to the package.json detected by the Stencil compiler. |
excludeComponents | An array of component tag names to exclude from the React output target. Useful if you want to prevent certain web components from being in the React library. |
experimentalUseClient | If true , the generated output target will include the use client; directive. |
customElementsDir | The directory where the custom elements are saved. This value is automatically detected from the Stencil configuration file for the dist-custom-elements output target. If you are working in an environment that uses absolute paths, consider setting this value manually. |
FAQs
React output target for @stencil/core components.
The npm package @stencil/react-output-target receives a total of 16,045 weekly downloads. As such, @stencil/react-output-target popularity was classified as popular.
We found that @stencil/react-output-target demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.