@nasti-toolchain/nasti 1.6.1 → 1.6.2
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 +104 -5
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +105 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +103 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +104 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -793,7 +793,7 @@ import pc from "picocolors";
|
|
|
793
793
|
async function build(inlineConfig = {}) {
|
|
794
794
|
const config = await resolveConfig(inlineConfig, "build");
|
|
795
795
|
const startTime = performance.now();
|
|
796
|
-
console.log(pc.cyan("\n\u{1F528} nasti build") + pc.dim(` v${"1.6.
|
|
796
|
+
console.log(pc.cyan("\n\u{1F528} nasti build") + pc.dim(` v${"1.6.2"}`));
|
|
797
797
|
console.log(pc.dim(` root: ${config.root}`));
|
|
798
798
|
console.log(pc.dim(` mode: ${config.mode}`));
|
|
799
799
|
const outDir = path7.resolve(config.root, config.build.outDir);
|
|
@@ -1104,7 +1104,7 @@ __export(middleware_exports, {
|
|
|
1104
1104
|
import path9 from "path";
|
|
1105
1105
|
import fs8 from "fs";
|
|
1106
1106
|
import { createRequire as createRequire2 } from "module";
|
|
1107
|
-
import { fileURLToPath } from "url";
|
|
1107
|
+
import { fileURLToPath, pathToFileURL as pathToFileURL2 } from "url";
|
|
1108
1108
|
function getReactRefreshRuntimeEsm() {
|
|
1109
1109
|
if (__refreshRuntimeCache) return __refreshRuntimeCache;
|
|
1110
1110
|
let cjsPath;
|
|
@@ -1312,6 +1312,8 @@ async function bundlePackageAsEsm(entryFile) {
|
|
|
1312
1312
|
return esmBundleCache.get(entryFile);
|
|
1313
1313
|
}
|
|
1314
1314
|
async function doBundlePackage(entryFile) {
|
|
1315
|
+
const shim = await tryGenerateSubpathShim(entryFile);
|
|
1316
|
+
if (shim != null) return shim;
|
|
1315
1317
|
const { rolldown: rolldown4 } = await import("rolldown");
|
|
1316
1318
|
const bundle = await rolldown4({
|
|
1317
1319
|
input: entryFile,
|
|
@@ -1341,6 +1343,103 @@ async function doBundlePackage(entryFile) {
|
|
|
1341
1343
|
}
|
|
1342
1344
|
return code;
|
|
1343
1345
|
}
|
|
1346
|
+
async function tryGenerateSubpathShim(entryFile) {
|
|
1347
|
+
const NM = `${path9.sep}node_modules${path9.sep}`;
|
|
1348
|
+
if (!entryFile.includes(NM)) return null;
|
|
1349
|
+
let pkgDir = null;
|
|
1350
|
+
let pkgName = null;
|
|
1351
|
+
let dir = path9.dirname(entryFile);
|
|
1352
|
+
while (true) {
|
|
1353
|
+
const pkgJsonPath = path9.join(dir, "package.json");
|
|
1354
|
+
if (fs8.existsSync(pkgJsonPath)) {
|
|
1355
|
+
try {
|
|
1356
|
+
const pkg = JSON.parse(fs8.readFileSync(pkgJsonPath, "utf-8"));
|
|
1357
|
+
if (typeof pkg?.name === "string" && pkg.name) {
|
|
1358
|
+
pkgDir = dir;
|
|
1359
|
+
pkgName = pkg.name;
|
|
1360
|
+
break;
|
|
1361
|
+
}
|
|
1362
|
+
} catch {
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
const parent = path9.dirname(dir);
|
|
1366
|
+
if (parent === dir) return null;
|
|
1367
|
+
dir = parent;
|
|
1368
|
+
if (!dir.includes(NM)) return null;
|
|
1369
|
+
}
|
|
1370
|
+
if (!pkgDir || !pkgName) return null;
|
|
1371
|
+
const entryExt = path9.extname(entryFile);
|
|
1372
|
+
const mainEntry = pickMainEntryByExtension(pkgDir, entryExt);
|
|
1373
|
+
if (!mainEntry) return null;
|
|
1374
|
+
if (path9.resolve(mainEntry) === path9.resolve(entryFile)) return null;
|
|
1375
|
+
let mainNs;
|
|
1376
|
+
let subNs;
|
|
1377
|
+
try {
|
|
1378
|
+
mainNs = await import(pathToFileURL2(mainEntry).href);
|
|
1379
|
+
subNs = await import(pathToFileURL2(entryFile).href);
|
|
1380
|
+
} catch {
|
|
1381
|
+
return null;
|
|
1382
|
+
}
|
|
1383
|
+
if (!mainNs || typeof mainNs !== "object") return null;
|
|
1384
|
+
if (!subNs || typeof subNs !== "object") return null;
|
|
1385
|
+
const subKeys = Object.keys(subNs).filter(
|
|
1386
|
+
(k) => k !== "__esModule" && k !== "default" && VALID_IDENT.test(k)
|
|
1387
|
+
);
|
|
1388
|
+
if (subKeys.length === 0) return null;
|
|
1389
|
+
for (const k of subKeys) {
|
|
1390
|
+
if (!(k in mainNs)) return null;
|
|
1391
|
+
if (mainNs[k] !== subNs[k]) return null;
|
|
1392
|
+
}
|
|
1393
|
+
if ("default" in subNs) {
|
|
1394
|
+
if (!("default" in mainNs)) return null;
|
|
1395
|
+
if (mainNs["default"] !== subNs["default"]) return null;
|
|
1396
|
+
}
|
|
1397
|
+
const lines = [
|
|
1398
|
+
`// Nasti subpath shim \u2192 ${pkgName} (avoid duplicate bundling)`,
|
|
1399
|
+
`import * as __pkg from "/@modules/${pkgName}";`
|
|
1400
|
+
];
|
|
1401
|
+
for (const k of subKeys) {
|
|
1402
|
+
lines.push(`export const ${k} = __pkg[${JSON.stringify(k)}];`);
|
|
1403
|
+
}
|
|
1404
|
+
if ("default" in subNs) {
|
|
1405
|
+
lines.push(`export default ("default" in __pkg ? __pkg["default"] : __pkg);`);
|
|
1406
|
+
}
|
|
1407
|
+
return lines.join("\n") + "\n";
|
|
1408
|
+
}
|
|
1409
|
+
function pickMainEntryByExtension(pkgDir, preferredExt) {
|
|
1410
|
+
const pkgJsonPath = path9.join(pkgDir, "package.json");
|
|
1411
|
+
let pkg;
|
|
1412
|
+
try {
|
|
1413
|
+
pkg = JSON.parse(fs8.readFileSync(pkgJsonPath, "utf-8"));
|
|
1414
|
+
} catch {
|
|
1415
|
+
return null;
|
|
1416
|
+
}
|
|
1417
|
+
const candidates = [];
|
|
1418
|
+
const collectFromExportObject = (obj) => {
|
|
1419
|
+
if (!obj || typeof obj !== "object") return;
|
|
1420
|
+
for (const cond of ["import", "module", "default", "require", "node"]) {
|
|
1421
|
+
const v = obj[cond];
|
|
1422
|
+
if (typeof v === "string") candidates.push(v);
|
|
1423
|
+
else if (v && typeof v === "object") collectFromExportObject(v);
|
|
1424
|
+
}
|
|
1425
|
+
};
|
|
1426
|
+
const dot = pkg?.exports?.["."];
|
|
1427
|
+
if (typeof dot === "string") candidates.push(dot);
|
|
1428
|
+
else if (dot && typeof dot === "object") collectFromExportObject(dot);
|
|
1429
|
+
if (typeof pkg.module === "string") candidates.push(pkg.module);
|
|
1430
|
+
if (typeof pkg.main === "string") candidates.push(pkg.main);
|
|
1431
|
+
for (const cand of candidates) {
|
|
1432
|
+
if (path9.extname(cand) === preferredExt) {
|
|
1433
|
+
const full = path9.resolve(pkgDir, cand);
|
|
1434
|
+
if (fs8.existsSync(full)) return full;
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
for (const cand of candidates) {
|
|
1438
|
+
const full = path9.resolve(pkgDir, cand);
|
|
1439
|
+
if (fs8.existsSync(full)) return full;
|
|
1440
|
+
}
|
|
1441
|
+
return null;
|
|
1442
|
+
}
|
|
1344
1443
|
function rewriteExternalRequires(code) {
|
|
1345
1444
|
const pkgs = /* @__PURE__ */ new Set();
|
|
1346
1445
|
const re = /__require\(["']([^"']+)["']\)/g;
|
|
@@ -1851,7 +1950,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
1851
1950
|
const localUrl = `http://localhost:${actualPort}`;
|
|
1852
1951
|
const networkUrl = host === "0.0.0.0" ? `http://${getNetworkAddress()}:${actualPort}` : null;
|
|
1853
1952
|
console.log();
|
|
1854
|
-
console.log(pc3.cyan(" nasti dev server") + pc3.dim(` v${"1.6.
|
|
1953
|
+
console.log(pc3.cyan(" nasti dev server") + pc3.dim(` v${"1.6.2"}`));
|
|
1855
1954
|
console.log();
|
|
1856
1955
|
console.log(` ${pc3.green(">")} Local: ${pc3.cyan(localUrl)}`);
|
|
1857
1956
|
if (networkUrl) {
|
|
@@ -1975,7 +2074,7 @@ async function buildElectron(inlineConfig = {}) {
|
|
|
1975
2074
|
const config = await resolveConfig({ ...inlineConfig, target: "electron" }, "build");
|
|
1976
2075
|
const startTime = performance.now();
|
|
1977
2076
|
assertElectronVersion(config);
|
|
1978
|
-
console.log(pc2.cyan("\n\u26A1 nasti build (electron)") + pc2.dim(` v${"1.6.
|
|
2077
|
+
console.log(pc2.cyan("\n\u26A1 nasti build (electron)") + pc2.dim(` v${"1.6.2"}`));
|
|
1979
2078
|
console.log(pc2.dim(` root: ${config.root}`));
|
|
1980
2079
|
console.log(pc2.dim(` mode: ${config.mode}`));
|
|
1981
2080
|
console.log(pc2.dim(` target: electron (\u2265 ${config.electron.minVersion})`));
|
|
@@ -2122,7 +2221,7 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
2122
2221
|
const { noSpawn, ...rest } = inlineConfig;
|
|
2123
2222
|
const config = await resolveConfig({ ...rest, target: "electron" }, "serve");
|
|
2124
2223
|
warnElectronVersion(config);
|
|
2125
|
-
console.log(pc4.cyan("\n\u26A1 nasti electron dev") + pc4.dim(` v${"1.6.
|
|
2224
|
+
console.log(pc4.cyan("\n\u26A1 nasti electron dev") + pc4.dim(` v${"1.6.2"}`));
|
|
2126
2225
|
const { createServer: createServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
|
|
2127
2226
|
const server = await createServer2({ ...rest, target: "electron" });
|
|
2128
2227
|
await server.listen();
|