esbuild-plugin-solid
Advanced tools
Comparing version 0.4.2 to 0.5.0
import { Plugin } from "esbuild"; | ||
export interface SolidOptions { | ||
hydratable?: boolean; | ||
generate?: 'dom' | 'ssr'; | ||
import { TransformOptions } from "@babel/core"; | ||
/** Configuration options for esbuild-plugin-solid */ | ||
export interface Options { | ||
/** The options to use for @babel/preset-typescript @default {} */ | ||
typescript?: object; | ||
/** | ||
* Pass any additional babel transform options. They will be merged with | ||
* the transformations required by Solid. | ||
* | ||
* @default {} | ||
*/ | ||
babel?: 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. | ||
* - "universal" is for using custom renderers from solid-js/universal | ||
* | ||
* @default "dom" | ||
*/ | ||
generate?: 'ssr' | 'dom' | 'universal'; | ||
/** | ||
* 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 declare function solidPlugin(options?: SolidOptions): Plugin; | ||
export declare function solidPlugin(options?: Options): Plugin; |
{ | ||
"name": "esbuild-plugin-solid", | ||
"version": "0.4.2", | ||
"version": "0.5.0", | ||
"description": "Solid's integration for ESBuild", | ||
"main": "dist/cjs/plugin.js", | ||
"module": "dist/esm/plugin.js", | ||
"main": "dist/cjs/plugin.cjs", | ||
"module": "dist/esm/plugin.mjs", | ||
"types": "dist/types/plugin.d.ts", | ||
"type": "module", | ||
"exports": { | ||
"default": "./dist/cjs/plugin.js", | ||
"node": "./dist/cjs/plugin.js", | ||
"import": "./dist/esm/plugin.js" | ||
".": { | ||
"default": "./dist/cjs/plugin.cjs", | ||
"node": "./dist/cjs/plugin.cjs", | ||
"import": "./dist/esm/plugin.mjs" | ||
} | ||
}, | ||
@@ -33,22 +36,21 @@ "files": [ | ||
"dependencies": { | ||
"@babel/core": "^7.16.5", | ||
"@babel/preset-typescript": "^7.16.5", | ||
"babel-preset-solid": "^1.2.6" | ||
"@babel/core": "^7.20.12", | ||
"@babel/preset-typescript": "^7.18.6", | ||
"babel-preset-solid": "^1.6.9" | ||
}, | ||
"devDependencies": { | ||
"@skypack/package-check": "^0.2.2", | ||
"@types/babel__core": "^7.1.17", | ||
"@types/node": "^17.0.4", | ||
"del": "^6.0.0", | ||
"esbuild": "^0.14.8", | ||
"serve": "^13.0.2", | ||
"solid-js": "^1.2.6", | ||
"typescript": "^4.5.4" | ||
"@types/babel__core": "^7.20.0", | ||
"@types/node": "^18.11.18", | ||
"del": "^7.0.0", | ||
"esbuild": "^0.17.3", | ||
"serve": "^14.1.2", | ||
"solid-js": "^1.6.9", | ||
"typescript": "^4.9.4" | ||
}, | ||
"scripts": { | ||
"build": "node scripts/build && tsc", | ||
"test": "node scripts/test && serve tests", | ||
"build": "node ./scripts/build.js && tsc", | ||
"test": "node ./scripts/test.js && serve tests", | ||
"check": "package-check" | ||
}, | ||
"readme": "# esbuild-plugin-solid\n\nPlugin to compile [solid-js](https://github.com/ryansolid/solid) jsx components with [esbuild](https://esbuild.github.io/).\n\n/!\\ **Disclaimer** /!\\\n\nAt the time of writing this, `esbuild` is not AS performant in term of dead code elimination as `rollup` is.\n\nRollup is the preferred way to bundle solid apps as it generally produce smaller code.\n\nIn my tests, a hello world :\n\n* `rollup`: 5.95kb\n* `esbuild`: 9.65kb\n\n## Install\n\n`solid-js` and `esbuild` are peer dependencies\n\n```bash\n# For npm\nnpm install solid-js\nnpm install -D esbuild esbuild-plugin-solid\n\n# For pnpm\npnpm add solid-js\npnpm add -D esbuild esbuild-plugin-solid\n\n# For yarn\nyarn add solid-js\nyarn add -D esbuild esbuild-plugin-solid\n```\n\n## Usage\n\nOnce installed you need to configure `esbuild` to use this plugin.\n\n```js\nconst { build } = require('esbuild');\nconst { solidPlugin } = require('esbuild-plugin-solid');\n\nbuild({\n entryPoints: ['app.jsx'],\n bundle: true,\n outfile: 'out.js',\n plugins: [solidPlugin()],\n}).catch(() => process.exit(1))\n```\n\n## Configuration\n\nThere's no configuration as of now.\n\n## How it works\n\nThis is a 30 lines of code plugin. All it does is parse every import source code, check if JSX syntax is present using a dumb regex and transforming the file with `@babel/core`, `@babel/preset-typescript` and `babel-preset-solid`.\n\nOut of the box it checks every `/(t|j)sx?/` files and only transforms the one with JSX syntax in it.\n\n## Contributing\n\nThis package uses [pnpm](https://pnpm.js.org/) so you might want to install it if you don't have it.\n\nOnce done, you can just `pnpm build` & `pnpm test` to build & test your changes.\n\n`pnpm test` [will build](./scripts/test.js) a [dumb module](./tests/index.tsx) with the plugin and open a local web server serving the `tests` folder for you to check if things still work." | ||
} | ||
} |
@@ -52,4 +52,85 @@ # esbuild-plugin-solid | ||
There's no configuration as of now. | ||
The following options are available and can be passed to the plugin: | ||
```ts | ||
/** Configuration options for esbuild-plugin-solid */ | ||
export interface Options { | ||
/** The options to use for @babel/preset-typescript @default {} */ | ||
typescript: object | ||
/** | ||
* Pass any additional babel transform options. They will be merged with | ||
* the transformations required by Solid. | ||
* | ||
* @default {} | ||
*/ | ||
babel: | ||
| 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. | ||
* - "universal" is for using custom renderers from solid-js/universal | ||
* | ||
* @default "dom" | ||
*/ | ||
generate?: 'ssr' | 'dom' | 'universal'; | ||
/** | ||
* 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[]; | ||
}; | ||
} | ||
``` | ||
## How it works | ||
@@ -67,2 +148,2 @@ | ||
`pnpm test` [will build](./scripts/test.js) a [dumb module](./tests/index.tsx) with the plugin and open a local web server serving the `tests` folder for you to check if things still work. | ||
`pnpm test` [will build](./scripts/test.js) a [dumb module](./tests/index.tsx) with the plugin and open a local web server serving the `tests` folder for you to check if things still work. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22237
7
170
148
Yes
1
Updated@babel/core@^7.20.12
Updatedbabel-preset-solid@^1.6.9