@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.cjs
CHANGED
|
@@ -769,16 +769,92 @@ function rewriteImports(code, _config) {
|
|
|
769
769
|
}
|
|
770
770
|
);
|
|
771
771
|
}
|
|
772
|
+
function resolveNodeModule(root, moduleName) {
|
|
773
|
+
let pkgName;
|
|
774
|
+
let subpath;
|
|
775
|
+
if (moduleName.startsWith("@")) {
|
|
776
|
+
const parts = moduleName.split("/");
|
|
777
|
+
pkgName = parts.slice(0, 2).join("/");
|
|
778
|
+
subpath = parts.slice(2).join("/");
|
|
779
|
+
} else {
|
|
780
|
+
const slash = moduleName.indexOf("/");
|
|
781
|
+
pkgName = slash === -1 ? moduleName : moduleName.slice(0, slash);
|
|
782
|
+
subpath = slash === -1 ? "" : moduleName.slice(slash + 1);
|
|
783
|
+
}
|
|
784
|
+
let pkgDir = null;
|
|
785
|
+
let dir = root;
|
|
786
|
+
for (; ; ) {
|
|
787
|
+
const candidate = import_node_path4.default.join(dir, "node_modules", pkgName);
|
|
788
|
+
if (import_node_fs4.default.existsSync(candidate)) {
|
|
789
|
+
pkgDir = candidate;
|
|
790
|
+
break;
|
|
791
|
+
}
|
|
792
|
+
const parent = import_node_path4.default.dirname(dir);
|
|
793
|
+
if (parent === dir) break;
|
|
794
|
+
dir = parent;
|
|
795
|
+
}
|
|
796
|
+
if (!pkgDir) return null;
|
|
797
|
+
const pkgJsonPath = import_node_path4.default.join(pkgDir, "package.json");
|
|
798
|
+
if (!import_node_fs4.default.existsSync(pkgJsonPath)) return null;
|
|
799
|
+
let pkg;
|
|
800
|
+
try {
|
|
801
|
+
pkg = JSON.parse(import_node_fs4.default.readFileSync(pkgJsonPath, "utf-8"));
|
|
802
|
+
} catch {
|
|
803
|
+
return null;
|
|
804
|
+
}
|
|
805
|
+
if (pkg.exports) {
|
|
806
|
+
const exportKey = subpath ? `./${subpath}` : ".";
|
|
807
|
+
const resolved = resolvePackageExports(pkg.exports, exportKey, pkgDir);
|
|
808
|
+
if (resolved) return resolved;
|
|
809
|
+
}
|
|
810
|
+
if (subpath) {
|
|
811
|
+
const direct = import_node_path4.default.join(pkgDir, subpath);
|
|
812
|
+
if (import_node_fs4.default.existsSync(direct) && import_node_fs4.default.statSync(direct).isFile()) return direct;
|
|
813
|
+
for (const ext of RESOLVE_EXTENSIONS) {
|
|
814
|
+
if (import_node_fs4.default.existsSync(direct + ext)) return direct + ext;
|
|
815
|
+
}
|
|
816
|
+
return null;
|
|
817
|
+
}
|
|
818
|
+
for (const field of ["module", "jsnext:main", "jsnext", "main"]) {
|
|
819
|
+
if (typeof pkg[field] === "string") {
|
|
820
|
+
const entry = import_node_path4.default.join(pkgDir, pkg[field]);
|
|
821
|
+
if (import_node_fs4.default.existsSync(entry)) return entry;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
return null;
|
|
825
|
+
}
|
|
826
|
+
function resolvePackageExports(exports2, key, pkgDir) {
|
|
827
|
+
if (typeof exports2 === "string") {
|
|
828
|
+
return key === "." ? import_node_path4.default.join(pkgDir, exports2) : null;
|
|
829
|
+
}
|
|
830
|
+
const entry = exports2[key];
|
|
831
|
+
if (entry === void 0) return null;
|
|
832
|
+
return resolveExportValue(entry, pkgDir);
|
|
833
|
+
}
|
|
834
|
+
function resolveExportValue(value, pkgDir) {
|
|
835
|
+
if (typeof value === "string") return import_node_path4.default.join(pkgDir, value);
|
|
836
|
+
if (Array.isArray(value)) {
|
|
837
|
+
for (const item of value) {
|
|
838
|
+
const r = resolveExportValue(item, pkgDir);
|
|
839
|
+
if (r) return r;
|
|
840
|
+
}
|
|
841
|
+
return null;
|
|
842
|
+
}
|
|
843
|
+
if (value && typeof value === "object") {
|
|
844
|
+
for (const cond of ESM_CONDITIONS) {
|
|
845
|
+
if (cond in value) {
|
|
846
|
+
const r = resolveExportValue(value[cond], pkgDir);
|
|
847
|
+
if (r) return r;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
return null;
|
|
852
|
+
}
|
|
772
853
|
function resolveUrlToFile(url, root) {
|
|
773
854
|
const cleanUrl = url.split("?")[0];
|
|
774
855
|
if (cleanUrl.startsWith("/@modules/")) {
|
|
775
856
|
const moduleName = cleanUrl.slice("/@modules/".length);
|
|
776
|
-
|
|
777
|
-
const req = (0, import_node_module.createRequire)(import_node_path4.default.resolve(root, "package.json"));
|
|
778
|
-
return req.resolve(moduleName);
|
|
779
|
-
} catch {
|
|
780
|
-
return null;
|
|
781
|
-
}
|
|
857
|
+
return resolveNodeModule(root, moduleName);
|
|
782
858
|
}
|
|
783
859
|
const filePath = import_node_path4.default.resolve(root, cleanUrl.replace(/^\//, ""));
|
|
784
860
|
if (import_node_fs4.default.existsSync(filePath) && import_node_fs4.default.statSync(filePath).isFile()) {
|
|
@@ -899,17 +975,17 @@ if (!window.__nasti_hot_map) window.__nasti_hot_map = new Map();
|
|
|
899
975
|
window.__NASTI_HMR__ = { createHotContext };
|
|
900
976
|
`;
|
|
901
977
|
}
|
|
902
|
-
var import_node_path4, import_node_fs4,
|
|
978
|
+
var import_node_path4, import_node_fs4, RESOLVE_EXTENSIONS, ESM_CONDITIONS;
|
|
903
979
|
var init_middleware = __esm({
|
|
904
980
|
"src/server/middleware.ts"() {
|
|
905
981
|
"use strict";
|
|
906
982
|
import_node_path4 = __toESM(require("path"), 1);
|
|
907
983
|
import_node_fs4 = __toESM(require("fs"), 1);
|
|
908
|
-
import_node_module = require("module");
|
|
909
984
|
init_transformer();
|
|
910
985
|
init_html();
|
|
911
986
|
init_env();
|
|
912
987
|
RESOLVE_EXTENSIONS = [".tsx", ".ts", ".jsx", ".js", ".mjs", ".json", ".vue"];
|
|
988
|
+
ESM_CONDITIONS = ["import", "browser", "module", "default"];
|
|
913
989
|
}
|
|
914
990
|
});
|
|
915
991
|
|
|
@@ -973,7 +1049,7 @@ var init_hmr = __esm({
|
|
|
973
1049
|
// src/plugins/resolve.ts
|
|
974
1050
|
function resolvePlugin(config) {
|
|
975
1051
|
const { alias, extensions } = config.resolve;
|
|
976
|
-
const require2 = (0,
|
|
1052
|
+
const require2 = (0, import_node_module.createRequire)(import_node_path6.default.resolve(config.root, "package.json"));
|
|
977
1053
|
return {
|
|
978
1054
|
name: "nasti:resolve",
|
|
979
1055
|
enforce: "pre",
|
|
@@ -1039,13 +1115,13 @@ function tryResolveFile(file, extensions) {
|
|
|
1039
1115
|
}
|
|
1040
1116
|
return null;
|
|
1041
1117
|
}
|
|
1042
|
-
var import_node_path6, import_node_fs6,
|
|
1118
|
+
var import_node_path6, import_node_fs6, import_node_module;
|
|
1043
1119
|
var init_resolve = __esm({
|
|
1044
1120
|
"src/plugins/resolve.ts"() {
|
|
1045
1121
|
"use strict";
|
|
1046
1122
|
import_node_path6 = __toESM(require("path"), 1);
|
|
1047
1123
|
import_node_fs6 = __toESM(require("fs"), 1);
|
|
1048
|
-
|
|
1124
|
+
import_node_module = require("module");
|
|
1049
1125
|
}
|
|
1050
1126
|
});
|
|
1051
1127
|
|
|
@@ -1246,7 +1322,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
1246
1322
|
const localUrl = `http://localhost:${actualPort}`;
|
|
1247
1323
|
const networkUrl = host === "0.0.0.0" ? `http://${getNetworkAddress()}:${actualPort}` : null;
|
|
1248
1324
|
console.log();
|
|
1249
|
-
console.log(import_picocolors.default.cyan(" nasti dev server") + import_picocolors.default.dim(` v${"1.3.
|
|
1325
|
+
console.log(import_picocolors.default.cyan(" nasti dev server") + import_picocolors.default.dim(` v${"1.3.2"}`));
|
|
1250
1326
|
console.log();
|
|
1251
1327
|
console.log(` ${import_picocolors.default.green(">")} Local: ${import_picocolors.default.cyan(localUrl)}`);
|
|
1252
1328
|
if (networkUrl) {
|
|
@@ -1324,7 +1400,7 @@ __export(build_exports, {
|
|
|
1324
1400
|
async function build(inlineConfig = {}) {
|
|
1325
1401
|
const config = await resolveConfig(inlineConfig, "build");
|
|
1326
1402
|
const startTime = performance.now();
|
|
1327
|
-
console.log(import_picocolors2.default.cyan("\n\u{1F528} nasti build") + import_picocolors2.default.dim(` v${"1.3.
|
|
1403
|
+
console.log(import_picocolors2.default.cyan("\n\u{1F528} nasti build") + import_picocolors2.default.dim(` v${"1.3.2"}`));
|
|
1328
1404
|
console.log(import_picocolors2.default.dim(` root: ${config.root}`));
|
|
1329
1405
|
console.log(import_picocolors2.default.dim(` mode: ${config.mode}`));
|
|
1330
1406
|
const outDir = import_node_path10.default.resolve(config.root, config.build.outDir);
|
|
@@ -1549,6 +1625,6 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
|
|
|
1549
1625
|
}
|
|
1550
1626
|
});
|
|
1551
1627
|
cli.help();
|
|
1552
|
-
cli.version("1.3.
|
|
1628
|
+
cli.version("1.3.2");
|
|
1553
1629
|
cli.parse();
|
|
1554
1630
|
//# sourceMappingURL=cli.cjs.map
|