From 14cda90260c9595ee16c308037f4a7c8ead3f451 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 19 Nov 2026 10:46:07 +0800 Subject: [PATCH 1/3] fix(types): expose the Solid hoistProps option --- src/types.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/types.ts b/src/types.ts index 996c02b..e5314ce 100644 --- a/src/types.ts +++ b/src/types.ts @@ -43,6 +43,11 @@ export type SolidPresetOptions = { * @default false */ hydratable?: boolean; + /** + * Whether to share component prop getters across instances in SSR output. + * @default true + */ + hoistProps?: TransformOptions['hoistProps']; /** * Whether to automatically delegate supported events. * @default true From e169217771cfeb2e4dd5c05d8335fddc17b9cb71 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 19 Nov 2026 10:58:23 +0800 Subject: [PATCH 2/3] refactor(types): derive Solid options from the compiler --- src/types.ts | 150 +++------------------------------------------------ 1 file changed, 7 insertions(+), 143 deletions(-) diff --git a/src/types.ts b/src/types.ts index e5314ce..f799db5 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2,149 +2,13 @@ import type { TransformOptions } from '@solidjs/compiler'; export type SolidCompiler = 'babel' | 'native'; -/** - * Options passed to the Solid JSX compiler. - * - * The option types are aligned with `@solidjs/compiler` and adjusted - * for `@solidjs/babel-plugin`. - * - * https://github.com/solidjs/solid/blob/next/packages/compiler/types.d.ts - * https://github.com/solidjs/solid/tree/next/packages/babel-plugin - */ -export type SolidPresetOptions = { - /** - * The runtime module from which compiler helpers are imported. - * @default '@solidjs/web' - */ - moduleName?: string; - /** - * Whether to generate development-only runtime checks and metadata. - * Defaults to true in Rspack development mode. - */ - dev?: boolean; - /** - * Include component names, binding names, and source locations in compiler output. - * Defaults to the compiler's `dev` setting. - */ - sourceNames?: TransformOptions['sourceNames']; - /** - * The output mode of the compiler. - * - `dom` generates DOM operations. - * - `ssr` generates HTML strings for server-side rendering. - * - `universal` generates output for a custom renderer. - * - `dynamic` routes configured native elements to the DOM renderer and - * uses the universal renderer as a fallback. - * - * @default 'dom' - */ - generate?: 'dom' | 'ssr' | 'universal' | 'dynamic'; - /** - * Whether to include hydration markers in the generated output. - * @default false - */ - hydratable?: boolean; - /** - * Whether to share component prop getters across instances in SSR output. - * @default true - */ - hoistProps?: TransformOptions['hoistProps']; - /** - * Whether to automatically delegate supported events. - * @default true - */ - delegateEvents?: boolean; - /** - * Additional event names that should always use delegation. - * @default [] - */ - delegatedEvents?: string[]; - /** - * Whether to optimize simple boolean expressions and ternaries in JSX. - * @default true - */ - wrapConditionals?: boolean; - /** - * Whether to set the current render context on custom elements and slots. - * @default true - */ - contextToCustomElements?: boolean; - /** - * Component export names that should be recognized and automatically - * imported from the runtime module. - * @default `['For', 'Show', 'Switch', 'Match', 'Loading', 'Reveal', 'Portal', 'Repeat', 'Dynamic', 'Errored']` - */ - builtIns?: string[]; - /** - * The runtime helper used for reactive effect wrapping. - * Set to `false` to disable effect wrapping. - * @default 'effect' - */ +/** Options passed to the Solid JSX compiler. Rspack supplies the filename and source map settings. */ +export type SolidPresetOptions = Omit< + TransformOptions, + 'filename' | 'sourceMap' | 'effectWrapper' | 'memoWrapper' +> & { + /** Babel also accepts a custom runtime helper name. Defaults to `'effect'`. */ effectWrapper?: string | false; - /** - * The comment marker used to assert that an expression is static and does - * not need reactive wrapping. - * @default '@static' - */ - staticMarker?: string; - /** - * The runtime helper used to memoize derived expressions. - * Set to `false` to disable memo wrapping. - * @default 'memo' - */ + /** Babel also accepts a custom runtime helper name. Defaults to `'memo'`. */ memoWrapper?: string | false; - /** - * Whether to validate HTML nesting in generated templates. - * @default true - */ - validate?: boolean; - /** - * Whether to omit unnecessary nested closing tags from template strings. - * More information: - * https://github.com/solidjs/solid/blob/main/CHANGELOG.md#smaller-templates - * - * @default false - */ - omitNestedClosingTags?: boolean; - /** - * Whether to omit the final closing tag from template strings when safe. - * Disable this for compatibility with parsers that require explicit closing - * tags. - * - * @default true - */ - omitLastClosingTag?: boolean; - /** - * Whether to omit quotes around attribute values when safe. - * Disable this for compatibility with parsers that require quoted values. - * - * @default true - */ - omitQuotes?: boolean; - /** - * Whether quoted attributes may omit the following separator space. - * Set to `false` for strict HTML or SVG parsers. - * @default true - */ - omitAttributeSpacing?: boolean; - /** - * Whether to inline static style values into generated template strings. - * When disabled, style values are applied at runtime. - * @default true - */ - inlineStyles?: boolean; - /** - * Restrict JSX transformation to files whose `@jsxImportSource` pragma - * matches this value. Set to `false` to disable this check. - * @default false - */ - requireImportSource?: false | string; - /** - * Renderer configurations used by the `dynamic` output mode. - * @default [] - */ - renderers?: Array<{ - name: string; - moduleName?: string; - elements: string[]; - }>; }; From 28c5bbd7d6cb021a9bdbb0ffcee2a1485ac1cf90 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 19 Nov 2026 11:05:47 +0800 Subject: [PATCH 3/3] refactor(types): inherit compiler wrapper options --- src/index.ts | 3 +-- src/types.ts | 9 ++------- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/index.ts b/src/index.ts index 96c4f85..2adb440 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,6 @@ import { createRequire } from 'node:module'; import type { TransformOptions } from '@babel/core'; import type { LoaderDefinition } from '@rspack/core'; -import type { TransformOptions as NativeTransformOptions } from '@solidjs/compiler'; import { applyRefresh, getTransformFilename, @@ -93,7 +92,7 @@ const solidLoader: LoaderDefinition = async function ( ...solid, filename, sourceMap: this.sourceMap || Boolean(sourceMap), - } as NativeTransformOptions); + }); callback( null, diff --git a/src/types.ts b/src/types.ts index f799db5..1770810 100644 --- a/src/types.ts +++ b/src/types.ts @@ -5,10 +5,5 @@ export type SolidCompiler = 'babel' | 'native'; /** Options passed to the Solid JSX compiler. Rspack supplies the filename and source map settings. */ export type SolidPresetOptions = Omit< TransformOptions, - 'filename' | 'sourceMap' | 'effectWrapper' | 'memoWrapper' -> & { - /** Babel also accepts a custom runtime helper name. Defaults to `'effect'`. */ - effectWrapper?: string | false; - /** Babel also accepts a custom runtime helper name. Defaults to `'memo'`. */ - memoWrapper?: string | false; -}; + 'filename' | 'sourceMap' +>;