@tsrx/bun-plugin-react 0.1.81 → 0.1.83

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.
package/README.md CHANGED
@@ -36,5 +36,17 @@ Bun.plugin(tsrxReact());
36
36
  ## Options
37
37
 
38
38
  - `jsxImportSource`: automatic JSX runtime import source (default: `'react'`).
39
+ - `runtimeImports`: helper import mode (`'compiler'` by default, or `'direct'` for
40
+ standalone runtime imports).
39
41
  - `emitCss`: whether to emit virtual CSS imports (default: `true`).
40
42
  - `include`, `exclude`: regex filters for source files.
43
+
44
+ When using `runtimeImports: 'direct'`, install the runtime as a direct production
45
+ dependency of the package that owns the compiled modules:
46
+
47
+ ```bash
48
+ pnpm add @tsrx/react-runtime
49
+ ```
50
+
51
+ Bun may bundle the helpers into its output, but this plugin only emits bare
52
+ `@tsrx/react-runtime/*` imports and does not provide the runtime package.
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Bun plugin for @tsrx/react (.tsrx modules)",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.1.81",
6
+ "version": "0.1.83",
7
7
  "type": "module",
8
8
  "publishConfig": {
9
9
  "access": "public"
@@ -20,7 +20,7 @@
20
20
  }
21
21
  },
22
22
  "dependencies": {
23
- "@tsrx/react": "0.2.58"
23
+ "@tsrx/react": "0.2.60"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "bun": "^1.0.0",
package/src/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  /** @import { BunPlugin, Target, Transpiler } from 'bun' */
2
+ /** @import { RuntimeImportMode } from '@tsrx/react' */
2
3
 
3
4
  import { readFile } from 'node:fs/promises';
4
5
  import { compile } from '@tsrx/react';
@@ -13,6 +14,7 @@ const CSS_QUERY_PATTERN = /\?tsrx-css&lang\.css$/;
13
14
  * exclude?: RegExp | RegExp[],
14
15
  * jsxImportSource?: string,
15
16
  * emitCss?: boolean,
17
+ * runtimeImports?: RuntimeImportMode,
16
18
  * }} TsrxReactBunPluginOptions
17
19
  */
18
20
 
@@ -90,6 +92,7 @@ function create_transpiler(jsx_import_source, target) {
90
92
  export function tsrxReact(options = {}) {
91
93
  const jsx_import_source = options.jsxImportSource ?? 'react';
92
94
  const emit_css = options.emitCss ?? true;
95
+ const compile_options = { runtimeImports: options.runtimeImports };
93
96
 
94
97
  /** @type {Map<string, string>} */
95
98
  const css_cache = new Map();
@@ -118,7 +121,7 @@ export function tsrxReact(options = {}) {
118
121
  if (!should_compile(options, args.path)) return undefined;
119
122
 
120
123
  const source = await readFile(args.path, 'utf-8');
121
- const { code, css } = compile(source, args.path);
124
+ const { code, css } = compile(source, args.path, compile_options);
122
125
  const css_id = to_css_id(args.path);
123
126
 
124
127
  let output = code;
package/types/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import type { BunPlugin } from 'bun';
2
+ import type { RuntimeImportMode } from '@tsrx/react';
2
3
 
3
4
  export interface TsrxReactBunPluginOptions {
5
+ /** Direct mode requires `@tsrx/react-runtime` as a direct production dependency. */
6
+ runtimeImports?: RuntimeImportMode;
4
7
  include?: RegExp;
5
8
  exclude?: RegExp | RegExp[];
6
9
  jsxImportSource?: string;