@tsrx/rspack-plugin-preact 0.0.74 → 0.0.75

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Rspack plugin for @tsrx/preact",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.0.74",
6
+ "version": "0.0.75",
7
7
  "type": "module",
8
8
  "publishConfig": {
9
9
  "access": "public"
@@ -20,7 +20,7 @@
20
20
  }
21
21
  },
22
22
  "dependencies": {
23
- "@tsrx/preact": "0.1.58"
23
+ "@tsrx/preact": "0.1.59"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "@rspack/core": ">=1.6.0"
package/src/css-loader.js CHANGED
@@ -1,5 +1,7 @@
1
1
  /** @import { LoaderContext } from '@rspack/core' */
2
2
 
3
+ /** @import { RuntimeImportMode } from '@tsrx/preact' */
4
+
3
5
  import { compile } from '@tsrx/preact';
4
6
 
5
7
  /**
@@ -7,7 +9,7 @@ import { compile } from '@tsrx/preact';
7
9
  * the scoped CSS emitted by its `<style>` block. Invoked when rspack resolves
8
10
  * the sibling `?tsrx-css&lang.css` import prepended by the JS loader.
9
11
  *
10
- * @this {LoaderContext<{ suspenseSource?: string }>}
12
+ * @this {LoaderContext<{ suspenseSource?: string, runtimeImports?: RuntimeImportMode }>}
11
13
  * @param {string} source
12
14
  * @returns {void}
13
15
  */
package/src/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  /** @import { Compiler, RspackPluginInstance } from '@rspack/core' */
2
+ /** @import { RuntimeImportMode } from '@tsrx/preact' */
2
3
 
3
4
  import path from 'node:path';
4
5
  import { fileURLToPath } from 'node:url';
@@ -23,12 +24,13 @@ const CSS_QUERY_PATTERN = /tsrx-css/;
23
24
  */
24
25
  export class TsrxPreactRspackPlugin {
25
26
  /**
26
- * @param {{ jsxImportSource?: string, suspenseSource?: string }} [options]
27
+ * @param {{ jsxImportSource?: string, suspenseSource?: string, runtimeImports?: RuntimeImportMode }} [options]
27
28
  */
28
29
  constructor(options = {}) {
29
30
  this.options = {
30
31
  jsxImportSource: options.jsxImportSource ?? 'preact',
31
32
  suspenseSource: options.suspenseSource,
33
+ runtimeImports: options.runtimeImports ?? 'compiler',
32
34
  };
33
35
  }
34
36
 
@@ -85,6 +87,7 @@ export class TsrxPreactRspackPlugin {
85
87
  loader: JS_LOADER,
86
88
  options: {
87
89
  suspenseSource: this.options.suspenseSource,
90
+ runtimeImports: this.options.runtimeImports,
88
91
  },
89
92
  },
90
93
  ],
@@ -98,6 +101,7 @@ export class TsrxPreactRspackPlugin {
98
101
  loader: CSS_LOADER,
99
102
  options: {
100
103
  suspenseSource: this.options.suspenseSource,
104
+ runtimeImports: this.options.runtimeImports,
101
105
  },
102
106
  },
103
107
  ],
package/src/js-loader.js CHANGED
@@ -1,5 +1,7 @@
1
1
  /** @import { LoaderContext } from '@rspack/core' */
2
2
 
3
+ /** @import { RuntimeImportMode } from '@tsrx/preact' */
4
+
3
5
  import { compile } from '@tsrx/preact';
4
6
 
5
7
  /**
@@ -7,7 +9,7 @@ import { compile } from '@tsrx/preact';
7
9
  * prepends an `import` to the sibling virtual CSS module so rspack can
8
10
  * include the styles in the asset graph.
9
11
  *
10
- * @this {LoaderContext<{ suspenseSource?: string }>}
12
+ * @this {LoaderContext<{ suspenseSource?: string, runtimeImports?: RuntimeImportMode }>}
11
13
  * @param {string} source
12
14
  * @returns {void}
13
15
  */
package/types/index.d.ts CHANGED
@@ -1,14 +1,18 @@
1
1
  import type { Compiler, RspackPluginInstance } from '@rspack/core';
2
+ import type { RuntimeImportMode } from '@tsrx/preact';
2
3
 
3
4
  export interface TsrxPreactRspackPluginOptions {
4
5
  jsxImportSource?: string;
5
6
  suspenseSource?: string;
7
+ /** Direct mode requires `@tsrx/preact-runtime` as a direct production dependency. */
8
+ runtimeImports?: RuntimeImportMode;
6
9
  }
7
10
 
8
11
  export declare class TsrxPreactRspackPlugin implements RspackPluginInstance {
9
12
  constructor(options?: TsrxPreactRspackPluginOptions);
10
13
  options: Required<Pick<TsrxPreactRspackPluginOptions, 'jsxImportSource'>> &
11
- Pick<TsrxPreactRspackPluginOptions, 'suspenseSource'>;
14
+ Pick<TsrxPreactRspackPluginOptions, 'suspenseSource'> &
15
+ Required<Pick<TsrxPreactRspackPluginOptions, 'runtimeImports'>>;
12
16
  apply(compiler: Compiler): void;
13
17
  }
14
18