@rsbuild/plugin-solid 1.0.0 → 1.0.1-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/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.cjs ADDED
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ PLUGIN_SOLID_NAME: () => PLUGIN_SOLID_NAME,
34
+ pluginSolid: () => pluginSolid
35
+ });
36
+ module.exports = __toCommonJS(src_exports);
37
+ var import_plugin_babel = require("@rsbuild/plugin-babel");
38
+ var PLUGIN_SOLID_NAME = "rsbuild:solid";
39
+ function pluginSolid(options = {}) {
40
+ return {
41
+ name: PLUGIN_SOLID_NAME,
42
+ setup(api) {
43
+ api.modifyBundlerChain(
44
+ async (chain, { CHAIN_ID, environment, isProd, target }) => {
45
+ const environmentConfig = environment.config;
46
+ (0, import_plugin_babel.modifyBabelLoaderOptions)({
47
+ chain,
48
+ CHAIN_ID,
49
+ modifier: (babelOptions) => {
50
+ babelOptions.presets = [
51
+ [
52
+ require.resolve("babel-preset-solid"),
53
+ options.solidPresetOptions || {}
54
+ ]
55
+ ];
56
+ babelOptions.parserOpts = { plugins: ["jsx", "typescript"] };
57
+ const usingHMR = !isProd && environmentConfig.dev.hmr && target === "web";
58
+ if (usingHMR) {
59
+ babelOptions.plugins ??= [];
60
+ babelOptions.plugins.push([
61
+ require.resolve("solid-refresh/babel")
62
+ ]);
63
+ chain.resolve.alias.merge({
64
+ "solid-refresh": require.resolve("solid-refresh/dist/solid-refresh.mjs")
65
+ });
66
+ }
67
+ return babelOptions;
68
+ }
69
+ });
70
+ }
71
+ );
72
+ }
73
+ };
74
+ }
75
+ // Annotate the CommonJS export names for ESM import in node:
76
+ 0 && (module.exports = {
77
+ PLUGIN_SOLID_NAME,
78
+ pluginSolid
79
+ });
package/dist/index.d.ts CHANGED
@@ -1,8 +1,11 @@
1
- import { RsbuildPlugin } from '@rsbuild/core';
2
-
3
- type PluginSolidPresetOptions = {
4
- solidPresetOptions?: any;
1
+ import type { RsbuildPlugin } from '@rsbuild/core';
2
+ import type { SolidPresetOptions } from './types';
3
+ export type PluginSolidOptions = {
4
+ /**
5
+ * Options passed to `babel-preset-solid`.
6
+ * @see https://www.npmjs.com/package/babel-preset-solid
7
+ */
8
+ solidPresetOptions?: SolidPresetOptions;
5
9
  };
6
- declare function pluginSolid(options?: PluginSolidPresetOptions): RsbuildPlugin;
7
-
8
- export { PluginSolidPresetOptions, pluginSolid };
10
+ export declare const PLUGIN_SOLID_NAME = "rsbuild:solid";
11
+ export declare function pluginSolid(options?: PluginSolidOptions): RsbuildPlugin;
package/dist/index.js CHANGED
@@ -1,65 +1,60 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ import { createRequire } from 'module';
2
+ var require = createRequire(import.meta['url']);
29
3
 
30
- // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
33
- pluginSolid: () => pluginSolid
4
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
5
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
6
+ }) : x)(function(x) {
7
+ if (typeof require !== "undefined")
8
+ return require.apply(this, arguments);
9
+ throw Error('Dynamic require of "' + x + '" is not supported');
34
10
  });
