@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/cli.js
CHANGED
|
@@ -739,7 +739,7 @@ __export(middleware_exports, {
|
|
|
739
739
|
import path4 from "path";
|
|
740
740
|
import fs4 from "fs";
|
|
741
741
|
import { createRequire } from "module";
|
|
742
|
-
import { fileURLToPath } from "url";
|
|
742
|
+
import { fileURLToPath, pathToFileURL as pathToFileURL2 } from "url";
|
|
743
743
|
function getReactRefreshRuntimeEsm() {
|
|
744
744
|
if (__refreshRuntimeCache) return __refreshRuntimeCache;
|
|
745
745
|
let cjsPath;
|
|
@@ -947,6 +947,8 @@ async function bundlePackageAsEsm(entryFile) {
|
|
|
947
947
|
return esmBundleCache.get(entryFile);
|
|
948
948
|
}
|
|
949
949
|
async function doBundlePackage(entryFile) {
|
|
950
|
+
const shim = await tryGenerateSubpathShim(entryFile);
|
|
951
|
+
if (shim != null) return shim;
|
|
950
952
|
const { rolldown: rolldown4 } = await import("rolldown");
|
|
951
953
|
const bundle = await rolldown4({
|
|
952
954
|
input: entryFile,
|
|
@@ -976,6 +978,103 @@ async function doBundlePackage(entryFile) {
|
|
|
976
978
|
}
|
|
977
979
|
return code;
|
|
978
980
|
}
|
|
981
|
+
async function tryGenerateSubpathShim(entryFile) {
|
|
982
|
+
const NM = `${path4.sep}node_modules${path4.sep}`;
|
|
983
|
+
if (!entryFile.includes(NM)) return null;
|
|
984
|
+
let pkgDir = null;
|
|
985
|
+
let pkgName = null;
|
|
986
|
+
let dir = path4.dirname(entryFile);
|
|
987
|
+
while (true) {
|
|
988
|
+
const pkgJsonPath = path4.join(dir, "package.json");
|
|
989
|
+
if (fs4.existsSync(pkgJsonPath)) {
|
|
990
|
+
try {
|
|
991
|
+
const pkg = JSON.parse(fs4.readFileSync(pkgJsonPath, "utf-8"));
|
|
992
|
+
if (typeof pkg?.name === "string" && pkg.name) {
|
|
993
|
+
pkgDir = dir;
|
|
994
|
+
pkgName = pkg.name;
|
|
995
|
+
break;
|
|
996
|
+
}
|
|
997
|
+
} catch {
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
const parent = path4.dirname(dir);
|
|
1001
|
+
if (parent === dir) return null;
|
|
1002
|
+
dir = parent;
|
|
1003
|
+
if (!dir.includes(NM)) return null;
|
|
1004
|
+
}
|
|
1005
|
+
if (!pkgDir || !pkgName) return null;
|
|
1006
|
+
const entryExt = path4.extname(entryFile);
|
|
1007
|
+
const mainEntry = pickMainEntryByExtension(pkgDir, entryExt);
|
|
1008
|
+
if (!mainEntry) return null;
|
|
1009
|
+
if (path4.resolve(mainEntry) === path4.resolve(entryFile)) return null;
|
|
1010
|
+
let mainNs;
|
|
1011
|
+
let subNs;
|
|
1012
|
+
try {
|
|
1013
|
+
mainNs = await import(pathToFileURL2(mainEntry).href);
|
|
1014
|
+
subNs = await import(pathToFileURL2(entryFile).href);
|
|
1015
|
+
} catch {
|
|
1016
|
+
return null;
|
|
1017
|
+
}
|
|
1018
|
+
if (!mainNs || typeof mainNs !== "object") return null;
|
|
1019
|
+
if (!subNs || typeof subNs !== "object") return null;
|
|
1020
|
+
const subKeys = Object.keys(subNs).filter(
|
|
1021
|
+
(k) => k !== "__esModule" && k !== "default" && VALID_IDENT.test(k)
|
|
1022
|
+
);
|
|
1023
|
+
if (subKeys.length === 0) return null;
|
|
1024
|
+
for (const k of subKeys) {
|
|
1025
|
+
if (!(k in mainNs)) return null;
|
|
1026
|
+
if (mainNs[k] !== subNs[k]) return null;
|
|
1027
|
+
}
|
|
1028
|
+
if ("default" in subNs) {
|
|
1029
|
+
if (!("default" in mainNs)) return null;
|
|
1030
|
+
if (mainNs["default"] !== subNs["default"]) return null;
|
|
1031
|
+
}
|
|
1032
|
+
const lines = [
|
|
1033
|
+
`// Nasti subpath shim \u2192 ${pkgName} (avoid duplicate bundling)`,
|
|
1034
|
+
`import * as __pkg from "/@modules/${pkgName}";`
|
|
1035
|
+
];
|
|
1036
|
+
for (const k of subKeys) {
|
|
1037
|
+
lines.push(`export const ${k} = __pkg[${JSON.stringify(k)}];`);
|
|
1038
|
+
}
|
|
1039
|
+
if ("default" in subNs) {
|
|
1040
|
+
lines.push(`export default ("default" in __pkg ? __pkg["default"] : __pkg);`);
|
|
1041
|
+
}
|
|
1042
|
+
return lines.join("\n") + "\n";
|
|
1043
|
+
}
|
|
1044
|
+
function pickMainEntryByExtension(pkgDir, preferredExt) {
|
|
1045
|
+
const pkgJsonPath = path4.join(pkgDir, "package.json");
|
|
1046
|
+
let pkg;
|
|
1047
|
+
try {
|
|
1048
|
+
pkg = JSON.parse(fs4.readFileSync(pkgJsonPath, "utf-8"));
|
|
1049
|
+
} catch {
|
|
1050
|
+
return null;
|
|
1051
|
+
}
|
|
1052
|
+
const candidates = [];
|
|
1053
|
+
const collectFromExportObject = (obj) => {
|
|
1054
|
+
if (!obj || typeof obj !== "object") return;
|
|
1055
|
+
for (const cond of ["import", "module", "default", "require", "node"]) {
|
|
1056
|
+
const v = obj[cond];
|
|
1057
|
+
if (typeof v === "string") candidates.push(v);
|
|
1058
|
+
else if (v && typeof v === "object") collectFromExportObject(v);
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
1061
|
+
const dot = pkg?.exports?.["."];
|
|
1062
|
+
if (typeof dot === "string") candidates.push(dot);
|
|
1063
|
+
else if (dot && typeof dot === "object") collectFromExportObject(dot);
|
|
1064
|
+
if (typeof pkg.module === "string") candidates.push(pkg.module);
|
|
1065
|
+
if (typeof pkg.main === "string") candidates.push(pkg.main);
|
|
1066
|
+
for (const cand of candidates) {
|
|
1067
|
+
if (path4.extname(cand) === preferredExt) {
|
|
1068
|
+
const full = path4.resolve(pkgDir, cand);
|
|
1069
|
+
if (fs4.existsSync(full)) return full;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
for (const cand of candidates) {
|
|
1073
|
+
const full = path4.resolve(pkgDir, cand);
|
|
1074
|
+
if (fs4.existsSync(full)) return full;
|
|
1075
|
+
}
|
|
1076
|
+
return null;
|
|
1077
|
+
}
|
|
979
1078
|
function rewriteExternalRequires(code) {
|
|
980
1079
|
const pkgs = /* @__PURE__ */ new Set();
|
|
981
1080
|
const re = /__require\(["']([^"']+)["']\)/g;
|
|
@@ -1691,7 +1790,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
1691
1790
|
const localUrl = `http://localhost:${actualPort}`;
|
|
1692
1791
|
const networkUrl = host === "0.0.0.0" ? `http://${getNetworkAddress()}:${actualPort}` : null;
|
|
1693
1792
|
console.log();
|
|
1694
|
-
console.log(pc.cyan(" nasti dev server") + pc.dim(` v${"1.6.
|
|
1793
|
+
console.log(pc.cyan(" nasti dev server") + pc.dim(` v${"1.6.2"}`));
|
|
1695
1794
|
console.log();
|
|
1696
1795
|
console.log(` ${pc.green(">")} Local: ${pc.cyan(localUrl)}`);
|
|
1697
1796
|
if (networkUrl) {
|
|
@@ -1814,7 +1913,7 @@ import pc2 from "picocolors";
|
|
|
1814
1913
|
async function build(inlineConfig = {}) {
|
|
1815
1914
|
const config = await resolveConfig(inlineConfig, "build");
|
|
1816
1915
|
const startTime = performance.now();
|
|
1817
|
-
console.log(pc2.cyan("\n\u{1F528} nasti build") + pc2.dim(` v${"1.6.
|
|
1916
|
+
console.log(pc2.cyan("\n\u{1F528} nasti build") + pc2.dim(` v${"1.6.2"}`));
|
|
1818
1917
|
console.log(pc2.dim(` root: ${config.root}`));
|
|
1819
1918
|
console.log(pc2.dim(` mode: ${config.mode}`));
|
|
1820
1919
|
const outDir = path10.resolve(config.root, config.build.outDir);
|
|
@@ -1974,7 +2073,7 @@ async function buildElectron(inlineConfig = {}) {
|
|
|
1974
2073
|
const config = await resolveConfig({ ...inlineConfig, target: "electron" }, "build");
|
|
1975
2074
|
const startTime = performance.now();
|
|
1976
2075
|
assertElectronVersion(config);
|
|
1977
|
-
console.log(pc3.cyan("\n\u26A1 nasti build (electron)") + pc3.dim(` v${"1.6.
|
|
2076
|
+
console.log(pc3.cyan("\n\u26A1 nasti build (electron)") + pc3.dim(` v${"1.6.2"}`));
|
|
1978
2077
|
console.log(pc3.dim(` root: ${config.root}`));
|
|
1979
2078
|
console.log(pc3.dim(` mode: ${config.mode}`));
|
|
1980
2079
|
console.log(pc3.dim(` target: electron (\u2265 ${config.electron.minVersion})`));
|
|
@@ -2128,7 +2227,7 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
2128
2227
|
const { noSpawn, ...rest } = inlineConfig;
|
|
2129
2228
|
const config = await resolveConfig({ ...rest, target: "electron" }, "serve");
|
|
2130
2229
|
warnElectronVersion(config);
|
|
2131
|
-
console.log(pc4.cyan("\n\u26A1 nasti electron dev") + pc4.dim(` v${"1.6.
|
|
2230
|
+
console.log(pc4.cyan("\n\u26A1 nasti electron dev") + pc4.dim(` v${"1.6.2"}`));
|
|
2132
2231
|
const { createServer: createServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
|
|
2133
2232
|
const server = await createServer2({ ...rest, target: "electron" });
|
|
2134
2233
|
await server.listen();
|
|
@@ -2455,6 +2554,6 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
|
|
|
2455
2554
|
}
|
|
2456
2555
|
});
|
|
2457
2556
|
cli.help();
|
|
2458
|
-
cli.version("1.6.
|
|
2557
|
+
cli.version("1.6.2");
|
|
2459
2558
|
cli.parse();
|
|
2460
2559
|
//# sourceMappingURL=cli.js.map
|