@nasti-toolchain/nasti 1.3.1 → 1.3.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 +90 -14
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +89 -13
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +86 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +86 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -628,7 +628,6 @@ __export(middleware_exports, {
|
|
|
628
628
|
});
|
|
629
629
|
import path4 from "path";
|
|
630
630
|
import fs4 from "fs";
|
|
631
|
-
import { createRequire } from "module";
|
|
632
631
|
function transformMiddleware(ctx) {
|
|
633
632
|
ctx.envDefine = buildEnvDefine(
|
|
634
633
|
loadEnv(ctx.config.mode, ctx.config.root, ctx.config.envPrefix),
|
|
@@ -748,16 +747,92 @@ function rewriteImports(code, _config) {
|
|
|
748
747
|
}
|
|
749
748
|
);
|
|
750
749
|
}
|
|
750
|
+
function resolveNodeModule(root, moduleName) {
|
|
751
|
+
let pkgName;
|
|
752
|
+
let subpath;
|
|
753
|
+
if (moduleName.startsWith("@")) {
|
|
754
|
+
const parts = moduleName.split("/");
|
|
755
|
+
pkgName = parts.slice(0, 2).join("/");
|
|
756
|
+
subpath = parts.slice(2).join("/");
|
|
757
|
+
} else {
|
|
758
|
+
const slash = moduleName.indexOf("/");
|
|
759
|
+
pkgName = slash === -1 ? moduleName : moduleName.slice(0, slash);
|
|
760
|
+
subpath = slash === -1 ? "" : moduleName.slice(slash + 1);
|
|
761
|
+
}
|
|
762
|
+
let pkgDir = null;
|
|
763
|
+
let dir = root;
|
|
764
|
+
for (; ; ) {
|
|
765
|
+
const candidate = path4.join(dir, "node_modules", pkgName);
|
|
766
|
+
if (fs4.existsSync(candidate)) {
|
|
767
|
+
pkgDir = candidate;
|
|
768
|
+
break;
|
|
769
|
+
}
|
|
770
|
+
const parent = path4.dirname(dir);
|
|
771
|
+
if (parent === dir) break;
|
|
772
|
+
dir = parent;
|
|
773
|
+
}
|
|
774
|
+
if (!pkgDir) return null;
|
|
775
|
+
const pkgJsonPath = path4.join(pkgDir, "package.json");
|
|
776
|
+
if (!fs4.existsSync(pkgJsonPath)) return null;
|
|
777
|
+
let pkg;
|
|
778
|
+
try {
|
|
779
|
+
pkg = JSON.parse(fs4.readFileSync(pkgJsonPath, "utf-8"));
|
|
780
|
+
} catch {
|
|
781
|
+
return null;
|
|
782
|
+
}
|
|
783
|
+
if (pkg.exports) {
|
|
784
|
+
const exportKey = subpath ? `./${subpath}` : ".";
|
|
785
|
+
const resolved = resolvePackageExports(pkg.exports, exportKey, pkgDir);
|
|
786
|
+
if (resolved) return resolved;
|
|
787
|
+
}
|
|
788
|
+
if (subpath) {
|
|
789
|
+
const direct = path4.join(pkgDir, subpath);
|
|
790
|
+
if (fs4.existsSync(direct) && fs4.statSync(direct).isFile()) return direct;
|
|
791
|
+
for (const ext of RESOLVE_EXTENSIONS) {
|
|
792
|
+
if (fs4.existsSync(direct + ext)) return direct + ext;
|
|
793
|
+
}
|
|
794
|
+
return null;
|
|
795
|
+
}
|
|
796
|
+
for (const field of ["module", "jsnext:main", "jsnext", "main"]) {
|
|
797
|
+
if (typeof pkg[field] === "string") {
|
|
798
|
+
const entry = path4.join(pkgDir, pkg[field]);
|
|
799
|
+
if (fs4.existsSync(entry)) return entry;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
return null;
|
|
803
|
+
}
|
|
804
|
+
function resolvePackageExports(exports, key, pkgDir) {
|
|
805
|
+
if (typeof exports === "string") {
|
|
806
|
+
return key === "." ? path4.join(pkgDir, exports) : null;
|
|
807
|
+
}
|
|
808
|
+
const entry = exports[key];
|
|
809
|
+
if (entry === void 0) return null;
|
|
810
|
+
return resolveExportValue(entry, pkgDir);
|
|
811
|
+
}
|
|
812
|
+
function resolveExportValue(value, pkgDir) {
|
|
813
|
+
if (typeof value === "string") return path4.join(pkgDir, value);
|
|
814
|
+
if (Array.isArray(value)) {
|
|
815
|
+
for (const item of value) {
|
|
816
|
+
const r = resolveExportValue(item, pkgDir);
|
|
817
|
+
if (r) return r;
|
|
818
|
+
}
|
|
819
|
+
return null;
|
|
820
|
+
}
|
|
821
|
+
if (value && typeof value === "object") {
|
|
822
|
+
for (const cond of ESM_CONDITIONS) {
|
|
823
|
+
if (cond in value) {
|
|
824
|
+
const r = resolveExportValue(value[cond], pkgDir);
|
|
825
|
+
if (r) return r;
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
return null;
|
|
830
|
+
}
|
|
751
831
|
function resolveUrlToFile(url, root) {
|
|
752
832
|
const cleanUrl = url.split("?")[0];
|
|
753
833
|
if (cleanUrl.startsWith("/@modules/")) {
|
|
754
834
|
const moduleName = cleanUrl.slice("/@modules/".length);
|
|
755
|
-
|
|
756
|
-
const req = createRequire(path4.resolve(root, "package.json"));
|
|
757
|
-
return req.resolve(moduleName);
|
|
758
|
-
} catch {
|
|
759
|
-
return null;
|
|
760
|
-
}
|
|
835
|
+
return resolveNodeModule(root, moduleName);
|
|
761
836
|
}
|
|
762
837
|
const filePath = path4.resolve(root, cleanUrl.replace(/^\//, ""));
|
|
763
838
|
if (fs4.existsSync(filePath) && fs4.statSync(filePath).isFile()) {
|
|
@@ -878,7 +953,7 @@ if (!window.__nasti_hot_map) window.__nasti_hot_map = new Map();
|
|
|
878
953
|
window.__NASTI_HMR__ = { createHotContext };
|
|
879
954
|
`;
|
|
880
955
|
}
|
|
881
|
-
var RESOLVE_EXTENSIONS;
|
|
956
|
+
var RESOLVE_EXTENSIONS, ESM_CONDITIONS;
|
|
882
957
|
var init_middleware = __esm({
|
|
883
958
|
"src/server/middleware.ts"() {
|
|
884
959
|
"use strict";
|
|
@@ -886,6 +961,7 @@ var init_middleware = __esm({
|
|
|
886
961
|
init_html();
|
|
887
962
|
init_env();
|
|
888
963
|
RESOLVE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".mjs", ".json", ".vue"];
|
|
964
|
+
ESM_CONDITIONS = ["import", "browser", "module", "default"];
|
|
889
965
|
}
|
|
890
966
|
});
|
|
891
967
|
|
|
@@ -948,10 +1024,10 @@ var init_hmr = __esm({
|
|
|
948
1024
|
// src/plugins/resolve.ts
|
|
949
1025
|
import path6 from "path";
|
|
950
1026
|
import fs6 from "fs";
|
|
951
|
-
import { createRequire
|
|
1027
|
+
import { createRequire } from "module";
|
|
952
1028
|
function resolvePlugin(config) {
|
|
953
1029
|
const { alias, extensions } = config.resolve;
|
|
954
|
-
const require2 =
|
|
1030
|
+
const require2 = createRequire(path6.resolve(config.root, "package.json"));
|
|
955
1031
|
return {
|
|
956
1032
|
name: "nasti:resolve",
|
|
957
1033
|
enforce: "pre",
|
|
@@ -1226,7 +1302,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
1226
1302
|
const localUrl = `http://localhost:${actualPort}`;
|
|
1227
1303
|
const networkUrl = host === "0.0.0.0" ? `http://${getNetworkAddress()}:${actualPort}` : null;
|
|
1228
1304
|
console.log();
|
|
1229
|
-
console.log(pc.cyan(" nasti dev server") + pc.dim(` v${"1.3.
|
|
1305
|
+
console.log(pc.cyan(" nasti dev server") + pc.dim(` v${"1.3.2"}`));
|
|
1230
1306
|
console.log();
|
|
1231
1307
|
console.log(` ${pc.green(">")} Local: ${pc.cyan(localUrl)}`);
|
|
1232
1308
|
if (networkUrl) {
|
|
@@ -1300,7 +1376,7 @@ import pc2 from "picocolors";
|
|
|
1300
1376
|
async function build(inlineConfig = {}) {
|
|
1301
1377
|
const config = await resolveConfig(inlineConfig, "build");
|
|
1302
1378
|
const startTime = performance.now();
|
|
1303
|
-
console.log(pc2.cyan("\n\u{1F528} nasti build") + pc2.dim(` v${"1.3.
|
|
1379
|
+
console.log(pc2.cyan("\n\u{1F528} nasti build") + pc2.dim(` v${"1.3.2"}`));
|
|
1304
1380
|
console.log(pc2.dim(` root: ${config.root}`));
|
|
1305
1381
|
console.log(pc2.dim(` mode: ${config.mode}`));
|
|
1306
1382
|
const outDir = path10.resolve(config.root, config.build.outDir);
|
|
@@ -1520,6 +1596,6 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
|
|
|
1520
1596
|
}
|
|
1521
1597
|
});
|
|
1522
1598
|
cli.help();
|
|
1523
|
-
cli.version("1.3.
|
|
1599
|
+
cli.version("1.3.2");
|
|
1524
1600
|
cli.parse();
|
|
1525
1601
|
//# sourceMappingURL=cli.js.map
|