@hyperpackai/plugin-react 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 HyperPack contributors
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.
@@ -0,0 +1,23 @@
1
+ import type { HyperPackPlugin } from "@hyperpackai/core";
2
+ export interface ReactPluginOptions {
3
+ /**
4
+ * Babel/esbuild target for JSX.
5
+ * @default "react-jsx" (React 17+ automatic runtime)
6
+ */
7
+ runtime?: "classic" | "automatic";
8
+ /**
9
+ * Enable React Fast Refresh in development.
10
+ * Automatically disabled when react-refresh is not installed.
11
+ * @default true
12
+ */
13
+ fastRefresh?: boolean;
14
+ }
15
+ /**
16
+ * HyperPack plugin for React applications.
17
+ *
18
+ * - Enables React Fast Refresh when react-refresh is available
19
+ * - Configures JSX automatic runtime
20
+ * - Sets jsxImportSource for automatic React import
21
+ */
22
+ export declare function reactPlugin(options?: ReactPluginOptions): HyperPackPlugin;
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,OAAO,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IAElC;;;;OAIG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,OAAO,GAAE,kBAAuB,GAAG,eAAe,CAuC7E"}
package/dist/index.js ADDED
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @hyperpackai/plugin-react
3
+ *
4
+ * Opt-in React integration for HyperPack.
5
+ * Adds React Fast Refresh HMR when react-refresh is installed.
6
+ *
7
+ * Usage in hyperpack.config.ts:
8
+ *
9
+ * import { reactPlugin } from "@hyperpackai/plugin-react";
10
+ *
11
+ * export default {
12
+ * plugins: [reactPlugin()]
13
+ * };
14
+ *
15
+ * Requires react-refresh in your project's devDependencies:
16
+ * npm install -D react-refresh
17
+ */
18
+ import { createRequire } from "node:module";
19
+ import path from "node:path";
20
+ /**
21
+ * HyperPack plugin for React applications.
22
+ *
23
+ * - Enables React Fast Refresh when react-refresh is available
24
+ * - Configures JSX automatic runtime
25
+ * - Sets jsxImportSource for automatic React import
26
+ */
27
+ export function reactPlugin(options = {}) {
28
+ const { runtime = "automatic", fastRefresh = true } = options;
29
+ return {
30
+ name: "@hyperpackai/plugin-react",
31
+ config(config) {
32
+ // Ensure React JSX automatic runtime is configured
33
+ return {
34
+ ...config,
35
+ jsxImportSource: runtime === "automatic" ? "react" : undefined
36
+ };
37
+ },
38
+ buildStart() {
39
+ // Validate react is installed
40
+ try {
41
+ const req = createRequire(path.join(process.cwd(), "package.json"));
42
+ req.resolve("react");
43
+ }
44
+ catch {
45
+ console.warn("[plugin-react] React is not installed. Add react and react-dom to your dependencies.");
46
+ }
47
+ // Validate react-refresh if fast refresh is enabled
48
+ if (fastRefresh) {
49
+ try {
50
+ const req = createRequire(path.join(process.cwd(), "package.json"));
51
+ req.resolve("react-refresh");
52
+ }
53
+ catch {
54
+ console.warn("[plugin-react] react-refresh is not installed. Fast Refresh disabled.\n" +
55
+ " Install it: npm install -D react-refresh");
56
+ }
57
+ }
58
+ }
59
+ };
60
+ }
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@hyperpackai/plugin-react",
3
+ "version": "0.1.0",
4
+ "description": "HyperPack plugin for React — Fast Refresh, JSX transform, and optimized bundling.",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": ["dist", "README.md", "LICENSE"],
15
+ "license": "MIT",
16
+ "engines": { "node": ">=20.0.0" },
17
+ "keywords": ["hyperpack", "plugin", "react", "fast-refresh", "hmr"],
18
+ "scripts": {
19
+ "build": "tsc -b",
20
+ "dev": "tsc -b --watch"
21
+ },
22
+ "dependencies": {
23
+ "@hyperpackai/core": "0.1.0"
24
+ },
25
+ "peerDependencies": {
26
+ "react": ">=18.0.0",
27
+ "react-dom": ">=18.0.0",
28
+ "react-refresh": ">=0.14.0"
29
+ },
30
+ "peerDependenciesMeta": {
31
+ "react-refresh": { "optional": true }
32
+ },
33
+ "publishConfig": {
34
+ "access": "public",
35
+ "registry": "https://registry.npmjs.org/"
36
+ },
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/tharikajis-dev/HyperPack"
40
+ }
41
+ }