UNPKG

@stencil/react-output-target

Version:

React output target for @stencil/core components.

1 lines 29.3 kB
{"version":3,"file":"index.cjs","sources":["../src/utils/string-utils.ts","../src/create-es-modules-components-file.ts","../src/create-stencil-react-components.ts","../src/create-component-wrappers.ts","../src/index.ts"],"sourcesContent":["export const kebabToPascalCase = (str: string) =>\n str\n .toLowerCase()\n .split('-')\n .map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))\n .join('');\n\nexport const kebabToCamelCase = (str: string) => str.replace(/-([_a-z])/g, (_, letter) => letter.toUpperCase());\n\nconst slashesToCamelCase = (str: string) => str.replace(/\\/([a-z])/g, (_, letter) => letter.toUpperCase());\n\nexport const eventListenerName = (eventName: string) => {\n const slashesConverted = slashesToCamelCase(eventName);\n return kebabToCamelCase(`on-${slashesConverted}`);\n};\n","import type { ComponentCompilerMeta } from '@stencil/core/internal';\nimport path from 'node:path';\nimport { Project } from 'ts-morph';\nimport { kebabToPascalCase } from './utils/string-utils.js';\n\nexport const createEsModulesComponentsFile = async ({\n components,\n project,\n outDir,\n}: {\n components: ComponentCompilerMeta[];\n project?: Project;\n outDir?: string;\n}) => {\n const tsProject = project || new Project({ useInMemoryFileSystem: true });\n const disableEslint = `/* eslint-disable */\\n`;\n const autogeneratedComment = `/**\n * This file was automatically generated by the Stencil React Output Target.\n * Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.\n */\\n\\n`;\n const outFile = path.join(outDir || '', 'components.ts');\n const sourceFile = tsProject.createSourceFile(outFile, autogeneratedComment + disableEslint, {\n overwrite: true,\n });\n\n for (const component of components) {\n const tagName = component.tagName;\n const reactTagName = kebabToPascalCase(tagName);\n const fileName = component.tagName;\n sourceFile.addExportDeclaration({\n moduleSpecifier: `./${fileName}.js`,\n namedExports: [reactTagName],\n });\n }\n\n sourceFile.organizeImports();\n sourceFile.formatText();\n await sourceFile.save();\n\n return sourceFile;\n};\n","import type { ComponentCompilerMeta } from '@stencil/core/internal';\nimport { Project, VariableDeclarationKind } from 'ts-morph';\nimport { eventListenerName, kebabToPascalCase } from './utils/string-utils.js';\nimport type { RenderToStringOptions } from './runtime/ssr.js';\n\ninterface ReactEvent {\n originalName: string;\n name: string;\n type: string;\n}\n\nexport const createStencilReactComponents = ({\n components,\n stencilPackageName,\n customElementsDir,\n hydrateModule,\n clientModule,\n serializeShadowRoot,\n}: {\n components: ComponentCompilerMeta[];\n stencilPackageName: string;\n customElementsDir: string;\n hydrateModule?: string;\n clientModule?: string;\n serializeShadowRoot?: RenderToStringOptions['serializeShadowRoot'];\n}) => {\n const project = new Project({ useInMemoryFileSystem: true });\n\n /**\n * automatically attach the `use client` directive if we are not generating\n * server side rendering components.\n */\n const useClientDirective = !hydrateModule ? `'use client';\\n\\n` : '';\n const autogeneratedComment = `/**\n * This file was automatically generated by the Stencil React Output Target.\n * Changes to this file may cause incorrect behavior and will be lost if the code is regenerated.\n */\\n\\n`;\n\n const disableEslint = `/* eslint-disable */\\n`;\n const createComponentImport = hydrateModule\n ? [\n `// @ts-ignore - ignore potential type issues as the project is importing itself`,\n `import * as clientComponents from '${clientModule}';`,\n '',\n `import { createComponent, type SerializeShadowRootOptions, type HydrateModule, type ReactWebComponent, type DynamicFunction } from '@stencil/react-output-target/ssr';`,\n ].join('\\n')\n : `import { createComponent } from '@stencil/react-output-target/runtime';`;\n const sourceFile = project.createSourceFile(\n 'component.ts',\n `${useClientDirective}${autogeneratedComment}${disableEslint}\nimport React from 'react';\n${createComponentImport}\nimport type { EventName, StencilReactComponent } from '@stencil/react-output-target/runtime';\n `\n );\n\n /**\n * Add the `serializeShadowRoot` variable to the file if the hydrateModule is provided.\n */\n if (hydrateModule) {\n sourceFile.addVariableStatement({\n isExported: true,\n declarationKind: VariableDeclarationKind.Const,\n declarations: [\n {\n name: 'serializeShadowRoot',\n type: 'SerializeShadowRootOptions',\n initializer: serializeShadowRoot\n ? JSON.stringify(serializeShadowRoot)\n : '{ default: \"declarative-shadow-dom\" }',\n },\n ],\n });\n }\n\n for (const component of components) {\n const tagName = component.tagName;\n const reactTagName = kebabToPascalCase(tagName);\n const componentElement = `${reactTagName}Element`;\n const componentCustomEvent = `${reactTagName}CustomEvent`;\n\n sourceFile.addImportDeclaration({\n moduleSpecifier: `${stencilPackageName}/${customElementsDir}/${tagName}.js`,\n namedImports: [\n {\n name: reactTagName,\n alias: componentElement,\n },\n {\n name: 'defineCustomElement',\n alias: `define${reactTagName}`,\n },\n ],\n });\n\n const publicEvents = (component.events || []).filter((e) => e.internal === false);\n const events: ReactEvent[] = [];\n\n for (const event of publicEvents) {\n if (Object.keys(event.complexType.references).length > 0) {\n /**\n * Import the referenced types from the component library.\n * Stencil will automatically re-export type definitions from the components,\n * if they are used in the component's property or event types.\n */\n for (const referenceKey of Object.keys(event.complexType.references)) {\n const reference = event.complexType.references[referenceKey];\n const isGlobalType = reference.location === 'global';\n /**\n * Global type references should not have an explicit import.\n * The type should be available globally.\n */\n if (!isGlobalType) {\n sourceFile.addImportDeclaration({\n moduleSpecifier: stencilPackageName,\n namedImports: [\n {\n name: referenceKey,\n isTypeOnly: true,\n },\n ],\n });\n }\n }\n\n /**\n * Import the CustomEvent type for the web component from the Stencil package.\n *\n * For example:\n * ```\n * import type { ComponentCustomEvent } from 'my-component-library';\n * ```\n */\n sourceFile.addImportDeclaration({\n moduleSpecifier: stencilPackageName,\n namedImports: [\n {\n name: componentCustomEvent,\n isTypeOnly: true,\n },\n ],\n });\n\n events.push({\n originalName: event.name,\n name: eventListenerName(event.name),\n type: `EventName<${componentCustomEvent}<${event.complexType.original}>>`,\n });\n } else {\n events.push({\n originalName: event.name,\n name: eventListenerName(event.name),\n type: `EventName<CustomEvent<${event.complexType.original}>>`,\n });\n }\n }\n\n const componentEventNamesType = `${reactTagName}Events`;\n\n sourceFile.addTypeAlias({\n isExported: true,\n name: componentEventNamesType,\n type: events.length > 0 ? `{ ${events.map((e) => `${e.name}: ${e.type}`).join(',\\n')} }` : 'NonNullable<unknown>',\n });\n\n const clientComponentCall = `/*@__PURE__*/ createComponent<${componentElement}, ${componentEventNamesType}>({\n tagName: '${tagName}',\n elementClass: ${componentElement},\n // @ts-ignore - ignore potential React type mismatches between the Stencil Output Target and your project.\n react: React,\n events: {${events.map((e) => `${e.name}: '${e.originalName}'`).join(',\\n')}} as ${componentEventNamesType},\n defineCustomElement: define${reactTagName}\n })`;\n const serverComponentCall = `/*@__PURE__*/ createComponent<${componentElement}, ${componentEventNamesType}>({\n tagName: '${tagName}',\n properties: {${component.properties\n /**\n * Filter out properties that don't have an attribute.\n * These are properties with complex types and can't be serialized.\n */\n .filter((prop) => Boolean(prop.attribute))\n .map((e) => `${e.name}: '${e.attribute}'`)\n .join(',\\n')}},\n hydrateModule: import('${hydrateModule}') as Promise<HydrateModule>,\n clientModule: clientComponents.${reactTagName} as ReactWebComponent<${componentElement}, ${componentEventNamesType}>,\n serializeShadowRoot,\n })`;\n\n sourceFile.addVariableStatement({\n isExported: true,\n declarationKind: VariableDeclarationKind.Const,\n // React as never is a hack to by-pass a @types/react issue.\n declarations: [\n {\n name: reactTagName,\n type: `StencilReactComponent<${componentElement}, ${componentEventNamesType}>`,\n initializer: hydrateModule ? serverComponentCall : clientComponentCall,\n },\n ],\n });\n }\n\n sourceFile.organizeImports();\n sourceFile.formatText();\n\n return sourceFile.getFullText();\n};\n","import type { ComponentCompilerMeta } from '@stencil/core/internal';\nimport path from 'node:path';\nimport { Project, SourceFile } from 'ts-morph';\nimport { createEsModulesComponentsFile } from './create-es-modules-components-file.js';\nimport { createStencilReactComponents } from './create-stencil-react-components.js';\nimport type { RenderToStringOptions } from './runtime/ssr.js';\n\nexport const createComponentWrappers = async ({\n stencilPackageName,\n components,\n outDir,\n esModules,\n customElementsDir,\n excludeComponents,\n project,\n hydrateModule,\n clientModule,\n excludeServerSideRenderingFor,\n serializeShadowRoot,\n}: {\n stencilPackageName: string;\n components: ComponentCompilerMeta[];\n customElementsDir: string;\n outDir: string;\n esModules?: boolean;\n excludeComponents?: string[];\n project: Project;\n hydrateModule?: string;\n clientModule?: string;\n excludeServerSideRenderingFor?: string[];\n serializeShadowRoot?: RenderToStringOptions['serializeShadowRoot'];\n}) => {\n const sourceFiles: SourceFile[] = [];\n\n const filteredComponents = components.filter((c) => {\n if (c.internal === true) {\n /**\n * Skip internal components\n */\n return false;\n }\n if (excludeComponents?.includes(c.tagName)) {\n /**\n * Skip excluded components\n */\n return false;\n }\n\n return true;\n });\n\n if (filteredComponents.length === 0) {\n return [];\n }\n\n const fileContents: Record<string, string> = {};\n\n /**\n * create a single file with all components or a separate file for each component\n * @param components - the components to create the file for\n * @param filename - the filename of the file to create\n */\n function createComponentFile(components: ComponentCompilerMeta[], filename = 'components') {\n /**\n * create a single file with all components\n */\n const outputPath = path.join(outDir, `${filename}.ts`);\n\n /**\n * create a client side component\n */\n const stencilReactComponent = createStencilReactComponents({\n components,\n stencilPackageName,\n customElementsDir,\n });\n fileContents[outputPath] = stencilReactComponent;\n\n /**\n * create a server side component\n */\n if (hydrateModule) {\n const outputPath = path.join(outDir, `${filename}.server.ts`);\n const stencilReactComponent = createStencilReactComponents({\n components: components.filter(\n (c) => !excludeServerSideRenderingFor || !excludeServerSideRenderingFor.includes(c.tagName)\n ),\n stencilPackageName,\n customElementsDir,\n hydrateModule,\n clientModule,\n serializeShadowRoot,\n });\n fileContents[outputPath] = stencilReactComponent;\n }\n }\n\n if (esModules) {\n /**\n * create a separate file for each component\n */\n for (const component of filteredComponents) {\n createComponentFile([component], component.tagName);\n }\n const componentsSource = await createEsModulesComponentsFile({ components: filteredComponents, project, outDir });\n sourceFiles.push(componentsSource);\n } else {\n createComponentFile(filteredComponents);\n }\n\n await Promise.all(\n Object.entries(fileContents).map(async ([outputPath, content]) => {\n const sourceFile = project.createSourceFile(outputPath, content, { overwrite: true });\n await sourceFile.save();\n sourceFiles.push(sourceFile);\n })\n );\n\n return sourceFiles;\n};\n","import type { BuildCtx, OutputTargetCustom, OutputTargetDistCustomElements } from '@stencil/core/internal';\nimport { Project } from 'ts-morph';\nimport { createComponentWrappers } from './create-component-wrappers.js';\nimport type { RenderToStringOptions } from './runtime/ssr.js';\n\nexport interface ReactOutputTargetOptions {\n /**\n * Specify the output directory or path where the generated React components will be saved.\n */\n outDir: string;\n /**\n * Specify the components that should be excluded from the React output target.\n */\n excludeComponents?: string[];\n /**\n * The package name of the Stencil project.\n *\n * This value is automatically detected from the package.json file of the Stencil project.\n * If the validation fails, you can manually assign the package name.\n */\n stencilPackageName?: string;\n /**\n * The directory where the custom elements are saved.\n *\n * This value is automatically detected from the Stencil configuration file for the dist-custom-elements output target.\n * If you are working in an environment that uses absolute paths, consider setting this value manually.\n */\n customElementsDir?: string;\n /**\n * To enable server side rendering, provide the path to the hydrate module, e.g. `my-component/hydrate`.\n * By default this value is undefined and server side rendering is disabled.\n */\n hydrateModule?: string;\n /**\n * The name of the package that exports all React wrapped Stencil components for client side rendering.\n * This options is required when `hydrateModule` is set for server side rendering to work.\n */\n clientModule?: string;\n /**\n * Specify the components that should be excluded from server side rendering.\n */\n excludeServerSideRenderingFor?: string[];\n /**\n * If `true`, the output target will generate a separate ES module for each React component wrapper. Defaults to `false`.\n * @default false\n */\n esModules?: boolean;\n /**\n * Configure how Stencil serializes the components shadow root.\n * - If set to `declarative-shadow-dom` the component will be rendered within a Declarative Shadow DOM.\n * - If set to `scoped` Stencil will render the contents of the shadow root as a `scoped: true` component\n * and the shadow DOM will be created during client-side hydration.\n * - Alternatively you can mix and match the two by providing an object with `declarative-shadow-dom` and `scoped` keys,\n * the value arrays containing the tag names of the components that should be rendered in that mode.\n *\n * Examples:\n * - `{ 'declarative-shadow-dom': ['my-component-1', 'another-component'], default: 'scoped' }`\n * Render all components as `scoped` apart from `my-component-1` and `another-component`\n * - `{ 'scoped': ['an-option-component'], default: 'declarative-shadow-dom' }`\n * Render all components within `declarative-shadow-dom` apart from `an-option-component`\n * - `'scoped'` Render all components as `scoped`\n * - `false` disables shadow root serialization\n *\n * *NOTE* `true` has been deprecated in favor of `declarative-shadow-dom` and `scoped`\n * @default 'declarative-shadow-dom'\n */\n serializeShadowRoot?: RenderToStringOptions['serializeShadowRoot'];\n}\n\nconst PLUGIN_NAME = 'react-output-target';\n\nconst DIST_CUSTOM_ELEMENTS_DEFAULT_DIR = 'dist/components';\nconst DIST_CUSTOM_ELEMENTS = 'dist-custom-elements';\nconst HYDRATE_OUTPUT_TARGET = 'dist-hydrate-script';\n\ninterface ReactOutputTarget extends OutputTargetCustom {\n __internal_getCustomElementsDir: () => string;\n}\n\n/**\n * Creates an output target for binding Stencil components to be used in a React context\n * @public\n * @param outputTarget the user-defined output target defined in a Stencil configuration file\n * @returns an output target that can be used by the Stencil compiler\n */\nexport const reactOutputTarget = ({\n outDir,\n esModules,\n stencilPackageName,\n excludeComponents,\n customElementsDir: customElementsDirOverride,\n hydrateModule,\n clientModule,\n excludeServerSideRenderingFor,\n serializeShadowRoot,\n}: ReactOutputTargetOptions): ReactOutputTarget => {\n let customElementsDir = DIST_CUSTOM_ELEMENTS_DEFAULT_DIR;\n return {\n type: 'custom',\n name: PLUGIN_NAME,\n validate(config) {\n /**\n * Validate the configuration to ensure that the dist-custom-elements\n * output target is defined in the Stencil configuration.\n *\n * This context is used to detect a customized output path.\n */\n if (customElementsDirOverride) {\n customElementsDir = customElementsDirOverride;\n } else {\n const customElementsOutputTarget = (config.outputTargets || []).find(\n (o) => o.type === DIST_CUSTOM_ELEMENTS\n ) as OutputTargetDistCustomElements;\n if (customElementsOutputTarget == null) {\n throw new Error(\n `The '${PLUGIN_NAME}' requires '${DIST_CUSTOM_ELEMENTS}' output target. Add { type: '${DIST_CUSTOM_ELEMENTS}' }, to the outputTargets config.`\n );\n }\n if (customElementsOutputTarget.dir !== undefined) {\n /**\n * If the developer has configured a custom output path for the Stencil components,\n * we need to use that path when importing the components in the React components.\n */\n customElementsDir = customElementsOutputTarget.dir;\n }\n\n /**\n * Validate the configuration for `dist-custom-elements` output target to ensure that\n * the bundle generates its own runtime. This is important because we need to ensure that\n * the Stencil runtime has hydration flags set which the default Stencil runtime does not have.\n */\n if (customElementsOutputTarget.externalRuntime !== false) {\n throw new Error(\n `The '${PLUGIN_NAME}' requires the '${DIST_CUSTOM_ELEMENTS}' output target to have 'externalRuntime: false' set in its configuration.`\n );\n }\n }\n\n /**\n * Validate the configuration to ensure that the dist-hydrate-script\n * output target is defined in the Stencil configuration if the hydrateModule is provided.\n */\n if (hydrateModule) {\n const hydrateOutputTarget = (config.outputTargets || []).find((o) => o.type === HYDRATE_OUTPUT_TARGET);\n if (hydrateOutputTarget == null) {\n throw new Error(\n `The '${PLUGIN_NAME}' requires '${HYDRATE_OUTPUT_TARGET}' output target when the 'hydrateModule' option is set. Add { type: '${HYDRATE_OUTPUT_TARGET}' }, to the outputTargets config.`\n );\n }\n\n if (clientModule == null) {\n throw new Error(\n `The '${PLUGIN_NAME}' requires the 'clientModule' option when the 'hydrateModule' option is set. Please provide the clientModule manually to the ${PLUGIN_NAME} output target.`\n );\n }\n }\n\n if (!outDir) {\n throw new Error(`The 'outDir' option is required.`);\n }\n\n /**\n * Validate the configuration to detect the package name of the Stencil project.\n */\n if (stencilPackageName === undefined) {\n if (config.sys && config.packageJsonFilePath) {\n const { name: packageName } = JSON.parse(config.sys.readFileSync(config.packageJsonFilePath, 'utf8'));\n stencilPackageName = packageName;\n }\n\n if (!stencilPackageName) {\n throw new Error(\n `Unable to find the package name in the package.json file: ${config.packageJsonFilePath}. Please provide the stencilPackageName manually to the ${PLUGIN_NAME} output target.`\n );\n }\n }\n },\n async generator(_config, compilerCtx, buildCtx: BuildCtx) {\n const timespan = buildCtx.createTimeSpan(`generate ${PLUGIN_NAME} started`, true);\n\n const components = buildCtx.components;\n\n const project = new Project();\n\n const sourceFiles = await createComponentWrappers({\n outDir,\n components,\n stencilPackageName: stencilPackageName!,\n customElementsDir,\n excludeComponents,\n esModules: esModules === true,\n project,\n hydrateModule,\n clientModule,\n excludeServerSideRenderingFor,\n serializeShadowRoot,\n });\n\n await Promise.all(\n sourceFiles.map((sourceFile) => compilerCtx.fs.writeFile(sourceFile.getFilePath(), sourceFile.getFullText()))\n );\n\n timespan.finish(`generate ${PLUGIN_NAME} finished`);\n },\n __internal_getCustomElementsDir() {\n return customElementsDir;\n },\n };\n};\n"],"names":["kebabToPascalCase","str","segment","kebabToCamelCase","_","letter","slashesToCamelCase","eventListenerName","eventName","slashesConverted","createEsModulesComponentsFile","components","project","outDir","tsProject","Project","disableEslint","autogeneratedComment","outFile","path","sourceFile","component","tagName","reactTagName","fileName","createStencilReactComponents","stencilPackageName","customElementsDir","hydrateModule","clientModule","serializeShadowRoot","useClientDirective","createComponentImport","VariableDeclarationKind","componentElement","componentCustomEvent","publicEvents","e","events","event","referenceKey","componentEventNamesType","clientComponentCall","serverComponentCall","prop","createComponentWrappers","esModules","excludeComponents","excludeServerSideRenderingFor","sourceFiles","filteredComponents","c","fileContents","createComponentFile","filename","outputPath","stencilReactComponent","componentsSource","content","PLUGIN_NAME","DIST_CUSTOM_ELEMENTS_DEFAULT_DIR","DIST_CUSTOM_ELEMENTS","HYDRATE_OUTPUT_TARGET","reactOutputTarget","customElementsDirOverride","config","customElementsOutputTarget","o","packageName","_config","compilerCtx","buildCtx","timespan"],"mappings":"mIAAaA,EAAqBC,GAChCA,EACG,YAAA,EACA,MAAM,GAAG,EACT,IAAKC,GAAYA,EAAQ,OAAO,CAAC,EAAE,cAAgBA,EAAQ,MAAM,CAAC,CAAC,EACnE,KAAK,EAAE,EAECC,EAAoBF,GAAgBA,EAAI,QAAQ,aAAc,CAACG,EAAGC,IAAWA,EAAO,aAAa,EAExGC,EAAsBL,GAAgBA,EAAI,QAAQ,aAAc,CAACG,EAAGC,IAAWA,EAAO,aAAa,EAE5FE,EAAqBC,GAAsB,CAChD,MAAAC,EAAmBH,EAAmBE,CAAS,EAC9C,OAAAL,EAAiB,MAAMM,CAAgB,EAAE,CAClD,ECTaC,EAAgC,MAAO,CAClD,WAAAC,EACA,QAAAC,EACA,OAAAC,CACF,IAIM,CACJ,MAAMC,EAAYF,GAAW,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