@nasti-toolchain/nasti 1.6.0 → 1.6.1
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 +68 -21
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +68 -21
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +67 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +67 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -954,7 +954,7 @@ async function transformRequest(url, ctx) {
|
|
|
954
954
|
config.mode
|
|
955
955
|
);
|
|
956
956
|
code = replaceEnvInCode(code, envDefine);
|
|
957
|
-
code = rewriteImports(code, config);
|
|
957
|
+
code = rewriteImports(code, config, filePath);
|
|
958
958
|
const transformResult = { code };
|
|
959
959
|
mod.transformResult = transformResult;
|
|
960
960
|
return transformResult;
|
|
@@ -1036,26 +1036,73 @@ async function injectCjsNamedExports(code, entryFile) {
|
|
|
1036
1036
|
return code;
|
|
1037
1037
|
}
|
|
1038
1038
|
}
|
|
1039
|
-
function rewriteImports(code,
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1039
|
+
function rewriteImports(code, config, filePath) {
|
|
1040
|
+
const root = config.root;
|
|
1041
|
+
const fileDir = import_node_path4.default.dirname(filePath);
|
|
1042
|
+
const aliasEntries = Object.entries(config.resolve.alias).sort(
|
|
1043
|
+
([a], [b]) => b.length - a.length
|
|
1044
|
+
);
|
|
1045
|
+
const toRootUrl = (abs) => "/" + import_node_path4.default.relative(root, abs).replace(/\\/g, "/");
|
|
1046
|
+
const transformSpec = (spec) => {
|
|
1047
|
+
const suffixMatch = spec.match(/[?#].*$/);
|
|
1048
|
+
const suffix = suffixMatch ? suffixMatch[0] : "";
|
|
1049
|
+
const baseSpec = suffix ? spec.slice(0, -suffix.length) : spec;
|
|
1050
|
+
for (const [key, value] of aliasEntries) {
|
|
1051
|
+
if (baseSpec === key || baseSpec.startsWith(key + "/")) {
|
|
1052
|
+
const aliasBase = resolveAliasTarget(value, root);
|
|
1053
|
+
const sub = baseSpec.slice(key.length).replace(/^\//, "");
|
|
1054
|
+
const target = sub ? import_node_path4.default.join(aliasBase, sub) : aliasBase;
|
|
1055
|
+
const resolved = tryResolveDiskPath(target);
|
|
1056
|
+
return resolved && isUnderRoot(resolved, root) ? toRootUrl(resolved) + suffix : spec;
|
|
1057
|
+
}
|
|
1044
1058
|
}
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
return `import ${quote}/@modules/${specifier}${quote}`;
|
|
1059
|
+
if (baseSpec.startsWith("./") || baseSpec.startsWith("../")) {
|
|
1060
|
+
const target = import_node_path4.default.resolve(fileDir, baseSpec);
|
|
1061
|
+
const resolved = tryResolveDiskPath(target);
|
|
1062
|
+
return resolved && isUnderRoot(resolved, root) ? toRootUrl(resolved) + suffix : spec;
|
|
1050
1063
|
}
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
return `import(${quote}/@modules/${specifier}${quote})`;
|
|
1064
|
+
if (baseSpec.startsWith("/") && !baseSpec.startsWith("/@")) {
|
|
1065
|
+
const target = import_node_path4.default.join(root, baseSpec.replace(/^\//, ""));
|
|
1066
|
+
const resolved = tryResolveDiskPath(target);
|
|
1067
|
+
return resolved && isUnderRoot(resolved, root) ? toRootUrl(resolved) + suffix : spec;
|
|
1056
1068
|
}
|
|
1069
|
+
if (baseSpec.startsWith("/")) return spec;
|
|
1070
|
+
return `/@modules/${spec}`;
|
|
1071
|
+
};
|
|
1072
|
+
return code.replace(
|
|
1073
|
+
/\bfrom\s+(['"])([^'"]+)\1/g,
|
|
1074
|
+
(_m, q, s) => `from ${q}${transformSpec(s)}${q}`
|
|
1075
|
+
).replace(
|
|
1076
|
+
/\bimport\s+(['"])([^'"]+)\1/g,
|
|
1077
|
+
(_m, q, s) => `import ${q}${transformSpec(s)}${q}`
|
|
1078
|
+
).replace(
|
|
1079
|
+
/\bimport\s*\(\s*(['"])([^'"]+)\1\s*\)/g,
|
|
1080
|
+
(_m, q, s) => `import(${q}${transformSpec(s)}${q})`
|
|
1057
1081
|
);
|
|
1058
1082
|
}
|
|
1083
|
+
function resolveAliasTarget(value, root) {
|
|
1084
|
+
if (import_node_path4.default.isAbsolute(value) && import_node_fs4.default.existsSync(value)) return value;
|
|
1085
|
+
if (value.startsWith("/")) return import_node_path4.default.join(root, value.slice(1));
|
|
1086
|
+
return import_node_path4.default.resolve(root, value);
|
|
1087
|
+
}
|
|
1088
|
+
function tryResolveDiskPath(target) {
|
|
1089
|
+
if (import_node_fs4.default.existsSync(target) && import_node_fs4.default.statSync(target).isFile()) return target;
|
|
1090
|
+
for (const ext of RESOLVE_EXTENSIONS) {
|
|
1091
|
+
const withExt = target + ext;
|
|
1092
|
+
if (import_node_fs4.default.existsSync(withExt) && import_node_fs4.default.statSync(withExt).isFile()) return withExt;
|
|
1093
|
+
}
|
|
1094
|
+
if (import_node_fs4.default.existsSync(target) && import_node_fs4.default.statSync(target).isDirectory()) {
|
|
1095
|
+
for (const ext of RESOLVE_EXTENSIONS) {
|
|
1096
|
+
const idx = import_node_path4.default.join(target, "index" + ext);
|
|
1097
|
+
if (import_node_fs4.default.existsSync(idx) && import_node_fs4.default.statSync(idx).isFile()) return idx;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
return null;
|
|
1101
|
+
}
|
|
1102
|
+
function isUnderRoot(abs, root) {
|
|
1103
|
+
const rel = import_node_path4.default.relative(root, abs);
|
|
1104
|
+
return !!rel && !rel.startsWith("..") && !import_node_path4.default.isAbsolute(rel);
|
|
1105
|
+
}
|
|
1059
1106
|
function resolveNodeModule(root, moduleName) {
|
|
1060
1107
|
let pkgName;
|
|
1061
1108
|
let subpath;
|
|
@@ -1664,7 +1711,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
1664
1711
|
const localUrl = `http://localhost:${actualPort}`;
|
|
1665
1712
|
const networkUrl = host === "0.0.0.0" ? `http://${getNetworkAddress()}:${actualPort}` : null;
|
|
1666
1713
|
console.log();
|
|
1667
|
-
console.log(import_picocolors.default.cyan(" nasti dev server") + import_picocolors.default.dim(` v${"1.6.
|
|
1714
|
+
console.log(import_picocolors.default.cyan(" nasti dev server") + import_picocolors.default.dim(` v${"1.6.1"}`));
|
|
1668
1715
|
console.log();
|
|
1669
1716
|
console.log(` ${import_picocolors.default.green(">")} Local: ${import_picocolors.default.cyan(localUrl)}`);
|
|
1670
1717
|
if (networkUrl) {
|
|
@@ -1791,7 +1838,7 @@ __export(build_exports, {
|
|
|
1791
1838
|
async function build(inlineConfig = {}) {
|
|
1792
1839
|
const config = await resolveConfig(inlineConfig, "build");
|
|
1793
1840
|
const startTime = performance.now();
|
|
1794
|
-
console.log(import_picocolors2.default.cyan("\n\u{1F528} nasti build") + import_picocolors2.default.dim(` v${"1.6.
|
|
1841
|
+
console.log(import_picocolors2.default.cyan("\n\u{1F528} nasti build") + import_picocolors2.default.dim(` v${"1.6.1"}`));
|
|
1795
1842
|
console.log(import_picocolors2.default.dim(` root: ${config.root}`));
|
|
1796
1843
|
console.log(import_picocolors2.default.dim(` mode: ${config.mode}`));
|
|
1797
1844
|
const outDir = import_node_path10.default.resolve(config.root, config.build.outDir);
|
|
@@ -1952,7 +1999,7 @@ async function buildElectron(inlineConfig = {}) {
|
|
|
1952
1999
|
const config = await resolveConfig({ ...inlineConfig, target: "electron" }, "build");
|
|
1953
2000
|
const startTime = performance.now();
|
|
1954
2001
|
assertElectronVersion(config);
|
|
1955
|
-
console.log(import_picocolors3.default.cyan("\n\u26A1 nasti build (electron)") + import_picocolors3.default.dim(` v${"1.6.
|
|
2002
|
+
console.log(import_picocolors3.default.cyan("\n\u26A1 nasti build (electron)") + import_picocolors3.default.dim(` v${"1.6.1"}`));
|
|
1956
2003
|
console.log(import_picocolors3.default.dim(` root: ${config.root}`));
|
|
1957
2004
|
console.log(import_picocolors3.default.dim(` mode: ${config.mode}`));
|
|
1958
2005
|
console.log(import_picocolors3.default.dim(` target: electron (\u2265 ${config.electron.minVersion})`));
|
|
@@ -2104,7 +2151,7 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
2104
2151
|
const { noSpawn, ...rest } = inlineConfig;
|
|
2105
2152
|
const config = await resolveConfig({ ...rest, target: "electron" }, "serve");
|
|
2106
2153
|
warnElectronVersion(config);
|
|
2107
|
-
console.log(import_picocolors4.default.cyan("\n\u26A1 nasti electron dev") + import_picocolors4.default.dim(` v${"1.6.
|
|
2154
|
+
console.log(import_picocolors4.default.cyan("\n\u26A1 nasti electron dev") + import_picocolors4.default.dim(` v${"1.6.1"}`));
|
|
2108
2155
|
const { createServer: createServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
|
|
2109
2156
|
const server = await createServer2({ ...rest, target: "electron" });
|
|
2110
2157
|
await server.listen();
|
|
@@ -2439,6 +2486,6 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
|
|
|
2439
2486
|
}
|
|
2440
2487
|
});
|
|
2441
2488
|
cli.help();
|
|
2442
|
-
cli.version("1.6.
|
|
2489
|
+
cli.version("1.6.1");
|
|
2443
2490
|
cli.parse();
|
|
2444
2491
|
//# sourceMappingURL=cli.cjs.map
|