@marko/run 0.5.17 → 0.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/.tsbuildinfo +1 -1
- package/dist/adapter/index.cjs +71 -193
- package/dist/adapter/index.js +71 -193
- package/dist/adapter/middleware.cjs +70 -202
- package/dist/adapter/middleware.js +70 -192
- package/dist/cli/index.mjs +92 -81
- package/dist/runtime/internal.cjs +1 -1
- package/dist/runtime/internal.js +1 -1
- package/dist/vite/index.cjs +91 -80
- package/dist/vite/index.js +91 -80
- package/dist/vite/types.d.ts +1 -0
- package/dist/vite/utils/log.d.ts +2 -2
- package/package.json +12 -13
- package/dist/adapter/polyfill.d.ts +0 -11
package/dist/cli/index.mjs
CHANGED
|
@@ -25,7 +25,6 @@ import {
|
|
|
25
25
|
// src/vite/plugin.ts
|
|
26
26
|
import markoVitePlugin from "@marko/vite";
|
|
27
27
|
import browserslist from "browserslist";
|
|
28
|
-
import { createHash } from "crypto";
|
|
29
28
|
import createDebug from "debug";
|
|
30
29
|
import { resolveToEsbuildTarget } from "esbuild-plugin-browserslist";
|
|
31
30
|
import fs3 from "fs";
|
|
@@ -1607,10 +1606,7 @@ var HttpVerbColors = {
|
|
|
1607
1606
|
function verbColor(verb) {
|
|
1608
1607
|
return verb in HttpVerbColors ? HttpVerbColors[verb] : kleur2.gray;
|
|
1609
1608
|
}
|
|
1610
|
-
function logRoutesTable(routes, bundle
|
|
1611
|
-
function getRouteChunkName(route) {
|
|
1612
|
-
return options.sanitizeFileName(`${route.entryName}.marko`);
|
|
1613
|
-
}
|
|
1609
|
+
function logRoutesTable(routes, bundle) {
|
|
1614
1610
|
const hasMiddleware = routes.list.some((route) => route.middleware.length);
|
|
1615
1611
|
const hasMeta = routes.list.some((route) => route.meta);
|
|
1616
1612
|
const headings = ["Method", "Path", "Entry"];
|
|
@@ -1648,9 +1644,7 @@ function logRoutesTable(routes, bundle, options) {
|
|
|
1648
1644
|
if (route.page && (verb === "get" || verb === "head")) {
|
|
1649
1645
|
entryType.push(kleur2.yellow("page"));
|
|
1650
1646
|
if (verb === "get") {
|
|
1651
|
-
size = prettySize(
|
|
1652
|
-
computeRouteSize(getRouteChunkName(route), bundle)
|
|
1653
|
-
);
|
|
1647
|
+
size = prettySize(computeRouteSize(route, bundle));
|
|
1654
1648
|
}
|
|
1655
1649
|
}
|
|
1656
1650
|
const row = [verbCell];
|
|
@@ -1670,15 +1664,18 @@ function logRoutesTable(routes, bundle, options) {
|
|
|
1670
1664
|
const row = [kleur2.bold(kleur2.white("*")), key, kleur2.yellow("page")];
|
|
1671
1665
|
hasMiddleware && row.push("");
|
|
1672
1666
|
hasMeta && row.push("");
|
|
1673
|
-
row.push(prettySize(computeRouteSize(
|
|
1667
|
+
row.push(prettySize(computeRouteSize(route, bundle)));
|
|
1674
1668
|
table.push(row);
|
|
1675
1669
|
}
|
|
1676
1670
|
console.log(table.toString());
|
|
1677
1671
|
}
|
|
1678
|
-
function computeRouteSize(
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1672
|
+
function computeRouteSize(route, bundle) {
|
|
1673
|
+
const facadeModuleId = route.templateFilePath && `${route.templateFilePath}.html`;
|
|
1674
|
+
if (facadeModuleId) {
|
|
1675
|
+
for (const chunk of Object.values(bundle)) {
|
|
1676
|
+
if (chunk.type === "chunk" && chunk.isEntry && chunk.facadeModuleId === facadeModuleId) {
|
|
1677
|
+
return computeChunkSize(chunk, bundle);
|
|
1678
|
+
}
|
|
1682
1679
|
}
|
|
1683
1680
|
}
|
|
1684
1681
|
return [0, 0];
|
|
@@ -1781,6 +1778,8 @@ function markoRun(opts = {}) {
|
|
|
1781
1778
|
let { routesDir, adapter, ...markoVitePluginOptions } = opts;
|
|
1782
1779
|
let store;
|
|
1783
1780
|
let root;
|
|
1781
|
+
let shouldEmptyOutDir = false;
|
|
1782
|
+
let outputDir;
|
|
1784
1783
|
let resolvedRoutesDir;
|
|
1785
1784
|
let entryFilesDir;
|
|
1786
1785
|
let entryFilesDirPosix;
|
|
@@ -1868,25 +1867,32 @@ function markoRun(opts = {}) {
|
|
|
1868
1867
|
);
|
|
1869
1868
|
}
|
|
1870
1869
|
}
|
|
1871
|
-
if (page
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1870
|
+
if (page) {
|
|
1871
|
+
if (layouts.length) {
|
|
1872
|
+
const relativePath = path4.relative(
|
|
1873
|
+
resolvedRoutesDir,
|
|
1874
|
+
page.filePath
|
|
1875
|
+
);
|
|
1876
|
+
const routeFileDir = path4.join(entryFilesDir, relativePath, "..");
|
|
1877
|
+
const routeFileRelativePathPosix = normalizePath(
|
|
1878
|
+
path4.relative(routeFileDir, root)
|
|
1879
|
+
);
|
|
1880
|
+
fs3.mkdirSync(routeFileDir, { recursive: true });
|
|
1881
|
+
const pageNameIndex = page.name.indexOf("+page");
|
|
1882
|
+
const pageNamePrefix = pageNameIndex > 0 ? `${page.name.slice(0, pageNameIndex)}.` : "";
|
|
1883
|
+
fs3.writeFileSync(
|
|
1884
|
+
route.templateFilePath = path4.join(
|
|
1885
|
+
routeFileDir,
|
|
1886
|
+
pageNamePrefix + "route.marko"
|
|
1887
|
+
),
|
|
1888
|
+
renderRouteTemplate(
|
|
1889
|
+
route,
|
|
1890
|
+
(to) => path4.posix.join(routeFileRelativePathPosix, to)
|
|
1891
|
+
)
|
|
1892
|
+
);
|
|
1893
|
+
} else {
|
|
1894
|
+
route.templateFilePath = page.filePath;
|
|
1895
|
+
}
|
|
1890
1896
|
}
|
|
1891
1897
|
virtualFiles.set(
|
|
1892
1898
|
path4.posix.join(root, `${route.entryName}.js`),
|
|
@@ -1895,23 +1901,30 @@ function markoRun(opts = {}) {
|
|
|
1895
1901
|
}
|
|
1896
1902
|
for (const route of Object.values(routes2.special)) {
|
|
1897
1903
|
const { page, layouts, key } = route;
|
|
1898
|
-
if (page
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1904
|
+
if (page) {
|
|
1905
|
+
if (layouts.length) {
|
|
1906
|
+
const relativePath = path4.relative(
|
|
1907
|
+
resolvedRoutesDir,
|
|
1908
|
+
page.filePath
|
|
1909
|
+
);
|
|
1910
|
+
const routeFileDir = path4.join(entryFilesDir, relativePath, "..");
|
|
1911
|
+
const routeFileRelativePathPosix = normalizePath(
|
|
1912
|
+
path4.relative(routeFileDir, root)
|
|
1913
|
+
);
|
|
1914
|
+
fs3.mkdirSync(routeFileDir, { recursive: true });
|
|
1915
|
+
fs3.writeFileSync(
|
|
1916
|
+
route.templateFilePath = path4.join(
|
|
1917
|
+
routeFileDir,
|
|
1918
|
+
`route.${key}.marko`
|
|
1919
|
+
),
|
|
1920
|
+
renderRouteTemplate(
|
|
1921
|
+
route,
|
|
1922
|
+
(to) => path4.posix.join(routeFileRelativePathPosix, to)
|
|
1923
|
+
)
|
|
1924
|
+
);
|
|
1925
|
+
} else {
|
|
1926
|
+
route.templateFilePath = page.filePath;
|
|
1927
|
+
}
|
|
1915
1928
|
}
|
|
1916
1929
|
}
|
|
1917
1930
|
if (routes2.middleware.length) {
|
|
@@ -1964,7 +1977,7 @@ function markoRun(opts = {}) {
|
|
|
1964
1977
|
name: `${PLUGIN_NAME_PREFIX}:pre`,
|
|
1965
1978
|
enforce: "pre",
|
|
1966
1979
|
async config(config2, env) {
|
|
1967
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1980
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
1968
1981
|
const externalPluginOptions = getExternalPluginOptions(config2);
|
|
1969
1982
|
if (externalPluginOptions) {
|
|
1970
1983
|
opts = mergeConfig(opts, externalPluginOptions);
|
|
@@ -1995,11 +2008,8 @@ function markoRun(opts = {}) {
|
|
|
1995
2008
|
markoVitePluginOptions.runtimeId = opts.runtimeId;
|
|
1996
2009
|
markoVitePluginOptions.basePathVar = opts.basePathVar;
|
|
1997
2010
|
resolvedRoutesDir = path4.resolve(root, routesDir);
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
".marko",
|
|
2001
|
-
createHash("shake256", { outputLength: 4 }).update(root).digest("hex")
|
|
2002
|
-
);
|
|
2011
|
+
outputDir = path4.join(root, ((_d = config2.build) == null ? void 0 : _d.outDir) || "dist");
|
|
2012
|
+
entryFilesDir = path4.join(outputDir, ".marko-run");
|
|
2003
2013
|
entryFilesDirPosix = normalizePath(entryFilesDir);
|
|
2004
2014
|
relativeEntryFilesDirPosix = normalizePath(
|
|
2005
2015
|
path4.relative(root, entryFilesDir)
|
|
@@ -2007,9 +2017,9 @@ function markoRun(opts = {}) {
|
|
|
2007
2017
|
typesDir = path4.join(root, ".marko-run");
|
|
2008
2018
|
devEntryFile = path4.join(root, "index.html");
|
|
2009
2019
|
devEntryFilePosix = normalizePath(devEntryFile);
|
|
2010
|
-
let outDir = ((
|
|
2011
|
-
const assetsDir = ((
|
|
2012
|
-
let rollupOutputOptions = (
|
|
2020
|
+
let outDir = ((_e = config2.build) == null ? void 0 : _e.outDir) || "dist";
|
|
2021
|
+
const assetsDir = ((_f = config2.build) == null ? void 0 : _f.assetsDir) || "assets";
|
|
2022
|
+
let rollupOutputOptions = (_h = (_g = config2.build) == null ? void 0 : _g.rollupOptions) == null ? void 0 : _h.output;
|
|
2013
2023
|
if (isBuild) {
|
|
2014
2024
|
if (!isSSRBuild) {
|
|
2015
2025
|
outDir = path4.join(outDir, CLIENT_OUT_DIR);
|
|
@@ -2049,9 +2059,10 @@ function markoRun(opts = {}) {
|
|
|
2049
2059
|
}));
|
|
2050
2060
|
}
|
|
2051
2061
|
}
|
|
2052
|
-
const browserslistTarget = isBuild && !((
|
|
2062
|
+
const browserslistTarget = isBuild && !((_i = config2.build) == null ? void 0 : _i.target) ? browserslist(void 0, {
|
|
2053
2063
|
path: root
|
|
2054
2064
|
}) : void 0;
|
|
2065
|
+
shouldEmptyOutDir = ((_j = config2.build) == null ? void 0 : _j.emptyOutDir) ?? true;
|
|
2055
2066
|
let pluginConfig = {
|
|
2056
2067
|
logLevel: isBuild ? "warn" : void 0,
|
|
2057
2068
|
define: isBuild ? {
|
|
@@ -2069,18 +2080,17 @@ function markoRun(opts = {}) {
|
|
|
2069
2080
|
target: (browserslistTarget == null ? void 0 : browserslistTarget.length) ? resolveToEsbuildTarget(browserslistTarget, {
|
|
2070
2081
|
printUnknownTargets: false
|
|
2071
2082
|
}) : void 0,
|
|
2072
|
-
emptyOutDir: isSSRBuild,
|
|
2073
|
-
// Avoid server & client deleting files from each other.
|
|
2074
2083
|
copyPublicDir: !isSSRBuild,
|
|
2075
2084
|
ssrEmitAssets: false,
|
|
2085
|
+
emptyOutDir: false,
|
|
2076
2086
|
rollupOptions: {
|
|
2077
2087
|
output: rollupOutputOptions
|
|
2078
2088
|
},
|
|
2079
2089
|
modulePreload: { polyfill: false },
|
|
2080
|
-
sourcemap: ((
|
|
2090
|
+
sourcemap: ((_k = config2.build) == null ? void 0 : _k.sourcemap) ?? (isBuild && !isSSRBuild)
|
|
2081
2091
|
},
|
|
2082
2092
|
optimizeDeps: {
|
|
2083
|
-
entries: !((
|
|
2093
|
+
entries: !((_l = config2.optimizeDeps) == null ? void 0 : _l.entries) ? [
|
|
2084
2094
|
"src/pages/**/*+{page,layout}.marko",
|
|
2085
2095
|
"!**/__snapshots__/**",
|
|
2086
2096
|
`!**/__tests__/**`,
|
|
@@ -2168,6 +2178,11 @@ function markoRun(opts = {}) {
|
|
|
2168
2178
|
}).unwatch(typesDir + "/*");
|
|
2169
2179
|
},
|
|
2170
2180
|
async buildStart(_options) {
|
|
2181
|
+
if (isSSRBuild && shouldEmptyOutDir) {
|
|
2182
|
+
if (fs3.existsSync(outputDir)) {
|
|
2183
|
+
fs3.rmSync(outputDir, { recursive: true });
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2171
2186
|
if (isBuild && !isSSRBuild) {
|
|
2172
2187
|
try {
|
|
2173
2188
|
routeData = await store.read();
|
|
@@ -2268,17 +2283,22 @@ function markoRun(opts = {}) {
|
|
|
2268
2283
|
store.write(routeData);
|
|
2269
2284
|
await ((_a = opts == null ? void 0 : opts.emitRoutes) == null ? void 0 : _a.call(opts, routes.list));
|
|
2270
2285
|
} else if (process.env.MR_EXPLORER !== "true") {
|
|
2271
|
-
logRoutesTable(routes, bundle
|
|
2286
|
+
logRoutesTable(routes, bundle);
|
|
2272
2287
|
}
|
|
2273
2288
|
},
|
|
2274
2289
|
async closeBundle() {
|
|
2275
|
-
if (isBuild && !isSSRBuild
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2290
|
+
if (isBuild && !isSSRBuild) {
|
|
2291
|
+
if (fs3.existsSync(entryFilesDir)) {
|
|
2292
|
+
fs3.rmSync(entryFilesDir, { recursive: true });
|
|
2293
|
+
}
|
|
2294
|
+
if ((adapter == null ? void 0 : adapter.buildEnd) && routes) {
|
|
2295
|
+
await adapter.buildEnd(
|
|
2296
|
+
resolvedConfig,
|
|
2297
|
+
routes.list,
|
|
2298
|
+
routeData.builtEntries,
|
|
2299
|
+
routeData.sourceEntries
|
|
2300
|
+
);
|
|
2301
|
+
}
|
|
2282
2302
|
}
|
|
2283
2303
|
}
|
|
2284
2304
|
}
|
|
@@ -2370,15 +2390,6 @@ function getImporters(module, fileName, seen = /* @__PURE__ */ new Set()) {
|
|
|
2370
2390
|
}
|
|
2371
2391
|
return seen;
|
|
2372
2392
|
}
|
|
2373
|
-
function getModulesDir(root, dir = __dirname) {
|
|
2374
|
-
if (dir.startsWith(root)) {
|
|
2375
|
-
const index = dir.indexOf("node_modules");
|
|
2376
|
-
if (index >= 0) {
|
|
2377
|
-
return dir.slice(0, index + 12);
|
|
2378
|
-
}
|
|
2379
|
-
}
|
|
2380
|
-
return path4.join(root, "node_modules");
|
|
2381
|
-
}
|
|
2382
2393
|
var defaultConfigPlugin = {
|
|
2383
2394
|
name: `${PLUGIN_NAME_PREFIX}:defaults`,
|
|
2384
2395
|
enforce: "pre",
|
|
@@ -2428,7 +2439,7 @@ async function getAvailablePort(port) {
|
|
|
2428
2439
|
|
|
2429
2440
|
// src/cli/commands.ts
|
|
2430
2441
|
var __dirname2 = path5.dirname(fileURLToPath2(import.meta.url));
|
|
2431
|
-
var defaultConfigFileBases = ["
|
|
2442
|
+
var defaultConfigFileBases = ["vite.config"];
|
|
2432
2443
|
var defaultConfigFileExts = [".js", ".cjs", ".mjs", ".ts", ".mts"];
|
|
2433
2444
|
async function preview(entry, distEntry, cwd, configFile, port, outDir, envFile, args = []) {
|
|
2434
2445
|
var _a;
|
|
@@ -89,7 +89,7 @@ function createContext(route, request, platform, url = new URL(request.url)) {
|
|
|
89
89
|
}
|
|
90
90
|
async function call(handler, next, context) {
|
|
91
91
|
let response;
|
|
92
|
-
if (process.env.NODE_ENV
|
|
92
|
+
if (!process.env.NODE_ENV || process.env.NODE_ENV === "development") {
|
|
93
93
|
let nextCallCount = 0;
|
|
94
94
|
let didThrow = false;
|
|
95
95
|
try {
|
package/dist/runtime/internal.js
CHANGED
|
@@ -47,7 +47,7 @@ function createContext(route, request, platform, url = new URL(request.url)) {
|
|
|
47
47
|
}
|
|
48
48
|
async function call(handler, next, context) {
|
|
49
49
|
let response;
|
|
50
|
-
if (process.env.NODE_ENV
|
|
50
|
+
if (!process.env.NODE_ENV || process.env.NODE_ENV === "development") {
|
|
51
51
|
let nextCallCount = 0;
|
|
52
52
|
let didThrow = false;
|
|
53
53
|
try {
|
package/dist/vite/index.cjs
CHANGED
|
@@ -57,7 +57,6 @@ var __importMetaURL = (0, import_url.pathToFileURL)(__filename);
|
|
|
57
57
|
// src/vite/plugin.ts
|
|
58
58
|
var import_vite = __toESM(require("@marko/vite"), 1);
|
|
59
59
|
var import_browserslist = __toESM(require("browserslist"), 1);
|
|
60
|
-
var import_crypto = require("crypto");
|
|
61
60
|
var import_debug = __toESM(require("debug"), 1);
|
|
62
61
|
var import_esbuild_plugin_browserslist = require("esbuild-plugin-browserslist");
|
|
63
62
|
var import_fs3 = __toESM(require("fs"), 1);
|
|
@@ -1638,10 +1637,7 @@ var HttpVerbColors = {
|
|
|
1638
1637
|
function verbColor(verb) {
|
|
1639
1638
|
return verb in HttpVerbColors ? HttpVerbColors[verb] : import_kleur2.default.gray;
|
|
1640
1639
|
}
|
|
1641
|
-
function logRoutesTable(routes, bundle
|
|
1642
|
-
function getRouteChunkName(route) {
|
|
1643
|
-
return options.sanitizeFileName(`${route.entryName}.marko`);
|
|
1644
|
-
}
|
|
1640
|
+
function logRoutesTable(routes, bundle) {
|
|
1645
1641
|
const hasMiddleware = routes.list.some((route) => route.middleware.length);
|
|
1646
1642
|
const hasMeta = routes.list.some((route) => route.meta);
|
|
1647
1643
|
const headings = ["Method", "Path", "Entry"];
|
|
@@ -1679,9 +1675,7 @@ function logRoutesTable(routes, bundle, options) {
|
|
|
1679
1675
|
if (route.page && (verb === "get" || verb === "head")) {
|
|
1680
1676
|
entryType.push(import_kleur2.default.yellow("page"));
|
|
1681
1677
|
if (verb === "get") {
|
|
1682
|
-
size = prettySize(
|
|
1683
|
-
computeRouteSize(getRouteChunkName(route), bundle)
|
|
1684
|
-
);
|
|
1678
|
+
size = prettySize(computeRouteSize(route, bundle));
|
|
1685
1679
|
}
|
|
1686
1680
|
}
|
|
1687
1681
|
const row = [verbCell];
|
|
@@ -1701,15 +1695,18 @@ function logRoutesTable(routes, bundle, options) {
|
|
|
1701
1695
|
const row = [import_kleur2.default.bold(import_kleur2.default.white("*")), key, import_kleur2.default.yellow("page")];
|
|
1702
1696
|
hasMiddleware && row.push("");
|
|
1703
1697
|
hasMeta && row.push("");
|
|
1704
|
-
row.push(prettySize(computeRouteSize(
|
|
1698
|
+
row.push(prettySize(computeRouteSize(route, bundle)));
|
|
1705
1699
|
table.push(row);
|
|
1706
1700
|
}
|
|
1707
1701
|
console.log(table.toString());
|
|
1708
1702
|
}
|
|
1709
|
-
function computeRouteSize(
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1703
|
+
function computeRouteSize(route, bundle) {
|
|
1704
|
+
const facadeModuleId = route.templateFilePath && `${route.templateFilePath}.html`;
|
|
1705
|
+
if (facadeModuleId) {
|
|
1706
|
+
for (const chunk of Object.values(bundle)) {
|
|
1707
|
+
if (chunk.type === "chunk" && chunk.isEntry && chunk.facadeModuleId === facadeModuleId) {
|
|
1708
|
+
return computeChunkSize(chunk, bundle);
|
|
1709
|
+
}
|
|
1713
1710
|
}
|
|
1714
1711
|
}
|
|
1715
1712
|
return [0, 0];
|
|
@@ -1812,6 +1809,8 @@ function markoRun(opts = {}) {
|
|
|
1812
1809
|
let { routesDir, adapter, ...markoVitePluginOptions } = opts;
|
|
1813
1810
|
let store;
|
|
1814
1811
|
let root;
|
|
1812
|
+
let shouldEmptyOutDir = false;
|
|
1813
|
+
let outputDir;
|
|
1815
1814
|
let resolvedRoutesDir;
|
|
1816
1815
|
let entryFilesDir;
|
|
1817
1816
|
let entryFilesDirPosix;
|
|
@@ -1899,25 +1898,32 @@ function markoRun(opts = {}) {
|
|
|
1899
1898
|
);
|
|
1900
1899
|
}
|
|
1901
1900
|
}
|
|
1902
|
-
if (page
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1901
|
+
if (page) {
|
|
1902
|
+
if (layouts.length) {
|
|
1903
|
+
const relativePath = import_path4.default.relative(
|
|
1904
|
+
resolvedRoutesDir,
|
|
1905
|
+
page.filePath
|
|
1906
|
+
);
|
|
1907
|
+
const routeFileDir = import_path4.default.join(entryFilesDir, relativePath, "..");
|
|
1908
|
+
const routeFileRelativePathPosix = normalizePath(
|
|
1909
|
+
import_path4.default.relative(routeFileDir, root)
|
|
1910
|
+
);
|
|
1911
|
+
import_fs3.default.mkdirSync(routeFileDir, { recursive: true });
|
|
1912
|
+
const pageNameIndex = page.name.indexOf("+page");
|
|
1913
|
+
const pageNamePrefix = pageNameIndex > 0 ? `${page.name.slice(0, pageNameIndex)}.` : "";
|
|
1914
|
+
import_fs3.default.writeFileSync(
|
|
1915
|
+
route.templateFilePath = import_path4.default.join(
|
|
1916
|
+
routeFileDir,
|
|
1917
|
+
pageNamePrefix + "route.marko"
|
|
1918
|
+
),
|
|
1919
|
+
renderRouteTemplate(
|
|
1920
|
+
route,
|
|
1921
|
+
(to) => import_path4.default.posix.join(routeFileRelativePathPosix, to)
|
|
1922
|
+
)
|
|
1923
|
+
);
|
|
1924
|
+
} else {
|
|
1925
|
+
route.templateFilePath = page.filePath;
|
|
1926
|
+
}
|
|
1921
1927
|
}
|
|
1922
1928
|
virtualFiles.set(
|
|
1923
1929
|
import_path4.default.posix.join(root, `${route.entryName}.js`),
|
|
@@ -1926,23 +1932,30 @@ function markoRun(opts = {}) {
|
|
|
1926
1932
|
}
|
|
1927
1933
|
for (const route of Object.values(routes2.special)) {
|
|
1928
1934
|
const { page, layouts, key } = route;
|
|
1929
|
-
if (page
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1935
|
+
if (page) {
|
|
1936
|
+
if (layouts.length) {
|
|
1937
|
+
const relativePath = import_path4.default.relative(
|
|
1938
|
+
resolvedRoutesDir,
|
|
1939
|
+
page.filePath
|
|
1940
|
+
);
|
|
1941
|
+
const routeFileDir = import_path4.default.join(entryFilesDir, relativePath, "..");
|
|
1942
|
+
const routeFileRelativePathPosix = normalizePath(
|
|
1943
|
+
import_path4.default.relative(routeFileDir, root)
|
|
1944
|
+
);
|
|
1945
|
+
import_fs3.default.mkdirSync(routeFileDir, { recursive: true });
|
|
1946
|
+
import_fs3.default.writeFileSync(
|
|
1947
|
+
route.templateFilePath = import_path4.default.join(
|
|
1948
|
+
routeFileDir,
|
|
1949
|
+
`route.${key}.marko`
|
|
1950
|
+
),
|
|
1951
|
+
renderRouteTemplate(
|
|
1952
|
+
route,
|
|
1953
|
+
(to) => import_path4.default.posix.join(routeFileRelativePathPosix, to)
|
|
1954
|
+
)
|
|
1955
|
+
);
|
|
1956
|
+
} else {
|
|
1957
|
+
route.templateFilePath = page.filePath;
|
|
1958
|
+
}
|
|
1946
1959
|
}
|
|
1947
1960
|
}
|
|
1948
1961
|
if (routes2.middleware.length) {
|
|
@@ -1995,7 +2008,7 @@ function markoRun(opts = {}) {
|
|
|
1995
2008
|
name: `${PLUGIN_NAME_PREFIX}:pre`,
|
|
1996
2009
|
enforce: "pre",
|
|
1997
2010
|
async config(config2, env) {
|
|
1998
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2011
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
1999
2012
|
const externalPluginOptions = getExternalPluginOptions(config2);
|
|
2000
2013
|
if (externalPluginOptions) {
|
|
2001
2014
|
opts = (0, import_vite2.mergeConfig)(opts, externalPluginOptions);
|
|
@@ -2026,11 +2039,8 @@ function markoRun(opts = {}) {
|
|
|
2026
2039
|
markoVitePluginOptions.runtimeId = opts.runtimeId;
|
|
2027
2040
|
markoVitePluginOptions.basePathVar = opts.basePathVar;
|
|
2028
2041
|
resolvedRoutesDir = import_path4.default.resolve(root, routesDir);
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
".marko",
|
|
2032
|
-
(0, import_crypto.createHash)("shake256", { outputLength: 4 }).update(root).digest("hex")
|
|
2033
|
-
);
|
|
2042
|
+
outputDir = import_path4.default.join(root, ((_d = config2.build) == null ? void 0 : _d.outDir) || "dist");
|
|
2043
|
+
entryFilesDir = import_path4.default.join(outputDir, ".marko-run");
|
|
2034
2044
|
entryFilesDirPosix = normalizePath(entryFilesDir);
|
|
2035
2045
|
relativeEntryFilesDirPosix = normalizePath(
|
|
2036
2046
|
import_path4.default.relative(root, entryFilesDir)
|
|
@@ -2038,9 +2048,9 @@ function markoRun(opts = {}) {
|
|
|
2038
2048
|
typesDir = import_path4.default.join(root, ".marko-run");
|
|
2039
2049
|
devEntryFile = import_path4.default.join(root, "index.html");
|
|
2040
2050
|
devEntryFilePosix = normalizePath(devEntryFile);
|
|
2041
|
-
let outDir = ((
|
|
2042
|
-
const assetsDir = ((
|
|
2043
|
-
let rollupOutputOptions = (
|
|
2051
|
+
let outDir = ((_e = config2.build) == null ? void 0 : _e.outDir) || "dist";
|
|
2052
|
+
const assetsDir = ((_f = config2.build) == null ? void 0 : _f.assetsDir) || "assets";
|
|
2053
|
+
let rollupOutputOptions = (_h = (_g = config2.build) == null ? void 0 : _g.rollupOptions) == null ? void 0 : _h.output;
|
|
2044
2054
|
if (isBuild) {
|
|
2045
2055
|
if (!isSSRBuild) {
|
|
2046
2056
|
outDir = import_path4.default.join(outDir, CLIENT_OUT_DIR);
|
|
@@ -2080,9 +2090,10 @@ function markoRun(opts = {}) {
|
|
|
2080
2090
|
}));
|
|
2081
2091
|
}
|
|
2082
2092
|
}
|
|
2083
|
-
const browserslistTarget = isBuild && !((
|
|
2093
|
+
const browserslistTarget = isBuild && !((_i = config2.build) == null ? void 0 : _i.target) ? (0, import_browserslist.default)(void 0, {
|
|
2084
2094
|
path: root
|
|
2085
2095
|
}) : void 0;
|
|
2096
|
+
shouldEmptyOutDir = ((_j = config2.build) == null ? void 0 : _j.emptyOutDir) ?? true;
|
|
2086
2097
|
let pluginConfig = {
|
|
2087
2098
|
logLevel: isBuild ? "warn" : void 0,
|
|
2088
2099
|
define: isBuild ? {
|
|
@@ -2100,18 +2111,17 @@ function markoRun(opts = {}) {
|
|
|
2100
2111
|
target: (browserslistTarget == null ? void 0 : browserslistTarget.length) ? (0, import_esbuild_plugin_browserslist.resolveToEsbuildTarget)(browserslistTarget, {
|
|
2101
2112
|
printUnknownTargets: false
|
|
2102
2113
|
}) : void 0,
|
|
2103
|
-
emptyOutDir: isSSRBuild,
|
|
2104
|
-
// Avoid server & client deleting files from each other.
|
|
2105
2114
|
copyPublicDir: !isSSRBuild,
|
|
2106
2115
|
ssrEmitAssets: false,
|
|
2116
|
+
emptyOutDir: false,
|
|
2107
2117
|
rollupOptions: {
|
|
2108
2118
|
output: rollupOutputOptions
|
|
2109
2119
|
},
|
|
2110
2120
|
modulePreload: { polyfill: false },
|
|
2111
|
-
sourcemap: ((
|
|
2121
|
+
sourcemap: ((_k = config2.build) == null ? void 0 : _k.sourcemap) ?? (isBuild && !isSSRBuild)
|
|
2112
2122
|
},
|
|
2113
2123
|
optimizeDeps: {
|
|
2114
|
-
entries: !((
|
|
2124
|
+
entries: !((_l = config2.optimizeDeps) == null ? void 0 : _l.entries) ? [
|
|
2115
2125
|
"src/pages/**/*+{page,layout}.marko",
|
|
2116
2126
|
"!**/__snapshots__/**",
|
|
2117
2127
|
`!**/__tests__/**`,
|
|
@@ -2199,6 +2209,11 @@ function markoRun(opts = {}) {
|
|
|
2199
2209
|
}).unwatch(typesDir + "/*");
|
|
2200
2210
|
},
|
|
2201
2211
|
async buildStart(_options) {
|
|
2212
|
+
if (isSSRBuild && shouldEmptyOutDir) {
|
|
2213
|
+
if (import_fs3.default.existsSync(outputDir)) {
|
|
2214
|
+
import_fs3.default.rmSync(outputDir, { recursive: true });
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2202
2217
|
if (isBuild && !isSSRBuild) {
|
|
2203
2218
|
try {
|
|
2204
2219
|
routeData = await store.read();
|
|
@@ -2299,17 +2314,22 @@ function markoRun(opts = {}) {
|
|
|
2299
2314
|
store.write(routeData);
|
|
2300
2315
|
await ((_a = opts == null ? void 0 : opts.emitRoutes) == null ? void 0 : _a.call(opts, routes.list));
|
|
2301
2316
|
} else if (process.env.MR_EXPLORER !== "true") {
|
|
2302
|
-
logRoutesTable(routes, bundle
|
|
2317
|
+
logRoutesTable(routes, bundle);
|
|
2303
2318
|
}
|
|
2304
2319
|
},
|
|
2305
2320
|
async closeBundle() {
|
|
2306
|
-
if (isBuild && !isSSRBuild
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2321
|
+
if (isBuild && !isSSRBuild) {
|
|
2322
|
+
if (import_fs3.default.existsSync(entryFilesDir)) {
|
|
2323
|
+
import_fs3.default.rmSync(entryFilesDir, { recursive: true });
|
|
2324
|
+
}
|
|
2325
|
+
if ((adapter == null ? void 0 : adapter.buildEnd) && routes) {
|
|
2326
|
+
await adapter.buildEnd(
|
|
2327
|
+
resolvedConfig,
|
|
2328
|
+
routes.list,
|
|
2329
|
+
routeData.builtEntries,
|
|
2330
|
+
routeData.sourceEntries
|
|
2331
|
+
);
|
|
2332
|
+
}
|
|
2313
2333
|
}
|
|
2314
2334
|
}
|
|
2315
2335
|
}
|
|
@@ -2396,15 +2416,6 @@ function getImporters(module2, fileName, seen = /* @__PURE__ */ new Set()) {
|
|
|
2396
2416
|
}
|
|
2397
2417
|
return seen;
|
|
2398
2418
|
}
|
|
2399
|
-
function getModulesDir(root, dir = __dirname) {
|
|
2400
|
-
if (dir.startsWith(root)) {
|
|
2401
|
-
const index = dir.indexOf("node_modules");
|
|
2402
|
-
if (index >= 0) {
|
|
2403
|
-
return dir.slice(0, index + 12);
|
|
2404
|
-
}
|
|
2405
|
-
}
|
|
2406
|
-
return import_path4.default.join(root, "node_modules");
|
|
2407
|
-
}
|
|
2408
2419
|
var defaultConfigPlugin = {
|
|
2409
2420
|
name: `${PLUGIN_NAME_PREFIX}:defaults`,
|
|
2410
2421
|
enforce: "pre",
|