diff --git a/src/index.ts b/src/index.ts index 0abd6b4..4917fc0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -47,6 +47,68 @@ export interface Options { | TransformOptions | ((source: string, id: string, ssr: boolean) => TransformOptions) | ((source: string, id: string, ssr: boolean) => Promise); + /** + * Pass any additional [babel-plugin-jsx-dom-expressions](https://github.com/ryansolid/dom-expressions/tree/main/packages/babel-plugin-jsx-dom-expressions#plugin-options). + * They will be merged with the defaults sets by [babel-preset-solid](https://github.com/solidjs/solid/blob/main/packages/babel-preset-solid/index.js#L8-L25). + * + * @default {} + */ + solid: { + /** + * The name of the runtime module to import the methods from. + * + * @default "solid-js/web" + */ + moduleName?: string; + + /** + * The output mode of the compiler. + * Can be: + * - "dom" is standard output + * - "ssr" is for server side rendering of strings. + * + * @default "dom" + */ + generate?: 'ssr' | 'dom'; + + /** + * Indicate whether the output should contain hydratable markers. + * + * @default false + */ + hydratable?: boolean; + + /** + * Boolean to indicate whether to enable automatic event delegation on camelCase. + * + * @default true + */ + delegateEvents?: boolean; + + /** + * Boolean indicates whether smart conditional detection should be used. + * This optimizes simple boolean expressions and ternaries in JSX. + * + * @default true + */ + wrapConditionals?: boolean; + + /** + * Boolean indicates whether to set current render context on Custom Elements and slots. + * Useful for seemless Context API with Web Components. + * + * @default true + */ + contextToCustomElements?: boolean; + + /** + * Array of Component exports from module, that aren't included by default with the library. + * This plugin will automatically import them if it comes across them in the JSX. + * + * @default ["For","Show","Switch","Match","Suspense","SuspenseList","Portal","Index","Dynamic","ErrorBoundary"] + */ + builtIns?: string[]; + }; } export default function solidPlugin(options: Partial = {}): Plugin { @@ -112,7 +174,7 @@ export default function solidPlugin(options: Partial = {}): Plugin { const opts: TransformOptions = { filename: id, - presets: [[solid, solidOptions]], + presets: [[solid, { ...solidOptions, ...(options.solid || {}) }]], plugins: needHmr ? [[solidRefresh, { bundler: 'vite' }]] : [], };