@tsrx/rspack-plugin-vue 0.0.69 → 0.0.71

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/vue",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.0.69",
6
+ "version": "0.0.71",
7
7
  "type": "module",
8
8
  "publishConfig": {
9
9
  "access": "public"
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "source-map": "^0.7.6",
24
- "@tsrx/vue": "0.1.57"
24
+ "@tsrx/vue": "0.1.59"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "@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/vue' */
4
+
3
5
  import { compile } from '@tsrx/vue';
4
6
 
5
7
  /**
@@ -7,7 +9,7 @@ import { compile } from '@tsrx/vue';
7
9
  * scoped CSS emitted by its `<style>` block. Invoked when rspack resolves the
8
10
  * sibling `?tsrx-css&lang.css` import prepended by the JS loader.
9
11
  *
10
- * @this {LoaderContext<object>}
12
+ * @this {LoaderContext<{ runtimeImports?: RuntimeImportMode }>}
11
13
  * @param {string} source
12
14
  * @returns {void}
13
15
  */
@@ -16,7 +18,7 @@ export default function cssLoader(source) {
16
18
  const resourcePath = this.resourcePath;
17
19
 
18
20
  try {
19
- const { css } = compile(source, resourcePath);
21
+ const { css } = compile(source, resourcePath, this.getOptions?.());
20
22
  callback(null, css);
21
23
  } catch (/** @type {any} */ err) {
22
24
  callback(err);
package/src/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  /** @import { Compiler, RspackPluginInstance } from '@rspack/core' */
2
+ /** @import { RuntimeImportMode } from '@tsrx/vue' */
2
3
 
3
4
  import path from 'node:path';
4
5
  import { fileURLToPath } from 'node:url';
@@ -26,11 +27,12 @@ const SOURCE_EXTENSION_PATTERN = /\.[cm]?[jt]sx?$/;
26
27
  */
27
28
  export class TsrxVueRspackPlugin {
28
29
  /**
29
- * @param {{ vapor?: { macros?: boolean | object, compiler?: { runtimeModuleName?: string } } }} [options]
30
+ * @param {{ vapor?: { macros?: boolean | object, compiler?: { runtimeModuleName?: string } }, runtimeImports?: RuntimeImportMode }} [options]
30
31
  */
31
32
  constructor(options = {}) {
32
33
  this.options = {
33
34
  vapor: options.vapor,
35
+ runtimeImports: options.runtimeImports ?? 'compiler',
34
36
  };
35
37
  }
36
38
 
@@ -92,6 +94,9 @@ export class TsrxVueRspackPlugin {
92
94
  },
93
95
  {
94
96
  loader: JS_LOADER,
97
+ options: {
98
+ runtimeImports: this.options.runtimeImports,
99
+ },
95
100
  },
96
101
  ],
97
102
  },
@@ -102,6 +107,9 @@ export class TsrxVueRspackPlugin {
102
107
  use: [
103
108
  {
104
109
  loader: CSS_LOADER,
110
+ options: {
111
+ runtimeImports: this.options.runtimeImports,
112
+ },
105
113
  },
106
114
  ],
107
115
  },
package/src/js-loader.js CHANGED
@@ -1,5 +1,7 @@
1
1
  /** @import { LoaderContext } from '@rspack/core' */
2
2
 
3
+ /** @import { RuntimeImportMode } from '@tsrx/vue' */
4
+
3
5
  import { compile } from '@tsrx/vue';
4
6
 
5
7
  /**
@@ -7,7 +9,7 @@ import { compile } from '@tsrx/vue';
7
9
  * present, 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<object>}
12
+ * @this {LoaderContext<{ runtimeImports?: RuntimeImportMode }>}
11
13
  * @param {string} source
12
14
  * @returns {void}
13
15
  */
@@ -16,7 +18,7 @@ export default function jsLoader(source) {
16
18
  const resourcePath = this.resourcePath;
17
19
 
18
20
  try {
19
- const { code, map, css } = compile(source, resourcePath);
21
+ const { code, map, css } = compile(source, resourcePath, this.getOptions?.());
20
22
 
21
23
  let output = code;
22
24
  /** @type {typeof map | null} */
package/types/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Compiler, RspackPluginInstance } from '@rspack/core';
2
+ import type { RuntimeImportMode } from '@tsrx/vue';
2
3
 
3
4
  export interface TsrxVueRspackVaporOptions {
4
5
  macros?: boolean | object;
@@ -9,11 +10,14 @@ export interface TsrxVueRspackVaporOptions {
9
10
 
10
11
  export interface TsrxVueRspackPluginOptions {
11
12
  vapor?: TsrxVueRspackVaporOptions;
13
+ /** Direct mode requires `@tsrx/vue-runtime` as a direct production dependency. */
14
+ runtimeImports?: RuntimeImportMode;
12
15
  }
13
16
 
14
17
  export declare class TsrxVueRspackPlugin implements RspackPluginInstance {
15
18
  constructor(options?: TsrxVueRspackPluginOptions);
16
- options: TsrxVueRspackPluginOptions;
19
+ options: Pick<TsrxVueRspackPluginOptions, 'vapor'> &
20
+ Required<Pick<TsrxVueRspackPluginOptions, 'runtimeImports'>>;
17
21
  apply(compiler: Compiler): void;
18
22
  }
19
23