@powerlines/plugin-react 0.1.396 → 0.1.398
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/components/react-optimized.cjs +14 -29
- package/dist/components/react-optimized.mjs +14 -29
- package/dist/components/react-optimized.mjs.map +1 -1
- package/dist/index.cjs +1 -5
- package/dist/index.mjs +1 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
- package/dist/_virtual/_rolldown/runtime.mjs +0 -3
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
-
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
4
3
|
let defu = require("defu");
|
|
5
4
|
defu = require_runtime.__toESM(defu);
|
|
6
5
|
let _alloy_js_core = require("@alloy-js/core");
|
|
@@ -16,34 +15,20 @@ const isOptimizationEnabledRefkey = (0, _powerlines_plugin_alloy_helpers_refkey.
|
|
|
16
15
|
*/
|
|
17
16
|
function ReactOptimizedBuiltin(props) {
|
|
18
17
|
const [{ override }, rest] = (0, _alloy_js_core.splitProps)(props, ["override"]);
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
async: false,
|
|
34
|
-
"export": true,
|
|
35
|
-
name: "isOptimizationEnabled",
|
|
36
|
-
returnType: "boolean",
|
|
37
|
-
get children() {
|
|
38
|
-
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_core.Show, {
|
|
39
|
-
when: override !== void 0,
|
|
40
|
-
fallback: _alloy_js_core.code`return !env.DISABLE_REACT_COMPILER && !isDevelopment; `,
|
|
41
|
-
children: _alloy_js_core.code`return ${override};`
|
|
42
|
-
}), (0, _alloy_js_core_jsx_runtime.createIntrinsic)("hbr", {})];
|
|
43
|
-
}
|
|
44
|
-
})];
|
|
45
|
-
}
|
|
46
|
-
}));
|
|
18
|
+
return <_powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile {...rest} id="react/optimized" description="A built-in module to provide access to environment configuration to determine React optimizations." builtinImports={(0, defu.default)({ env: ["env", "isDevelopment"] }, rest.builtinImports ?? {})}>
|
|
19
|
+
<_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc heading="A gating function to determine if the optimized [React compiler](https://react.dev/reference/react-compiler) source code should be used.">
|
|
20
|
+
<_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink>
|
|
21
|
+
{`https://react.dev/reference/react-compiler/gating`}
|
|
22
|
+
</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink>
|
|
23
|
+
<_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>
|
|
24
|
+
{`A boolean indicating if the React compiler's optimizations should be used.`}
|
|
25
|
+
</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns>
|
|
26
|
+
</_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc>
|
|
27
|
+
<_alloy_js_typescript.FunctionDeclaration refkey={isOptimizationEnabledRefkey} async={false} export={true} name="isOptimizationEnabled" returnType="boolean">
|
|
28
|
+
<_alloy_js_core.Show when={override !== void 0} fallback={_alloy_js_core.code`return !env.DISABLE_REACT_COMPILER && !isDevelopment; `}>{_alloy_js_core.code`return ${override};`}</_alloy_js_core.Show>
|
|
29
|
+
<hbr />
|
|
30
|
+
</_alloy_js_typescript.FunctionDeclaration>
|
|
31
|
+
</_powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile>;
|
|
47
32
|
}
|
|
48
33
|
|
|
49
34
|
//#endregion
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createComponent, createIntrinsic, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
1
|
import defu from "defu";
|
|
3
2
|
import { Show, code, splitProps } from "@alloy-js/core";
|
|
4
3
|
import { FunctionDeclaration } from "@alloy-js/typescript";
|
|
@@ -13,34 +12,20 @@ const isOptimizationEnabledRefkey = refkey("isOptimizationEnabled");
|
|
|
13
12
|
*/
|
|
14
13
|
function ReactOptimizedBuiltin(props) {
|
|
15
14
|
const [{ override }, rest] = splitProps(props, ["override"]);
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
async: false,
|
|
31
|
-
"export": true,
|
|
32
|
-
name: "isOptimizationEnabled",
|
|
33
|
-
returnType: "boolean",
|
|
34
|
-
get children() {
|
|
35
|
-
return [createComponent(Show, {
|
|
36
|
-
when: override !== void 0,
|
|
37
|
-
fallback: code`return !env.DISABLE_REACT_COMPILER && !isDevelopment; `,
|
|
38
|
-
children: code`return ${override};`
|
|
39
|
-
}), createIntrinsic("hbr", {})];
|
|
40
|
-
}
|
|
41
|
-
})];
|
|
42
|
-
}
|
|
43
|
-
}));
|
|
15
|
+
return <BuiltinFile {...rest} id="react/optimized" description="A built-in module to provide access to environment configuration to determine React optimizations." builtinImports={defu({ env: ["env", "isDevelopment"] }, rest.builtinImports ?? {})}>
|
|
16
|
+
<TSDoc heading="A gating function to determine if the optimized [React compiler](https://react.dev/reference/react-compiler) source code should be used.">
|
|
17
|
+
<TSDocLink>
|
|
18
|
+
{`https://react.dev/reference/react-compiler/gating`}
|
|
19
|
+
</TSDocLink>
|
|
20
|
+
<TSDocReturns>
|
|
21
|
+
{`A boolean indicating if the React compiler's optimizations should be used.`}
|
|
22
|
+
</TSDocReturns>
|
|
23
|
+
</TSDoc>
|
|
24
|
+
<FunctionDeclaration refkey={isOptimizationEnabledRefkey} async={false} export={true} name="isOptimizationEnabled" returnType="boolean">
|
|
25
|
+
<Show when={override !== void 0} fallback={code`return !env.DISABLE_REACT_COMPILER && !isDevelopment; `}>{code`return ${override};`}</Show>
|
|
26
|
+
<hbr />
|
|
27
|
+
</FunctionDeclaration>
|
|
28
|
+
</BuiltinFile>;
|
|
44
29
|
}
|
|
45
30
|
|
|
46
31
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-optimized.mjs","names":[
|
|
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,CAAC,gBACK,MACJ,qBACA,iHACA,gBAAgB,KACd,EAAE,KAAK,CAAC,OAAO,gBAAgB,EAAE,EACjC,KAAK,kBAAkB,EAAE,CAC1B,EAAE;MACH,CAAC,MAAM,mJAAmJ;QACxJ,CAAC,UAAU;WACR,oDAAoD;QACvD,EAAE,UAAU;QACZ,CAAC,aAAa;WACX,6EAA6E;QAChF,EAAE,aAAa;MACjB,EAAE,MAAM;MACR,CAAC,oBACC,QAAQ,6BACR,OAAO,OACP,QAAQ,MACR,6BACA,qBAAqB;QACrB,CAAC,KACC,MAAM,aAAa,QACnB,UAAU,IAAI,2DAA2D,IAAI,UAAU,SAAS,GAAG,EAAE,KAAK;QAC5G,CAAC,MAAM;MACT,EAAE,oBAAoB;IACxB,EAAE"}
|
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,6 @@ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toString
|
|
|
2
2
|
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
3
|
const require_components_react_optimized = require('./components/react-optimized.cjs');
|
|
4
4
|
require('./components/index.cjs');
|
|
5
|
-
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
6
5
|
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
7
6
|
let _powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
|
|
8
7
|
let _powerlines_plugin_babel = require("@powerlines/plugin-babel");
|
|
@@ -91,10 +90,7 @@ const plugin = (options = {}) => {
|
|
|
91
90
|
});
|
|
92
91
|
},
|
|
93
92
|
async prepare() {
|
|
94
|
-
|
|
95
|
-
return (0, _powerlines_plugin_alloy_render.render)(this, (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_react_optimized.ReactOptimizedBuiltin, { get override() {
|
|
96
|
-
return _self$.config.react.compiler === false ? false : void 0;
|
|
97
|
-
} }));
|
|
93
|
+
return (0, _powerlines_plugin_alloy_render.render)(this, <require_components_react_optimized.ReactOptimizedBuiltin override={this.config.react.compiler === false ? false : void 0} />);
|
|
98
94
|
}
|
|
99
95
|
}
|
|
100
96
|
];
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ReactOptimizedBuiltin } from "./components/react-optimized.mjs";
|
|
2
2
|
import "./components/index.mjs";
|
|
3
|
-
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
4
3
|
import { ReflectionKind, ReflectionVisibility } from "@powerlines/deepkit/vendor/type";
|
|
5
4
|
import { render } from "@powerlines/plugin-alloy/render";
|
|
6
5
|
import babel from "@powerlines/plugin-babel";
|
|
@@ -85,10 +84,7 @@ const plugin = (options = {}) => {
|
|
|
85
84
|
});
|
|
86
85
|
},
|
|
87
86
|
async prepare() {
|
|
88
|
-
|
|
89
|
-
return render(this, createComponent(ReactOptimizedBuiltin, { get override() {
|
|
90
|
-
return _self$.config.react.compiler === false ? false : void 0;
|
|
91
|
-
} }));
|
|
87
|
+
return render(this, <ReactOptimizedBuiltin override={this.config.react.compiler === false ? false : void 0} />);
|
|
92
88
|
}
|
|
93
89
|
}
|
|
94
90
|
];
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["ReflectionKind","ReflectionVisibility","render","babel","env","LogLevelLabel","viteReactPlugin","defu","isMatchFound","ReactOptimizedBuiltin","plugin","options","name","config","react","jsxImportSource","tsconfig","tsconfigJson","compilerOptions","jsxRuntime","compiler","target","compilationMode","gating","source","framework","importSpecifierName","enableReanimatedCheck","logger","logEvent","filename","event","log","kind","SUCCESS","INFO","DEBUG","TRACE","ERROR","depArrayLoc","identifierName","decorations","filter","dec","map","join","reason","detail","category","description","measurement","entryType","duration","fnLoc","configResolved","dependencies","devDependencies","plugins","push","lib","module","jsx","environment","consumer","resolveJsonModule","vite","types","viteBuildConfig","build","unshift","reactRefreshHost","hasProperty","addProperty","optional","readonly","visibility","public","type","boolean","default","prepare","_self$","_$createComponent","override","undefined"],"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,MAAaU,UAGXC,UAA8B,EAAE,KAC7B;AAC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UAAKjD,SAASC,aAAaC,gBAAgBgD,UAAU,EAAE;AAEvD,SACE,CAAC1D,aACC,eACA,KAAKQ,SAASC,aAAaC,gBAAgBgD,MAC5C,CAED,MAAKlD,SAASC,aAAaC,gBAAgBgD,MAAMR,KAC/C,cACD;KAGH,MAAMS,kBAAmB,KAAKtD,OAC3BoD;AACHE,qBAAgBC,UAAU,EAAE;AAC5BD,qBAAgBC,MAAM/C,SAAS;AAE/B8C,qBAAgBV,YAAY,EAAE;AAC9BU,qBAAgBV,QAAQY,QACtB/D,gBAAgB;MACdH,OAAQ,KAAKU,OAAqCV;MAClDY,iBAAiB,KAAKF,OAAOC,MAAMC;MACnCI,YAAY,KAAKN,OAAOC,MAAMK;MAC9BmD,kBAAkB,KAAKzD,OAAOC,MAAMwD;MACrC,CACH,CAAC;;AAGH,QACE,KAAKlE,KAAK8D,OAAO9D,OACjB,CAAC,KAAKA,IAAI8D,MAAM9D,IAAImE,YAAY,yBAAyB,CAEzD,MAAKnE,IAAI8D,MAAM9D,IAAIoE,YAAY;KAC7B5D,MAAM;KACN6D,UAAU;KACVC,UAAU;KACVzB,aAAa;KACb0B,YAAY1E,qBAAqB2E;KACjCC,MAAM,EACJ5C,MAAMjC,eAAe8E,SACtB;KACDC,SAAS;KACV,CAAC;;GAGN,MAAMC,UAAU;IAAA,MAAAC,SAAA;AACd,WAAO/E,OACL,MAAIgF,gBACHzE,uBAAqB,EAAA,IACpB0E,WAAQ;AAAA,YAAEF,OAAKpE,OAAOC,MAAMM,aAAa,QAAQ,QAAQgE;OAAS,CAEtE,CAAC;;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,OAAO,SAChB,MAAM,OAAO,cACT,KAAK,MAAM,OAAO,gBAClB,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a,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.398",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing a Powerlines plugin for building a React application.",
|
|
6
6
|
"repository": {
|
|
@@ -141,27 +141,27 @@
|
|
|
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.342",
|
|
145
|
+
"@powerlines/plugin-alloy": "^0.25.28",
|
|
146
|
+
"@powerlines/plugin-babel": "^0.12.347",
|
|
147
|
+
"@powerlines/plugin-env": "^0.16.63",
|
|
148
148
|
"@storm-software/config-tools": "1.189.28",
|
|
149
149
|
"@stryke/cli": "^0.13.29",
|
|
150
150
|
"@stryke/convert": "^0.6.53",
|
|
151
151
|
"@stryke/fs": "^0.33.57",
|
|
152
152
|
"@stryke/path": "^0.26.19",
|
|
153
|
-
"@vitejs/plugin-react": "^5.
|
|
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.9"
|
|
157
157
|
},
|
|
158
158
|
"devDependencies": {
|
|
159
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
160
|
-
"@types/node": "^25.
|
|
159
|
+
"@powerlines/plugin-plugin": "^0.12.295",
|
|
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": "74a26c533ea4d67ba1b3e297256309c2e23f6e62"
|
|
167
167
|
}
|