@woodsportal/hubspot-kit 1.0.33 → 1.0.35
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/CHANGELOG.md +12 -0
- package/dist/cli.js +131 -79
- package/dist/cli.js.map +1 -1
- package/package.json +2 -2
- package/scripts/node-loader-interop.mjs +20 -0
- package/scripts/run-dev.mjs +57 -42
- package/scripts/vite/ensure-dev-kit-shims.js +39 -14
- package/scripts/vite/ensure-dev-kit-shims.test.mjs +47 -0
- package/scripts/vite/react-dev-plugin-options.js +1 -1
- package/vite/vite.config.dev.mjs +91 -66
package/CHANGELOG.md
CHANGED
|
@@ -19,6 +19,18 @@
|
|
|
19
19
|
- **CSS entries** — shared `tailwind.css.config.css`; documented never-merge rules on `main.dev.css` / `main.prod.css`
|
|
20
20
|
- **`wp doctor`** — CSS pipeline checks (prefix, `.temp` @source, `skipRuntimeCss`, `module.css` dw utilities, CDN `require_css` warning)
|
|
21
21
|
|
|
22
|
+
## 1.0.35 — 2026-06-08
|
|
23
|
+
|
|
24
|
+
### Dev server
|
|
25
|
+
- **Vite config load** — lazy-load kit plugins (defer `@babel/*` prefix plugin) so Node 22.18+ / 23.x do not crash with `getStatus` during config import; `wp doctor` warns on affected Node versions (Node 24 LTS recommended)
|
|
26
|
+
- **Windows dev shims** — create `.wphs/.kit-module-config` via directory junction (or copy fallback) and bootstrap shims via copy when symlinks fail; fixes `jsxDEV` export errors from `react/jsx-dev-runtime`
|
|
27
|
+
- **Vite dev** — pre-bundle React JSX runtimes and dedupe `react` / `react-dom`
|
|
28
|
+
|
|
29
|
+
## 1.0.34 — 2026-06-08
|
|
30
|
+
|
|
31
|
+
### Dev server
|
|
32
|
+
- **`wp dev` / `wp local`** — spawn Vite via `node …/vite/bin/vite.js` (or `vite.cmd` on Windows) instead of `.bin/vite` shell shim; fixes `ENOENT` on Windows
|
|
33
|
+
|
|
22
34
|
## 1.0.33 — 2026-06-08
|
|
23
35
|
|
|
24
36
|
### Dev server
|
package/dist/cli.js
CHANGED
|
@@ -302,8 +302,8 @@ function defaultBaselineDir(projectRoot, config) {
|
|
|
302
302
|
}
|
|
303
303
|
|
|
304
304
|
// src/cli/commands/doctor.ts
|
|
305
|
-
import { existsSync as
|
|
306
|
-
import { join, resolve as
|
|
305
|
+
import { existsSync as existsSync7, readFileSync as readFileSync5 } from "fs";
|
|
306
|
+
import { join, resolve as resolve8 } from "path";
|
|
307
307
|
|
|
308
308
|
// src/lib/cli-spinner.ts
|
|
309
309
|
import * as p from "@clack/prompts";
|
|
@@ -797,6 +797,57 @@ function isUploadOnlyPreexistingProject(projectRoot, moduleArtifactDirs) {
|
|
|
797
797
|
return moduleArtifactDirs.some((dir) => existsSync5(resolve6(dir, "fields.json")));
|
|
798
798
|
}
|
|
799
799
|
|
|
800
|
+
// src/vite/resolve-dev-config.ts
|
|
801
|
+
import { existsSync as existsSync6 } from "fs";
|
|
802
|
+
import { platform } from "os";
|
|
803
|
+
import { resolve as resolve7 } from "path";
|
|
804
|
+
var CONSUMER_DEV_CONFIG = "vite.config.dev.mjs";
|
|
805
|
+
var VITE_JS_SEGMENTS = ["node_modules", "vite", "bin", "vite.js"];
|
|
806
|
+
function resolveDevViteConfigPath(projectRoot) {
|
|
807
|
+
const consumerConfig = resolve7(projectRoot, CONSUMER_DEV_CONFIG);
|
|
808
|
+
if (existsSync6(consumerConfig)) {
|
|
809
|
+
return consumerConfig;
|
|
810
|
+
}
|
|
811
|
+
return kitPath("vite", "vite.config.dev.mjs");
|
|
812
|
+
}
|
|
813
|
+
function isProjectViteInstalled(projectRoot) {
|
|
814
|
+
return existsSync6(resolve7(projectRoot, ...VITE_JS_SEGMENTS));
|
|
815
|
+
}
|
|
816
|
+
function resolveProjectViteSpawn(projectRoot) {
|
|
817
|
+
const viteJs = resolve7(projectRoot, ...VITE_JS_SEGMENTS);
|
|
818
|
+
if (existsSync6(viteJs)) {
|
|
819
|
+
return { command: process.execPath, prefixArgs: [viteJs] };
|
|
820
|
+
}
|
|
821
|
+
const binDir = resolve7(projectRoot, "node_modules", ".bin");
|
|
822
|
+
if (platform() === "win32") {
|
|
823
|
+
const winCmd = resolve7(binDir, "vite.cmd");
|
|
824
|
+
if (existsSync6(winCmd)) {
|
|
825
|
+
return { command: winCmd, prefixArgs: [] };
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
const posixShim = resolve7(binDir, "vite");
|
|
829
|
+
if (existsSync6(posixShim)) {
|
|
830
|
+
return { command: posixShim, prefixArgs: [] };
|
|
831
|
+
}
|
|
832
|
+
return null;
|
|
833
|
+
}
|
|
834
|
+
function formatProjectViteSpawn(spawn2) {
|
|
835
|
+
return [spawn2.command, ...spawn2.prefixArgs].join(" ");
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
// src/lib/node-loader-interop.ts
|
|
839
|
+
var NODE_LTS_RECOMMENDED = "24";
|
|
840
|
+
function nodeLoaderInteropWarning() {
|
|
841
|
+
const [major, minor] = process.versions.node.split(".").map(Number);
|
|
842
|
+
if (major === 22 && minor >= 18) {
|
|
843
|
+
return `Node 22.18+ can fail loading Vite config (getStatus). Upgrade to Node ${NODE_LTS_RECOMMENDED} LTS or the latest Node 22 patch.`;
|
|
844
|
+
}
|
|
845
|
+
if (major === 23 && minor < 4) {
|
|
846
|
+
return `Node 23.0\u201323.3 can fail loading Vite config (getStatus). Upgrade to Node ${NODE_LTS_RECOMMENDED} LTS.`;
|
|
847
|
+
}
|
|
848
|
+
return null;
|
|
849
|
+
}
|
|
850
|
+
|
|
800
851
|
// src/cli/commands/doctor.ts
|
|
801
852
|
function checkNode() {
|
|
802
853
|
const major = Number(process.versions.node.split(".")[0]);
|
|
@@ -805,7 +856,7 @@ function checkNode() {
|
|
|
805
856
|
name: "node",
|
|
806
857
|
ok,
|
|
807
858
|
message: ok ? `Node ${process.versions.node}` : `Node ${process.versions.node} (need >= 20)`,
|
|
808
|
-
remediation: ok ? void 0 : "Install Node
|
|
859
|
+
remediation: ok ? void 0 : "Install Node 24 LTS (recommended) or Node 20 LTS.",
|
|
809
860
|
severity: "error"
|
|
810
861
|
};
|
|
811
862
|
}
|
|
@@ -862,8 +913,8 @@ function checkConfig(ctx) {
|
|
|
862
913
|
function checkEnvFiles(ctx) {
|
|
863
914
|
return ctx.config.env.tiers.map((tier) => {
|
|
864
915
|
const file = tier === "dev" ? ".env.dev" : tier === "stg" ? ".env.stg" : ".env.prod";
|
|
865
|
-
const path =
|
|
866
|
-
const ok =
|
|
916
|
+
const path = resolve8(ctx.projectRoot, file);
|
|
917
|
+
const ok = existsSync7(path);
|
|
867
918
|
return {
|
|
868
919
|
name: `env-${tier}`,
|
|
869
920
|
ok,
|
|
@@ -875,8 +926,8 @@ function checkEnvFiles(ctx) {
|
|
|
875
926
|
}
|
|
876
927
|
function checkLegacyBuildIdFile(ctx) {
|
|
877
928
|
if (isThemeProject(ctx.config) || !usesCdnPipeline(ctx.config)) return null;
|
|
878
|
-
const legacy =
|
|
879
|
-
if (!
|
|
929
|
+
const legacy = resolve8(ctx.projectRoot, ".portal-build-id");
|
|
930
|
+
if (!existsSync7(legacy)) return null;
|
|
880
931
|
return {
|
|
881
932
|
name: "legacy-build-id",
|
|
882
933
|
ok: false,
|
|
@@ -887,8 +938,8 @@ function checkLegacyBuildIdFile(ctx) {
|
|
|
887
938
|
}
|
|
888
939
|
function checkBuildId(ctx) {
|
|
889
940
|
if (isThemeProject(ctx.config) || !usesCdnPipeline(ctx.config)) return null;
|
|
890
|
-
const file =
|
|
891
|
-
const ok =
|
|
941
|
+
const file = resolve8(ctx.projectRoot, ctx.config.cdn.buildIdFile);
|
|
942
|
+
const ok = existsSync7(file);
|
|
892
943
|
return {
|
|
893
944
|
name: "build-id",
|
|
894
945
|
ok,
|
|
@@ -942,7 +993,7 @@ function checkDevSlug(ctx) {
|
|
|
942
993
|
};
|
|
943
994
|
}
|
|
944
995
|
function isUploadOnlyProject(ctx) {
|
|
945
|
-
const moduleDirs = [
|
|
996
|
+
const moduleDirs = [resolve8(ctx.projectRoot, ctx.config.module.uploadPath)];
|
|
946
997
|
return isUploadOnlyPreexistingProject(ctx.projectRoot, moduleDirs);
|
|
947
998
|
}
|
|
948
999
|
function checkUploadOnlyNote(ctx) {
|
|
@@ -956,8 +1007,8 @@ function checkUploadOnlyNote(ctx) {
|
|
|
956
1007
|
};
|
|
957
1008
|
}
|
|
958
1009
|
function checkDevViteConfig(ctx) {
|
|
959
|
-
const path =
|
|
960
|
-
const ok =
|
|
1010
|
+
const path = resolve8(ctx.projectRoot, "vite.config.dev.mjs");
|
|
1011
|
+
const ok = existsSync7(path);
|
|
961
1012
|
return {
|
|
962
1013
|
name: "vite-dev-config",
|
|
963
1014
|
ok,
|
|
@@ -968,8 +1019,8 @@ function checkDevViteConfig(ctx) {
|
|
|
968
1019
|
}
|
|
969
1020
|
function checkMetaJson(ctx) {
|
|
970
1021
|
if (isThemeProject(ctx.config)) return null;
|
|
971
|
-
const path =
|
|
972
|
-
if (!
|
|
1022
|
+
const path = resolve8(ctx.projectRoot, "public/meta.json");
|
|
1023
|
+
if (!existsSync7(path)) {
|
|
973
1024
|
return {
|
|
974
1025
|
name: "meta-json",
|
|
975
1026
|
ok: false,
|
|
@@ -1001,8 +1052,8 @@ function checkMetaJson(ctx) {
|
|
|
1001
1052
|
}
|
|
1002
1053
|
async function checkCdnMirrorPublic(ctx) {
|
|
1003
1054
|
if (isThemeProject(ctx.config) || !usesCdnPipeline(ctx.config)) return null;
|
|
1004
|
-
const mirrorPath =
|
|
1005
|
-
if (!
|
|
1055
|
+
const mirrorPath = resolve8(ctx.projectRoot, ctx.config.cdn?.mirror ?? "portal.cdn.json");
|
|
1056
|
+
if (!existsSync7(mirrorPath)) {
|
|
1006
1057
|
return {
|
|
1007
1058
|
name: "cdn-mirror-public",
|
|
1008
1059
|
ok: false,
|
|
@@ -1065,8 +1116,8 @@ async function checkCdnMirrorPublic(ctx) {
|
|
|
1065
1116
|
severity: "warn"
|
|
1066
1117
|
};
|
|
1067
1118
|
}
|
|
1068
|
-
const manifestPath =
|
|
1069
|
-
if (!
|
|
1119
|
+
const manifestPath = resolve8(ctx.projectRoot, "dist/cdn/manifest.json");
|
|
1120
|
+
if (!existsSync7(manifestPath)) {
|
|
1070
1121
|
return {
|
|
1071
1122
|
name: "cdn-mirror-public",
|
|
1072
1123
|
ok: true,
|
|
@@ -1112,8 +1163,8 @@ async function checkCdnMirrorPublic(ctx) {
|
|
|
1112
1163
|
}
|
|
1113
1164
|
function checkFieldsJson(ctx) {
|
|
1114
1165
|
if (isThemeProject(ctx.config)) return null;
|
|
1115
|
-
const path =
|
|
1116
|
-
if (!
|
|
1166
|
+
const path = resolve8(ctx.projectRoot, "public/fields.json");
|
|
1167
|
+
if (!existsSync7(path)) {
|
|
1117
1168
|
return {
|
|
1118
1169
|
name: "fields-json",
|
|
1119
1170
|
ok: false,
|
|
@@ -1153,8 +1204,8 @@ function checkFieldsJson(ctx) {
|
|
|
1153
1204
|
}
|
|
1154
1205
|
}
|
|
1155
1206
|
function readProjectFile(projectRoot, relativePath) {
|
|
1156
|
-
const path =
|
|
1157
|
-
if (!
|
|
1207
|
+
const path = resolve8(projectRoot, relativePath);
|
|
1208
|
+
if (!existsSync7(path)) {
|
|
1158
1209
|
return null;
|
|
1159
1210
|
}
|
|
1160
1211
|
return readFileSync5(path, "utf8");
|
|
@@ -1224,8 +1275,8 @@ function checkCssPipeline(ctx) {
|
|
|
1224
1275
|
}
|
|
1225
1276
|
const moduleOutDir = ctx.config.module?.outDir;
|
|
1226
1277
|
if (moduleOutDir && usesCdnPipeline(ctx.config)) {
|
|
1227
|
-
const moduleCssPath =
|
|
1228
|
-
if (
|
|
1278
|
+
const moduleCssPath = resolve8(ctx.projectRoot, moduleOutDir, "module.css");
|
|
1279
|
+
if (existsSync7(moduleCssPath)) {
|
|
1229
1280
|
const css = readFileSync5(moduleCssPath, "utf8");
|
|
1230
1281
|
const hasDwUtilities = /dw\\:/.test(css) || /\.dw:/.test(css);
|
|
1231
1282
|
checks.push({
|
|
@@ -1241,8 +1292,8 @@ function checkCssPipeline(ctx) {
|
|
|
1241
1292
|
}
|
|
1242
1293
|
function checkHybridModuleHtml(ctx) {
|
|
1243
1294
|
if (isThemeProject(ctx.config) || !usesCdnPipeline(ctx.config)) return null;
|
|
1244
|
-
const path =
|
|
1245
|
-
if (!
|
|
1295
|
+
const path = resolve8(ctx.projectRoot, "public/module.html");
|
|
1296
|
+
if (!existsSync7(path)) {
|
|
1246
1297
|
return {
|
|
1247
1298
|
name: "module-html",
|
|
1248
1299
|
ok: false,
|
|
@@ -1269,8 +1320,8 @@ function checkHybridModuleHtml(ctx) {
|
|
|
1269
1320
|
function checkCdnViteConfigs(ctx) {
|
|
1270
1321
|
if (isThemeProject(ctx.config) || !usesCdnPipeline(ctx.config)) return [];
|
|
1271
1322
|
return ["vite.config.cdn-vendor.mjs", "vite.config.cdn-app.mjs"].map((file) => {
|
|
1272
|
-
const path =
|
|
1273
|
-
const ok =
|
|
1323
|
+
const path = resolve8(ctx.projectRoot, file);
|
|
1324
|
+
const ok = existsSync7(path);
|
|
1274
1325
|
return {
|
|
1275
1326
|
name: file.replace(/\./g, "-"),
|
|
1276
1327
|
ok,
|
|
@@ -1282,8 +1333,8 @@ function checkCdnViteConfigs(ctx) {
|
|
|
1282
1333
|
}
|
|
1283
1334
|
function checkDevEntry(ctx) {
|
|
1284
1335
|
const checks = [];
|
|
1285
|
-
const indexHtml =
|
|
1286
|
-
const hasIndex =
|
|
1336
|
+
const indexHtml = resolve8(ctx.projectRoot, "index.html");
|
|
1337
|
+
const hasIndex = existsSync7(indexHtml);
|
|
1287
1338
|
checks.push({
|
|
1288
1339
|
name: "index-html",
|
|
1289
1340
|
ok: hasIndex,
|
|
@@ -1291,8 +1342,8 @@ function checkDevEntry(ctx) {
|
|
|
1291
1342
|
remediation: hasIndex ? void 0 : "Re-run wp init or copy index.html from kit templates",
|
|
1292
1343
|
severity: "error"
|
|
1293
1344
|
});
|
|
1294
|
-
const localDev =
|
|
1295
|
-
const hasEntry =
|
|
1345
|
+
const localDev = resolve8(ctx.projectRoot, ctx.config.entries.localDev);
|
|
1346
|
+
const hasEntry = existsSync7(localDev);
|
|
1296
1347
|
checks.push({
|
|
1297
1348
|
name: "local-dev-entry",
|
|
1298
1349
|
ok: hasEntry,
|
|
@@ -1319,7 +1370,7 @@ function checkDevEntry(ctx) {
|
|
|
1319
1370
|
}
|
|
1320
1371
|
function checkKitScripts() {
|
|
1321
1372
|
const script = kitPath("scripts", "build-cdn.mjs");
|
|
1322
|
-
const ok =
|
|
1373
|
+
const ok = existsSync7(script);
|
|
1323
1374
|
return {
|
|
1324
1375
|
name: "kit-scripts",
|
|
1325
1376
|
ok,
|
|
@@ -1332,8 +1383,8 @@ function checkWphsWorkspace(ctx) {
|
|
|
1332
1383
|
const workspace = ctx.config.dev.moduleConfigDir;
|
|
1333
1384
|
const checks = [];
|
|
1334
1385
|
for (const legacy of [".dev", ".woodsportal"]) {
|
|
1335
|
-
const legacyPath =
|
|
1336
|
-
if (
|
|
1386
|
+
const legacyPath = resolve8(ctx.projectRoot, legacy);
|
|
1387
|
+
if (existsSync7(legacyPath)) {
|
|
1337
1388
|
checks.push({
|
|
1338
1389
|
name: `legacy-${legacy}`,
|
|
1339
1390
|
ok: false,
|
|
@@ -1343,7 +1394,7 @@ function checkWphsWorkspace(ctx) {
|
|
|
1343
1394
|
});
|
|
1344
1395
|
}
|
|
1345
1396
|
}
|
|
1346
|
-
if (
|
|
1397
|
+
if (existsSync7(resolve8(ctx.projectRoot, ".wp-hs-baseline"))) {
|
|
1347
1398
|
checks.push({
|
|
1348
1399
|
name: "legacy-baseline",
|
|
1349
1400
|
ok: false,
|
|
@@ -1362,10 +1413,10 @@ function checkWphsWorkspace(ctx) {
|
|
|
1362
1413
|
});
|
|
1363
1414
|
return checks;
|
|
1364
1415
|
}
|
|
1365
|
-
const wphsRoot =
|
|
1416
|
+
const wphsRoot = resolve8(ctx.projectRoot, workspace);
|
|
1366
1417
|
const required = ["config", "assets/branding", "fixtures", "cache", "audit/baseline", "state"];
|
|
1367
1418
|
for (const sub of required) {
|
|
1368
|
-
const ok =
|
|
1419
|
+
const ok = existsSync7(join(wphsRoot, sub));
|
|
1369
1420
|
checks.push({
|
|
1370
1421
|
name: `wphs-${sub.replace(/\//g, "-")}`,
|
|
1371
1422
|
ok,
|
|
@@ -1378,8 +1429,8 @@ function checkWphsWorkspace(ctx) {
|
|
|
1378
1429
|
}
|
|
1379
1430
|
function checkAdapter(ctx) {
|
|
1380
1431
|
if (isThemeProject(ctx.config)) return null;
|
|
1381
|
-
const adapterPath =
|
|
1382
|
-
const ok =
|
|
1432
|
+
const adapterPath = resolve8(ctx.projectRoot, ctx.config.dev.adapter);
|
|
1433
|
+
const ok = existsSync7(adapterPath);
|
|
1383
1434
|
return {
|
|
1384
1435
|
name: "wphs-adapter",
|
|
1385
1436
|
ok,
|
|
@@ -1390,8 +1441,8 @@ function checkAdapter(ctx) {
|
|
|
1390
1441
|
}
|
|
1391
1442
|
function checkModuleConfigUiDeps(ctx) {
|
|
1392
1443
|
if (isThemeProject(ctx.config)) return [];
|
|
1393
|
-
const pkgPath =
|
|
1394
|
-
if (!
|
|
1444
|
+
const pkgPath = resolve8(ctx.projectRoot, "package.json");
|
|
1445
|
+
if (!existsSync7(pkgPath)) return [];
|
|
1395
1446
|
let deps = {};
|
|
1396
1447
|
try {
|
|
1397
1448
|
const pkg = JSON.parse(readFileSync5(pkgPath, "utf8"));
|
|
@@ -1410,12 +1461,21 @@ function checkModuleConfigUiDeps(ctx) {
|
|
|
1410
1461
|
};
|
|
1411
1462
|
});
|
|
1412
1463
|
}
|
|
1464
|
+
function checkNodeLoaderInterop() {
|
|
1465
|
+
const warning = nodeLoaderInteropWarning();
|
|
1466
|
+
return {
|
|
1467
|
+
name: "node-loader-interop",
|
|
1468
|
+
ok: !warning,
|
|
1469
|
+
message: warning ?? `Node ${process.versions.node} (Vite config load OK)`,
|
|
1470
|
+
remediation: warning ?? void 0,
|
|
1471
|
+
severity: "warn"
|
|
1472
|
+
};
|
|
1473
|
+
}
|
|
1413
1474
|
function checkViteInstalled(ctx) {
|
|
1414
|
-
if (isThemeProject(ctx.config) && !
|
|
1475
|
+
if (isThemeProject(ctx.config) && !existsSync7(resolve8(ctx.projectRoot, "vite.config.dev.mjs"))) {
|
|
1415
1476
|
return null;
|
|
1416
1477
|
}
|
|
1417
|
-
const
|
|
1418
|
-
const ok = existsSync6(localBin);
|
|
1478
|
+
const ok = isProjectViteInstalled(ctx.projectRoot);
|
|
1419
1479
|
return {
|
|
1420
1480
|
name: "vite",
|
|
1421
1481
|
ok,
|
|
@@ -1444,7 +1504,7 @@ async function gatherDoctorChecks(ctx) {
|
|
|
1444
1504
|
{
|
|
1445
1505
|
title: "Checking Node, Vite, and kit scripts",
|
|
1446
1506
|
task: async () => {
|
|
1447
|
-
checks.push(checkNode(), checkKitScripts());
|
|
1507
|
+
checks.push(checkNode(), checkNodeLoaderInterop(), checkKitScripts());
|
|
1448
1508
|
const uploadOnlyNote = checkUploadOnlyNote(ctx);
|
|
1449
1509
|
if (uploadOnlyNote) {
|
|
1450
1510
|
checks.push(uploadOnlyNote);
|
|
@@ -1569,21 +1629,21 @@ async function runConfigValidate(ctx) {
|
|
|
1569
1629
|
}
|
|
1570
1630
|
|
|
1571
1631
|
// src/cli/commands/build.ts
|
|
1572
|
-
import { resolve as
|
|
1632
|
+
import { resolve as resolve10 } from "path";
|
|
1573
1633
|
|
|
1574
1634
|
// src/lib/cli-banner.ts
|
|
1575
1635
|
import pc3 from "picocolors";
|
|
1576
1636
|
|
|
1577
1637
|
// src/lib/kit-version.ts
|
|
1578
1638
|
import { readFileSync as readFileSync6 } from "fs";
|
|
1579
|
-
import { resolve as
|
|
1639
|
+
import { resolve as resolve9 } from "path";
|
|
1580
1640
|
var cachedVersion = null;
|
|
1581
1641
|
function readKitVersion() {
|
|
1582
1642
|
if (cachedVersion) {
|
|
1583
1643
|
return cachedVersion;
|
|
1584
1644
|
}
|
|
1585
1645
|
try {
|
|
1586
|
-
const pkg = JSON.parse(readFileSync6(
|
|
1646
|
+
const pkg = JSON.parse(readFileSync6(resolve9(getKitRoot(), "package.json"), "utf8"));
|
|
1587
1647
|
cachedVersion = pkg.version ?? "0.0.0";
|
|
1588
1648
|
} catch {
|
|
1589
1649
|
cachedVersion = "0.0.0";
|
|
@@ -1715,7 +1775,7 @@ function buildTasks(ctx, options, run) {
|
|
|
1715
1775
|
title: `Building monolith module (${tier})`,
|
|
1716
1776
|
task: async () => {
|
|
1717
1777
|
await run("run-vite-build.mjs", [
|
|
1718
|
-
|
|
1778
|
+
resolve10(ctx.projectRoot, "vite.config.monolith.mjs"),
|
|
1719
1779
|
...tierToStgFlag(tier)
|
|
1720
1780
|
]);
|
|
1721
1781
|
await run("run-hubspot-module-postbuild.mjs");
|
|
@@ -1729,7 +1789,7 @@ function buildTasks(ctx, options, run) {
|
|
|
1729
1789
|
task: async () => {
|
|
1730
1790
|
if (options.cdnEsm) {
|
|
1731
1791
|
await run("run-vite-build.mjs", [
|
|
1732
|
-
|
|
1792
|
+
resolve10(ctx.projectRoot, "vite.config.cdn-esm.mjs"),
|
|
1733
1793
|
...tierToStgFlag(tier)
|
|
1734
1794
|
]);
|
|
1735
1795
|
} else {
|
|
@@ -1744,7 +1804,7 @@ function buildTasks(ctx, options, run) {
|
|
|
1744
1804
|
title: `Building HubSpot module (${tier})`,
|
|
1745
1805
|
task: async () => {
|
|
1746
1806
|
await run("run-vite-build.mjs", [
|
|
1747
|
-
|
|
1807
|
+
resolve10(ctx.projectRoot, "vite.config.hubspot.mjs"),
|
|
1748
1808
|
...tierToStgFlag(tier)
|
|
1749
1809
|
]);
|
|
1750
1810
|
await run("run-hubspot-module-postbuild.mjs");
|
|
@@ -1841,7 +1901,7 @@ async function runBuild(ctx, options) {
|
|
|
1841
1901
|
command: "build",
|
|
1842
1902
|
tier,
|
|
1843
1903
|
ok: true,
|
|
1844
|
-
outDir:
|
|
1904
|
+
outDir: resolve10(ctx.projectRoot, ctx.config.module.outDir)
|
|
1845
1905
|
});
|
|
1846
1906
|
} else if (!options.quiet) {
|
|
1847
1907
|
printCommandDone(ctx, "Build complete");
|
|
@@ -1858,40 +1918,24 @@ async function runBuild(ctx, options) {
|
|
|
1858
1918
|
import { existsSync as existsSync8 } from "fs";
|
|
1859
1919
|
import { resolve as resolve11 } from "path";
|
|
1860
1920
|
import { spawn } from "child_process";
|
|
1861
|
-
|
|
1862
|
-
// src/vite/resolve-dev-config.ts
|
|
1863
|
-
import { existsSync as existsSync7 } from "fs";
|
|
1864
|
-
import { resolve as resolve10 } from "path";
|
|
1865
|
-
var CONSUMER_DEV_CONFIG = "vite.config.dev.mjs";
|
|
1866
|
-
function resolveDevViteConfigPath(projectRoot) {
|
|
1867
|
-
const consumerConfig = resolve10(projectRoot, CONSUMER_DEV_CONFIG);
|
|
1868
|
-
if (existsSync7(consumerConfig)) {
|
|
1869
|
-
return consumerConfig;
|
|
1870
|
-
}
|
|
1871
|
-
return kitPath("vite", "vite.config.dev.mjs");
|
|
1872
|
-
}
|
|
1873
|
-
function resolveProjectViteBin(projectRoot) {
|
|
1874
|
-
const localBin = resolve10(projectRoot, "node_modules", ".bin", "vite");
|
|
1875
|
-
if (existsSync7(localBin)) {
|
|
1876
|
-
return localBin;
|
|
1877
|
-
}
|
|
1878
|
-
return "vite";
|
|
1879
|
-
}
|
|
1880
|
-
|
|
1881
|
-
// src/cli/commands/dev.ts
|
|
1882
1921
|
async function runDev(ctx, options) {
|
|
1883
1922
|
const port = options.port ?? 3e3;
|
|
1923
|
+
const nodeWarning = nodeLoaderInteropWarning();
|
|
1924
|
+
if (nodeWarning) {
|
|
1925
|
+
ctx.logger.warn(nodeWarning);
|
|
1926
|
+
}
|
|
1884
1927
|
const env = {
|
|
1885
1928
|
...process.env,
|
|
1886
1929
|
WP_HS_PROJECT_ROOT: ctx.projectRoot
|
|
1887
1930
|
};
|
|
1888
1931
|
const configPath = resolveDevViteConfigPath(ctx.projectRoot);
|
|
1889
|
-
const
|
|
1932
|
+
const viteSpawn = resolveProjectViteSpawn(ctx.projectRoot);
|
|
1890
1933
|
if (ctx.global.dryRun) {
|
|
1891
|
-
|
|
1934
|
+
const dryRunTarget = viteSpawn ? formatProjectViteSpawn(viteSpawn) : "vite";
|
|
1935
|
+
ctx.logger.info(`[dry-run] ${dryRunTarget} --config ${configPath} --port ${port}`);
|
|
1892
1936
|
return ExitCode.SUCCESS;
|
|
1893
1937
|
}
|
|
1894
|
-
if (
|
|
1938
|
+
if (!viteSpawn) {
|
|
1895
1939
|
throw new WpHsError("vite is not installed in this project.", {
|
|
1896
1940
|
exitCode: ExitCode.PREREQUISITE,
|
|
1897
1941
|
remediation: "Run yarn install or npm install. If this is an older wp init project, add vite and peers to devDependencies (run wp init again or see @woodsportal/hubspot-kit templates)."
|
|
@@ -1911,8 +1955,16 @@ async function runDev(ctx, options) {
|
|
|
1911
1955
|
});
|
|
1912
1956
|
return new Promise((resolvePromise) => {
|
|
1913
1957
|
const child = spawn(
|
|
1914
|
-
|
|
1915
|
-
[
|
|
1958
|
+
viteSpawn.command,
|
|
1959
|
+
[
|
|
1960
|
+
...viteSpawn.prefixArgs,
|
|
1961
|
+
"--config",
|
|
1962
|
+
configPath,
|
|
1963
|
+
"--port",
|
|
1964
|
+
String(port),
|
|
1965
|
+
"--mode",
|
|
1966
|
+
"dev"
|
|
1967
|
+
],
|
|
1916
1968
|
{
|
|
1917
1969
|
cwd: ctx.projectRoot,
|
|
1918
1970
|
env,
|