@nasti-toolchain/nasti 1.6.3 → 1.6.4
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 +131 -71
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +121 -61
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +186 -126
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +175 -115
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
package/dist/cli.cjs
CHANGED
|
@@ -919,9 +919,9 @@ function transformMiddleware(ctx) {
|
|
|
919
919
|
async function transformRequest(url, ctx) {
|
|
920
920
|
const { config, pluginContainer, moduleGraph } = ctx;
|
|
921
921
|
const cleanReqUrl = url.split("?")[0];
|
|
922
|
-
const
|
|
923
|
-
if (
|
|
924
|
-
return
|
|
922
|
+
const cached2 = moduleGraph.getModuleByUrl(url);
|
|
923
|
+
if (cached2?.transformResult) {
|
|
924
|
+
return cached2.transformResult;
|
|
925
925
|
}
|
|
926
926
|
if (cleanReqUrl === "/@react-refresh") {
|
|
927
927
|
return { code: getReactRefreshRuntimeEsm() };
|
|
@@ -1160,19 +1160,20 @@ function rewriteExternalRequires(code) {
|
|
|
1160
1160
|
}
|
|
1161
1161
|
async function injectCjsNamedExports(code, entryFile) {
|
|
1162
1162
|
try {
|
|
1163
|
-
const { createRequire:
|
|
1164
|
-
const req =
|
|
1163
|
+
const { createRequire: createRequire5 } = await import("module");
|
|
1164
|
+
const req = createRequire5(entryFile);
|
|
1165
1165
|
const cjsExports = req(entryFile);
|
|
1166
1166
|
if (!cjsExports || typeof cjsExports !== "object" && typeof cjsExports !== "function" || Array.isArray(cjsExports)) return code;
|
|
1167
1167
|
const namedKeys = Object.keys(cjsExports).filter(
|
|
1168
1168
|
(k) => k !== "__esModule" && k !== "default" && VALID_IDENT.test(k)
|
|
1169
1169
|
);
|
|
1170
|
-
|
|
1170
|
+
const hasEsmInterop = cjsExports.__esModule === true && "default" in cjsExports;
|
|
1171
|
+
if (!hasEsmInterop && namedKeys.length === 0) return code;
|
|
1171
1172
|
return code.replace(
|
|
1172
1173
|
/^export default (\w+\(\));?\s*$/m,
|
|
1173
1174
|
(_, call) => [
|
|
1174
1175
|
`const __cjsMod = ${call};`,
|
|
1175
|
-
`export default __cjsMod;`,
|
|
1176
|
+
hasEsmInterop ? `export default __cjsMod.default;` : `export default __cjsMod;`,
|
|
1176
1177
|
...namedKeys.map((k) => `export const ${k} = __cjsMod[${JSON.stringify(k)}];`)
|
|
1177
1178
|
].join("\n")
|
|
1178
1179
|
);
|
|
@@ -1659,6 +1660,59 @@ var init_resolve = __esm({
|
|
|
1659
1660
|
}
|
|
1660
1661
|
});
|
|
1661
1662
|
|
|
1663
|
+
// src/plugins/tailwind.ts
|
|
1664
|
+
function hasTailwindDirectives(css) {
|
|
1665
|
+
const withoutBlockComments = css.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
1666
|
+
const withoutLineComments = withoutBlockComments.replace(/\/\/.*$/gm, "");
|
|
1667
|
+
return TAILWIND_DIRECTIVE_RE.test(withoutLineComments);
|
|
1668
|
+
}
|
|
1669
|
+
async function loadTailwind(projectRoot) {
|
|
1670
|
+
if (cached && cachedRoot === projectRoot) return cached;
|
|
1671
|
+
const req = (0, import_node_module3.createRequire)(import_node_path7.default.join(projectRoot, "package.json"));
|
|
1672
|
+
let nodePath;
|
|
1673
|
+
let oxidePath;
|
|
1674
|
+
try {
|
|
1675
|
+
nodePath = req.resolve("@tailwindcss/node");
|
|
1676
|
+
oxidePath = req.resolve("@tailwindcss/oxide");
|
|
1677
|
+
} catch {
|
|
1678
|
+
throw new Error(
|
|
1679
|
+
"[nasti] CSS contains Tailwind v4 directives but `@tailwindcss/node` and/or `@tailwindcss/oxide` are not installed in this project. Install them with: npm i -D tailwindcss @tailwindcss/node @tailwindcss/oxide"
|
|
1680
|
+
);
|
|
1681
|
+
}
|
|
1682
|
+
const node = await import((0, import_node_url3.pathToFileURL)(nodePath).href);
|
|
1683
|
+
const oxide = await import((0, import_node_url3.pathToFileURL)(oxidePath).href);
|
|
1684
|
+
cached = { node, oxide };
|
|
1685
|
+
cachedRoot = projectRoot;
|
|
1686
|
+
return cached;
|
|
1687
|
+
}
|
|
1688
|
+
async function compileTailwind(css, fromFile, projectRoot) {
|
|
1689
|
+
const { node, oxide } = await loadTailwind(projectRoot);
|
|
1690
|
+
const dependencies = [];
|
|
1691
|
+
const compiler = await node.compile(css, {
|
|
1692
|
+
base: import_node_path7.default.dirname(fromFile),
|
|
1693
|
+
from: fromFile,
|
|
1694
|
+
onDependency: (p) => dependencies.push(p)
|
|
1695
|
+
});
|
|
1696
|
+
const scanner = new oxide.Scanner({ sources: compiler.sources });
|
|
1697
|
+
const candidates = scanner.scan();
|
|
1698
|
+
return {
|
|
1699
|
+
css: compiler.build(candidates),
|
|
1700
|
+
dependencies: [...dependencies, ...scanner.files]
|
|
1701
|
+
};
|
|
1702
|
+
}
|
|
1703
|
+
var import_node_path7, import_node_module3, import_node_url3, TAILWIND_DIRECTIVE_RE, cached, cachedRoot;
|
|
1704
|
+
var init_tailwind = __esm({
|
|
1705
|
+
"src/plugins/tailwind.ts"() {
|
|
1706
|
+
"use strict";
|
|
1707
|
+
import_node_path7 = __toESM(require("path"), 1);
|
|
1708
|
+
import_node_module3 = require("module");
|
|
1709
|
+
import_node_url3 = require("url");
|
|
1710
|
+
TAILWIND_DIRECTIVE_RE = /@(?:import\s+["']tailwindcss(?:\b|\/)|tailwind\b|theme\b|apply\b|plugin\b|source\b|utility\b|variant\b|custom-variant\b|reference\b)/;
|
|
1711
|
+
cached = null;
|
|
1712
|
+
cachedRoot = null;
|
|
1713
|
+
}
|
|
1714
|
+
});
|
|
1715
|
+
|
|
1662
1716
|
// src/plugins/css.ts
|
|
1663
1717
|
function cssPlugin(config) {
|
|
1664
1718
|
return {
|
|
@@ -1667,9 +1721,14 @@ function cssPlugin(config) {
|
|
|
1667
1721
|
if (source.endsWith(".css")) return null;
|
|
1668
1722
|
return null;
|
|
1669
1723
|
},
|
|
1670
|
-
transform(code, id) {
|
|
1724
|
+
async transform(code, id) {
|
|
1671
1725
|
if (!id.endsWith(".css")) return null;
|
|
1672
|
-
|
|
1726
|
+
let cssSource = code;
|
|
1727
|
+
if (hasTailwindDirectives(code)) {
|
|
1728
|
+
const compiled = await compileTailwind(code, id, config.root);
|
|
1729
|
+
cssSource = compiled.css;
|
|
1730
|
+
}
|
|
1731
|
+
const rewritten = rewriteCssUrls(cssSource, id, config.root);
|
|
1673
1732
|
if (config.command === "serve") {
|
|
1674
1733
|
const escaped = JSON.stringify(rewritten);
|
|
1675
1734
|
return {
|
|
@@ -1704,16 +1763,17 @@ function rewriteCssUrls(css, from, root) {
|
|
|
1704
1763
|
if (url.startsWith("/") || url.startsWith("data:") || url.startsWith("http")) {
|
|
1705
1764
|
return match;
|
|
1706
1765
|
}
|
|
1707
|
-
const resolved =
|
|
1708
|
-
const relative = "/" +
|
|
1766
|
+
const resolved = import_node_path8.default.resolve(import_node_path8.default.dirname(from), url);
|
|
1767
|
+
const relative = "/" + import_node_path8.default.relative(root, resolved);
|
|
1709
1768
|
return `url(${relative})`;
|
|
1710
1769
|
});
|
|
1711
1770
|
}
|
|
1712
|
-
var
|
|
1771
|
+
var import_node_path8;
|
|
1713
1772
|
var init_css = __esm({
|
|
1714
1773
|
"src/plugins/css.ts"() {
|
|
1715
1774
|
"use strict";
|
|
1716
|
-
|
|
1775
|
+
import_node_path8 = __toESM(require("path"), 1);
|
|
1776
|
+
init_tailwind();
|
|
1717
1777
|
}
|
|
1718
1778
|
});
|
|
1719
1779
|
|
|
@@ -1728,7 +1788,7 @@ function assetsPlugin(config) {
|
|
|
1728
1788
|
return null;
|
|
1729
1789
|
},
|
|
1730
1790
|
load(id) {
|
|
1731
|
-
const ext =
|
|
1791
|
+
const ext = import_node_path9.default.extname(id.replace(/\?.*$/, ""));
|
|
1732
1792
|
if (id.endsWith("?raw")) {
|
|
1733
1793
|
const file = id.slice(0, -4);
|
|
1734
1794
|
if (import_node_fs7.default.existsSync(file)) {
|
|
@@ -1740,12 +1800,12 @@ function assetsPlugin(config) {
|
|
|
1740
1800
|
const file = id.replace(/\?.*$/, "");
|
|
1741
1801
|
if (!import_node_fs7.default.existsSync(file)) return null;
|
|
1742
1802
|
if (config.command === "serve") {
|
|
1743
|
-
const url = "/" +
|
|
1803
|
+
const url = "/" + import_node_path9.default.relative(config.root, file);
|
|
1744
1804
|
return `export default ${JSON.stringify(url)}`;
|
|
1745
1805
|
}
|
|
1746
1806
|
const content = import_node_fs7.default.readFileSync(file);
|
|
1747
1807
|
const hash = import_node_crypto.default.createHash("sha256").update(content).digest("hex").slice(0, 8);
|
|
1748
|
-
const basename =
|
|
1808
|
+
const basename = import_node_path9.default.basename(file, ext);
|
|
1749
1809
|
const hashedName = `${config.build.assetsDir}/${basename}.${hash}${ext}`;
|
|
1750
1810
|
return `export default ${JSON.stringify(config.base + hashedName)}`;
|
|
1751
1811
|
}
|
|
@@ -1753,11 +1813,11 @@ function assetsPlugin(config) {
|
|
|
1753
1813
|
}
|
|
1754
1814
|
};
|
|
1755
1815
|
}
|
|
1756
|
-
var
|
|
1816
|
+
var import_node_path9, import_node_fs7, import_node_crypto, ASSET_EXTENSIONS;
|
|
1757
1817
|
var init_assets = __esm({
|
|
1758
1818
|
"src/plugins/assets.ts"() {
|
|
1759
1819
|
"use strict";
|
|
1760
|
-
|
|
1820
|
+
import_node_path9 = __toESM(require("path"), 1);
|
|
1761
1821
|
import_node_fs7 = __toESM(require("fs"), 1);
|
|
1762
1822
|
import_node_crypto = __toESM(require("crypto"), 1);
|
|
1763
1823
|
ASSET_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
@@ -1810,20 +1870,20 @@ async function createServer(inlineConfig = {}) {
|
|
|
1810
1870
|
pluginContainer,
|
|
1811
1871
|
moduleGraph
|
|
1812
1872
|
}));
|
|
1813
|
-
const publicDir =
|
|
1873
|
+
const publicDir = import_node_path10.default.resolve(config.root, "public");
|
|
1814
1874
|
app.use((0, import_sirv.default)(publicDir, { dev: true, etag: true }));
|
|
1815
1875
|
app.use((0, import_sirv.default)(config.root, { dev: true, etag: true }));
|
|
1816
1876
|
const httpServer = import_node_http.default.createServer(app);
|
|
1817
1877
|
const ws = createWebSocketServer(httpServer);
|
|
1818
1878
|
const ignoredSegments = /* @__PURE__ */ new Set(["node_modules", ".git", ".nasti"]);
|
|
1819
|
-
const outDirAbs =
|
|
1879
|
+
const outDirAbs = import_node_path10.default.resolve(config.root, config.build.outDir);
|
|
1820
1880
|
const watcher = (0, import_chokidar.watch)(config.root, {
|
|
1821
1881
|
ignored: (filePath) => {
|
|
1822
1882
|
if (filePath === config.root) return false;
|
|
1823
|
-
if (filePath === outDirAbs || filePath.startsWith(outDirAbs +
|
|
1824
|
-
const rel =
|
|
1825
|
-
if (!rel || rel.startsWith("..") ||
|
|
1826
|
-
for (const seg of rel.split(
|
|
1883
|
+
if (filePath === outDirAbs || filePath.startsWith(outDirAbs + import_node_path10.default.sep)) return true;
|
|
1884
|
+
const rel = import_node_path10.default.relative(config.root, filePath);
|
|
1885
|
+
if (!rel || rel.startsWith("..") || import_node_path10.default.isAbsolute(rel)) return false;
|
|
1886
|
+
for (const seg of rel.split(import_node_path10.default.sep)) {
|
|
1827
1887
|
if (ignoredSegments.has(seg)) return true;
|
|
1828
1888
|
}
|
|
1829
1889
|
return false;
|
|
@@ -1855,7 +1915,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
1855
1915
|
const localUrl = `http://localhost:${actualPort}`;
|
|
1856
1916
|
const networkUrl = host === "0.0.0.0" ? `http://${getNetworkAddress()}:${actualPort}` : null;
|
|
1857
1917
|
console.log();
|
|
1858
|
-
console.log(import_picocolors.default.cyan(" nasti dev server") + import_picocolors.default.dim(` v${"1.6.
|
|
1918
|
+
console.log(import_picocolors.default.cyan(" nasti dev server") + import_picocolors.default.dim(` v${"1.6.4"}`));
|
|
1859
1919
|
console.log();
|
|
1860
1920
|
console.log(` ${import_picocolors.default.green(">")} Local: ${import_picocolors.default.cyan(localUrl)}`);
|
|
1861
1921
|
if (networkUrl) {
|
|
@@ -1911,12 +1971,12 @@ function getNetworkAddress() {
|
|
|
1911
1971
|
}
|
|
1912
1972
|
return "localhost";
|
|
1913
1973
|
}
|
|
1914
|
-
var import_node_http,
|
|
1974
|
+
var import_node_http, import_node_path10, import_node_os, import_connect, import_sirv, import_chokidar, import_picocolors;
|
|
1915
1975
|
var init_server = __esm({
|
|
1916
1976
|
"src/server/index.ts"() {
|
|
1917
1977
|
"use strict";
|
|
1918
1978
|
import_node_http = __toESM(require("http"), 1);
|
|
1919
|
-
|
|
1979
|
+
import_node_path10 = __toESM(require("path"), 1);
|
|
1920
1980
|
import_node_os = __toESM(require("os"), 1);
|
|
1921
1981
|
import_connect = __toESM(require("connect"), 1);
|
|
1922
1982
|
import_sirv = __toESM(require("sirv"), 1);
|
|
@@ -1956,14 +2016,14 @@ function electronPlugin(config) {
|
|
|
1956
2016
|
}
|
|
1957
2017
|
};
|
|
1958
2018
|
}
|
|
1959
|
-
var
|
|
2019
|
+
var import_node_module4, NODE_BUILTINS, ELECTRON_MODULES;
|
|
1960
2020
|
var init_electron = __esm({
|
|
1961
2021
|
"src/plugins/electron.ts"() {
|
|
1962
2022
|
"use strict";
|
|
1963
|
-
|
|
2023
|
+
import_node_module4 = require("module");
|
|
1964
2024
|
NODE_BUILTINS = /* @__PURE__ */ new Set([
|
|
1965
|
-
...
|
|
1966
|
-
...
|
|
2025
|
+
...import_node_module4.builtinModules,
|
|
2026
|
+
...import_node_module4.builtinModules.map((m) => `node:${m}`)
|
|
1967
2027
|
]);
|
|
1968
2028
|
ELECTRON_MODULES = /* @__PURE__ */ new Set([
|
|
1969
2029
|
"electron",
|
|
@@ -1982,10 +2042,10 @@ __export(build_exports, {
|
|
|
1982
2042
|
async function build(inlineConfig = {}) {
|
|
1983
2043
|
const config = await resolveConfig(inlineConfig, "build");
|
|
1984
2044
|
const startTime = performance.now();
|
|
1985
|
-
console.log(import_picocolors2.default.cyan("\n\u{1F528} nasti build") + import_picocolors2.default.dim(` v${"1.6.
|
|
2045
|
+
console.log(import_picocolors2.default.cyan("\n\u{1F528} nasti build") + import_picocolors2.default.dim(` v${"1.6.4"}`));
|
|
1986
2046
|
console.log(import_picocolors2.default.dim(` root: ${config.root}`));
|
|
1987
2047
|
console.log(import_picocolors2.default.dim(` mode: ${config.mode}`));
|
|
1988
|
-
const outDir =
|
|
2048
|
+
const outDir = import_node_path11.default.resolve(config.root, config.build.outDir);
|
|
1989
2049
|
if (config.build.emptyOutDir && import_node_fs8.default.existsSync(outDir)) {
|
|
1990
2050
|
import_node_fs8.default.rmSync(outDir, { recursive: true, force: true });
|
|
1991
2051
|
}
|
|
@@ -1997,14 +2057,14 @@ async function build(inlineConfig = {}) {
|
|
|
1997
2057
|
for (const match of scriptMatches) {
|
|
1998
2058
|
const src = match[1];
|
|
1999
2059
|
if (src && !src.startsWith("http")) {
|
|
2000
|
-
entryPoints.push(
|
|
2060
|
+
entryPoints.push(import_node_path11.default.resolve(config.root, src.replace(/^\//, "")));
|
|
2001
2061
|
}
|
|
2002
2062
|
}
|
|
2003
2063
|
}
|
|
2004
2064
|
if (entryPoints.length === 0) {
|
|
2005
2065
|
const fallbackEntries = ["src/main.ts", "src/main.tsx", "src/main.js", "src/index.ts", "src/index.tsx", "src/index.js"];
|
|
2006
2066
|
for (const entry of fallbackEntries) {
|
|
2007
|
-
const fullPath =
|
|
2067
|
+
const fullPath = import_node_path11.default.resolve(config.root, entry);
|
|
2008
2068
|
if (import_node_fs8.default.existsSync(fullPath)) {
|
|
2009
2069
|
entryPoints.push(fullPath);
|
|
2010
2070
|
break;
|
|
@@ -2069,8 +2129,8 @@ async function build(inlineConfig = {}) {
|
|
|
2069
2129
|
await bundle.close();
|
|
2070
2130
|
await pluginContainer.buildEnd();
|
|
2071
2131
|
for (const ef of pluginContainer.getEmittedFiles()) {
|
|
2072
|
-
const dest =
|
|
2073
|
-
import_node_fs8.default.mkdirSync(
|
|
2132
|
+
const dest = import_node_path11.default.resolve(outDir, ef.fileName);
|
|
2133
|
+
import_node_fs8.default.mkdirSync(import_node_path11.default.dirname(dest), { recursive: true });
|
|
2074
2134
|
import_node_fs8.default.writeFileSync(dest, ef.source);
|
|
2075
2135
|
}
|
|
2076
2136
|
if (html) {
|
|
@@ -2088,14 +2148,14 @@ async function build(inlineConfig = {}) {
|
|
|
2088
2148
|
}
|
|
2089
2149
|
for (const chunk of output) {
|
|
2090
2150
|
if (chunk.type === "chunk" && chunk.isEntry && chunk.facadeModuleId) {
|
|
2091
|
-
const originalEntry =
|
|
2151
|
+
const originalEntry = import_node_path11.default.relative(config.root, chunk.facadeModuleId);
|
|
2092
2152
|
processedHtml = processedHtml.replace(
|
|
2093
2153
|
new RegExp(`(src=["'])/?(${escapeRegExp(originalEntry)})(["'])`, "g"),
|
|
2094
2154
|
`$1${config.base}${chunk.fileName}$3`
|
|
2095
2155
|
);
|
|
2096
2156
|
}
|
|
2097
2157
|
}
|
|
2098
|
-
import_node_fs8.default.writeFileSync(
|
|
2158
|
+
import_node_fs8.default.writeFileSync(import_node_path11.default.resolve(outDir, "index.html"), processedHtml);
|
|
2099
2159
|
}
|
|
2100
2160
|
const elapsed = ((performance.now() - startTime) / 1e3).toFixed(2);
|
|
2101
2161
|
const totalSize = output.reduce((sum, chunk) => {
|
|
@@ -2117,11 +2177,11 @@ function formatSize(bytes) {
|
|
|
2117
2177
|
function escapeRegExp(string) {
|
|
2118
2178
|
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2119
2179
|
}
|
|
2120
|
-
var
|
|
2180
|
+
var import_node_path11, import_node_fs8, import_rolldown, import_picocolors2;
|
|
2121
2181
|
var init_build = __esm({
|
|
2122
2182
|
"src/build/index.ts"() {
|
|
2123
2183
|
"use strict";
|
|
2124
|
-
|
|
2184
|
+
import_node_path11 = __toESM(require("path"), 1);
|
|
2125
2185
|
import_node_fs8 = __toESM(require("fs"), 1);
|
|
2126
2186
|
import_rolldown = require("rolldown");
|
|
2127
2187
|
init_config();
|
|
@@ -2147,16 +2207,16 @@ async function buildElectron(inlineConfig = {}) {
|
|
|
2147
2207
|
const config = await resolveConfig({ ...inlineConfig, target: "electron" }, "build");
|
|
2148
2208
|
const startTime = performance.now();
|
|
2149
2209
|
assertElectronVersion(config);
|
|
2150
|
-
console.log(import_picocolors3.default.cyan("\n\u26A1 nasti build (electron)") + import_picocolors3.default.dim(` v${"1.6.
|
|
2210
|
+
console.log(import_picocolors3.default.cyan("\n\u26A1 nasti build (electron)") + import_picocolors3.default.dim(` v${"1.6.4"}`));
|
|
2151
2211
|
console.log(import_picocolors3.default.dim(` root: ${config.root}`));
|
|
2152
2212
|
console.log(import_picocolors3.default.dim(` mode: ${config.mode}`));
|
|
2153
2213
|
console.log(import_picocolors3.default.dim(` target: electron (\u2265 ${config.electron.minVersion})`));
|
|
2154
|
-
const outDir =
|
|
2214
|
+
const outDir = import_node_path12.default.resolve(config.root, config.build.outDir);
|
|
2155
2215
|
if (config.build.emptyOutDir && import_node_fs9.default.existsSync(outDir)) {
|
|
2156
2216
|
import_node_fs9.default.rmSync(outDir, { recursive: true, force: true });
|
|
2157
2217
|
}
|
|
2158
2218
|
import_node_fs9.default.mkdirSync(outDir, { recursive: true });
|
|
2159
|
-
const rendererOutDir =
|
|
2219
|
+
const rendererOutDir = import_node_path12.default.join(outDir, "renderer");
|
|
2160
2220
|
const { build: build2 } = await Promise.resolve().then(() => (init_build(), build_exports));
|
|
2161
2221
|
await build2({
|
|
2162
2222
|
...inlineConfig,
|
|
@@ -2167,7 +2227,7 @@ async function buildElectron(inlineConfig = {}) {
|
|
|
2167
2227
|
emptyOutDir: false
|
|
2168
2228
|
}
|
|
2169
2229
|
});
|
|
2170
|
-
const mainEntry =
|
|
2230
|
+
const mainEntry = import_node_path12.default.resolve(config.root, config.electron.main);
|
|
2171
2231
|
if (!import_node_fs9.default.existsSync(mainEntry)) {
|
|
2172
2232
|
throw new Error(
|
|
2173
2233
|
`Electron main entry not found: ${config.electron.main}
|
|
@@ -2186,7 +2246,7 @@ async function buildElectron(inlineConfig = {}) {
|
|
|
2186
2246
|
console.warn(import_picocolors3.default.yellow(` \u26A0 preload entry not found, skipped: ${entry}`));
|
|
2187
2247
|
continue;
|
|
2188
2248
|
}
|
|
2189
|
-
const base =
|
|
2249
|
+
const base = import_node_path12.default.basename(entry).replace(/\.[^.]+$/, "");
|
|
2190
2250
|
const out = outFileName(outDir, base, config.electron.preloadFormat);
|
|
2191
2251
|
await bundleNode(config, entry, {
|
|
2192
2252
|
outFile: out,
|
|
@@ -2198,10 +2258,10 @@ async function buildElectron(inlineConfig = {}) {
|
|
|
2198
2258
|
const elapsed = ((performance.now() - startTime) / 1e3).toFixed(2);
|
|
2199
2259
|
console.log(import_picocolors3.default.green(`
|
|
2200
2260
|
\u2713 Electron build complete in ${elapsed}s`));
|
|
2201
|
-
console.log(import_picocolors3.default.dim(` renderer: ${
|
|
2202
|
-
console.log(import_picocolors3.default.dim(` main: ${
|
|
2261
|
+
console.log(import_picocolors3.default.dim(` renderer: ${import_node_path12.default.relative(config.root, rendererOutDir)}/`));
|
|
2262
|
+
console.log(import_picocolors3.default.dim(` main: ${import_node_path12.default.relative(config.root, mainFile)}`));
|
|
2203
2263
|
for (const pf of preloadFiles) {
|
|
2204
|
-
console.log(import_picocolors3.default.dim(` preload: ${
|
|
2264
|
+
console.log(import_picocolors3.default.dim(` preload: ${import_node_path12.default.relative(config.root, pf)}`));
|
|
2205
2265
|
}
|
|
2206
2266
|
console.log();
|
|
2207
2267
|
return { rendererOutDir, mainFile, preloadFiles };
|
|
@@ -2232,7 +2292,7 @@ async function bundleNode(config, entry, opts) {
|
|
|
2232
2292
|
plugins: [oxcTransformPlugin, electronPlugin(config), resolvePlugin(config)],
|
|
2233
2293
|
...config.build.rolldownOptions
|
|
2234
2294
|
});
|
|
2235
|
-
import_node_fs9.default.mkdirSync(
|
|
2295
|
+
import_node_fs9.default.mkdirSync(import_node_path12.default.dirname(opts.outFile), { recursive: true });
|
|
2236
2296
|
await bundle.write({
|
|
2237
2297
|
file: opts.outFile,
|
|
2238
2298
|
format: opts.format === "cjs" ? "cjs" : "esm",
|
|
@@ -2241,16 +2301,16 @@ async function bundleNode(config, entry, opts) {
|
|
|
2241
2301
|
codeSplitting: false
|
|
2242
2302
|
});
|
|
2243
2303
|
await bundle.close();
|
|
2244
|
-
console.log(import_picocolors3.default.dim(` \u2713 ${opts.label} \u2192 ${
|
|
2304
|
+
console.log(import_picocolors3.default.dim(` \u2713 ${opts.label} \u2192 ${import_node_path12.default.relative(config.root, opts.outFile)}`));
|
|
2245
2305
|
return opts.outFile;
|
|
2246
2306
|
}
|
|
2247
2307
|
function outFileName(outDir, base, format) {
|
|
2248
2308
|
const ext = format === "cjs" ? ".cjs" : ".mjs";
|
|
2249
|
-
return
|
|
2309
|
+
return import_node_path12.default.join(outDir, base + ext);
|
|
2250
2310
|
}
|
|
2251
2311
|
function normalizePreload(preload, root) {
|
|
2252
2312
|
const list = Array.isArray(preload) ? preload : preload ? [preload] : [];
|
|
2253
|
-
return list.map((p) =>
|
|
2313
|
+
return list.map((p) => import_node_path12.default.resolve(root, p));
|
|
2254
2314
|
}
|
|
2255
2315
|
function assertElectronVersion(config) {
|
|
2256
2316
|
const min = config.electron.minVersion;
|
|
@@ -2265,7 +2325,7 @@ function assertElectronVersion(config) {
|
|
|
2265
2325
|
}
|
|
2266
2326
|
function detectInstalledElectron(root) {
|
|
2267
2327
|
try {
|
|
2268
|
-
const pkgPath =
|
|
2328
|
+
const pkgPath = import_node_path12.default.resolve(root, "node_modules/electron/package.json");
|
|
2269
2329
|
if (!import_node_fs9.default.existsSync(pkgPath)) return null;
|
|
2270
2330
|
const pkg = JSON.parse(import_node_fs9.default.readFileSync(pkgPath, "utf-8"));
|
|
2271
2331
|
const major = parseInt(String(pkg.version).split(".")[0], 10);
|
|
@@ -2274,11 +2334,11 @@ function detectInstalledElectron(root) {
|
|
|
2274
2334
|
return null;
|
|
2275
2335
|
}
|
|
2276
2336
|
}
|
|
2277
|
-
var
|
|
2337
|
+
var import_node_path12, import_node_fs9, import_rolldown2, import_picocolors3;
|
|
2278
2338
|
var init_electron2 = __esm({
|
|
2279
2339
|
"src/build/electron.ts"() {
|
|
2280
2340
|
"use strict";
|
|
2281
|
-
|
|
2341
|
+
import_node_path12 = __toESM(require("path"), 1);
|
|
2282
2342
|
import_node_fs9 = __toESM(require("fs"), 1);
|
|
2283
2343
|
import_rolldown2 = require("rolldown");
|
|
2284
2344
|
import_picocolors3 = __toESM(require("picocolors"), 1);
|
|
@@ -2299,17 +2359,17 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
2299
2359
|
const { noSpawn, ...rest } = inlineConfig;
|
|
2300
2360
|
const config = await resolveConfig({ ...rest, target: "electron" }, "serve");
|
|
2301
2361
|
warnElectronVersion(config);
|
|
2302
|
-
console.log(import_picocolors4.default.cyan("\n\u26A1 nasti electron dev") + import_picocolors4.default.dim(` v${"1.6.
|
|
2362
|
+
console.log(import_picocolors4.default.cyan("\n\u26A1 nasti electron dev") + import_picocolors4.default.dim(` v${"1.6.4"}`));
|
|
2303
2363
|
const { createServer: createServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
|
|
2304
2364
|
const server = await createServer2({ ...rest, target: "electron" });
|
|
2305
2365
|
await server.listen();
|
|
2306
2366
|
const devUrl = `http://localhost:${server.config.server.port}/`;
|
|
2307
2367
|
console.log(import_picocolors4.default.dim(` renderer: ${devUrl}`));
|
|
2308
|
-
const stageDir =
|
|
2368
|
+
const stageDir = import_node_path13.default.resolve(config.root, ".nasti");
|
|
2309
2369
|
import_node_fs10.default.mkdirSync(stageDir, { recursive: true });
|
|
2310
|
-
const mainEntry =
|
|
2370
|
+
const mainEntry = import_node_path13.default.resolve(config.root, config.electron.main);
|
|
2311
2371
|
const preloadEntries = normalizePreload(config.electron.preload, config.root);
|
|
2312
|
-
const builtMainFile =
|
|
2372
|
+
const builtMainFile = import_node_path13.default.join(stageDir, "main" + extFor(config.electron.mainFormat));
|
|
2313
2373
|
const builtPreloadFiles = [];
|
|
2314
2374
|
const compileAll = async () => {
|
|
2315
2375
|
await compileNode(config, mainEntry, {
|
|
@@ -2320,8 +2380,8 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
2320
2380
|
builtPreloadFiles.length = 0;
|
|
2321
2381
|
for (const entry of preloadEntries) {
|
|
2322
2382
|
if (!import_node_fs10.default.existsSync(entry)) continue;
|
|
2323
|
-
const base =
|
|
2324
|
-
const out =
|
|
2383
|
+
const base = import_node_path13.default.basename(entry).replace(/\.[^.]+$/, "");
|
|
2384
|
+
const out = import_node_path13.default.join(stageDir, base + extFor(config.electron.preloadFormat));
|
|
2325
2385
|
await compileNode(config, entry, {
|
|
2326
2386
|
outFile: out,
|
|
2327
2387
|
format: config.electron.preloadFormat,
|
|
@@ -2436,7 +2496,7 @@ async function compileNode(config, entry, opts) {
|
|
|
2436
2496
|
platform: "node",
|
|
2437
2497
|
plugins: [oxcTransformPlugin, electronPlugin(config), resolvePlugin(config)]
|
|
2438
2498
|
});
|
|
2439
|
-
import_node_fs10.default.mkdirSync(
|
|
2499
|
+
import_node_fs10.default.mkdirSync(import_node_path13.default.dirname(opts.outFile), { recursive: true });
|
|
2440
2500
|
await bundle.write({
|
|
2441
2501
|
file: opts.outFile,
|
|
2442
2502
|
format: opts.format === "cjs" ? "cjs" : "esm",
|
|
@@ -2453,7 +2513,7 @@ function resolveElectronBinary(config) {
|
|
|
2453
2513
|
return config.electron.electronPath;
|
|
2454
2514
|
}
|
|
2455
2515
|
try {
|
|
2456
|
-
const require2 = (0,
|
|
2516
|
+
const require2 = (0, import_node_module5.createRequire)(import_node_path13.default.resolve(config.root, "package.json"));
|
|
2457
2517
|
const pathFile = require2.resolve("electron");
|
|
2458
2518
|
const electronModule = require2(pathFile);
|
|
2459
2519
|
if (typeof electronModule === "string" && import_node_fs10.default.existsSync(electronModule)) {
|
|
@@ -2481,13 +2541,13 @@ function warnElectronVersion(config) {
|
|
|
2481
2541
|
);
|
|
2482
2542
|
}
|
|
2483
2543
|
}
|
|
2484
|
-
var
|
|
2544
|
+
var import_node_path13, import_node_fs10, import_node_module5, import_node_child_process, import_chokidar2, import_picocolors4, import_rolldown3;
|
|
2485
2545
|
var init_electron_dev = __esm({
|
|
2486
2546
|
"src/server/electron-dev.ts"() {
|
|
2487
2547
|
"use strict";
|
|
2488
|
-
|
|
2548
|
+
import_node_path13 = __toESM(require("path"), 1);
|
|
2489
2549
|
import_node_fs10 = __toESM(require("fs"), 1);
|
|
2490
|
-
|
|
2550
|
+
import_node_module5 = require("module");
|
|
2491
2551
|
import_node_child_process = require("child_process");
|
|
2492
2552
|
import_chokidar2 = __toESM(require("chokidar"), 1);
|
|
2493
2553
|
import_picocolors4 = __toESM(require("picocolors"), 1);
|
|
@@ -2609,11 +2669,11 @@ cli.command("electron-build [root]", "Build Electron app for production").option
|
|
|
2609
2669
|
cli.command("preview [root]", "Preview production build").option("--port <port>", "Port number", { default: 4173 }).option("--host [host]", "Hostname").option("--outDir <dir>", "Output directory to serve", { default: "dist" }).action(async (root, options) => {
|
|
2610
2670
|
try {
|
|
2611
2671
|
const http2 = await import("http");
|
|
2612
|
-
const
|
|
2672
|
+
const path14 = await import("path");
|
|
2613
2673
|
const sirv2 = (await import("sirv")).default;
|
|
2614
2674
|
const connect2 = (await import("connect")).default;
|
|
2615
|
-
const resolvedRoot =
|
|
2616
|
-
const outDir =
|
|
2675
|
+
const resolvedRoot = path14.resolve(root ?? ".");
|
|
2676
|
+
const outDir = path14.resolve(resolvedRoot, options.outDir);
|
|
2617
2677
|
const app = connect2();
|
|
2618
2678
|
app.use(sirv2(outDir, { single: true, etag: true, gzip: true, brotli: true }));
|
|
2619
2679
|
const port = options.port;
|
|
@@ -2634,6 +2694,6 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
|
|
|
2634
2694
|
}
|
|
2635
2695
|
});
|
|
2636
2696
|
cli.help();
|
|
2637
|
-
cli.version("1.6.
|
|
2697
|
+
cli.version("1.6.4");
|
|
2638
2698
|
cli.parse();
|
|
2639
2699
|
//# sourceMappingURL=cli.cjs.map
|