@rsbuild/plugin-solid 0.0.0-next-20231207110454

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-present Bytedance, Inc. and its affiliates.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,19 @@
1
+ <p align="center">
2
+ <a href="https://rsbuild.dev" target="blank"><img src="https://github.com/web-infra-dev/rsbuild/assets/7237365/84abc13e-b620-468f-a90b-dbf28e7e9427" alt="Rsbuild Logo" /></a>
3
+ </p>
4
+
5
+ # Rsbuild
6
+
7
+ Unleash the power of Rspack with the out-of-the-box build tool.
8
+
9
+ ## Documentation
10
+
11
+ https://rsbuild.dev/
12
+
13
+ ## Contributing
14
+
15
+ Please read the [Contributing Guide](https://github.com/web-infra-dev/rsbuild/blob/main/CONTRIBUTING.md).
16
+
17
+ ## License
18
+
19
+ Rsbuild is [MIT licensed](https://github.com/web-infra-dev/rsbuild/blob/main/LICENSE).
@@ -0,0 +1,77 @@
1
+ import { RsbuildPlugin } from '@rsbuild/core';
2
+
3
+ /**
4
+ * babel-preset-solid options
5
+ *
6
+ * https://github.com/solidjs/solid/blob/main/packages/babel-preset-solid/index.js
7
+ *
8
+ * https://github.com/ryansolid/dom-expressions/blob/main/packages/babel-plugin-jsx-dom-expressions/README.md
9
+ */
10
+ type SolidPresetOptions = {
11
+ /**
12
+ * The name of the runtime module to import the methods from.
13
+ */
14
+ moduleName?: string;
15
+ /**
16
+ * The output mode of the compiler. Can be "dom"(default), "ssr". "dom" is standard output. "ssr" is for server side rendering of strings.
17
+ * @default 'dom'
18
+ */
19
+ generate?: 'dom' | 'ssr';
20
+ /**
21
+ * Indicate whether the output should contain hydratable markers.
22
+ * @default false
23
+ */
24
+ hydratable?: boolean;
25
+ /**
26
+ * Boolean to indicate whether to enable automatic event delegation on camelCase.
27
+ * @default true
28
+ */
29
+ delegateEvents: boolean;
30
+ /**
31
+ * Boolean indicates whether smart conditional detection should be used. This optimizes simple boolean expressions and ternaries in JSX.
32
+ * @default true
33
+ */
34
+ wrapConditionals?: boolean;
35
+ /**
36
+ * Boolean indicates whether to set current render context on Custom Elements and slots. Useful for seemless Context API with Web Components.
37
+ * @default false
38
+ */
39
+ contextToCustomElements?: boolean;
40
+ /**
41
+ * 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.
42
+ * @default string[]
43
+ */
44
+ builtIns?: string[];
45
+ /**
46
+ * This plugin leverages a heuristic for reactive wrapping and lazy evaluation of JSX expressions.
47
+ * @default 'effect'
48
+ */
49
+ effectWrapper?: string;
50
+ /**
51
+ * Comment decorator string indicates the static expression, used to tell the compiler not to wrap them by effect function
52
+ * @default '@once'
53
+ */
54
+ staticMarker?: string;
55
+ /**
56
+ * Memos let you efficiently use a derived value in many reactive computations. This option indicates the memo function name
57
+ * @default 'memo'
58
+ */
59
+ memoWrapper?: string;
60
+ /**
61
+ * Checks for properly formed HTML by checking for elements that would not be allowed in certain parent elements.
62
+ * @default true
63
+ */
64
+ validate?: boolean;
65
+ /**
66
+ * Removes unnecessary closing tags from the template output.
67
+ * @default true
68
+ */
69
+ omitNestedClosingTags?: boolean;
70
+ };
71
+
72
+ type PluginSolidPresetOptions = {
73
+ solidPresetOptions?: SolidPresetOptions;
74
+ };
75
+ declare function pluginSolid(options?: PluginSolidPresetOptions): RsbuildPlugin;
76
+
77
+ export { PluginSolidPresetOptions, pluginSolid };
package/dist/index.js ADDED
@@ -0,0 +1,74 @@
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
+ pluginSolid: () => pluginSolid
34
+ });
35
+ module.exports = __toCommonJS(src_exports);
36
+ function pluginSolid(options = {}) {
37
+ return {
38
+ name: "rsbuild:solid",
39
+ pre: ["rsbuild:babel"],
40
+ setup(api) {
41
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd }) => {
42
+ [CHAIN_ID.RULE.JS, CHAIN_ID.RULE.JS_DATA_URI].forEach((ruleId) => {
43
+ if (chain.module.rules.has(ruleId)) {
44
+ const rsbuildConfig = api.getNormalizedConfig();
45
+ const rule = chain.module.rule(ruleId);
46
+ if (rule.uses.has(CHAIN_ID.USE.BABEL)) {
47
+ rule.use(CHAIN_ID.USE.BABEL).tap((babelConfig) => {
48
+ babelConfig.presets ?? (babelConfig.presets = []);
49
+ babelConfig.presets.push([
50
+ require.resolve("babel-preset-solid"),
51
+ options.solidPresetOptions || {}
52
+ ]);
53
+ if (!isProd && rsbuildConfig.dev.hmr) {
54
+ babelConfig.plugins ?? (babelConfig.plugins = []);
55
+ babelConfig.plugins.push([
56
+ require.resolve("solid-refresh/babel")
57
+ ]);
58
+ chain.resolve.alias.merge({
59
+ "solid-refresh": require.resolve("solid-refresh/dist/solid-refresh.mjs")
60
+ });
61
+ }
62
+ return babelConfig;
63
+ });
64
+ }
65
+ }
66
+ });
67
+ });
68
+ }
69
+ };
70
+ }
71
+ // Annotate the CommonJS export names for ESM import in node:
72
+ 0 && (module.exports = {
73
+ pluginSolid
74
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,57 @@
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.41.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/requireShims.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"],
22
+ setup(api) {
23
+ api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd }) => {
24
+ [CHAIN_ID.RULE.JS, CHAIN_ID.RULE.JS_DATA_URI].forEach((ruleId) => {
25
+ if (chain.module.rules.has(ruleId)) {
26
+ const rsbuildConfig = api.getNormalizedConfig();
27
+ const rule = chain.module.rule(ruleId);
28
+ if (rule.uses.has(CHAIN_ID.USE.BABEL)) {
29
+ rule.use(CHAIN_ID.USE.BABEL).tap((babelConfig) => {
30
+ babelConfig.presets ?? (babelConfig.presets = []);
31
+ babelConfig.presets.push([
32
+ __require.resolve("babel-preset-solid"),
33
+ options.solidPresetOptions || {}
34
+ ]);
35
+ if (!isProd && rsbuildConfig.dev.hmr) {
36
+ babelConfig.plugins ?? (babelConfig.plugins = []);
37
+ babelConfig.plugins.push([
38
+ __require.resolve("solid-refresh/babel")
39
+ ]);
40
+ chain.resolve.alias.merge({
41
+ "solid-refresh": __require.resolve(
42
+ "solid-refresh/dist/solid-refresh.mjs"
43
+ )
44
+ });
45
+ }
46
+ return babelConfig;
47
+ });
48
+ }
49
+ }
50
+ });
51
+ });
52
+ }
53
+ };
54
+ }
55
+ export {
56
+ pluginSolid
57
+ };
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@rsbuild/plugin-solid",
3
+ "version": "0.0.0-next-20231207110454",
4
+ "description": "Solid plugin for Rsbuild",
5
+ "homepage": "https://rsbuild.dev",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/web-infra-dev/rsbuild",
9
+ "directory": "packages/plugin-solid"
10
+ },
11
+ "license": "MIT",
12
+ "type": "commonjs",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.mjs",
17
+ "default": "./dist/index.js"
18
+ }
19
+ },
20
+ "main": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
22
+ "files": [
23
+ "dist"
24
+ ],
25
+ "dependencies": {
26
+ "babel-preset-solid": "^1.8.6",
27
+ "solid-refresh": "^0.6.0",
28
+ "@rsbuild/shared": "0.0.0-next-20231207110454"
29
+ },
30
+ "devDependencies": {
31
+ "@types/babel__core": "^7.20.3",
32
+ "typescript": "^5.3.0",
33
+ "@rsbuild/core": "0.0.0-next-20231207110454",
34
+ "@rsbuild/plugin-babel": "0.0.0-next-20231207110454",
35
+ "@rsbuild/test-helper": "0.0.0-next-20231207110454",
36
+ "@rsbuild/webpack": "0.0.0-next-20231207110454"
37
+ },
38
+ "peerDependencies": {
39
+ "@rsbuild/core": "0.0.0-next-20231207110454"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public",
43
+ "provenance": true,
44
+ "registry": "https://registry.npmjs.org/"
45
+ },
46
+ "scripts": {
47
+ "build": "modern build",
48
+ "dev": "modern build --watch"
49
+ }
50
+ }