Skip to content

Commit

Permalink
✨ Adding babel-preset-solid options from the vite plugin (fix #13)
Browse files Browse the repository at this point in the history
  • Loading branch information
amoutonbrady committed Jun 6, 2021
1 parent 6389e88 commit 584d4e9
Showing 1 changed file with 63 additions and 1 deletion.
64 changes: 63 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,68 @@ export interface Options {
| TransformOptions
| ((source: string, id: string, ssr: boolean) => TransformOptions)
| ((source: string, id: string, ssr: boolean) => Promise<TransformOptions>);
/**
* 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<Options> = {}): Plugin {
Expand Down Expand Up @@ -112,7 +174,7 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {

const opts: TransformOptions = {
filename: id,
presets: [[solid, solidOptions]],
presets: [[solid, { ...solidOptions, ...(options.solid || {}) }]],
plugins: needHmr ? [[solidRefresh, { bundler: 'vite' }]] : [],
};

Expand Down

0 comments on commit 584d4e9

Please sign in to comment.