@rsbuild/plugin-solid 2.0.0-alpha.3 → 2.0.0-beta.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/dist/index.cjs CHANGED
@@ -20,10 +20,24 @@ __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_expo
20
20
  });
21
21
  const external_node_module_namespaceObject = require("node:module"), plugin_babel_namespaceObject = require("@rsbuild/plugin-babel"), src_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), PLUGIN_SOLID_NAME = 'rsbuild:solid';
22
22
  function pluginSolid(options = {}) {
23
+ let { dev, solid, solidPresetOptions, ssr } = options;
23
24
  return {
24
25
  name: PLUGIN_SOLID_NAME,
25
26
  setup (api) {
26
- api.modifyBundlerChain((chain, { CHAIN_ID, environment, isProd, target })=>{
27
+ api.modifyEnvironmentConfig((config)=>{
28
+ let conditionNames = config.resolve.conditionNames ?? [
29
+ '...'
30
+ ], useDevRuntime = dev ?? 'development' === config.mode;
31
+ config.resolve.conditionNames = [
32
+ ...new Set([
33
+ 'solid',
34
+ ...useDevRuntime ? [
35
+ 'development'
36
+ ] : [],
37
+ ...conditionNames
38
+ ])
39
+ ];
40
+ }), api.modifyBundlerChain((chain, { CHAIN_ID, environment, isProd, target })=>{
27
41
  let environmentConfig = environment.config;
28
42
  (0, plugin_babel_namespaceObject.modifyBabelLoaderOptions)({
29
43
  chain,
@@ -31,15 +45,28 @@ function pluginSolid(options = {}) {
31
45
  modifier: (babelOptions)=>(babelOptions.presets = [
32
46
  [
33
47
  src_require.resolve('babel-preset-solid'),
34
- options.solidPresetOptions || {}
48
+ {
49
+ ...ssr ? 'node' === target ? {
50
+ generate: 'ssr',
51
+ hydratable: !0
52
+ } : {
53
+ generate: 'dom',
54
+ hydratable: !0
55
+ } : {},
56
+ ...solidPresetOptions,
57
+ ...solid
58
+ }
35
59
  ]
36
60
  ], babelOptions.parserOpts = {
37
61
  plugins: [
38
62
  'jsx',
39
63
  "typescript"
40
64
  ]
41
- }, !isProd && environmentConfig.dev.hmr && 'web' === target && (babelOptions.plugins ??= [], babelOptions.plugins.push([
42
- src_require.resolve('solid-refresh/babel')
65
+ }, options.refresh?.disabled !== !0 && !isProd && environmentConfig.dev.hmr && 'web' === target && (babelOptions.plugins ??= [], babelOptions.plugins.push([
66
+ src_require.resolve('solid-refresh/babel'),
67
+ {
68
+ bundler: 'rspack-esm'
69
+ }
43
70
  ]), chain.resolve.alias.set('solid-refresh', src_require.resolve('solid-refresh/dist/solid-refresh.mjs'))), babelOptions)
44
71
  });
45
72
  });
package/dist/index.d.ts CHANGED
@@ -1,10 +1,36 @@
1
1
  import type { RsbuildPlugin } from '@rsbuild/core';
2
2
  import type { SolidPresetOptions } from './types.js';
3
3
  export type PluginSolidOptions = {
4
+ /**
5
+ * Whether to resolve Solid's development runtime.
6
+ * @default `true` in development mode, `false` in production mode
7
+ */
8
+ dev?: boolean;
9
+ /**
10
+ * Whether to generate output for Solid SSR.
11
+ * @default false
12
+ */
13
+ ssr?: boolean;
14
+ /**
15
+ * Configure Solid Refresh for HMR in development mode.
16
+ */
17
+ refresh?: {
18
+ /**
19
+ * Whether to disable Solid Refresh while keeping Rsbuild HMR enabled.
20
+ * @default false
21
+ */
22
+ disabled?: boolean;
23
+ };
4
24
  /**
5
25
  * Options passed to `babel-preset-solid`.
6
26
  * @see https://npmjs.com/package/babel-preset-solid
7
27
  */
28
+ solid?: SolidPresetOptions;
29
+ /**
30
+ * Options passed to `babel-preset-solid`.
31
+ * If both `solid` and `solidPresetOptions` are set, `solid` takes precedence.
32
+ * @deprecated Use `solid` instead.
33
+ */
8
34
  solidPresetOptions?: SolidPresetOptions;
9
35
  };
10
36
  export declare const PLUGIN_SOLID_NAME = "rsbuild:solid";
package/dist/index.js CHANGED
@@ -2,10 +2,24 @@ import { createRequire } from "node:module";
2
2
  import { modifyBabelLoaderOptions } from "@rsbuild/plugin-babel";
3
3
  let src_require = createRequire(import.meta.url), PLUGIN_SOLID_NAME = 'rsbuild:solid';
4
4
  function pluginSolid(options = {}) {
5
+ let { dev, solid, solidPresetOptions, ssr } = options;
5
6
  return {
6
7
  name: PLUGIN_SOLID_NAME,
7
8
  setup (api) {
8
- api.modifyBundlerChain((chain, { CHAIN_ID, environment, isProd, target })=>{
9
+ api.modifyEnvironmentConfig((config)=>{
10
+ let conditionNames = config.resolve.conditionNames ?? [
11
+ '...'
12
+ ], useDevRuntime = dev ?? 'development' === config.mode;
13
+ config.resolve.conditionNames = [
14
+ ...new Set([
15
+ 'solid',
16
+ ...useDevRuntime ? [
17
+ 'development'
18
+ ] : [],
19
+ ...conditionNames
20
+ ])
21
+ ];
22
+ }), api.modifyBundlerChain((chain, { CHAIN_ID, environment, isProd, target })=>{
9
23
  let environmentConfig = environment.config;
10
24
  modifyBabelLoaderOptions({
11
25
  chain,
@@ -13,15 +27,28 @@ function pluginSolid(options = {}) {
13
27
  modifier: (babelOptions)=>(babelOptions.presets = [
14
28
  [
15
29
  src_require.resolve('babel-preset-solid'),
16
- options.solidPresetOptions || {}
30
+ {
31
+ ...ssr ? 'node' === target ? {
32
+ generate: 'ssr',
33
+ hydratable: !0
34
+ } : {
35
+ generate: 'dom',
36
+ hydratable: !0
37
+ } : {},
38
+ ...solidPresetOptions,
39
+ ...solid
40
+ }
17
41
  ]
18
42
  ], babelOptions.parserOpts = {
19
43
  plugins: [
20
44
  'jsx',
21
45
  "typescript"
22
46
  ]
23
- }, !isProd && environmentConfig.dev.hmr && 'web' === target && (babelOptions.plugins ??= [], babelOptions.plugins.push([
24
- src_require.resolve('solid-refresh/babel')
47
+ }, options.refresh?.disabled !== !0 && !isProd && environmentConfig.dev.hmr && 'web' === target && (babelOptions.plugins ??= [], babelOptions.plugins.push([
48
+ src_require.resolve('solid-refresh/babel'),
49
+ {
50
+ bundler: 'rspack-esm'
51
+ }
25
52
  ]), chain.resolve.alias.set('solid-refresh', src_require.resolve('solid-refresh/dist/solid-refresh.mjs'))), babelOptions)
26
53
  });
27
54
  });
package/dist/types.d.ts CHANGED
@@ -11,10 +11,15 @@ export type SolidPresetOptions = {
11
11
  */
12
12
  moduleName?: string;
13
13
  /**
14
- * The output mode of the compiler. Can be "dom"(default), "ssr". "dom" is standard output. "ssr" is for server side rendering of strings.
15
- * @default 'dom'
14
+ * The output mode of the compiler.
15
+ * Can be:
16
+ * - "dom" is standard output
17
+ * - "ssr" is for server side rendering of strings.
18
+ * - "universal" is for using custom renderers from solid-js/universal
19
+ *
20
+ * @default "dom"
16
21
  */
17
- generate?: 'dom' | 'ssr';
22
+ generate?: 'ssr' | 'dom' | 'universal';
18
23
  /**
19
24
  * Indicate whether the output should contain hydratable markers.
20
25
  * @default false
@@ -61,8 +66,24 @@ export type SolidPresetOptions = {
61
66
  */
62
67
  validate?: boolean;
63
68
  /**
64
- * Removes unnecessary closing tags from the template output.
65
- * @default true
69
+ * Remove unnecessary closing tags from template strings. More info here:
70
+ * https://github.com/solidjs/solid/blob/main/CHANGELOG.md#smaller-templates
71
+ *
72
+ * @default false
66
73
  */
67
74
  omitNestedClosingTags?: boolean;
75
+ /**
76
+ * Remove the last closing tag from template strings. Enabled by default even when `omitNestedClosingTags` is disabled.
77
+ * Can be disabled for compatibility for some browser-like environments.
78
+ *
79
+ * @default true
80
+ */
81
+ omitLastClosingTag?: boolean;
82
+ /**
83
+ * Remove unnecessary quotes from template strings.
84
+ * Can be disabled for compatibility for some browser-like environments.
85
+ *
86
+ * @default true
87
+ */
88
+ omitQuotes?: boolean;
68
89
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-solid",
3
- "version": "2.0.0-alpha.3",
3
+ "version": "2.0.0-beta.0",
4
4
  "description": "Solid plugin for Rsbuild",
5
5
  "homepage": "https://rsbuild.rs",
6
6
  "repository": {
@@ -17,33 +17,38 @@
17
17
  "require": "./dist/index.cjs"
18
18
  }
19
19
  },
20
- "main": "./dist/index.cjs",
21
20
  "types": "./dist/index.d.ts",
22
21
  "files": [
23
22
  "dist"
24
23
  ],
25
24
  "dependencies": {
26
- "@rsbuild/plugin-babel": "^2.0.0-0",
27
- "babel-preset-solid": "^1.9.10",
28
- "solid-refresh": "0.6.3"
25
+ "babel-preset-solid": ">=2.0.0-beta.0 <2.0.0-experimental.0",
26
+ "solid-refresh": ">=0.8.0-next.7 < 0.8.0",
27
+ "@rsbuild/plugin-babel": "1.1.2"
29
28
  },
30
29
  "devDependencies": {
31
- "@rslib/core": "0.19.3",
30
+ "@rslib/core": "0.21.3",
32
31
  "@types/babel__core": "^7.20.5",
33
- "typescript": "^5.9.3",
34
- "@rsbuild/core": "2.0.0-alpha.3",
35
- "@scripts/test-helper": "1.0.1"
32
+ "typescript": "^6.0.3",
33
+ "@scripts/test-helper": "1.0.0",
34
+ "@rsbuild/core": "2.0.3"
36
35
  },
37
36
  "peerDependencies": {
38
- "@rsbuild/core": "^2.0.0-0"
37
+ "@rsbuild/core": "^1.0.0 || ^2.0.0-0",
38
+ "@solidjs/web": ">=2.0.0-beta.0 <2.0.0-experimental.0",
39
+ "solid-js": ">=2.0.0-beta.0 <2.0.0-experimental.0"
40
+ },
41
+ "peerDependenciesMeta": {
42
+ "@rsbuild/core": {
43
+ "optional": true
44
+ }
39
45
  },
40
46
  "publishConfig": {
41
47
  "access": "public",
42
48
  "registry": "https://registry.npmjs.org/"
43
49
  },
44
50
  "scripts": {
45
- "build": "rslib build",
46
- "dev": "rslib build -w",
47
- "bump": "pnpx bumpp --no-tag"
51
+ "build": "rslib",
52
+ "dev": "rslib -w"
48
53
  }
49
54
  }