@powerlines/plugin-react 0.1.517 → 0.1.519
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/_virtual/_rolldown/runtime.cjs +29 -1
- package/dist/components/index.cjs +4 -1
- package/dist/components/index.mjs +3 -1
- package/dist/components/react-optimized.cjs +50 -1
- package/dist/components/react-optimized.mjs +47 -1
- package/dist/components/react-optimized.mjs.map +1 -1
- package/dist/index.cjs +105 -1
- package/dist/index.mjs +97 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types/env.mjs +1 -1
- package/dist/types/index.mjs +1 -1
- package/dist/types/plugin.mjs +1 -1
- package/package.json +8 -8
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
13
|
+
__defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
23
|
+
value: mod,
|
|
24
|
+
enumerable: true
|
|
25
|
+
}) : target, mod));
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
exports.__toESM = __toESM;
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_components_react_optimized = require('./react-optimized.cjs');
|
|
3
|
+
|
|
4
|
+
exports.ReactOptimizedBuiltin = require_components_react_optimized.ReactOptimizedBuiltin;
|
|
@@ -1 +1,50 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
4
|
+
let defu = require("defu");
|
|
5
|
+
defu = require_runtime.__toESM(defu);
|
|
6
|
+
let _alloy_js_core = require("@alloy-js/core");
|
|
7
|
+
let _alloy_js_typescript = require("@alloy-js/typescript");
|
|
8
|
+
let _powerlines_plugin_alloy_helpers_refkey = require("@powerlines/plugin-alloy/helpers/refkey");
|
|
9
|
+
let _powerlines_plugin_alloy_typescript_components_builtin_file = require("@powerlines/plugin-alloy/typescript/components/builtin-file");
|
|
10
|
+
let _powerlines_plugin_alloy_typescript_components_tsdoc = require("@powerlines/plugin-alloy/typescript/components/tsdoc");
|
|
11
|
+
|
|
12
|
+
//#region src/components/react-optimized.tsx
|
|
13
|
+
const isOptimizationEnabledRefkey = (0, _powerlines_plugin_alloy_helpers_refkey.refkey)("isOptimizationEnabled");
|
|
14
|
+
/**
|
|
15
|
+
* Generates the `react/optimized` builtin module for the Powerlines project.
|
|
16
|
+
*/
|
|
17
|
+
function ReactOptimizedBuiltin(props) {
|
|
18
|
+
const [{ override }, rest] = (0, _alloy_js_core.splitProps)(props, ["override"]);
|
|
19
|
+
return (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_builtin_file.BuiltinFile, (0, _alloy_js_core_jsx_runtime.mergeProps)(rest, {
|
|
20
|
+
id: "react/optimized",
|
|
21
|
+
description: "A built-in module to provide access to environment configuration to determine React optimizations.",
|
|
22
|
+
get builtinImports() {
|
|
23
|
+
return (0, defu.default)({ env: ["env", "isDevelopment"] }, rest.builtinImports ?? {});
|
|
24
|
+
},
|
|
25
|
+
get children() {
|
|
26
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDoc, {
|
|
27
|
+
heading: "A gating function to determine if the optimized [React compiler](https://react.dev/reference/react-compiler) source code should be used.",
|
|
28
|
+
get children() {
|
|
29
|
+
return [(0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocLink, { children: `https://react.dev/reference/react-compiler/gating` }), (0, _alloy_js_core_jsx_runtime.createComponent)(_powerlines_plugin_alloy_typescript_components_tsdoc.TSDocReturns, { children: `A boolean indicating if the React compiler's optimizations should be used.` })];
|
|
30
|
+
}
|
|
31
|
+
}), (0, _alloy_js_core_jsx_runtime.createComponent)(_alloy_js_typescript.FunctionDeclaration, {
|
|
32
|
+
refkey: isOptimizationEnabledRefkey,
|
|
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
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
exports.ReactOptimizedBuiltin = ReactOptimizedBuiltin;
|
|
@@ -1,2 +1,48 @@
|
|
|
1
|
-
import{createComponent
|
|
1
|
+
import { createComponent, createIntrinsic, mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import defu from "defu";
|
|
3
|
+
import { Show, code, splitProps } from "@alloy-js/core";
|
|
4
|
+
import { FunctionDeclaration } from "@alloy-js/typescript";
|
|
5
|
+
import { refkey } from "@powerlines/plugin-alloy/helpers/refkey";
|
|
6
|
+
import { BuiltinFile } from "@powerlines/plugin-alloy/typescript/components/builtin-file";
|
|
7
|
+
import { TSDoc, TSDocLink, TSDocReturns } from "@powerlines/plugin-alloy/typescript/components/tsdoc";
|
|
8
|
+
|
|
9
|
+
//#region src/components/react-optimized.tsx
|
|
10
|
+
const isOptimizationEnabledRefkey = refkey("isOptimizationEnabled");
|
|
11
|
+
/**
|
|
12
|
+
* Generates the `react/optimized` builtin module for the Powerlines project.
|
|
13
|
+
*/
|
|
14
|
+
function ReactOptimizedBuiltin(props) {
|
|
15
|
+
const [{ override }, rest] = splitProps(props, ["override"]);
|
|
16
|
+
return createComponent(BuiltinFile, mergeProps(rest, {
|
|
17
|
+
id: "react/optimized",
|
|
18
|
+
description: "A built-in module to provide access to environment configuration to determine React optimizations.",
|
|
19
|
+
get builtinImports() {
|
|
20
|
+
return defu({ env: ["env", "isDevelopment"] }, rest.builtinImports ?? {});
|
|
21
|
+
},
|
|
22
|
+
get children() {
|
|
23
|
+
return [createComponent(TSDoc, {
|
|
24
|
+
heading: "A gating function to determine if the optimized [React compiler](https://react.dev/reference/react-compiler) source code should be used.",
|
|
25
|
+
get children() {
|
|
26
|
+
return [createComponent(TSDocLink, { children: `https://react.dev/reference/react-compiler/gating` }), createComponent(TSDocReturns, { children: `A boolean indicating if the React compiler's optimizations should be used.` })];
|
|
27
|
+
}
|
|
28
|
+
}), createComponent(FunctionDeclaration, {
|
|
29
|
+
refkey: isOptimizationEnabledRefkey,
|
|
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
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
export { ReactOptimizedBuiltin };
|
|
2
48
|
//# sourceMappingURL=react-optimized.mjs.map
|
|
@@ -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":";;;;;;;;;AAyBA,MAAM,8BAAC,OAAA,wBAAA;;;;AAKP,SAAgB,sBAAO,OAAA;UAEvB,YACE,QAAA,WAAgB,OAAA,CAAA,WAAA,CAAA;AAChB,QAAG,gBAAA,aAAA,WAAA,MAAA;EACH,IAAA;EACA,aAAW;EACb,IAAA,iBAAA;iBAEM,KAAA,CAAA,OAAA,gBAA8B;;EAGjC,IAAA,WAAe;AAChB,UAAA,CAAA,gBAAA,OAAA;IACK,SAAS;IACR,IAAG,WAAY;0CAEd,UAAA,qDACJ,CAAA,EAAA,gBAAA,cAAA,EACK,UAAI,8EACJ,CAAA,CAAA;;IAEJ,CAAA,EAAA,gBAAoB,qBAAA;IAClB,QAAQ;IACR,OAAK;IACL,UAAA;IACD,MAAM;IACL,YAAU;IACV,IAAI,WAAQ;AACV,YAAA,CAAA,gBAAS,MAAA;MACV,MAAA,aAAY;MACT,UAAU,IAAA;MACZ,UAAY,IAAA,UAAA,SAAA;MACd,CAAA,EAAK,gBAAA,OAAA,EAAA,CAAA,CAAA;;IAEN,CAAC,CAAA;;EAEL,CAAC,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1,105 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value
|
|
1
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } });
|
|
2
|
+
const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
3
|
+
const require_components_react_optimized = require('./components/react-optimized.cjs');
|
|
4
|
+
require('./components/index.cjs');
|
|
5
|
+
let _alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
|
|
6
|
+
let _powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
7
|
+
let _powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
|
|
8
|
+
let _powerlines_plugin_babel = require("@powerlines/plugin-babel");
|
|
9
|
+
_powerlines_plugin_babel = require_runtime.__toESM(_powerlines_plugin_babel);
|
|
10
|
+
let _powerlines_plugin_env = require("@powerlines/plugin-env");
|
|
11
|
+
_powerlines_plugin_env = require_runtime.__toESM(_powerlines_plugin_env);
|
|
12
|
+
let _vitejs_plugin_react = require("@vitejs/plugin-react");
|
|
13
|
+
_vitejs_plugin_react = require_runtime.__toESM(_vitejs_plugin_react);
|
|
14
|
+
let defu = require("defu");
|
|
15
|
+
defu = require_runtime.__toESM(defu);
|
|
16
|
+
let powerlines_typescript = require("powerlines/typescript");
|
|
17
|
+
|
|
18
|
+
//#region src/index.tsx
|
|
19
|
+
/**
|
|
20
|
+
* A package containing a Powerlines plugin for building a React application.
|
|
21
|
+
*/
|
|
22
|
+
const plugin = (options = {}) => {
|
|
23
|
+
return [
|
|
24
|
+
(0, _powerlines_plugin_babel.default)(options.babel),
|
|
25
|
+
(0, _powerlines_plugin_env.default)(options.env),
|
|
26
|
+
{
|
|
27
|
+
name: "react",
|
|
28
|
+
config() {
|
|
29
|
+
return (0, defu.default)({ react: options }, { react: { jsxImportSource: this.tsconfig.tsconfigJson.compilerOptions?.jsxImportSource } }, { react: {
|
|
30
|
+
jsxRuntime: "automatic",
|
|
31
|
+
jsxImportSource: "react",
|
|
32
|
+
compiler: {
|
|
33
|
+
target: "19",
|
|
34
|
+
compilationMode: "infer",
|
|
35
|
+
gating: {
|
|
36
|
+
source: `${this.config.framework}:react/optimized`,
|
|
37
|
+
importSpecifierName: "isOptimizationEnabled"
|
|
38
|
+
},
|
|
39
|
+
enableReanimatedCheck: true,
|
|
40
|
+
logger: { logEvent: (filename, event) => {
|
|
41
|
+
this.logger.log(event.kind === "CompileSuccess" || event.kind === "AutoDepsEligible" || event.kind === "AutoDepsDecorations" ? "info" : event.kind === "CompileSkip" || event.kind === "CompileDiagnostic" ? "debug" : event.kind === "Timing" ? "trace" : "error", `(${filename}) ${event.kind === "CompileSuccess" ? `React Compiler Success` : event.kind === "AutoDepsEligible" ? `React AutoDeps Eligible - ${event.depArrayLoc.identifierName || "No identifier"}` : event.kind === "AutoDepsDecorations" ? `React AutoDeps Decorations - ${event.decorations.filter((dec) => dec.identifierName).map((dec) => dec.identifierName).join(", ")}` : event.kind === "CompileSkip" ? `React Compile Skip - ${event.reason}` : event.kind === "CompileDiagnostic" ? `React Compile Diagnostic - (Category: ${event.detail.category}) ${event.detail.reason}${event.detail.description ? `\n${event.detail.description}` : ""}` : event.kind === "Timing" ? `React ${event.measurement.entryType} Timing (${event.measurement.name}) - ${event.measurement.duration}ms` : `React Compiler Error - ${event.fnLoc?.identifierName || "unknown location"}`}`);
|
|
42
|
+
} }
|
|
43
|
+
}
|
|
44
|
+
} });
|
|
45
|
+
},
|
|
46
|
+
configResolved() {
|
|
47
|
+
this.dependencies.react = "^19.2.3";
|
|
48
|
+
this.dependencies["react-dom"] = "^19.2.3";
|
|
49
|
+
this.devDependencies["@types/react"] = "^19.2.3";
|
|
50
|
+
this.devDependencies["@types/react-dom"] = "^19.2.3";
|
|
51
|
+
if (this.config.react.compiler !== false) {
|
|
52
|
+
this.config.babel ??= {};
|
|
53
|
+
this.config.babel.plugins ??= [];
|
|
54
|
+
this.config.babel.plugins.push(["babel-plugin-react-compiler", this.config.react.compiler ?? {}]);
|
|
55
|
+
}
|
|
56
|
+
this.tsconfig.tsconfigJson.compilerOptions ??= {};
|
|
57
|
+
this.tsconfig.tsconfigJson.compilerOptions.lib ??= [];
|
|
58
|
+
this.tsconfig.tsconfigJson.compilerOptions.module ??= "esnext";
|
|
59
|
+
this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource = this.config.react.jsxImportSource;
|
|
60
|
+
if (this.tsconfig.options.jsxImportSource === "react") this.tsconfig.tsconfigJson.compilerOptions.jsx ??= "react-jsx";
|
|
61
|
+
else this.tsconfig.tsconfigJson.compilerOptions.jsx ??= "preserve";
|
|
62
|
+
if (this.environment.consumer === "client") {
|
|
63
|
+
if (!(0, powerlines_typescript.isMatchFound)("dom", this.tsconfig.tsconfigJson.compilerOptions.lib)) this.tsconfig.tsconfigJson.compilerOptions.lib.push("DOM");
|
|
64
|
+
if (!(0, powerlines_typescript.isMatchFound)("dom.iterable", this.tsconfig.tsconfigJson.compilerOptions.lib)) this.tsconfig.tsconfigJson.compilerOptions.lib.push("DOM.Iterable");
|
|
65
|
+
}
|
|
66
|
+
if (!(0, powerlines_typescript.isMatchFound)("esnext", this.tsconfig.tsconfigJson.compilerOptions.lib)) this.tsconfig.tsconfigJson.compilerOptions.lib.push("ESNext");
|
|
67
|
+
if (this.tsconfig.options.resolveJsonModule !== true) this.tsconfig.tsconfigJson.compilerOptions.resolveJsonModule = true;
|
|
68
|
+
if (this.config.vite) {
|
|
69
|
+
this.tsconfig.tsconfigJson.compilerOptions.types ??= [];
|
|
70
|
+
if (!(0, powerlines_typescript.isMatchFound)("vite/client", this.tsconfig.tsconfigJson.compilerOptions.types)) this.tsconfig.tsconfigJson.compilerOptions.types.push("vite/client");
|
|
71
|
+
const viteBuildConfig = this.config.vite;
|
|
72
|
+
viteBuildConfig.build ??= {};
|
|
73
|
+
viteBuildConfig.build.target = "chrome95";
|
|
74
|
+
viteBuildConfig.plugins ??= [];
|
|
75
|
+
viteBuildConfig.plugins.unshift((0, _vitejs_plugin_react.default)({
|
|
76
|
+
babel: this.config.babel,
|
|
77
|
+
jsxImportSource: this.config.react.jsxImportSource,
|
|
78
|
+
jsxRuntime: this.config.react.jsxRuntime,
|
|
79
|
+
reactRefreshHost: this.config.react.reactRefreshHost
|
|
80
|
+
}));
|
|
81
|
+
}
|
|
82
|
+
if (this.env?.types?.env && !this.env.types.env.hasProperty("DISABLE_REACT_COMPILER")) this.env.types.env.addProperty({
|
|
83
|
+
name: "DISABLE_REACT_COMPILER",
|
|
84
|
+
optional: true,
|
|
85
|
+
readonly: true,
|
|
86
|
+
description: "Disables the React compiler optimizations.",
|
|
87
|
+
visibility: _powerlines_deepkit_vendor_type.ReflectionVisibility.public,
|
|
88
|
+
type: { kind: _powerlines_deepkit_vendor_type.ReflectionKind.boolean },
|
|
89
|
+
default: false
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
async prepare() {
|
|
93
|
+
const _self$ = this;
|
|
94
|
+
return (0, _powerlines_plugin_alloy_render.render)(this, (0, _alloy_js_core_jsx_runtime.createComponent)(require_components_react_optimized.ReactOptimizedBuiltin, { get override() {
|
|
95
|
+
return _self$.config.react.compiler === false ? false : void 0;
|
|
96
|
+
} }));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
];
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
//#endregion
|
|
103
|
+
exports.ReactOptimizedBuiltin = require_components_react_optimized.ReactOptimizedBuiltin;
|
|
104
|
+
exports.default = plugin;
|
|
105
|
+
exports.plugin = plugin;
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,98 @@
|
|
|
1
|
-
import{ReactOptimizedBuiltin
|
|
1
|
+
import { ReactOptimizedBuiltin } from "./components/react-optimized.mjs";
|
|
2
|
+
import "./components/index.mjs";
|
|
3
|
+
import { createComponent } from "@alloy-js/core/jsx-runtime";
|
|
4
|
+
import { ReflectionKind, ReflectionVisibility } from "@powerlines/deepkit/vendor/type";
|
|
5
|
+
import { render } from "@powerlines/plugin-alloy/render";
|
|
6
|
+
import babel from "@powerlines/plugin-babel";
|
|
7
|
+
import env from "@powerlines/plugin-env";
|
|
8
|
+
import viteReactPlugin from "@vitejs/plugin-react";
|
|
9
|
+
import defu from "defu";
|
|
10
|
+
import { isMatchFound } from "powerlines/typescript";
|
|
11
|
+
|
|
12
|
+
//#region src/index.tsx
|
|
13
|
+
/**
|
|
14
|
+
* A package containing a Powerlines plugin for building a React application.
|
|
15
|
+
*/
|
|
16
|
+
const plugin = (options = {}) => {
|
|
17
|
+
return [
|
|
18
|
+
babel(options.babel),
|
|
19
|
+
env(options.env),
|
|
20
|
+
{
|
|
21
|
+
name: "react",
|
|
22
|
+
config() {
|
|
23
|
+
return defu({ react: options }, { react: { jsxImportSource: this.tsconfig.tsconfigJson.compilerOptions?.jsxImportSource } }, { react: {
|
|
24
|
+
jsxRuntime: "automatic",
|
|
25
|
+
jsxImportSource: "react",
|
|
26
|
+
compiler: {
|
|
27
|
+
target: "19",
|
|
28
|
+
compilationMode: "infer",
|
|
29
|
+
gating: {
|
|
30
|
+
source: `${this.config.framework}:react/optimized`,
|
|
31
|
+
importSpecifierName: "isOptimizationEnabled"
|
|
32
|
+
},
|
|
33
|
+
enableReanimatedCheck: true,
|
|
34
|
+
logger: { logEvent: (filename, event) => {
|
|
35
|
+
this.logger.log(event.kind === "CompileSuccess" || event.kind === "AutoDepsEligible" || event.kind === "AutoDepsDecorations" ? "info" : event.kind === "CompileSkip" || event.kind === "CompileDiagnostic" ? "debug" : event.kind === "Timing" ? "trace" : "error", `(${filename}) ${event.kind === "CompileSuccess" ? `React Compiler Success` : event.kind === "AutoDepsEligible" ? `React AutoDeps Eligible - ${event.depArrayLoc.identifierName || "No identifier"}` : event.kind === "AutoDepsDecorations" ? `React AutoDeps Decorations - ${event.decorations.filter((dec) => dec.identifierName).map((dec) => dec.identifierName).join(", ")}` : event.kind === "CompileSkip" ? `React Compile Skip - ${event.reason}` : event.kind === "CompileDiagnostic" ? `React Compile Diagnostic - (Category: ${event.detail.category}) ${event.detail.reason}${event.detail.description ? `\n${event.detail.description}` : ""}` : event.kind === "Timing" ? `React ${event.measurement.entryType} Timing (${event.measurement.name}) - ${event.measurement.duration}ms` : `React Compiler Error - ${event.fnLoc?.identifierName || "unknown location"}`}`);
|
|
36
|
+
} }
|
|
37
|
+
}
|
|
38
|
+
} });
|
|
39
|
+
},
|
|
40
|
+
configResolved() {
|
|
41
|
+
this.dependencies.react = "^19.2.3";
|
|
42
|
+
this.dependencies["react-dom"] = "^19.2.3";
|
|
43
|
+
this.devDependencies["@types/react"] = "^19.2.3";
|
|
44
|
+
this.devDependencies["@types/react-dom"] = "^19.2.3";
|
|
45
|
+
if (this.config.react.compiler !== false) {
|
|
46
|
+
this.config.babel ??= {};
|
|
47
|
+
this.config.babel.plugins ??= [];
|
|
48
|
+
this.config.babel.plugins.push(["babel-plugin-react-compiler", this.config.react.compiler ?? {}]);
|
|
49
|
+
}
|
|
50
|
+
this.tsconfig.tsconfigJson.compilerOptions ??= {};
|
|
51
|
+
this.tsconfig.tsconfigJson.compilerOptions.lib ??= [];
|
|
52
|
+
this.tsconfig.tsconfigJson.compilerOptions.module ??= "esnext";
|
|
53
|
+
this.tsconfig.tsconfigJson.compilerOptions.jsxImportSource = this.config.react.jsxImportSource;
|
|
54
|
+
if (this.tsconfig.options.jsxImportSource === "react") this.tsconfig.tsconfigJson.compilerOptions.jsx ??= "react-jsx";
|
|
55
|
+
else this.tsconfig.tsconfigJson.compilerOptions.jsx ??= "preserve";
|
|
56
|
+
if (this.environment.consumer === "client") {
|
|
57
|
+
if (!isMatchFound("dom", this.tsconfig.tsconfigJson.compilerOptions.lib)) this.tsconfig.tsconfigJson.compilerOptions.lib.push("DOM");
|
|
58
|
+
if (!isMatchFound("dom.iterable", this.tsconfig.tsconfigJson.compilerOptions.lib)) this.tsconfig.tsconfigJson.compilerOptions.lib.push("DOM.Iterable");
|
|
59
|
+
}
|
|
60
|
+
if (!isMatchFound("esnext", this.tsconfig.tsconfigJson.compilerOptions.lib)) this.tsconfig.tsconfigJson.compilerOptions.lib.push("ESNext");
|
|
61
|
+
if (this.tsconfig.options.resolveJsonModule !== true) this.tsconfig.tsconfigJson.compilerOptions.resolveJsonModule = true;
|
|
62
|
+
if (this.config.vite) {
|
|
63
|
+
this.tsconfig.tsconfigJson.compilerOptions.types ??= [];
|
|
64
|
+
if (!isMatchFound("vite/client", this.tsconfig.tsconfigJson.compilerOptions.types)) this.tsconfig.tsconfigJson.compilerOptions.types.push("vite/client");
|
|
65
|
+
const viteBuildConfig = this.config.vite;
|
|
66
|
+
viteBuildConfig.build ??= {};
|
|
67
|
+
viteBuildConfig.build.target = "chrome95";
|
|
68
|
+
viteBuildConfig.plugins ??= [];
|
|
69
|
+
viteBuildConfig.plugins.unshift(viteReactPlugin({
|
|
70
|
+
babel: this.config.babel,
|
|
71
|
+
jsxImportSource: this.config.react.jsxImportSource,
|
|
72
|
+
jsxRuntime: this.config.react.jsxRuntime,
|
|
73
|
+
reactRefreshHost: this.config.react.reactRefreshHost
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
if (this.env?.types?.env && !this.env.types.env.hasProperty("DISABLE_REACT_COMPILER")) this.env.types.env.addProperty({
|
|
77
|
+
name: "DISABLE_REACT_COMPILER",
|
|
78
|
+
optional: true,
|
|
79
|
+
readonly: true,
|
|
80
|
+
description: "Disables the React compiler optimizations.",
|
|
81
|
+
visibility: ReflectionVisibility.public,
|
|
82
|
+
type: { kind: ReflectionKind.boolean },
|
|
83
|
+
default: false
|
|
84
|
+
});
|
|
85
|
+
},
|
|
86
|
+
async prepare() {
|
|
87
|
+
const _self$ = this;
|
|
88
|
+
return render(this, createComponent(ReactOptimizedBuiltin, { get override() {
|
|
89
|
+
return _self$.config.react.compiler === false ? false : void 0;
|
|
90
|
+
} }));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
];
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
//#endregion
|
|
97
|
+
export { ReactOptimizedBuiltin, plugin as default, plugin };
|
|
2
98
|
//# sourceMappingURL=index.mjs.map
|
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 viteReactPlugin, { BabelOptions } 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\";\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.logger.log(\n event.kind === \"CompileSuccess\" ||\n event.kind === \"AutoDepsEligible\" ||\n event.kind === \"AutoDepsDecorations\"\n ? \"info\"\n : event.kind === \"CompileSkip\" ||\n event.kind === \"CompileDiagnostic\"\n ? \"debug\"\n : event.kind === \"Timing\"\n ? \"trace\"\n : \"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 ${\n event.measurement.entryType\n } Timing (${event.measurement.name}) - ${\n event.measurement.duration\n }ms`\n : `React Compiler Error - ${\n event.fnLoc?.identifierName ||\n \"unknown location\"\n }`\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)\n .babel as BabelOptions,\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":"ofAkCA,MAAa,GAAI,EAAW,EAAA,GACnB,CAAA,EAAO,EAAO,MAAA,CAAA,EAAA,EAAA,IAAA,CAAA,cAEvB,QAAQ,CAC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AAC,KAAI,IAAK,MAAE,IAAA,YAAA,yBAAA,EACtC,KAAK,IAAI,MAAM,IAAI,YAAY,CAC7B,KAAM,yBACN,SAAU,GACV,SAAU,GACV,YAAa,6CACb,WAAY,EAAkB,OAC9B,KAAM,CACJ,KAAM,EAAe,QACtB,CACD,QAAS,GACV,CAAC,EAGN,MAAM,SAAO,CACX,IAAI,EAAA,KACJ,OAAG,EAAA,KAAA,EAAA,EAAA,CACF,IAAA,UAAA,CACD,OAAA,EAAiB,OAAA,MAAA,WAAA,GAAA,GAAA,IAAA,IAEhB,CAAC,CAAA,EAEL,CAAC"}
|
|
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 viteReactPlugin, { BabelOptions } 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\";\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.logger.log(\n event.kind === \"CompileSuccess\" ||\n event.kind === \"AutoDepsEligible\" ||\n event.kind === \"AutoDepsDecorations\"\n ? \"info\"\n : event.kind === \"CompileSkip\" ||\n event.kind === \"CompileDiagnostic\"\n ? \"debug\"\n : event.kind === \"Timing\"\n ? \"trace\"\n : \"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 ${\n event.measurement.entryType\n } Timing (${event.measurement.name}) - ${\n event.measurement.duration\n }ms`\n : `React Compiler Error - ${\n event.fnLoc?.identifierName ||\n \"unknown location\"\n }`\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)\n .babel as BabelOptions,\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":";;;;;;;;;;;;;;;AAkCA,MAAa,UAAI,UAAW,EAAA,KAAA;AAC5B,QAAS;EAAA,MAAO,QAAO,MAAA;EAAA,IAAA,QAAA,IAAA;EAAA;;GAEvB,SAAQ;AACN,WAAU,KAAM,EACd,OAAQ,SACV,EAAA,EACF,OAAA,gFAEE,EACG,EAAA,EACH,OAAA;KACK,YAAe;KACZ,iBAAS;KAClB,UAAA;MACU,QAAA;MACN,iBAAA;MACI,QAAA;OACC,QAAQ,GAAM,KAAA,OAAA,UAAA;OAChB,qBAAY;OAChB;MACQ,uBAAO;MACP,QAAG,EACD,WAAK,UAAA,UAAA;AACT,YAAA,OAAA,IA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,MAAM,UAAO;IACX,MAAI,SAAA;AACJ,WAAG,OAAA,MAAA,gBAAA,uBAAA,EACF,IAAA,WAAA;AACD,YAAA,OAAiB,OAAA,MAAA,aAAA,QAAA,QAAA;OAEhB,CAAC,CAAA;;GAEL;EAAC"}
|
package/dist/types/env.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export { };
|
package/dist/types/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export { };
|
package/dist/types/plugin.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{};
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.519",
|
|
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": "8.0.0-rc.4",
|
|
144
|
-
"@powerlines/plugin-vite": "^0.14.
|
|
145
|
-
"@powerlines/plugin-alloy": "^0.26.
|
|
146
|
-
"@powerlines/plugin-babel": "^0.12.
|
|
147
|
-
"@powerlines/plugin-env": "^0.16.
|
|
144
|
+
"@powerlines/plugin-vite": "^0.14.452",
|
|
145
|
+
"@powerlines/plugin-alloy": "^0.26.77",
|
|
146
|
+
"@powerlines/plugin-babel": "^0.12.451",
|
|
147
|
+
"@powerlines/plugin-env": "^0.16.184",
|
|
148
148
|
"@storm-software/config-tools": "^1.190.1",
|
|
149
149
|
"@stryke/cli": "^0.13.42",
|
|
150
150
|
"@stryke/convert": "^0.7.3",
|
|
@@ -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.7",
|
|
156
|
-
"powerlines": "^0.46.
|
|
156
|
+
"powerlines": "^0.46.5"
|
|
157
157
|
},
|
|
158
158
|
"devDependencies": {
|
|
159
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
159
|
+
"@powerlines/plugin-plugin": "^0.12.409",
|
|
160
160
|
"@types/node": "^25.6.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": "9af888c54e58a82744cc334a6b80da52429fa0ac"
|
|
167
167
|
}
|