35
- module.exports = __toCommonJS(src_exports);
11
+
12
+ // ../../node_modules/.pnpm/@modern-js+module-tools@2.54.6_eslint@9.6.0_typescript@5.5.2/node_modules/@modern-js/module-tools/shims/esm.js
13
+ import { fileURLToPath } from "url";
14
+ import path from "path";
15
+
16
+ // src/index.ts
17
+ import { modifyBabelLoaderOptions } from "@rsbuild/plugin-babel";
18
+ var PLUGIN_SOLID_NAME = "rsbuild:solid";
36
19
  function pluginSolid(options = {}) {
37
20
  return {
38
- name: "rsbuild:solid",
39
- pre: ["rsbuild:babel", "rsbuild-webpack:babel"],
21
+ name: PLUGIN_SOLID_NAME,
40
22
  setup(api) {
41
- api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
42
- [CHAIN_ID.RULE.JS, CHAIN_ID.RULE.JS_DATA_URI].forEach((ruleId) => {
43
- if (chain.module.rules.has(ruleId)) {
44
- const rule = chain.module.rule(ruleId);
45
- if (rule.uses.has(CHAIN_ID.USE.BABEL)) {
46
- rule.use(CHAIN_ID.USE.BABEL).tap((babelConfig) => {
47
- var _a;
48
- (_a = babelConfig.presets) != null ? _a : babelConfig.presets = [];
49
- babelConfig.presets.push([
50
- require.resolve("babel-preset-solid"),
23
+ api.modifyBundlerChain(
24
+ async (chain, { CHAIN_ID, environment, isProd, target }) => {
25
+ const environmentConfig = environment.config;
26
+ modifyBabelLoaderOptions({
27
+ chain,
28
+ CHAIN_ID,
29
+ modifier: (babelOptions) => {
30
+ babelOptions.presets = [
31
+ [
32
+ __require.resolve("babel-preset-solid"),
51
33
  options.solidPresetOptions || {}
34
+ ]
35
+ ];
36
+ babelOptions.parserOpts = { plugins: ["jsx", "typescript"] };
37
+ const usingHMR = !isProd && environmentConfig.dev.hmr && target === "web";
38
+ if (usingHMR) {
39
+ babelOptions.plugins ??= [];
40
+ babelOptions.plugins.push([
41
+ __require.resolve("solid-refresh/babel")
52
42
  ]);
53
- return babelConfig;
54
- });
43
+ chain.resolve.alias.merge({
44
+ "solid-refresh": __require.resolve(
45
+ "solid-refresh/dist/solid-refresh.mjs"
46
+ )
47
+ });
48
+ }
49
+ return babelOptions;
55
50
  }
56
- }
57
- });
58
- });
51
+ });
52
+ }
53
+ );
59
54
  }
60
55
  };
61
56
  }
62
- // Annotate the CommonJS export names for ESM import in node:
63
- 0 && (module.exports = {
57
+ export {
58
+ PLUGIN_SOLID_NAME,
64
59
  pluginSolid
65
- });
60
+ };
@@ -0,0 +1,68 @@
1
+ /**
2
+ * babel-preset-solid options
3
+ *
4
+ * https://github.com/solidjs/solid/blob/main/packages/babel-preset-solid/index.js
5
+ *
6
+ * https://github.com/ryansolid/dom-expressions/blob/main/packages/babel-plugin-jsx-dom-expressions/README.md
7
+ */
8
+ export type SolidPresetOptions = {
9
+ /**
10
+ * The name of the runtime module to import the methods from.
11
+ */
12
+ moduleName?: string;
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'
16
+ */
17
+ generate?: 'dom' | 'ssr';
18
+ /**
19
+ * Indicate whether the output should contain hydratable markers.
20
+ * @default false
21
+ */
22
+ hydratable?: boolean;
23
+ /**
24
+ * Boolean to indicate whether to enable automatic event delegation on camelCase.
25
+ * @default true
26
+ */
27
+ delegateEvents?: boolean;
28
+ /**
29
+ * Boolean indicates whether smart conditional detection should be used. This optimizes simple boolean expressions and ternaries in JSX.
30
+ * @default true
31
+ */
32
+ wrapConditionals?: boolean;
33
+ /**
34
+ * Boolean indicates whether to set current render context on Custom Elements and slots. Useful for seamless Context API with Web Components.
35
+ * @default false
36
+ */
37
+ contextToCustomElements?: boolean;
38
+ /**
39
+ * Array of Component exports from module, that aren't included by default with the library. This plugin will automatically import them if it comes across them in the JSX.
40
+ * @default string[]
41
+ */
42
+ builtIns?: string[];
43
+ /**
44
+ * This plugin leverages a heuristic for reactive wrapping and lazy evaluation of JSX expressions.
45
+ * @default 'effect'
46
+ */
47
+ effectWrapper?: string;
48
+ /**
49
+ * Comment decorator string indicates the static expression, used to tell the compiler not to wrap them by effect function
50
+ * @default '@once'
51
+ */
52
+ staticMarker?: string;
53
+ /**
54
+ * Memos let you efficiently use a derived value in many reactive computations. This option indicates the memo function name
55
+ * @default 'memo'
56
+ */
57
+ memoWrapper?: string;
58
+ /**
59
+ * Checks for properly formed HTML by checking for elements that would not be allowed in certain parent elements.
60
+ * @default true
61
+ */
62
+ validate?: boolean;
63
+ /**
64
+ * Removes unnecessary closing tags from the template output.
65
+ * @default true
66
+ */
67
+ omitNestedClosingTags?: boolean;
68
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-solid",
3
- "version": "1.0.0",
3
+ "version": "1.0.1-beta.0",
4
4
  "description": "Solid plugin for Rsbuild",
5
5
  "homepage": "https://rsbuild.dev",
6
6
  "repository": {
@@ -9,31 +9,32 @@
9
9
  "directory": "packages/plugin-solid"
10
10
  },
11
11
  "license": "MIT",
12
+ "type": "module",
12
13
  "exports": {
13
14
  ".": {
14
15
  "types": "./dist/index.d.ts",
15
- "import": "./dist/index.mjs",
16
- "default": "./dist/index.js"
16
+ "import": "./dist/index.js",
17
+ "require": "./dist/index.cjs"
17
18
  }
18
19
  },
19
- "main": "./dist/index.js",
20
+ "main": "./dist/index.cjs",
20
21
  "types": "./dist/index.d.ts",
21
22
  "files": [
22
23
  "dist"
23
24
  ],
24
25
  "dependencies": {
25
- "babel-preset-solid": "^1.8.4"
26
+ "babel-preset-solid": "^1.8.18",
27
+ "solid-refresh": "0.6.3",
28
+ "@rsbuild/plugin-babel": "1.0.1-beta.0"
26
29
  },
27
30
  "devDependencies": {
28
- "@babel/core": "^7.23.2",
29
- "typescript": "^5.3.0",
30
- "@rsbuild/plugin-babel": "1.0.0",
31
- "@rsbuild/core": "1.0.0",
32
- "@rsbuild/test-helper": "1.0.0",
33
- "@rsbuild/webpack": "1.0.0"
31
+ "@types/babel__core": "^7.20.5",
32
+ "typescript": "^5.5.2",
33
+ "@rsbuild/core": "1.0.1-beta.0",
34
+ "@scripts/test-helper": "1.0.1-beta.0"
34
35
  },
35
36
  "peerDependencies": {
36
- "@rsbuild/core": "^1.0.0"
37
+ "@rsbuild/core": "^1.0.1-beta.0"
37
38
  },
38
39
  "publishConfig": {
39
40
  "access": "public",
package/dist/index.mjs DELETED
@@ -1,45 +0,0 @@
1
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined")
5
- return require.apply(this, arguments);
6
- throw Error('Dynamic require of "' + x + '" is not supported');
7
- });
8
-
9
- // ../../node_modules/.pnpm/@modern-js+module-tools@2.40.0_typescript@5.3.2/node_modules/@modern-js/module-tools/shims/esm.js
10
- import { fileURLToPath } from "url";
11
- import path from "path";
12
-
13
- // ../../scripts/require_shims.js
14
- import { createRequire } from "module";
15
- global.require = createRequire(import.meta.url);
16
-
17
- // src/index.ts
18
- function pluginSolid(options = {}) {
19
- return {
20
- name: "rsbuild:solid",
21
- pre: ["rsbuild:babel", "rsbuild-webpack:babel"],
22
- setup(api) {
23
- api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
24
- [CHAIN_ID.RULE.JS, CHAIN_ID.RULE.JS_DATA_URI].forEach((ruleId) => {
25
- if (chain.module.rules.has(ruleId)) {
26
- const rule = chain.module.rule(ruleId);
27
- if (rule.uses.has(CHAIN_ID.USE.BABEL)) {
28
- rule.use(CHAIN_ID.USE.BABEL).tap((babelConfig) => {
29
- babelConfig.presets ?? (babelConfig.presets = []);
30
- babelConfig.presets.push([
31
- __require.resolve("babel-preset-solid"),
32
- options.solidPresetOptions || {}
33
- ]);
34
- return babelConfig;
35
- });
36
- }
37
- }
38
- });
39
- });
40
- }
41
- };
42
- }
43
- export {
44
- pluginSolid
45
- };