@rsbuild/plugin-svelte 0.2.17 → 0.3.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.
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # Rsbuild
6
6
 
7
- Unleash the power of Rspack with the out-of-the-box build tool.
7
+ The Rspack-based build tool. It's fast, out-of-the-box and extensible.
8
8
 
9
9
  ## Documentation
10
10
 
package/dist/index.d.ts CHANGED
@@ -1,13 +1,35 @@
1
1
  import { RsbuildPlugin } from '@rsbuild/core';
2
+ import { CompileOptions } from 'svelte/compiler';
3
+ import { AutoPreprocessOptions } from 'svelte-preprocess/dist/types';
4
+ export { AutoPreprocessOptions, Transformer } from 'svelte-preprocess/dist/types';
2
5
 
6
+ interface SvelteLoaderOptions {
7
+ compilerOptions?: Omit<CompileOptions, 'filename' | 'format' | 'generate'>;
8
+ /**
9
+ * Extra HMR options, the defaults are completely fine\
10
+ * You can safely omit hotOptions altogether
11
+ */
12
+ hotOptions?: {
13
+ /** Preserve local component state */
14
+ preserveLocalState?: boolean;
15
+ [key: string]: any;
16
+ };
17
+ [key: string]: any;
18
+ }
3
19
  type PluginSvelteOptions = {
4
20
  /**
5
21
  * The options of svelte-loader
6
22
  *
7
23
  * See https://github.com/sveltejs/svelte-loader
8
24
  */
9
- svelteLoaderOptions?: Record<string, any>;
25
+ svelteLoaderOptions?: SvelteLoaderOptions;
26
+ /**
27
+ * The options of svelte-preprocess
28
+ *
29
+ * See https://github.com/sveltejs/svelte-preprocess
30
+ */
31
+ preprocessOptions?: AutoPreprocessOptions;
10
32
  };
11
33
  declare function pluginSvelte(options?: PluginSvelteOptions): RsbuildPlugin;
12
34
 
13
- export { PluginSvelteOptions, pluginSvelte };
35
+ export { PluginSvelteOptions, SvelteLoaderOptions, pluginSvelte };
package/dist/index.js CHANGED
@@ -49,9 +49,9 @@ function pluginSvelte(options = {}) {
49
49
  );
50
50
  } catch (err) {
51
51
  import_core.logger.error(
52
- `Cannot resolve \`svelte\` package under the project directory, did you forget to install it?`
52
+ "Cannot resolve `svelte` package under the project directory, did you forget to install it?"
53
53
  );
54
- throw new Error(`Cannot resolve \`svelte\` package`, {
54
+ throw new Error("Cannot resolve `svelte` package", {
55
55
  cause: err
56
56
  });
57
57
  }
@@ -75,7 +75,7 @@ function pluginSvelte(options = {}) {
75
75
  compilerOptions: {
76
76
  dev: !isProd
77
77
  },
78
- preprocess: sveltePreprocess(),
78
+ preprocess: sveltePreprocess(options.preprocessOptions),
79
79
  emitCss: !rsbuildConfig.output.injectStyles,
80
80
  hotReload: !isProd && rsbuildConfig.dev.hmr
81
81
  },
package/dist/index.mjs CHANGED
@@ -31,9 +31,9 @@ function pluginSvelte(options = {}) {
31
31
  );
32
32
  } catch (err) {
33
33
  logger.error(
34
- `Cannot resolve \`svelte\` package under the project directory, did you forget to install it?`
34
+ "Cannot resolve `svelte` package under the project directory, did you forget to install it?"
35
35
  );
36
- throw new Error(`Cannot resolve \`svelte\` package`, {
36
+ throw new Error("Cannot resolve `svelte` package", {
37
37
  cause: err
38
38
  });
39
39
  }
@@ -57,7 +57,7 @@ function pluginSvelte(options = {}) {
57
57
  compilerOptions: {
58
58
  dev: !isProd
59
59
  },
60
- preprocess: sveltePreprocess(),
60
+ preprocess: sveltePreprocess(options.preprocessOptions),
61
61
  emitCss: !rsbuildConfig.output.injectStyles,
62
62
  hotReload: !isProd && rsbuildConfig.dev.hmr
63
63
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-svelte",
3
- "version": "0.2.17",
3
+ "version": "0.3.0",
4
4
  "description": "Svelte plugin for Rsbuild",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,13 +24,14 @@
24
24
  "dependencies": {
25
25
  "svelte-loader": "3.1.9",
26
26
  "svelte-preprocess": "^5.0.4",
27
- "@rsbuild/shared": "0.2.17"
27
+ "@rsbuild/shared": "0.3.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@types/node": "16.x",
31
+ "svelte": "^4.2.2",
31
32
  "typescript": "^5.3.0",
32
- "@rsbuild/core": "0.2.17",
33
- "@rsbuild/test-helper": "0.2.17"
33
+ "@rsbuild/core": "0.3.0",
34
+ "@rsbuild/test-helper": "0.3.0"
34
35
  },
35
36
  "publishConfig": {
36
37
  "access": "public",