esbuild-plugin-solarite 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +26 -0
  2. package/package.json +33 -0
  3. package/readme.md +26 -0
package/index.js ADDED
@@ -0,0 +1,26 @@
1
+ /** esbuild-plugin-solarite — an onLoad plugin that compiles .jsx/.tsx into Solarite precompile
2
+ * output before esbuild bundles, giving JSX the same runtime speed as `h` tagged templates. esbuild
3
+ * only ever sees plain JS. Build-time only; nothing is shipped to the browser. */
4
+ import fs from 'node:fs';
5
+ import { transform } from 'babel-plugin-solarite';
6
+
7
+ export default function solariteEsbuild(options = {}) {
8
+ return {
9
+ name: 'esbuild-plugin-solarite',
10
+ setup(build) {
11
+ build.onLoad({ filter: /\.[jt]sx$/ }, async args => {
12
+ const source = await fs.promises.readFile(args.path, 'utf8');
13
+ const { code, map } = transform(source, {
14
+ filename: args.path,
15
+ importSource: options.importSource,
16
+ sourceMaps: true,
17
+ });
18
+ let contents = code;
19
+ if (map)
20
+ contents += '\n//# sourceMappingURL=data:application/json;base64,' +
21
+ Buffer.from(JSON.stringify(map)).toString('base64');
22
+ return { contents, loader: 'js' };
23
+ });
24
+ },
25
+ };
26
+ }
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "esbuild-plugin-solarite",
3
+ "version": "0.7.0",
4
+ "description": "esbuild plugin that compiles JSX/TSX to Solarite precompile output, giving JSX the same runtime speed as h tagged templates.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "Eric Frost",
8
+ "main": "./index.js",
9
+ "exports": {
10
+ ".": "./index.js"
11
+ },
12
+ "files": [
13
+ "index.js",
14
+ "readme.md"
15
+ ],
16
+ "keywords": [
17
+ "solarite",
18
+ "jsx",
19
+ "tsx",
20
+ "esbuild",
21
+ "esbuild-plugin",
22
+ "precompile"
23
+ ],
24
+ "dependencies": {
25
+ "babel-plugin-solarite": "^0.7.0"
26
+ },
27
+ "peerDependencies": {
28
+ "solarite": "^0.7.0"
29
+ },
30
+ "peerDependenciesMeta": {
31
+ "solarite": { "optional": true }
32
+ }
33
+ }
package/readme.md ADDED
@@ -0,0 +1,26 @@
1
+ # esbuild-plugin-solarite
2
+
3
+ Compiles JSX/TSX into **Solarite precompile output** so JSX renders at the **same speed as `h` tagged
4
+ templates**. It runs as an esbuild `onLoad` plugin (esbuild only ever sees plain JS) and only at
5
+ build time — nothing is shipped to the browser.
6
+
7
+ Thin wrapper around [`babel-plugin-solarite`](../babel-plugin-solarite), which does the actual
8
+ compiling.
9
+
10
+ ```sh
11
+ npm install --save-dev esbuild-plugin-solarite
12
+ ```
13
+
14
+ ```js
15
+ import esbuild from 'esbuild';
16
+ import solarite from 'esbuild-plugin-solarite';
17
+
18
+ await esbuild.build({
19
+ entryPoints: ['app.tsx'], bundle: true, outfile: 'app.js',
20
+ plugins: [solarite()]
21
+ });
22
+ ```
23
+
24
+ ## Options
25
+
26
+ - `importSource` — runtime module specifier (default `"solarite/jsx-runtime"`).