create-krispya 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +73 -51
- package/dist/cli.d.cts +1 -1
- package/dist/cli.d.mts +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.mjs +65 -43
- package/dist/index.cjs +3 -1
- package/dist/index.d.cts +7 -3
- package/dist/index.d.mts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.mjs +1 -1
- package/dist/shared/{create-krispya.to8NBxeJ.d.ts → create-krispya.CcQTepKu.d.cts} +2 -1
- package/dist/shared/{create-krispya.to8NBxeJ.d.cts → create-krispya.CcQTepKu.d.mts} +2 -1
- package/dist/shared/{create-krispya.to8NBxeJ.d.mts → create-krispya.CcQTepKu.d.ts} +2 -1
- package/dist/shared/{create-krispya.DKKVmsqH.mjs → create-krispya.DZWMfM2v.mjs} +135 -67
- package/dist/shared/{create-krispya.DTHeUlq4.cjs → create-krispya.FNrYi_5V.cjs} +137 -66
- package/package.json +1 -1
|
@@ -183,6 +183,10 @@ function getLanguageFromTemplate(template) {
|
|
|
183
183
|
function getBaseTemplate(template) {
|
|
184
184
|
return template.replace("-js", "");
|
|
185
185
|
}
|
|
186
|
+
function shouldEnableReactCompiler(options) {
|
|
187
|
+
const template = options.template ?? "vanilla";
|
|
188
|
+
return getBaseTemplate(template) === "react" && (options.projectType ?? "app") === "app";
|
|
189
|
+
}
|
|
186
190
|
|
|
187
191
|
function unique(...array) {
|
|
188
192
|
const set = /* @__PURE__ */ new Set();
|
|
@@ -198,9 +202,7 @@ function merge(target, modification) {
|
|
|
198
202
|
const targetLabel = JSON.stringify(target);
|
|
199
203
|
const modificationLabel = JSON.stringify(modification);
|
|
200
204
|
if (modification == null) {
|
|
201
|
-
throw new Error(
|
|
202
|
-
`Cannot merge "${modificationLabel}" modification into target "${targetLabel}"`
|
|
203
|
-
);
|
|
205
|
+
throw new Error(`Cannot merge "${modificationLabel}" modification into target "${targetLabel}"`);
|
|
204
206
|
}
|
|
205
207
|
if (target == null) {
|
|
206
208
|
return modification;
|
|
@@ -447,16 +449,41 @@ function compareNumericSemver(a, b) {
|
|
|
447
449
|
}
|
|
448
450
|
return 0;
|
|
449
451
|
}
|
|
452
|
+
function getLatestMatchingMajorVersion(versions, majorVersion) {
|
|
453
|
+
return [...versions].filter((version) => version.split(".")[0] === majorVersion).sort((a, b) => compareNumericSemver(b, a))[0];
|
|
454
|
+
}
|
|
450
455
|
async function getLatestNpmMajorVersion(packageName, majorVersion, fallback) {
|
|
451
456
|
try {
|
|
452
457
|
const response = await fetch(`https://registry.npmjs.org/${packageName}`);
|
|
453
458
|
const data = await response.json();
|
|
454
|
-
const latestMatchingVersion =
|
|
459
|
+
const latestMatchingVersion = getLatestMatchingMajorVersion(
|
|
460
|
+
Object.keys(data.versions ?? {}),
|
|
461
|
+
majorVersion
|
|
462
|
+
);
|
|
455
463
|
return latestMatchingVersion ?? fallback;
|
|
456
464
|
} catch {
|
|
457
465
|
return fallback;
|
|
458
466
|
}
|
|
459
467
|
}
|
|
468
|
+
async function getLatestNpmMajorVersionAtOrBelow(packageName, majorVersion, fallback) {
|
|
469
|
+
try {
|
|
470
|
+
const response = await fetch(`https://registry.npmjs.org/${packageName}`);
|
|
471
|
+
const data = await response.json();
|
|
472
|
+
const versions = Object.keys(data.versions ?? {});
|
|
473
|
+
const requestedMajor = Number.parseInt(majorVersion, 10);
|
|
474
|
+
if (Number.isFinite(requestedMajor)) {
|
|
475
|
+
for (let major = requestedMajor; major >= 0; major -= 1) {
|
|
476
|
+
const latestMatchingVersion = getLatestMatchingMajorVersion(versions, String(major));
|
|
477
|
+
if (latestMatchingVersion != null) {
|
|
478
|
+
return latestMatchingVersion;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
return fallback;
|
|
483
|
+
} catch {
|
|
484
|
+
return fallback;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
460
487
|
async function getLatestPnpmVersion() {
|
|
461
488
|
return getLatestNpmVersion("pnpm", "10.11.0");
|
|
462
489
|
}
|
|
@@ -503,6 +530,7 @@ function parseWorkspaceYamlContent(content) {
|
|
|
503
530
|
}
|
|
504
531
|
|
|
505
532
|
const PACKAGE_VERSION_DEFINITIONS = {
|
|
533
|
+
"@babel/core": { fallbackVersion: "7.29.0" },
|
|
506
534
|
"@biomejs/biome": { fallbackVersion: "2.0.0" },
|
|
507
535
|
"@react-three/drei": { fallbackVersion: "10.0.0" },
|
|
508
536
|
"@react-three/fiber": { fallbackVersion: "9.0.0" },
|
|
@@ -512,16 +540,20 @@ const PACKAGE_VERSION_DEFINITIONS = {
|
|
|
512
540
|
"@react-three/rapier": { fallbackVersion: "2.1.0" },
|
|
513
541
|
"@react-three/uikit": { fallbackVersion: "0.8.15" },
|
|
514
542
|
"@react-three/xr": { fallbackVersion: "6.6.16" },
|
|
543
|
+
"@rolldown/plugin-babel": { fallbackVersion: "0.2.3" },
|
|
515
544
|
"@testing-library/dom": { fallbackVersion: "10.4.0" },
|
|
516
545
|
"@testing-library/react": { fallbackVersion: "16.2.0" },
|
|
546
|
+
"@types/babel__core": { fallbackVersion: "7.20.5" },
|
|
547
|
+
"@types/node": { fallbackVersion: "25.3.5" },
|
|
517
548
|
"@types/react": { fallbackVersion: "19.0.0" },
|
|
518
549
|
"@types/react-dom": { fallbackVersion: "19.0.0" },
|
|
519
550
|
"@types/three": { fallbackVersion: "0.175.0", prefix: "~" },
|
|
520
551
|
"@vitejs/plugin-basic-ssl": { fallbackVersion: "2.0.0" },
|
|
521
|
-
"@vitejs/plugin-react": { fallbackVersion: "
|
|
552
|
+
"@vitejs/plugin-react": { fallbackVersion: "6.0.1" },
|
|
522
553
|
"@viverse/cli": { fallbackVersion: "0.9.5-beta.8" },
|
|
523
554
|
eslint: { fallbackVersion: "9.17.0" },
|
|
524
555
|
"eslint-plugin-react-hooks": { fallbackVersion: "5.1.0" },
|
|
556
|
+
"babel-plugin-react-compiler": { fallbackVersion: "1.0.0" },
|
|
525
557
|
jsdom: { fallbackVersion: "26.0.0" },
|
|
526
558
|
koota: { fallbackVersion: "0.4.0" },
|
|
527
559
|
leva: { fallbackVersion: "0.10.0" },
|
|
@@ -536,7 +568,7 @@ const PACKAGE_VERSION_DEFINITIONS = {
|
|
|
536
568
|
typescript: { fallbackVersion: "5.9.3" },
|
|
537
569
|
"typescript-eslint": { fallbackVersion: "8.18.0" },
|
|
538
570
|
unbuild: { fallbackVersion: "3.5.0" },
|
|
539
|
-
vite: { fallbackVersion: "
|
|
571
|
+
vite: { fallbackVersion: "8.0.12" },
|
|
540
572
|
vitest: { fallbackVersion: "4.0.0" },
|
|
541
573
|
zustand: { fallbackVersion: "5.0.3" }
|
|
542
574
|
};
|
|
@@ -630,17 +662,12 @@ async function resolveEngine(options) {
|
|
|
630
662
|
}
|
|
631
663
|
return engine;
|
|
632
664
|
}
|
|
633
|
-
function formatNodeTypesVersion(versions = {},
|
|
665
|
+
function formatNodeTypesVersion(versions = {}, _engine) {
|
|
634
666
|
const resolvedVersion = versions["@types/node"];
|
|
635
667
|
if (resolvedVersion != null) {
|
|
636
668
|
return `^${resolvedVersion}`;
|
|
637
669
|
}
|
|
638
|
-
|
|
639
|
-
if (engineSpec.name === "node" && engineSpec.version) {
|
|
640
|
-
const majorVersion = engineSpec.version.split(".")[0];
|
|
641
|
-
return `^${majorVersion}.0.0`;
|
|
642
|
-
}
|
|
643
|
-
return "^22.0.0";
|
|
670
|
+
return formatResolvedPackageVersion(versions, "@types/node");
|
|
644
671
|
}
|
|
645
672
|
async function resolveNodeTypesVersion(engine, versions = {}) {
|
|
646
673
|
if (versions["@types/node"] != null) {
|
|
@@ -652,7 +679,11 @@ async function resolveNodeTypesVersion(engine, versions = {}) {
|
|
|
652
679
|
}
|
|
653
680
|
const nodeVersion = engineSpec.version ?? await getLatestNodeVersion();
|
|
654
681
|
const majorVersion = nodeVersion.split(".")[0];
|
|
655
|
-
return
|
|
682
|
+
return getLatestNpmMajorVersionAtOrBelow(
|
|
683
|
+
"@types/node",
|
|
684
|
+
majorVersion,
|
|
685
|
+
getPackageFallbackVersion("@types/node")
|
|
686
|
+
);
|
|
656
687
|
}
|
|
657
688
|
async function resolvePackageVersions(packageNames, existingVersions = {}) {
|
|
658
689
|
const versions = { ...existingVersions };
|
|
@@ -707,6 +738,7 @@ function collectProjectPackageNames(options) {
|
|
|
707
738
|
const isReact = baseTemplate === "react" || baseTemplate === "r3f";
|
|
708
739
|
const isR3f = baseTemplate === "r3f";
|
|
709
740
|
const isTypescript = language === "typescript";
|
|
741
|
+
const useReactCompiler = shouldEnableReactCompiler(options);
|
|
710
742
|
const inWorkspace = options.workspaceRoot != null;
|
|
711
743
|
const testing = options.testing ?? (isLibrary ? "vitest" : "none");
|
|
712
744
|
const linter = options.linter ?? "oxlint";
|
|
@@ -728,10 +760,18 @@ function collectProjectPackageNames(options) {
|
|
|
728
760
|
addPackageName(packageNames, explicitVersions, "react");
|
|
729
761
|
addPackageName(packageNames, explicitVersions, "react-dom");
|
|
730
762
|
addPackageName(packageNames, explicitVersions, "@vitejs/plugin-react");
|
|
763
|
+
if (useReactCompiler) {
|
|
764
|
+
addPackageName(packageNames, explicitVersions, "@babel/core");
|
|
765
|
+
addPackageName(packageNames, explicitVersions, "@rolldown/plugin-babel");
|
|
766
|
+
addPackageName(packageNames, explicitVersions, "babel-plugin-react-compiler");
|
|
767
|
+
}
|
|
731
768
|
}
|
|
732
769
|
if (isTypescript) {
|
|
733
770
|
addPackageName(packageNames, explicitVersions, "@types/react");
|
|
734
771
|
addPackageName(packageNames, explicitVersions, "@types/react-dom");
|
|
772
|
+
if (useReactCompiler) {
|
|
773
|
+
addPackageName(packageNames, explicitVersions, "@types/babel__core");
|
|
774
|
+
}
|
|
735
775
|
}
|
|
736
776
|
}
|
|
737
777
|
if (isR3f) {
|
|
@@ -848,7 +888,7 @@ function renderTypescriptConfig(baseTemplateOrParams) {
|
|
|
848
888
|
const devDependencies = {};
|
|
849
889
|
assignResolvedPackageVersion(devDependencies, versions, "typescript");
|
|
850
890
|
if (getEngineName(engine) === "node") {
|
|
851
|
-
devDependencies["@types/node"] = formatNodeTypesVersion(versions
|
|
891
|
+
devDependencies["@types/node"] = formatNodeTypesVersion(versions);
|
|
852
892
|
} else {
|
|
853
893
|
devDependencies["@types/node"] = "^22.0.0";
|
|
854
894
|
}
|
|
@@ -880,10 +920,7 @@ function renderTypescriptConfig(baseTemplateOrParams) {
|
|
|
880
920
|
const tsConfig = {
|
|
881
921
|
$schema: "https://json.schemastore.org/tsconfig",
|
|
882
922
|
files: [],
|
|
883
|
-
references: [
|
|
884
|
-
{ path: "./.config/tsconfig.app.json" },
|
|
885
|
-
{ path: "./.config/tsconfig.node.json" }
|
|
886
|
-
]
|
|
923
|
+
references: [{ path: "./.config/tsconfig.app.json" }, { path: "./.config/tsconfig.node.json" }]
|
|
887
924
|
};
|
|
888
925
|
files["tsconfig.json"] = {
|
|
889
926
|
type: "text",
|
|
@@ -1147,10 +1184,7 @@ function renderPackageJson(params) {
|
|
|
1147
1184
|
const allDevDependencies = { ...devDependencies };
|
|
1148
1185
|
const engine = getEngineSpec(options.engine);
|
|
1149
1186
|
if (getEngineName(engine) === "node" && engine.version) {
|
|
1150
|
-
allDevDependencies["@types/node"] ??= formatNodeTypesVersion(
|
|
1151
|
-
options.versions,
|
|
1152
|
-
options.engine
|
|
1153
|
-
);
|
|
1187
|
+
allDevDependencies["@types/node"] ??= formatNodeTypesVersion(options.versions, options.engine);
|
|
1154
1188
|
}
|
|
1155
1189
|
packageJson.scripts = resolvedScripts;
|
|
1156
1190
|
packageJson.dependencies = sortKeys(allDependencies);
|
|
@@ -1251,13 +1285,14 @@ function renderReadme(params) {
|
|
|
1251
1285
|
} else if (isReact) {
|
|
1252
1286
|
architectureDesc = [
|
|
1253
1287
|
`- \`src/app.${jsxExt}\` defines the main application component`,
|
|
1254
|
-
`- \`src/
|
|
1288
|
+
`- \`src/main.${jsxExt}\` renders the React app into the DOM`,
|
|
1255
1289
|
`- \`tests/\` contains your test files`,
|
|
1256
1290
|
`- Static assets can be placed in the \`public\` folder`
|
|
1257
1291
|
];
|
|
1258
1292
|
} else {
|
|
1259
1293
|
architectureDesc = [
|
|
1260
|
-
`- \`app.${jsxExt}\` defines the main application component containing your 3D content`,
|
|
1294
|
+
`- \`src/app.${jsxExt}\` defines the main application component containing your 3D content`,
|
|
1295
|
+
`- \`src/main.${jsxExt}\` renders the React app into the DOM`,
|
|
1261
1296
|
`- Modify the content inside the \`<Canvas>\` component to change what is visible on screen`,
|
|
1262
1297
|
`- \`tests/\` contains your test files`,
|
|
1263
1298
|
`- Static assets can be placed in the \`public\` folder`
|
|
@@ -1295,9 +1330,9 @@ const htmlContent = `<!DOCTYPE html>
|
|
|
1295
1330
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
1296
1331
|
<title>$title</title>
|
|
1297
1332
|
</head>
|
|
1298
|
-
<body
|
|
1333
|
+
<body>
|
|
1334
|
+
<div id="root"></div>
|
|
1299
1335
|
<script type="module" src="$indexPath"><\/script>
|
|
1300
|
-
<div style="width: 100dvw; height: 100dvh; overflow: hidden;" id="root"></div>
|
|
1301
1336
|
</body>
|
|
1302
1337
|
</html>`;
|
|
1303
1338
|
const viteHtmlContent = `<!DOCTYPE html>
|
|
@@ -1314,6 +1349,7 @@ const viteHtmlContent = `<!DOCTYPE html>
|
|
|
1314
1349
|
</html>`;
|
|
1315
1350
|
const indexContent = `import { StrictMode } from 'react'
|
|
1316
1351
|
import { createRoot } from 'react-dom/client'
|
|
1352
|
+
import './index.css'
|
|
1317
1353
|
import { App } from './app.js'
|
|
1318
1354
|
|
|
1319
1355
|
createRoot(document.getElementById('root')!).render(
|
|
@@ -1321,28 +1357,31 @@ createRoot(document.getElementById('root')!).render(
|
|
|
1321
1357
|
<App />
|
|
1322
1358
|
</StrictMode>,
|
|
1323
1359
|
)`;
|
|
1324
|
-
const viteIndexContent = `import './
|
|
1360
|
+
const viteIndexContent = `import './index.css'
|
|
1325
1361
|
|
|
1326
1362
|
document.querySelector('#app')!.innerHTML = \`
|
|
1327
1363
|
<h1>Hello Vite!</h1>
|
|
1328
1364
|
<p>Edit src/main.ts and save to see HMR in action.</p>
|
|
1329
1365
|
\``;
|
|
1330
|
-
const viteStyleContent =
|
|
1331
|
-
font-family:
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1366
|
+
const viteStyleContent = `:root {
|
|
1367
|
+
font-family:
|
|
1368
|
+
system-ui,
|
|
1369
|
+
-apple-system,
|
|
1370
|
+
sans-serif;
|
|
1371
|
+
line-height: 1.5;
|
|
1372
|
+
font-weight: 400;
|
|
1337
1373
|
}
|
|
1338
1374
|
|
|
1339
|
-
|
|
1340
|
-
|
|
1375
|
+
*,
|
|
1376
|
+
*::before,
|
|
1377
|
+
*::after {
|
|
1378
|
+
box-sizing: border-box;
|
|
1341
1379
|
}
|
|
1342
1380
|
|
|
1343
|
-
|
|
1344
|
-
|
|
1381
|
+
body {
|
|
1382
|
+
margin: 0;
|
|
1345
1383
|
}`;
|
|
1384
|
+
const viteEnvContent = `/// <reference types="vite/client" />`;
|
|
1346
1385
|
|
|
1347
1386
|
function renderSourceFiles(params) {
|
|
1348
1387
|
const { name, baseTemplate, language, isLibrary, codeSnippets, replacements } = params;
|
|
@@ -1352,6 +1391,9 @@ function renderSourceFiles(params) {
|
|
|
1352
1391
|
const isVanilla = baseTemplate === "vanilla";
|
|
1353
1392
|
const isReact = baseTemplate === "react";
|
|
1354
1393
|
const isR3f = baseTemplate === "r3f";
|
|
1394
|
+
if (!isLibrary && language === "typescript") {
|
|
1395
|
+
files["src/vite-env.d.ts"] = { type: "text", content: viteEnvContent };
|
|
1396
|
+
}
|
|
1355
1397
|
if (isLibrary) {
|
|
1356
1398
|
const libExt = isReact || isR3f ? jsxExt : ext;
|
|
1357
1399
|
let libContent;
|
|
@@ -1385,12 +1427,19 @@ function renderSourceFiles(params) {
|
|
|
1385
1427
|
files[`src/index.${libExt}`] = { type: "text", content: libContent };
|
|
1386
1428
|
} else if (isVanilla) {
|
|
1387
1429
|
files[`src/main.${ext}`] = { type: "text", content: viteIndexContent };
|
|
1388
|
-
files["src/
|
|
1430
|
+
files["src/index.css"] = { type: "text", content: viteStyleContent };
|
|
1389
1431
|
const indexHtml = viteHtmlContent.replace("$indexPath", `./src/main.${ext}`).replace("$title", name);
|
|
1390
1432
|
files["index.html"] = { type: "text", content: indexHtml };
|
|
1391
1433
|
} else {
|
|
1392
|
-
files[`src/
|
|
1393
|
-
|
|
1434
|
+
files[`src/main.${jsxExt}`] = {
|
|
1435
|
+
type: "text",
|
|
1436
|
+
content: language === "typescript" ? indexContent : indexContent.replace(
|
|
1437
|
+
"document.getElementById('root')!",
|
|
1438
|
+
"document.getElementById('root')"
|
|
1439
|
+
)
|
|
1440
|
+
};
|
|
1441
|
+
files["src/index.css"] = { type: "text", content: viteStyleContent };
|
|
1442
|
+
const indexHtml = htmlContent.replace("$indexPath", `./src/main.${jsxExt}`).replace("$title", name);
|
|
1394
1443
|
files["index.html"] = { type: "text", content: indexHtml };
|
|
1395
1444
|
codeSnippets["dom-end"]?.reverse();
|
|
1396
1445
|
codeSnippets["global-end"]?.reverse();
|
|
@@ -1432,7 +1481,7 @@ function renderSourceFiles(params) {
|
|
|
1432
1481
|
for (const { search, replace } of replacements) {
|
|
1433
1482
|
appCode = appCode.replace(search, replace);
|
|
1434
1483
|
}
|
|
1435
|
-
files[`src/app
|
|
1484
|
+
files[`src/app.${jsxExt}`] = { type: "text", content: appCode };
|
|
1436
1485
|
}
|
|
1437
1486
|
return files;
|
|
1438
1487
|
}
|
|
@@ -1756,7 +1805,7 @@ function formatValue(value, indent) {
|
|
|
1756
1805
|
if (value.startsWith("$raw:")) {
|
|
1757
1806
|
return value.slice(5);
|
|
1758
1807
|
}
|
|
1759
|
-
return
|
|
1808
|
+
return `'${value.replaceAll("\\", "\\\\").replaceAll("'", "\\'")}'`;
|
|
1760
1809
|
}
|
|
1761
1810
|
if (typeof value === "number" || typeof value === "boolean") {
|
|
1762
1811
|
return String(value);
|
|
@@ -1764,8 +1813,17 @@ function formatValue(value, indent) {
|
|
|
1764
1813
|
if (value === null) {
|
|
1765
1814
|
return "null";
|
|
1766
1815
|
}
|
|
1816
|
+
if (value === void 0) {
|
|
1817
|
+
return "undefined";
|
|
1818
|
+
}
|
|
1819
|
+
if (typeof value === "bigint") {
|
|
1820
|
+
return value.toString();
|
|
1821
|
+
}
|
|
1767
1822
|
if (Array.isArray(value)) {
|
|
1768
1823
|
if (value.length === 0) return "[]";
|
|
1824
|
+
if (value.every((item) => item == null || typeof item !== "object")) {
|
|
1825
|
+
return `[${value.map((item) => formatValue(item, indent + 1)).join(", ")}]`;
|
|
1826
|
+
}
|
|
1769
1827
|
const items = value.map((v) => `${innerSpaces}${formatValue(v, indent + 1)}`);
|
|
1770
1828
|
return `[
|
|
1771
1829
|
${items.join(",\n")}
|
|
@@ -1775,22 +1833,22 @@ ${spaces}]`;
|
|
|
1775
1833
|
const entries = Object.entries(value);
|
|
1776
1834
|
if (entries.length === 0) return "{}";
|
|
1777
1835
|
const props = entries.map(
|
|
1778
|
-
([key, val]) => `${innerSpaces}${key}: ${formatValue(val, indent + 1)}
|
|
1836
|
+
([key, val]) => `${innerSpaces}${key}: ${formatValue(val, indent + 1)},`
|
|
1779
1837
|
);
|
|
1780
1838
|
return `{
|
|
1781
|
-
${props.join("
|
|
1839
|
+
${props.join("\n")}
|
|
1782
1840
|
${spaces}}`;
|
|
1783
1841
|
}
|
|
1784
|
-
|
|
1842
|
+
throw new TypeError(`Unsupported vite config value type: ${typeof value}`);
|
|
1785
1843
|
}
|
|
1786
1844
|
function renderViteConfig(params) {
|
|
1787
1845
|
const { viteConfig, codeSnippets } = params;
|
|
1788
1846
|
const configBody = formatValue(viteConfig, 0);
|
|
1789
1847
|
const viteConfigContent = [
|
|
1790
|
-
`import { defineConfig } from
|
|
1848
|
+
`import { defineConfig } from 'vite';`,
|
|
1791
1849
|
...codeSnippets["vite-config-import"] ?? [],
|
|
1792
1850
|
``,
|
|
1793
|
-
`export default defineConfig(${configBody})
|
|
1851
|
+
`export default defineConfig(${configBody});`,
|
|
1794
1852
|
``
|
|
1795
1853
|
].join("\n");
|
|
1796
1854
|
return { type: "text", content: viteConfigContent };
|
|
@@ -2264,7 +2322,7 @@ function renderMonorepo(params) {
|
|
|
2264
2322
|
const isPnpm = packageManager.name === "pnpm";
|
|
2265
2323
|
const devDependencies = {};
|
|
2266
2324
|
if (engine?.name === "node" && engine.version) {
|
|
2267
|
-
devDependencies["@types/node"] = formatNodeTypesVersion(versions
|
|
2325
|
+
devDependencies["@types/node"] = formatNodeTypesVersion(versions);
|
|
2268
2326
|
} else {
|
|
2269
2327
|
devDependencies["@types/node"] = "^22.0.0";
|
|
2270
2328
|
}
|
|
@@ -2999,16 +3057,10 @@ function generateProvidersModule(builder) {
|
|
|
2999
3057
|
const resolvedProviders = providers.map((provider) => providerDefs[provider]);
|
|
3000
3058
|
const providerProps = resolvedProviders.flatMap((provider) => provider.props || []);
|
|
3001
3059
|
const providerImports = resolvedProviders.flatMap((provider) => provider.import);
|
|
3002
|
-
const wrappedComponents = resolvedProviders.filter(
|
|
3003
|
-
|
|
3004
|
-
);
|
|
3005
|
-
const
|
|
3006
|
-
(provider) => provider.type === "inline-jsx"
|
|
3007
|
-
);
|
|
3008
|
-
const layoutEffects = resolvedProviders.filter(
|
|
3009
|
-
(provider) => provider.type === "layout-effect"
|
|
3010
|
-
);
|
|
3011
|
-
const declaredProps = providerProps.map((prop) => `${prop.declaredPropName} = ${prop.declaredPropDefaultValue}`).join(", ");
|
|
3060
|
+
const wrappedComponents = resolvedProviders.filter((provider) => provider.type === "wrapped-jsx");
|
|
3061
|
+
const inlineComponents = resolvedProviders.filter((provider) => provider.type === "inline-jsx");
|
|
3062
|
+
const layoutEffects = resolvedProviders.filter((provider) => provider.type === "layout-effect");
|
|
3063
|
+
const declaredProps = providerProps.map((prop) => `${prop.declaredPropName} = ${String(prop.declaredPropDefaultValue)}`).join(", ");
|
|
3012
3064
|
const declaredTypes = providerProps.map((prop) => `${prop.declaredPropName}?: ${prop.declaredPropType}`).join("; ");
|
|
3013
3065
|
const reactImports = ["type ReactNode"];
|
|
3014
3066
|
if (layoutEffects.length) {
|
|
@@ -3025,11 +3077,11 @@ ${jsdoc.split("\n").map((line) => ` * ${line}`).join("\n")}
|
|
|
3025
3077
|
${layoutEffects.length ? `
|
|
3026
3078
|
useLayoutEffect(() => {
|
|
3027
3079
|
${layoutEffects.map((effect) => effect.code).join("\n")}
|
|
3028
|
-
}, [${layoutEffects.map((effect) => effect.props?.[0]?.propValue)}]);
|
|
3080
|
+
}, [${layoutEffects.map((effect) => effect.props?.[0]?.propValue).join(", ")}]);
|
|
3029
3081
|
` : ""}
|
|
3030
3082
|
return (
|
|
3031
3083
|
<>
|
|
3032
|
-
${inlineComponents.map((provider) => provider.code)}
|
|
3084
|
+
${inlineComponents.map((provider) => provider.code).join("\n")}
|
|
3033
3085
|
${wrappedComponents.reduce((acc, provider) => {
|
|
3034
3086
|
const props = provider.props?.map((prop) => `${prop.propName}={${prop.propValue}}`).join(" ");
|
|
3035
3087
|
return `<${provider.component} ${props}>${acc}</${provider.component}>`;
|
|
@@ -3288,7 +3340,7 @@ function planXr(builder, options) {
|
|
|
3288
3340
|
);
|
|
3289
3341
|
builder.inject("scene-start", "<XR store={store}>");
|
|
3290
3342
|
builder.inject("scene-end", "</XR>");
|
|
3291
|
-
builder.inject("vite-config-import", "import basicSsl from '@vitejs/plugin-basic-ssl'");
|
|
3343
|
+
builder.inject("vite-config-import", "import basicSsl from '@vitejs/plugin-basic-ssl';");
|
|
3292
3344
|
builder.configureVite({
|
|
3293
3345
|
server: {
|
|
3294
3346
|
host: true
|
|
@@ -3555,6 +3607,7 @@ function createProjectPlan(planInput) {
|
|
|
3555
3607
|
const isReact = baseTemplate === "react";
|
|
3556
3608
|
const isR3f = baseTemplate === "r3f";
|
|
3557
3609
|
const isLibrary = clonedOptions.projectType === "library";
|
|
3610
|
+
const useReactCompiler = shouldEnableReactCompiler(clonedOptions);
|
|
3558
3611
|
const libraryBundler = planInput.libraryBundler.tool;
|
|
3559
3612
|
const ide = planInput.ide.tool;
|
|
3560
3613
|
const files = {
|
|
@@ -3578,6 +3631,11 @@ function createProjectPlan(planInput) {
|
|
|
3578
3631
|
assignResolvedPackageVersion(dependencies, versions, "react");
|
|
3579
3632
|
assignResolvedPackageVersion(dependencies, versions, "react-dom");
|
|
3580
3633
|
assignResolvedPackageVersion(devDependencies, versions, "@vitejs/plugin-react");
|
|
3634
|
+
if (useReactCompiler) {
|
|
3635
|
+
assignResolvedPackageVersion(devDependencies, versions, "@babel/core");
|
|
3636
|
+
assignResolvedPackageVersion(devDependencies, versions, "@rolldown/plugin-babel");
|
|
3637
|
+
assignResolvedPackageVersion(devDependencies, versions, "babel-plugin-react-compiler");
|
|
3638
|
+
}
|
|
3581
3639
|
}
|
|
3582
3640
|
}
|
|
3583
3641
|
if (isR3f) {
|
|
@@ -3599,12 +3657,20 @@ function createProjectPlan(planInput) {
|
|
|
3599
3657
|
});
|
|
3600
3658
|
Object.assign(files, tsResult.files);
|
|
3601
3659
|
Object.assign(devDependencies, tsResult.devDependencies);
|
|
3660
|
+
if (useReactCompiler) {
|
|
3661
|
+
assignResolvedPackageVersion(devDependencies, versions, "@types/babel__core");
|
|
3662
|
+
}
|
|
3602
3663
|
}
|
|
3603
3664
|
const codeSnippets = {};
|
|
3604
3665
|
const vscodeSettings = {};
|
|
3605
3666
|
const scripts = {};
|
|
3606
3667
|
if (!isLibrary && (isReact || isR3f)) {
|
|
3607
|
-
codeSnippets["vite-config-import"] = [
|
|
3668
|
+
codeSnippets["vite-config-import"] = [
|
|
3669
|
+
useReactCompiler ? "import react, { reactCompilerPreset } from '@vitejs/plugin-react';" : "import react from '@vitejs/plugin-react';"
|
|
3670
|
+
];
|
|
3671
|
+
if (useReactCompiler) {
|
|
3672
|
+
codeSnippets["vite-config-import"].push("import babel from '@rolldown/plugin-babel';");
|
|
3673
|
+
}
|
|
3608
3674
|
}
|
|
3609
3675
|
if (!isLibrary && isR3f) {
|
|
3610
3676
|
codeSnippets["import"] = [`import { Canvas } from "@react-three/fiber"`];
|
|
@@ -3615,7 +3681,7 @@ function createProjectPlan(planInput) {
|
|
|
3615
3681
|
base: "./"
|
|
3616
3682
|
};
|
|
3617
3683
|
if (!isLibrary && (isReact || isR3f)) {
|
|
3618
|
-
viteConfig.plugins = ["$raw:react()"];
|
|
3684
|
+
viteConfig.plugins = useReactCompiler ? ["$raw:react()", "$raw:babel({ presets: [reactCompilerPreset()] })"] : ["$raw:react()"];
|
|
3619
3685
|
}
|
|
3620
3686
|
if (!isLibrary && isR3f) {
|
|
3621
3687
|
viteConfig.resolve = { dedupe: ["three"] };
|
|
@@ -3720,7 +3786,9 @@ function createProjectPlan(planInput) {
|
|
|
3720
3786
|
} else if (planInput.formatter.tool === "oxfmt") {
|
|
3721
3787
|
planOxfmt(builder, planInput.formatter);
|
|
3722
3788
|
} else if (planInput.formatter.tool === "biome" && planInput.linter.tool !== "biome") {
|
|
3723
|
-
planBiome(builder, {
|
|
3789
|
+
planBiome(builder, {
|
|
3790
|
+
formatter: planInput.formatter
|
|
3791
|
+
});
|
|
3724
3792
|
}
|
|
3725
3793
|
for (const { code, location } of clonedOptions.injections ?? []) {
|
|
3726
3794
|
builder.inject(location, code);
|
|
@@ -3858,6 +3926,7 @@ exports.getLanguageFromTemplate = getLanguageFromTemplate;
|
|
|
3858
3926
|
exports.getLatestNodeVersion = getLatestNodeVersion;
|
|
3859
3927
|
exports.getLatestNpmCliVersion = getLatestNpmCliVersion;
|
|
3860
3928
|
exports.getLatestNpmMajorVersion = getLatestNpmMajorVersion;
|
|
3929
|
+
exports.getLatestNpmMajorVersionAtOrBelow = getLatestNpmMajorVersionAtOrBelow;
|
|
3861
3930
|
exports.getLatestNpmVersion = getLatestNpmVersion;
|
|
3862
3931
|
exports.getLatestPnpmVersion = getLatestPnpmVersion;
|
|
3863
3932
|
exports.getLatestYarnVersion = getLatestYarnVersion;
|
|
@@ -3881,12 +3950,14 @@ exports.renderOxlintConfig = renderOxlintConfig;
|
|
|
3881
3950
|
exports.renderOxlintConfigPackage = renderOxlintConfigPackage;
|
|
3882
3951
|
exports.renderPrettierConfigPackage = renderPrettierConfigPackage;
|
|
3883
3952
|
exports.renderTypescriptConfigPackage = renderTypescriptConfigPackage;
|
|
3953
|
+
exports.renderViteConfig = renderViteConfig;
|
|
3884
3954
|
exports.renderVscodeFiles = renderVscodeFiles;
|
|
3885
3955
|
exports.renderVscodeFiles$1 = renderVscodeFiles$1;
|
|
3886
3956
|
exports.resolveDefaultPackageJsonScripts = resolveDefaultPackageJsonScripts;
|
|
3887
3957
|
exports.resolveMonorepoRootPackageVersions = resolveMonorepoRootPackageVersions;
|
|
3888
3958
|
exports.resolveProjectPlanInput = resolveProjectPlanInput;
|
|
3889
3959
|
exports.resolveWorkspacePlanInput = resolveWorkspacePlanInput;
|
|
3960
|
+
exports.shouldEnableReactCompiler = shouldEnableReactCompiler;
|
|
3890
3961
|
exports.toPrettierIgnoreContent = toPrettierIgnoreContent;
|
|
3891
3962
|
exports.unique = unique;
|
|
3892
3963
|
exports.validatePackageName = validatePackageName;
|