@powerlines/plugin-react 0.1.398 → 0.1.400
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.
|
@@ -7,6 +7,7 @@ let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
|
7
7
|
let _powerlines_plugin_alloy_helpers_refkey = require("@powerlines/plugin-alloy/helpers/refkey");
|
|
8
8
|
let _powerlines_plugin_alloy_typescript_components_builtin_file = require("@powerlines/plugin-alloy/typescript/components/builtin-file");
|
|
9
9
|
let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
|
|
10
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
10
11
|
|
|
11
12
|
//#region src/components/react-optimized.tsx
|
|
12
13
|
const isOptimizationEnabledRefkey = (0, _powerlines_plugin_alloy_helpers_refkey.refkey)("isOptimizationEnabled");
|
|
@@ -15,20 +16,27 @@ const isOptimizationEnabledRefkey = (0, _powerlines_plugin_alloy_helpers_refkey.
|
|
|
15
16
|
*/
|
|
16
17
|
function ReactOptimizedBuiltin(props) {
|
|
17
18
|
const [{ override }, rest] = (0, _alloy_js_core.splitProps)(props, ["override"]);
|
|
18
|
-
return
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
return /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile, {
|
|
20
|
+
...rest,
|
|
21
|
+
id: "react/optimized",
|
|
22
|
+
description: "A built-in module to provide access to environment configuration to determine React optimizations.",
|
|
23
|
+
builtinImports: (0, defu.default)({ env: ["env", "isDevelopment"] }, rest.builtinImports ?? {}),
|
|
24
|
+
children: [/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
25
|
+
heading: "A gating function to determine if the optimized [React compiler](https://react.dev/reference/react-compiler) source code should be used.",
|
|
26
|
+
children: [/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink, { children: `https://react.dev/reference/react-compiler/gating` }), /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `A boolean indicating if the React compiler's optimizations should be used.` })]
|
|
27
|
+
}), /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsxs)(_alloy_js_typescript.FunctionDeclaration, {
|
|
28
|
+
refkey: isOptimizationEnabledRefkey,
|
|
29
|
+
async: false,
|
|
30
|
+
export: true,
|
|
31
|
+
name: "isOptimizationEnabled",
|
|
32
|
+
returnType: "boolean",
|
|
33
|
+
children: [/* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(_alloy_js_core.Show, {
|
|
34
|
+
when: override !== void 0,
|
|
35
|
+
fallback: _alloy_js_core.code`return !env.DISABLE_REACT_COMPILER && !isDevelopment; `,
|
|
36
|
+
children: _alloy_js_core.code`return ${override};`
|
|
37
|
+
}), /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)("hbr", {})]
|
|
38
|
+
})]
|
|
39
|
+
});
|
|
32
40
|
}
|
|
33
41
|
|
|
34
42
|
//#endregion
|
|
@@ -4,6 +4,7 @@ import { FunctionDeclaration } from "@alloy-js/typescript";
|
|
|
4
4
|
import { refkey } from "@powerlines/plugin-alloy/helpers/refkey";
|
|
5
5
|
import { BuiltinFile } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
6
6
|
import { TSDoc, TSDocLink, TSDocReturns } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
|
|
7
|
+
import { jsx, jsxs } from "@alloy-js/core/jsx-runtime";
|
|
7
8
|
|
|
8
9
|
//#region src/components/react-optimized.tsx
|
|
9
10
|
const isOptimizationEnabledRefkey = refkey("isOptimizationEnabled");
|
|
@@ -12,20 +13,27 @@ const isOptimizationEnabledRefkey = refkey("isOptimizationEnabled");
|
|
|
12
13
|
*/
|
|
13
14
|
function ReactOptimizedBuiltin(props) {
|
|
14
15
|
const [{ override }, rest] = splitProps(props, ["override"]);
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
return /* @__PURE__ */ jsxs(BuiltinFile, {
|
|
17
|
+
...rest,
|
|
18
|
+
id: "react/optimized",
|
|
19
|
+
description: "A built-in module to provide access to environment configuration to determine React optimizations.",
|
|
20
|
+
builtinImports: defu({ env: ["env", "isDevelopment"] }, rest.builtinImports ?? {}),
|
|
21
|
+
children: [/* @__PURE__ */ jsxs(TSDoc, {
|
|
22
|
+
heading: "A gating function to determine if the optimized [React compiler](https://react.dev/reference/react-compiler) source code should be used.",
|
|
23
|
+
children: [/* @__PURE__ */ jsx(TSDocLink, { children: `https://react.dev/reference/react-compiler/gating` }), /* @__PURE__ */ jsx(TSDocReturns, { children: `A boolean indicating if the React compiler's optimizations should be used.` })]
|
|
24
|
+
}), /* @__PURE__ */ jsxs(FunctionDeclaration, {
|
|
25
|
+
refkey: isOptimizationEnabledRefkey,
|
|
26
|
+
async: false,
|
|
27
|
+
export: true,
|
|
28
|
+
name: "isOptimizationEnabled",
|
|
29
|
+
returnType: "boolean",
|
|
30
|
+
children: [/* @__PURE__ */ jsx(Show, {
|
|
31
|
+
when: override !== void 0,
|
|
32
|
+
fallback: code`return !env.DISABLE_REACT_COMPILER && !isDevelopment; `,
|
|
33
|
+
children: code`return ${override};`
|
|
34
|
+
}), /* @__PURE__ */ jsx("hbr", {})]
|
|
35
|
+
})]
|
|
36
|
+
});
|
|
29
37
|
}
|
|
30
38
|
|
|
31
39
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-optimized.mjs","names":[],"sources":["../../src/components/react-optimized.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, Show, splitProps } from \"@alloy-js/core\";\nimport { FunctionDeclaration } from \"@alloy-js/typescript\";\nimport { refkey } from \"@powerlines/plugin-alloy/helpers/refkey\";\nimport {\n BuiltinFile,\n BuiltinFileProps\n} from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport {\n TSDoc,\n TSDocLink,\n TSDocReturns\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport defu from \"defu\";\n\nexport interface ReactOptimizedBuiltinProps extends Omit<\n BuiltinFileProps,\n \"id\"\n> {\n override?: boolean;\n}\n\nconst isOptimizationEnabledRefkey = refkey(\"isOptimizationEnabled\");\n\n/**\n * Generates the `react/optimized` builtin module for the Powerlines project.\n */\nexport function ReactOptimizedBuiltin(props: ReactOptimizedBuiltinProps) {\n const [{ override }, rest] = splitProps(props, [\"override\"]);\n\n return (\n <BuiltinFile\n {...rest}\n id=\"react/optimized\"\n description=\"A built-in module to provide access to environment configuration to determine React optimizations.\"\n builtinImports={defu(\n { env: [\"env\", \"isDevelopment\"] },\n rest.builtinImports ?? {}\n )}>\n <TSDoc heading=\"A gating function to determine if the optimized [React compiler](https://react.dev/reference/react-compiler) source code should be used.\">\n <TSDocLink>\n {`https://react.dev/reference/react-compiler/gating`}\n </TSDocLink>\n <TSDocReturns>\n {`A boolean indicating if the React compiler's optimizations should be used.`}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n refkey={isOptimizationEnabledRefkey}\n async={false}\n export={true}\n name=\"isOptimizationEnabled\"\n returnType=\"boolean\">\n <Show\n when={override !== undefined}\n fallback={code`return !env.DISABLE_REACT_COMPILER && !isDevelopment; `}>{code`return ${override};`}</Show>\n <hbr />\n </FunctionDeclaration>\n </BuiltinFile>\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"react-optimized.mjs","names":[],"sources":["../../src/components/react-optimized.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, Show, splitProps } from \"@alloy-js/core\";\nimport { FunctionDeclaration } from \"@alloy-js/typescript\";\nimport { refkey } from \"@powerlines/plugin-alloy/helpers/refkey\";\nimport {\n BuiltinFile,\n BuiltinFileProps\n} from \"@powerlines/plugin-alloy/typescript/components/builtin-file\";\nimport {\n TSDoc,\n TSDocLink,\n TSDocReturns\n} from \"@powerlines/plugin-alloy/typescript/components/tsdoc\";\nimport defu from \"defu\";\n\nexport interface ReactOptimizedBuiltinProps extends Omit<\n BuiltinFileProps,\n \"id\"\n> {\n override?: boolean;\n}\n\nconst isOptimizationEnabledRefkey = refkey(\"isOptimizationEnabled\");\n\n/**\n * Generates the `react/optimized` builtin module for the Powerlines project.\n */\nexport function ReactOptimizedBuiltin(props: ReactOptimizedBuiltinProps) {\n const [{ override }, rest] = splitProps(props, [\"override\"]);\n\n return (\n <BuiltinFile\n {...rest}\n id=\"react/optimized\"\n description=\"A built-in module to provide access to environment configuration to determine React optimizations.\"\n builtinImports={defu(\n { env: [\"env\", \"isDevelopment\"] },\n rest.builtinImports ?? {}\n )}>\n <TSDoc heading=\"A gating function to determine if the optimized [React compiler](https://react.dev/reference/react-compiler) source code should be used.\">\n <TSDocLink>\n {`https://react.dev/reference/react-compiler/gating`}\n </TSDocLink>\n <TSDocReturns>\n {`A boolean indicating if the React compiler's optimizations should be used.`}\n </TSDocReturns>\n </TSDoc>\n <FunctionDeclaration\n refkey={isOptimizationEnabledRefkey}\n async={false}\n export={true}\n name=\"isOptimizationEnabled\"\n returnType=\"boolean\">\n <Show\n when={override !== undefined}\n fallback={code`return !env.DISABLE_REACT_COMPILER && !isDevelopment; `}>{code`return ${override};`}</Show>\n <hbr />\n </FunctionDeclaration>\n </BuiltinFile>\n );\n}\n"],"mappings":";;;;;;;;;AAuCA,MAAM,8BAA8B,OAAO,wBAAwB;;;;AAKnE,SAAgB,sBAAsB,OAAmC;CACvE,MAAM,CAAC,EAAE,YAAY,QAAQ,WAAW,OAAO,CAAC,WAAW,CAAC;AAE5D,QACE,qBAAC,aAAD;EACE,GAAI;EACJ,IAAG;EACH,aAAY;EACZ,gBAAgB,KACd,EAAE,KAAK,CAAC,OAAO,gBAAgB,EAAE,EACjC,KAAK,kBAAkB,EAAE,CAC1B;YAPH,CAQE,qBAAC,OAAD;GAAO,SAAQ;aAAf,CACE,oBAAC,WAAD,YACG,qDACS,GACZ,oBAAC,cAAD,YACG,8EACY,EACT;MACR,qBAAC,qBAAD;GACE,QAAQ;GACR,OAAO;GACP,QAAQ;GACR,MAAK;GACL,YAAW;aALb,CAME,oBAAC,MAAD;IACE,MAAM,aAAa;IACnB,UAAU,IAAI;cAA2D,IAAI,UAAU,SAAS;IAAU,GAC5G,oBAAC,OAAD,EAAO,EACa;KACV"}
|
package/dist/index.cjs
CHANGED
|
@@ -14,6 +14,7 @@ _vitejs_plugin_react = require_runtime.__toESM(_vitejs_plugin_react);
|
|
|
14
14
|
let defu = require("defu");
|
|
15
15
|
defu = require_runtime.__toESM(defu);
|
|
16
16
|
let powerlines_typescript_tsconfig = require("powerlines/typescript/tsconfig");
|
|
17
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
17
18
|
|
|
18
19
|
//#region src/index.tsx
|
|
19
20
|
/**
|
|
@@ -90,7 +91,7 @@ const plugin = (options = {}) => {
|
|
|
90
91
|
});
|
|
91
92
|
},
|
|
92
93
|
async prepare() {
|
|
93
|
-
return (0, _powerlines_plugin_alloy_render.render)(this,
|
|
94
|
+
return (0, _powerlines_plugin_alloy_render.render)(this, /* @__PURE__ */ (0, _alloy_js_core_jsx_runtime.jsx)(require_components_react_optimized.ReactOptimizedBuiltin, { override: this.config.react.compiler === false ? false : void 0 }));
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
];
|
package/dist/index.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { LogLevelLabel } from "@storm-software/config-tools/types";
|
|
|
8
8
|
import viteReactPlugin from "@vitejs/plugin-react";
|
|
9
9
|
import defu from "defu";
|
|
10
10
|
import { isMatchFound } from "powerlines/typescript/tsconfig";
|
|
11
|
+
import { jsx } from "@alloy-js/core/jsx-runtime";
|
|
11
12
|
|
|
12
13
|
//#region src/index.tsx
|
|
13
14
|
/**
|
|
@@ -84,7 +85,7 @@ const plugin = (options = {}) => {
|
|
|
84
85
|
});
|
|
85
86
|
},
|
|
86
87
|
async prepare() {
|
|
87
|
-
return render(this,
|
|
88
|
+
return render(this, /* @__PURE__ */ jsx(ReactOptimizedBuiltin, { override: this.config.react.compiler === false ? false : void 0 }));
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
91
|
];
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n ReflectionKind,\n ReflectionVisibility\n} from \"@powerlines/deepkit/vendor/type\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport babel, { BabelPluginResolvedConfig } from \"@powerlines/plugin-babel\";\nimport env from \"@powerlines/plugin-env\";\nimport { VitePluginResolvedConfig } from \"@powerlines/plugin-vite/types/plugin\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport viteReactPlugin from \"@vitejs/plugin-react\";\nimport type { LoggerEvent } from \"babel-plugin-react-compiler\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport { isMatchFound } from \"powerlines/typescript/tsconfig\";\nimport { ReactOptimizedBuiltin } from \"./components/react-optimized\";\nimport type { ReactPluginContext, ReactPluginOptions } from \"./types/plugin\";\n\nexport * from \"./components\";\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n react?: ReactPluginOptions;\n }\n}\n\n/**\n * A package containing a Powerlines plugin for building a React application.\n */\nexport const plugin = <\n TContext extends ReactPluginContext = ReactPluginContext\n>(\n options: ReactPluginOptions = {}\n) => {\n return [\n babel(options.babel),\n env(options.env),\n {\n name: \"react\",\n config() {\n return defu(\n {\n react: options\n },\n {\n react: {\n jsxImportSource: this.tsconfig.tsconfigJson.compilerOptions\n ?.jsxImportSource as string\n }\n },\n {\n react: {\n jsxRuntime: \"automatic\",\n jsxImportSource: \"react\",\n compiler: {\n target: \"19\",\n compilationMode: \"infer\",\n gating: {\n source: `${this.config.framework}:react/optimized`,\n importSpecifierName: \"isOptimizationEnabled\"\n },\n enableReanimatedCheck: true,\n logger: {\n logEvent: (filename: string | null, event: LoggerEvent) => {\n this.log(\n event.kind === \"CompileSuccess\"\n ? LogLevelLabel.SUCCESS\n : event.kind === \"AutoDepsEligible\" ||\n event.kind === \"AutoDepsDecorations\"\n ? LogLevelLabel.INFO\n : event.kind === \"CompileSkip\" ||\n event.kind === \"CompileDiagnostic\"\n ? LogLevelLabel.DEBUG\n : event.kind === \"Timing\"\n ? LogLevelLabel.TRACE\n : LogLevelLabel.ERROR,\n `(${filename}) ${\n event.kind === \"CompileSuccess\"\n ? `React Compiler Success`\n : event.kind === \"AutoDepsEligible\"\n ? `React AutoDeps Eligible - ${\n event.depArrayLoc.identifierName ||\n \"No identifier\"\n }`\n : event.kind === \"AutoDepsDecorations\"\n ? `React AutoDeps Decorations - ${event.decorations\n .filter(dec => dec.identifierName)\n .map(dec => dec.identifierName)\n .join(\", \")}`\n : event.kind === \"CompileSkip\"\n ? `React Compile Skip - ${event.reason}`\n : event.kind === \"CompileDiagnostic\"\n ? `React Compile Diagnostic - (Category: ${\n event.detail.category\n }) ${event.detail.reason}${\n event.detail.description\n ? `\\n${event.detail.description}`\n : \"\"\n }`\n : event.kind === \"Timing\"\n ? `React ${event.measurement.entryType} Timing (${event.measurement.name}) - ${event.measurement.duration}ms`\n : `React Compiler Error - ${event.fnLoc?.identifierName || \"unknown location\"}`\n }`\n );\n }\n }\n }\n } as ReactPluginOptions\n }\n );\n },\n configResolved() {\n this.dependencies.react = \"^19.2.3\";\n this.dependencies[\"react-dom\"] = \"^19.2.3\";\n\n this.devDependencies[\"@types/react\"] = \"^19.2.3\";\n this.devDependencies[\"@types/react-dom\"] = \"^19.2.3\";\n\n if (this.config.react.compiler !== false) {\n (this.config as BabelPluginResolvedConfig).babel ??=\n {} as BabelPluginResolvedConfig[\"babel\"];\n\n this.config.babel.plugins ??= [];\n this.config.babel.plugins.push([\n \"babel-plugin-react-compiler\",\n this.config.react.compiler\n ]);\n }\n\n this.tsconfig.tsconfigJson.compilerOptions ??= {};\n this.tsconfig.tsconfigJson.compilerOptions.lib ??= [];\n this.tsconfig.tsconfigJson.compilerOptions.module ??= \"esnext\";\n this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource =\n this.config.react.jsxImportSource;\n\n if (this.tsconfig.options.jsxImportSource === \"react\") {\n this.tsconfig.tsconfigJson.compilerOptions.jsx ??= \"react-jsx\";\n } else {\n this.tsconfig.tsconfigJson.compilerOptions.jsx ??= \"preserve\";\n }\n\n // Client platform\n if (this.environment.consumer === \"client\") {\n if (\n !isMatchFound(\"dom\", this.tsconfig.tsconfigJson.compilerOptions.lib)\n ) {\n this.tsconfig.tsconfigJson.compilerOptions.lib.push(\"DOM\");\n }\n\n if (\n !isMatchFound(\n \"dom.iterable\",\n this.tsconfig.tsconfigJson.compilerOptions.lib\n )\n ) {\n this.tsconfig.tsconfigJson.compilerOptions.lib.push(\"DOM.Iterable\");\n }\n }\n\n if (\n !isMatchFound(\n \"esnext\",\n this.tsconfig.tsconfigJson.compilerOptions.lib\n )\n ) {\n this.tsconfig.tsconfigJson.compilerOptions.lib.push(\"ESNext\");\n }\n\n if (this.tsconfig.options.resolveJsonModule !== true) {\n this.tsconfig.tsconfigJson.compilerOptions.resolveJsonModule = true;\n }\n\n if ((this.config as VitePluginResolvedConfig).vite) {\n this.tsconfig.tsconfigJson.compilerOptions.types ??= [];\n\n if (\n !isMatchFound(\n \"vite/client\",\n this.tsconfig.tsconfigJson.compilerOptions.types\n )\n ) {\n this.tsconfig.tsconfigJson.compilerOptions.types.push(\n \"vite/client\"\n );\n }\n\n const viteBuildConfig = (this.config as VitePluginResolvedConfig)\n .vite;\n viteBuildConfig.build ??= {};\n viteBuildConfig.build.target = \"chrome95\";\n\n viteBuildConfig.plugins ??= [];\n viteBuildConfig.plugins.unshift(\n viteReactPlugin({\n babel: (this.config as BabelPluginResolvedConfig).babel,\n jsxImportSource: this.config.react.jsxImportSource,\n jsxRuntime: this.config.react.jsxRuntime,\n reactRefreshHost: this.config.react.reactRefreshHost\n })\n );\n }\n\n if (\n this.env?.types?.env &&\n !this.env.types.env.hasProperty(\"DISABLE_REACT_COMPILER\")\n ) {\n this.env.types.env.addProperty({\n name: \"DISABLE_REACT_COMPILER\",\n optional: true,\n readonly: true,\n description: \"Disables the React compiler optimizations.\",\n visibility: ReflectionVisibility.public,\n type: {\n kind: ReflectionKind.boolean\n },\n default: false\n });\n }\n },\n async prepare() {\n return render(\n this,\n <ReactOptimizedBuiltin\n override={this.config.react.compiler === false ? false : undefined}\n />\n );\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;AA+CA,MAAa,UAGX,UAA8B,EAAE,KAC7B;AACH,QAAO;EACL,MAAM,QAAQ,MAAM;EACpB,IAAI,QAAQ,IAAI;EAChB;GACE,MAAM;GACN,SAAS;AACP,WAAO,KACL,EACE,OAAO,SACR,EACD,EACE,OAAO,EACL,iBAAiB,KAAK,SAAS,aAAa,iBACxC,iBACL,EACF,EACD,EACE,OAAO;KACL,YAAY;KACZ,iBAAiB;KACjB,UAAU;MACR,QAAQ;MACR,iBAAiB;MACjB,QAAQ;OACN,QAAQ,GAAG,KAAK,OAAO,UAAU;OACjC,qBAAqB;OACtB;MACD,uBAAuB;MACvB,QAAQ,EACN,WAAW,UAAyB,UAAuB;AACzD,YAAK,IACH,MAAM,SAAS,mBACX,cAAc,UACd,MAAM,SAAS,sBACb,MAAM,SAAS,wBACf,cAAc,OACd,MAAM,SAAS,iBACb,MAAM,SAAS,sBACf,cAAc,QACd,MAAM,SAAS,WACb,cAAc,QACd,cAAc,OACxB,IAAI,SAAS,IACX,MAAM,SAAS,mBACX,2BACA,MAAM,SAAS,qBACb,6BACE,MAAM,YAAY,kBAClB,oBAEF,MAAM,SAAS,wBACb,gCAAgC,MAAM,YACnC,QAAO,QAAO,IAAI,eAAe,CACjC,KAAI,QAA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AK,eAAe;;AAIvE,QACE,CAAC,aACC,UACA,KAAK,SAAS,aAAa,gBAAgB,IAC5C,CAED,MAAK,SAAS,aAAa,gBAAgB,IAAI,KAAK,SAAS;AAG/D,QAAI,KAAK,SAAS,QAAQ,sBAAsB,KAC9C,MAAK,SAAS,aAAa,gBAAgB,oBAAoB;AAGjE,QAAK,KAAK,OAAoC,MAAM;AAClD,UAAK,SAAS,aAAa,gBAAgB,UAAU,EAAE;AAEvD,SACE,CAAC,aACC,eACA,KAAK,SAAS,aAAa,gBAAgB,MAC5C,CAED,MAAK,SAAS,aAAa,gBAAgB,MAAM,KAC/C,cACD;KAGH,MAAM,kBAAmB,KAAK,OAC3B;AACH,qBAAgB,UAAU,EAAE;AAC5B,qBAAgB,MAAM,SAAS;AAE/B,qBAAgB,YAAY,EAAE;AAC9B,qBAAgB,QAAQ,QACtB,gBAAgB;MACd,OAAQ,KAAK,OAAqC;MAClD,iBAAiB,KAAK,OAAO,MAAM;MACnC,YAAY,KAAK,OAAO,MAAM;MAC9B,kBAAkB,KAAK,OAAO,MAAM;MACrC,CAAC,CACH;;AAGH,QACE,KAAK,KAAK,OAAO,OACjB,CAAC,KAAK,IAAI,MAAM,IAAI,YAAY,yBAAyB,CAEzD,MAAK,IAAI,MAAM,IAAI,YAAY;KAC7B,MAAM;KACN,UAAU;KACV,UAAU;KACV,aAAa;KACb,YAAY,qBAAqB;KACjC,MAAM,EACJ,MAAM,eAAe,SACtB;KACD,SAAS;KACV,CAAC;;GAGN,MAAM,UAAU;AACd,WAAO,OACL,MACA,CAAC,sBACC,UAAU,KAAK,OAAO,MAAM,aAAa,QAAQ,QAAQ,WAE5D;;GAEJ;EACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n ReflectionKind,\n ReflectionVisibility\n} from \"@powerlines/deepkit/vendor/type\";\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport babel, { BabelPluginResolvedConfig } from \"@powerlines/plugin-babel\";\nimport env from \"@powerlines/plugin-env\";\nimport { VitePluginResolvedConfig } from \"@powerlines/plugin-vite/types/plugin\";\nimport { LogLevelLabel } from \"@storm-software/config-tools/types\";\nimport viteReactPlugin from \"@vitejs/plugin-react\";\nimport type { LoggerEvent } from \"babel-plugin-react-compiler\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport { isMatchFound } from \"powerlines/typescript/tsconfig\";\nimport { ReactOptimizedBuiltin } from \"./components/react-optimized\";\nimport type { ReactPluginContext, ReactPluginOptions } from \"./types/plugin\";\n\nexport * from \"./components\";\nexport * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n react?: ReactPluginOptions;\n }\n}\n\n/**\n * A package containing a Powerlines plugin for building a React application.\n */\nexport const plugin = <\n TContext extends ReactPluginContext = ReactPluginContext\n>(\n options: ReactPluginOptions = {}\n) => {\n return [\n babel(options.babel),\n env(options.env),\n {\n name: \"react\",\n config() {\n return defu(\n {\n react: options\n },\n {\n react: {\n jsxImportSource: this.tsconfig.tsconfigJson.compilerOptions\n ?.jsxImportSource as string\n }\n },\n {\n react: {\n jsxRuntime: \"automatic\",\n jsxImportSource: \"react\",\n compiler: {\n target: \"19\",\n compilationMode: \"infer\",\n gating: {\n source: `${this.config.framework}:react/optimized`,\n importSpecifierName: \"isOptimizationEnabled\"\n },\n enableReanimatedCheck: true,\n logger: {\n logEvent: (filename: string | null, event: LoggerEvent) => {\n this.log(\n event.kind === \"CompileSuccess\"\n ? LogLevelLabel.SUCCESS\n : event.kind === \"AutoDepsEligible\" ||\n event.kind === \"AutoDepsDecorations\"\n ? LogLevelLabel.INFO\n : event.kind === \"CompileSkip\" ||\n event.kind === \"CompileDiagnostic\"\n ? LogLevelLabel.DEBUG\n : event.kind === \"Timing\"\n ? LogLevelLabel.TRACE\n : LogLevelLabel.ERROR,\n `(${filename}) ${\n event.kind === \"CompileSuccess\"\n ? `React Compiler Success`\n : event.kind === \"AutoDepsEligible\"\n ? `React AutoDeps Eligible - ${\n event.depArrayLoc.identifierName ||\n \"No identifier\"\n }`\n : event.kind === \"AutoDepsDecorations\"\n ? `React AutoDeps Decorations - ${event.decorations\n .filter(dec => dec.identifierName)\n .map(dec => dec.identifierName)\n .join(\", \")}`\n : event.kind === \"CompileSkip\"\n ? `React Compile Skip - ${event.reason}`\n : event.kind === \"CompileDiagnostic\"\n ? `React Compile Diagnostic - (Category: ${\n event.detail.category\n }) ${event.detail.reason}${\n event.detail.description\n ? `\\n${event.detail.description}`\n : \"\"\n }`\n : event.kind === \"Timing\"\n ? `React ${event.measurement.entryType} Timing (${event.measurement.name}) - ${event.measurement.duration}ms`\n : `React Compiler Error - ${event.fnLoc?.identifierName || \"unknown location\"}`\n }`\n );\n }\n }\n }\n } as ReactPluginOptions\n }\n );\n },\n configResolved() {\n this.dependencies.react = \"^19.2.3\";\n this.dependencies[\"react-dom\"] = \"^19.2.3\";\n\n this.devDependencies[\"@types/react\"] = \"^19.2.3\";\n this.devDependencies[\"@types/react-dom\"] = \"^19.2.3\";\n\n if (this.config.react.compiler !== false) {\n (this.config as BabelPluginResolvedConfig).babel ??=\n {} as BabelPluginResolvedConfig[\"babel\"];\n\n this.config.babel.plugins ??= [];\n this.config.babel.plugins.push([\n \"babel-plugin-react-compiler\",\n this.config.react.compiler\n ]);\n }\n\n this.tsconfig.tsconfigJson.compilerOptions ??= {};\n this.tsconfig.tsconfigJson.compilerOptions.lib ??= [];\n this.tsconfig.tsconfigJson.compilerOptions.module ??= \"esnext\";\n this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource =\n this.config.react.jsxImportSource;\n\n if (this.tsconfig.options.jsxImportSource === \"react\") {\n this.tsconfig.tsconfigJson.compilerOptions.jsx ??= \"react-jsx\";\n } else {\n this.tsconfig.tsconfigJson.compilerOptions.jsx ??= \"preserve\";\n }\n\n // Client platform\n if (this.environment.consumer === \"client\") {\n if (\n !isMatchFound(\"dom\", this.tsconfig.tsconfigJson.compilerOptions.lib)\n ) {\n this.tsconfig.tsconfigJson.compilerOptions.lib.push(\"DOM\");\n }\n\n if (\n !isMatchFound(\n \"dom.iterable\",\n this.tsconfig.tsconfigJson.compilerOptions.lib\n )\n ) {\n this.tsconfig.tsconfigJson.compilerOptions.lib.push(\"DOM.Iterable\");\n }\n }\n\n if (\n !isMatchFound(\n \"esnext\",\n this.tsconfig.tsconfigJson.compilerOptions.lib\n )\n ) {\n this.tsconfig.tsconfigJson.compilerOptions.lib.push(\"ESNext\");\n }\n\n if (this.tsconfig.options.resolveJsonModule !== true) {\n this.tsconfig.tsconfigJson.compilerOptions.resolveJsonModule = true;\n }\n\n if ((this.config as VitePluginResolvedConfig).vite) {\n this.tsconfig.tsconfigJson.compilerOptions.types ??= [];\n\n if (\n !isMatchFound(\n \"vite/client\",\n this.tsconfig.tsconfigJson.compilerOptions.types\n )\n ) {\n this.tsconfig.tsconfigJson.compilerOptions.types.push(\n \"vite/client\"\n );\n }\n\n const viteBuildConfig = (this.config as VitePluginResolvedConfig)\n .vite;\n viteBuildConfig.build ??= {};\n viteBuildConfig.build.target = \"chrome95\";\n\n viteBuildConfig.plugins ??= [];\n viteBuildConfig.plugins.unshift(\n viteReactPlugin({\n babel: (this.config as BabelPluginResolvedConfig).babel,\n jsxImportSource: this.config.react.jsxImportSource,\n jsxRuntime: this.config.react.jsxRuntime,\n reactRefreshHost: this.config.react.reactRefreshHost\n })\n );\n }\n\n if (\n this.env?.types?.env &&\n !this.env.types.env.hasProperty(\"DISABLE_REACT_COMPILER\")\n ) {\n this.env.types.env.addProperty({\n name: \"DISABLE_REACT_COMPILER\",\n optional: true,\n readonly: true,\n description: \"Disables the React compiler optimizations.\",\n visibility: ReflectionVisibility.public,\n type: {\n kind: ReflectionKind.boolean\n },\n default: false\n });\n }\n },\n async prepare() {\n return render(\n this,\n <ReactOptimizedBuiltin\n override={this.config.react.compiler === false ? false : undefined}\n />\n );\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;AA+CA,MAAa,UAGX,UAA8B,EAAE,KAC7B;AACH,QAAO;EACL,MAAM,QAAQ,MAAM;EACpB,IAAI,QAAQ,IAAI;EAChB;GACE,MAAM;GACN,SAAS;AACP,WAAO,KACL,EACE,OAAO,SACR,EACD,EACE,OAAO,EACL,iBAAiB,KAAK,SAAS,aAAa,iBACxC,iBACL,EACF,EACD,EACE,OAAO;KACL,YAAY;KACZ,iBAAiB;KACjB,UAAU;MACR,QAAQ;MACR,iBAAiB;MACjB,QAAQ;OACN,QAAQ,GAAG,KAAK,OAAO,UAAU;OACjC,qBAAqB;OACtB;MACD,uBAAuB;MACvB,QAAQ,EACN,WAAW,UAAyB,UAAuB;AACzD,YAAK,IACH,MAAM,SAAS,mBACX,cAAc,UACd,MAAM,SAAS,sBACb,MAAM,SAAS,wBACf,cAAc,OACd,MAAM,SAAS,iBACb,MAAM,SAAS,sBACf,cAAc,QACd,MAAM,SAAS,WACb,cAAc,QACd,cAAc,OACxB,IAAI,SAAS,IACX,MAAM,SAAS,mBACX,2BACA,MAAM,SAAS,qBACb,6BACE,MAAM,YAAY,kBAClB,oBAEF,MAAM,SAAS,wBACb,gCAAgC,MAAM,YACnC,QAAO,QAAO,IAAI,eAAe,CACjC,KAAI,QAAO,IAAI,eAAe,CAC9B,KAAK,KAAK,KACb,MAAM,SAAS,gBACb,wBAAwB,MAAM,WAC9B,MAAM,SAAS,sBACb,yCACE,MAAM,OAAO,SACd,IAAI,MAAM,OA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,KAAK,SAAS,QAAQ,sBAAsB,KAC9C,MAAK,SAAS,aAAa,gBAAgB,oBAAoB;AAGjE,QAAK,KAAK,OAAoC,MAAM;AAClD,UAAK,SAAS,aAAa,gBAAgB,UAAU,EAAE;AAEvD,SACE,CAAC,aACC,eACA,KAAK,SAAS,aAAa,gBAAgB,MAC5C,CAED,MAAK,SAAS,aAAa,gBAAgB,MAAM,KAC/C,cACD;KAGH,MAAM,kBAAmB,KAAK,OAC3B;AACH,qBAAgB,UAAU,EAAE;AAC5B,qBAAgB,MAAM,SAAS;AAE/B,qBAAgB,YAAY,EAAE;AAC9B,qBAAgB,QAAQ,QACtB,gBAAgB;MACd,OAAQ,KAAK,OAAqC;MAClD,iBAAiB,KAAK,OAAO,MAAM;MACnC,YAAY,KAAK,OAAO,MAAM;MAC9B,kBAAkB,KAAK,OAAO,MAAM;MACrC,CAAC,CACH;;AAGH,QACE,KAAK,KAAK,OAAO,OACjB,CAAC,KAAK,IAAI,MAAM,IAAI,YAAY,yBAAyB,CAEzD,MAAK,IAAI,MAAM,IAAI,YAAY;KAC7B,MAAM;KACN,UAAU;KACV,UAAU;KACV,aAAa;KACb,YAAY,qBAAqB;KACjC,MAAM,EACJ,MAAM,eAAe,SACtB;KACD,SAAS;KACV,CAAC;;GAGN,MAAM,UAAU;AACd,WAAO,OACL,MACA,oBAAC,uBAAD,EACE,UAAU,KAAK,OAAO,MAAM,aAAa,QAAQ,QAAQ,QACzD,EACH;;GAEJ;EACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.400",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing a Powerlines plugin for building a React application.",
|
|
6
6
|
"repository": {
|
|
@@ -141,10 +141,10 @@
|
|
|
141
141
|
"@alloy-js/markdown": "0.23.0-dev.1",
|
|
142
142
|
"@alloy-js/typescript": "0.23.0-dev.4",
|
|
143
143
|
"@babel/core": "^7.29.0",
|
|
144
|
-
"@powerlines/plugin-vite": "^0.14.
|
|
145
|
-
"@powerlines/plugin-alloy": "^0.25.
|
|
146
|
-
"@powerlines/plugin-babel": "^0.12.
|
|
147
|
-
"@powerlines/plugin-env": "^0.16.
|
|
144
|
+
"@powerlines/plugin-vite": "^0.14.344",
|
|
145
|
+
"@powerlines/plugin-alloy": "^0.25.30",
|
|
146
|
+
"@powerlines/plugin-babel": "^0.12.349",
|
|
147
|
+
"@powerlines/plugin-env": "^0.16.65",
|
|
148
148
|
"@storm-software/config-tools": "1.189.28",
|
|
149
149
|
"@stryke/cli": "^0.13.29",
|
|
150
150
|
"@stryke/convert": "^0.6.53",
|
|
@@ -153,15 +153,15 @@
|
|
|
153
153
|
"@vitejs/plugin-react": "^5.2.0",
|
|
154
154
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
155
155
|
"defu": "^6.1.4",
|
|
156
|
-
"powerlines": "^0.41.
|
|
156
|
+
"powerlines": "^0.41.11"
|
|
157
157
|
},
|
|
158
158
|
"devDependencies": {
|
|
159
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
159
|
+
"@powerlines/plugin-plugin": "^0.12.297",
|
|
160
160
|
"@types/node": "^25.5.0",
|
|
161
161
|
"@types/react": "^19.2.14",
|
|
162
162
|
"@types/react-dom": "^19.2.3"
|
|
163
163
|
},
|
|
164
164
|
"publishConfig": { "access": "public" },
|
|
165
165
|
"types": "./dist/index.d.cts",
|
|
166
|
-
"gitHead": "
|
|
166
|
+
"gitHead": "c13dc78b9ef6d6418df534f4ea7181162d06ff1d"
|
|
167
167
|
}
|