@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/vite/index.js
CHANGED
|
@@ -12,7 +12,6 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
12
12
|
// src/vite/plugin.ts
|
|
13
13
|
import markoVitePlugin from "@marko/vite";
|
|
14
14
|
import browserslist from "browserslist";
|
|
15
|
-
import { createHash } from "crypto";
|
|
16
15
|
import createDebug from "debug";
|
|
17
16
|
import { resolveToEsbuildTarget } from "esbuild-plugin-browserslist";
|
|
18
17
|
import fs3 from "fs";
|
|
@@ -1593,10 +1592,7 @@ var HttpVerbColors = {
|
|
|
1593
1592
|
function verbColor(verb) {
|
|
1594
1593
|
return verb in HttpVerbColors ? HttpVerbColors[verb] : kleur2.gray;
|
|
1595
1594
|
}
|
|
1596
|
-
function logRoutesTable(routes, bundle
|
|
1597
|
-
function getRouteChunkName(route) {
|
|
1598
|
-
return options.sanitizeFileName(`${route.entryName}.marko`);
|
|
1599
|
-
}
|
|
1595
|
+
function logRoutesTable(routes, bundle) {
|
|
1600
1596
|
const hasMiddleware = routes.list.some((route) => route.middleware.length);
|
|
1601
1597
|
const hasMeta = routes.list.some((route) => route.meta);
|
|
1602
1598
|
const headings = ["Method", "Path", "Entry"];
|
|
@@ -1634,9 +1630,7 @@ function logRoutesTable(routes, bundle, options) {
|
|
|
1634
1630
|
if (route.page && (verb === "get" || verb === "head")) {
|
|
1635
1631
|
entryType.push(kleur2.yellow("page"));
|
|
1636
1632
|
if (verb === "get") {
|
|
1637
|
-
size = prettySize(
|
|
1638
|
-
computeRouteSize(getRouteChunkName(route), bundle)
|
|
1639
|
-
);
|
|
1633
|
+
size = prettySize(computeRouteSize(route, bundle));
|
|
1640
1634
|
}
|
|
1641
1635
|
}
|
|
1642
1636
|
const row = [verbCell];
|
|
@@ -1656,15 +1650,18 @@ function logRoutesTable(routes, bundle, options) {
|
|
|
1656
1650
|
const row = [kleur2.bold(kleur2.white("*")), key, kleur2.yellow("page")];
|
|
1657
1651
|
hasMiddleware && row.push("");
|
|
1658
1652
|
hasMeta && row.push("");
|
|
1659
|
-
row.push(prettySize(computeRouteSize(
|
|
1653
|
+
row.push(prettySize(computeRouteSize(route, bundle)));
|
|
1660
1654
|
table.push(row);
|
|
1661
1655
|
}
|
|
1662
1656
|
console.log(table.toString());
|
|
1663
1657
|
}
|
|
1664
|
-
function computeRouteSize(
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1658
|
+
function computeRouteSize(route, bundle) {
|
|
1659
|
+
const facadeModuleId = route.templateFilePath && `${route.templateFilePath}.html`;
|
|
1660
|
+
if (facadeModuleId) {
|
|
1661
|
+
for (const chunk of Object.values(bundle)) {
|
|
1662
|
+
if (chunk.type === "chunk" && chunk.isEntry && chunk.facadeModuleId === facadeModuleId) {
|
|
1663
|
+
return computeChunkSize(chunk, bundle);
|
|
1664
|
+
}
|
|
1668
1665
|
}
|
|
1669
1666
|
}
|
|
1670
1667
|
return [0, 0];
|
|
@@ -1767,6 +1764,8 @@ function markoRun(opts = {}) {
|
|
|
1767
1764
|
let { routesDir, adapter, ...markoVitePluginOptions } = opts;
|
|
1768
1765
|
let store;
|
|
1769
1766
|
let root;
|
|
1767
|
+
let shouldEmptyOutDir = false;
|
|
1768
|
+
let outputDir;
|
|
1770
1769
|
let resolvedRoutesDir;
|
|
1771
1770
|
let entryFilesDir;
|
|
1772
1771
|
let entryFilesDirPosix;
|
|
@@ -1854,25 +1853,32 @@ function markoRun(opts = {}) {
|
|
|
1854
1853
|
);
|
|
1855
1854
|
}
|
|
1856
1855
|
}
|
|
1857
|
-
if (page
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1856
|
+
if (page) {
|
|
1857
|
+
if (layouts.length) {
|
|
1858
|
+
const relativePath = path4.relative(
|
|
1859
|
+
resolvedRoutesDir,
|
|
1860
|
+
page.filePath
|
|
1861
|
+
);
|
|
1862
|
+
const routeFileDir = path4.join(entryFilesDir, relativePath, "..");
|
|
1863
|
+
const routeFileRelativePathPosix = normalizePath(
|
|
1864
|
+
path4.relative(routeFileDir, root)
|
|
1865
|
+
);
|
|
1866
|
+
fs3.mkdirSync(routeFileDir, { recursive: true });
|
|
1867
|
+
const pageNameIndex = page.name.indexOf("+page");
|
|
1868
|
+
const pageNamePrefix = pageNameIndex > 0 ? `${page.name.slice(0, pageNameIndex)}.` : "";
|
|
1869
|
+
fs3.writeFileSync(
|
|
1870
|
+
route.templateFilePath = path4.join(
|
|
1871
|
+
routeFileDir,
|
|
1872
|
+
pageNamePrefix + "route.marko"
|
|
1873
|
+
),
|
|
1874
|
+
renderRouteTemplate(
|
|
1875
|
+
route,
|
|
1876
|
+
(to) => path4.posix.join(routeFileRelativePathPosix, to)
|
|
1877
|
+
)
|
|
1878
|
+
);
|
|
1879
|
+
} else {
|
|
1880
|
+
route.templateFilePath = page.filePath;
|
|
1881
|
+
}
|
|
1876
1882
|
}
|
|
1877
1883
|
virtualFiles.set(
|
|
1878
1884
|
path4.posix.join(root, `${route.entryName}.js`),
|
|
@@ -1881,23 +1887,30 @@ function markoRun(opts = {}) {
|
|
|
1881
1887
|
}
|
|
1882
1888
|
for (const route of Object.values(routes2.special)) {
|
|
1883
1889
|
const { page, layouts, key } = route;
|
|
1884
|
-
if (page
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1890
|
+
if (page) {
|
|
1891
|
+
if (layouts.length) {
|
|
1892
|
+
const relativePath = path4.relative(
|
|
1893
|
+
resolvedRoutesDir,
|
|
1894
|
+
page.filePath
|
|
1895
|
+
);
|
|
1896
|
+
const routeFileDir = path4.join(entryFilesDir, relativePath, "..");
|
|
1897
|
+
const routeFileRelativePathPosix = normalizePath(
|
|
1898
|
+
path4.relative(routeFileDir, root)
|
|
1899
|
+
);
|
|
1900
|
+
fs3.mkdirSync(routeFileDir, { recursive: true });
|
|
1901
|
+
fs3.writeFileSync(
|
|
1902
|
+
route.templateFilePath = path4.join(
|
|
1903
|
+
routeFileDir,
|
|
1904
|
+
`route.${key}.marko`
|
|
1905
|
+
),
|
|
1906
|
+
renderRouteTemplate(
|
|
1907
|
+
route,
|
|
1908
|
+
(to) => path4.posix.join(routeFileRelativePathPosix, to)
|
|
1909
|
+
)
|
|
1910
|
+
);
|
|
1911
|
+
} else {
|
|
1912
|
+
route.templateFilePath = page.filePath;
|
|
1913
|
+
}
|
|
1901
1914
|
}
|
|
1902
1915
|
}
|
|
1903
1916
|
if (routes2.middleware.length) {
|
|
@@ -1950,7 +1963,7 @@ function markoRun(opts = {}) {
|
|
|
1950
1963
|
name: `${PLUGIN_NAME_PREFIX}:pre`,
|
|
1951
1964
|
enforce: "pre",
|
|
1952
1965
|
async config(config2, env) {
|
|
1953
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
1966
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
1954
1967
|
const externalPluginOptions = getExternalPluginOptions(config2);
|
|
1955
1968
|
if (externalPluginOptions) {
|
|
1956
1969
|
opts = mergeConfig(opts, externalPluginOptions);
|
|
@@ -1981,11 +1994,8 @@ function markoRun(opts = {}) {
|
|
|
1981
1994
|
markoVitePluginOptions.runtimeId = opts.runtimeId;
|
|
1982
1995
|
markoVitePluginOptions.basePathVar = opts.basePathVar;
|
|
1983
1996
|
resolvedRoutesDir = path4.resolve(root, routesDir);
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
".marko",
|
|
1987
|
-
createHash("shake256", { outputLength: 4 }).update(root).digest("hex")
|
|
1988
|
-
);
|
|
1997
|
+
outputDir = path4.join(root, ((_d = config2.build) == null ? void 0 : _d.outDir) || "dist");
|
|
1998
|
+
entryFilesDir = path4.join(outputDir, ".marko-run");
|
|
1989
1999
|
entryFilesDirPosix = normalizePath(entryFilesDir);
|
|
1990
2000
|
relativeEntryFilesDirPosix = normalizePath(
|
|
1991
2001
|
path4.relative(root, entryFilesDir)
|
|
@@ -1993,9 +2003,9 @@ function markoRun(opts = {}) {
|
|
|
1993
2003
|
typesDir = path4.join(root, ".marko-run");
|
|
1994
2004
|
devEntryFile = path4.join(root, "index.html");
|
|
1995
2005
|
devEntryFilePosix = normalizePath(devEntryFile);
|
|
1996
|
-
let outDir = ((
|
|
1997
|
-
const assetsDir = ((
|
|
1998
|
-
let rollupOutputOptions = (
|
|
2006
|
+
let outDir = ((_e = config2.build) == null ? void 0 : _e.outDir) || "dist";
|
|
2007
|
+
const assetsDir = ((_f = config2.build) == null ? void 0 : _f.assetsDir) || "assets";
|
|
2008
|
+
let rollupOutputOptions = (_h = (_g = config2.build) == null ? void 0 : _g.rollupOptions) == null ? void 0 : _h.output;
|
|
1999
2009
|
if (isBuild) {
|
|
2000
2010
|
if (!isSSRBuild) {
|
|
2001
2011
|
outDir = path4.join(outDir, CLIENT_OUT_DIR);
|
|
@@ -2035,9 +2045,10 @@ function markoRun(opts = {}) {
|
|
|
2035
2045
|
}));
|
|
2036
2046
|
}
|
|
2037
2047
|
}
|
|
2038
|
-
const browserslistTarget = isBuild && !((
|
|
2048
|
+
const browserslistTarget = isBuild && !((_i = config2.build) == null ? void 0 : _i.target) ? browserslist(void 0, {
|
|
2039
2049
|
path: root
|
|
2040
2050
|
}) : void 0;
|
|
2051
|
+
shouldEmptyOutDir = ((_j = config2.build) == null ? void 0 : _j.emptyOutDir) ?? true;
|
|
2041
2052
|
let pluginConfig = {
|
|
2042
2053
|
logLevel: isBuild ? "warn" : void 0,
|
|
2043
2054
|
define: isBuild ? {
|
|
@@ -2055,18 +2066,17 @@ function markoRun(opts = {}) {
|
|
|
2055
2066
|
target: (browserslistTarget == null ? void 0 : browserslistTarget.length) ? resolveToEsbuildTarget(browserslistTarget, {
|
|
2056
2067
|
printUnknownTargets: false
|
|
2057
2068
|
}) : void 0,
|
|
2058
|
-
emptyOutDir: isSSRBuild,
|
|
2059
|
-
// Avoid server & client deleting files from each other.
|
|
2060
2069
|
copyPublicDir: !isSSRBuild,
|
|
2061
2070
|
ssrEmitAssets: false,
|
|
2071
|
+
emptyOutDir: false,
|
|
2062
2072
|
rollupOptions: {
|
|
2063
2073
|
output: rollupOutputOptions
|
|
2064
2074
|
},
|
|
2065
2075
|
modulePreload: { polyfill: false },
|
|
2066
|
-
sourcemap: ((
|
|
2076
|
+
sourcemap: ((_k = config2.build) == null ? void 0 : _k.sourcemap) ?? (isBuild && !isSSRBuild)
|
|
2067
2077
|
},
|
|
2068
2078
|
optimizeDeps: {
|
|
2069
|
-
entries: !((
|
|
2079
|
+
entries: !((_l = config2.optimizeDeps) == null ? void 0 : _l.entries) ? [
|
|
2070
2080
|
"src/pages/**/*+{page,layout}.marko",
|
|
2071
2081
|
"!**/__snapshots__/**",
|
|
2072
2082
|
`!**/__tests__/**`,
|
|
@@ -2154,6 +2164,11 @@ function markoRun(opts = {}) {
|
|
|
2154
2164
|
}).unwatch(typesDir + "/*");
|
|
2155
2165
|
},
|
|
2156
2166
|
async buildStart(_options) {
|
|
2167
|
+
if (isSSRBuild && shouldEmptyOutDir) {
|
|
2168
|
+
if (fs3.existsSync(outputDir)) {
|
|
2169
|
+
fs3.rmSync(outputDir, { recursive: true });
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2157
2172
|
if (isBuild && !isSSRBuild) {
|
|
2158
2173
|
try {
|
|
2159
2174
|
routeData = await store.read();
|
|
@@ -2254,17 +2269,22 @@ function markoRun(opts = {}) {
|
|
|
2254
2269
|
store.write(routeData);
|
|
2255
2270
|
await ((_a = opts == null ? void 0 : opts.emitRoutes) == null ? void 0 : _a.call(opts, routes.list));
|
|
2256
2271
|
} else if (process.env.MR_EXPLORER !== "true") {
|
|
2257
|
-
logRoutesTable(routes, bundle
|
|
2272
|
+
logRoutesTable(routes, bundle);
|
|
2258
2273
|
}
|
|
2259
2274
|
},
|
|
2260
2275
|
async closeBundle() {
|
|
2261
|
-
if (isBuild && !isSSRBuild
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2276
|
+
if (isBuild && !isSSRBuild) {
|
|
2277
|
+
if (fs3.existsSync(entryFilesDir)) {
|
|
2278
|
+
fs3.rmSync(entryFilesDir, { recursive: true });
|
|
2279
|
+
}
|
|
2280
|
+
if ((adapter == null ? void 0 : adapter.buildEnd) && routes) {
|
|
2281
|
+
await adapter.buildEnd(
|
|
2282
|
+
resolvedConfig,
|
|
2283
|
+
routes.list,
|
|
2284
|
+
routeData.builtEntries,
|
|
2285
|
+
routeData.sourceEntries
|
|
2286
|
+
);
|
|
2287
|
+
}
|
|
2268
2288
|
}
|
|
2269
2289
|
}
|
|
2270
2290
|
}
|
|
@@ -2351,15 +2371,6 @@ function getImporters(module, fileName, seen = /* @__PURE__ */ new Set()) {
|
|
|
2351
2371
|
}
|
|
2352
2372
|
return seen;
|
|
2353
2373
|
}
|
|
2354
|
-
function getModulesDir(root, dir = __dirname) {
|
|
2355
|
-
if (dir.startsWith(root)) {
|
|
2356
|
-
const index = dir.indexOf("node_modules");
|
|
2357
|
-
if (index >= 0) {
|
|
2358
|
-
return dir.slice(0, index + 12);
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
return path4.join(root, "node_modules");
|
|
2362
|
-
}
|
|
2363
2374
|
var defaultConfigPlugin = {
|
|
2364
2375
|
name: `${PLUGIN_NAME_PREFIX}:defaults`,
|
|
2365
2376
|
enforce: "pre",
|
package/dist/vite/types.d.ts
CHANGED
package/dist/vite/utils/log.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OutputBundle } from "rollup";
|
|
2
2
|
import type { BuiltRoutes } from "../types";
|
|
3
|
-
export declare function logRoutesTable(routes: BuiltRoutes, bundle: OutputBundle
|
|
3
|
+
export declare function logRoutesTable(routes: BuiltRoutes, bundle: OutputBundle): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/run",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "The Marko application framework.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"marko"
|
|
@@ -54,24 +54,23 @@
|
|
|
54
54
|
"build": "rm -rf ./dist && tsc -b && tsx scripts/build.ts"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@marko/run-explorer": "^0.1
|
|
58
|
-
"@marko/vite": "^5.0.
|
|
59
|
-
"browserslist": "^4.24.
|
|
57
|
+
"@marko/run-explorer": "^1.0.1",
|
|
58
|
+
"@marko/vite": "^5.0.14",
|
|
59
|
+
"browserslist": "^4.24.4",
|
|
60
60
|
"cli-table3": "^0.6.5",
|
|
61
|
-
"compression": "^1.
|
|
62
|
-
"debug": "^4.
|
|
63
|
-
"dotenv": "^16.4.
|
|
61
|
+
"compression": "^1.8.0",
|
|
62
|
+
"debug": "^4.4.0",
|
|
63
|
+
"dotenv": "^16.4.7",
|
|
64
64
|
"draftlog": "^1.0.13",
|
|
65
|
-
"esbuild-plugin-browserslist": "^0.
|
|
66
|
-
"glob": "^11.0.
|
|
65
|
+
"esbuild-plugin-browserslist": "^0.16.0",
|
|
66
|
+
"glob": "^11.0.1",
|
|
67
67
|
"human-format": "^1.2.1",
|
|
68
68
|
"kleur": "^4.1.5",
|
|
69
69
|
"parse-node-args": "^1.1.2",
|
|
70
70
|
"sade": "^1.8.1",
|
|
71
71
|
"serve-static": "^1.16.2",
|
|
72
|
-
"supports-color": "^
|
|
73
|
-
"
|
|
74
|
-
"vite": "^6.0.0",
|
|
72
|
+
"supports-color": "^10.0.0",
|
|
73
|
+
"vite": "^6.2.1",
|
|
75
74
|
"warp10": "^2.1.0"
|
|
76
75
|
},
|
|
77
76
|
"devDependencies": {
|
|
@@ -89,7 +88,7 @@
|
|
|
89
88
|
"body-parser": "^1.20.3",
|
|
90
89
|
"cross-env": "^7.0.3",
|
|
91
90
|
"diff": "^7.0.0",
|
|
92
|
-
"esbuild": "^0.
|
|
91
|
+
"esbuild": "^0.25.1",
|
|
93
92
|
"express": "^4.21.1",
|
|
94
93
|
"jsdom": "^25.0.1",
|
|
95
94
|
"mocha": "^10.8.2",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ServerResponse } from "http";
|
|
2
|
-
declare global {
|
|
3
|
-
interface Headers {
|
|
4
|
-
getSetCookie: () => string[];
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
export declare const appendHeader: typeof appendHeader_platform;
|
|
8
|
-
declare function appendHeader_platform(response: ServerResponse, name: string, value: string | readonly string[]): void;
|
|
9
|
-
export declare const getSetCookie: typeof getSetCookie_fallback;
|
|
10
|
-
export declare function getSetCookie_fallback(headers: Headers): string | string[] | undefined;
|
|
11
|
-
export {};
|