-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add solid_options for solid babel plugin options #13
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import path from 'path' | ||
import * as tsup from 'tsup' | ||
import * as esbuild from 'esbuild' | ||
import { solidPlugin } from 'esbuild-plugin-solid' | ||
import { type Options, solidPlugin } from 'esbuild-plugin-solid' | ||
|
||
export interface EntryOptions { | ||
name?: string | undefined | ||
|
@@ -11,6 +11,14 @@ export interface EntryOptions { | |
dev_entry?: boolean | string | ||
/** Setting `true` will generate a server-only entry (default: `false`) */ | ||
server_entry?: boolean | string | ||
/** | ||
* 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). | ||
* Option `generate` will be set to `ssr` if `server_entry` is set to `true` and `dom` otherwise. | ||
* | ||
* @default {} | ||
*/ | ||
solid_options?: Options['solid'] | undefined | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why only |
||
} | ||
|
||
export type ModifyEsbuildOptions = ( | ||
|
@@ -67,6 +75,7 @@ export interface EntryType { | |
dev: boolean | ||
server: boolean | ||
jsx: boolean | ||
solid_options: Options['solid'] | ||
} | ||
|
||
export interface BuildItem { | ||
|
@@ -127,6 +136,7 @@ export function parsePresetOptions( | |
dev: !!options.dev_entry, | ||
server: !!options.server_entry, | ||
jsx: options.entry.endsWith('.jsx') || options.entry.endsWith('.tsx'), | ||
solid_options: options.solid_options, | ||
}, | ||
} | ||
}) | ||
|
@@ -179,7 +189,11 @@ export function generateTsupOptions( | |
if (item) { | ||
item.entries.add(entry) | ||
} else { | ||
items.push({ type: { dev, server, jsx }, entries: new Set([entry]) }) | ||
const solid_options = entry.options.solid_options ?? {} | ||
items.push({ | ||
type: { dev, server, jsx, solid_options }, | ||
entries: new Set([entry]), | ||
}) | ||
} | ||
} | ||
} | ||
|
@@ -247,7 +261,12 @@ export function generateTsupOptions( | |
}, | ||
esbuildPlugins: !type.jsx | ||
? [ | ||
solidPlugin({ solid: { generate: type.server ? 'ssr' : 'dom' } }), | ||
solidPlugin({ | ||
solid: { | ||
generate: type.server ? 'ssr' : 'dom', | ||
...type.solid_options, | ||
}, | ||
}), | ||
Comment on lines
-250
to
+269
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. imo this should be added to preset, not entry, options as |
||
...options.esbuild_plugins, | ||
] | ||
: options.esbuild_plugins, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please alias Options or the while import as solid so it's obvious what Options is.