@marko/run 0.4.5 → 0.4.6
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/dev-server.d.ts +2 -2
- package/dist/adapter/index.cjs +179 -134
- package/dist/adapter/index.d.ts +1 -1
- package/dist/adapter/index.js +182 -135
- package/dist/adapter/middleware.cjs +13 -4
- package/dist/adapter/middleware.d.ts +0 -1
- package/dist/adapter/middleware.js +13 -4
- package/dist/adapter/polyfill.d.ts +0 -1
- package/dist/adapter/utils.d.ts +16 -0
- package/dist/cli/index.mjs +207 -181
- package/dist/runtime/internal.cjs +7 -5
- package/dist/runtime/internal.d.ts +1 -0
- package/dist/runtime/internal.js +5 -4
- package/dist/runtime/router.d.ts +2 -2
- package/dist/vite/index.cjs +206 -180
- package/dist/vite/index.js +207 -181
- package/dist/vite/utils/ast.d.ts +1 -0
- package/dist/vite/utils/server.d.ts +0 -3
- package/package.json +25 -25
package/dist/vite/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import { glob } from "glob";
|
|
|
16
16
|
import { fileURLToPath } from "url";
|
|
17
17
|
import browserslist from "browserslist";
|
|
18
18
|
import { resolveToEsbuildTarget } from "esbuild-plugin-browserslist";
|
|
19
|
-
import { mergeConfig } from "vite";
|
|
19
|
+
import { buildErrorMessage, mergeConfig } from "vite";
|
|
20
20
|
import markoVitePlugin from "@marko/vite";
|
|
21
21
|
|
|
22
22
|
// src/vite/constants.ts
|
|
@@ -885,45 +885,6 @@ function writeRouteEntryHandler(writer, route, verb) {
|
|
|
885
885
|
continuations.join();
|
|
886
886
|
writer.writeBlockEnd("}");
|
|
887
887
|
}
|
|
888
|
-
function renderErrorRouter(error, options = {
|
|
889
|
-
trailingSlashes: "RedirectWithout"
|
|
890
|
-
}) {
|
|
891
|
-
const writer = createStringWriter();
|
|
892
|
-
writer.write(`
|
|
893
|
-
// @marko/run/router
|
|
894
|
-
import { createContext } from '${virtualFilePrefix}/runtime/internal';
|
|
895
|
-
import errorPage from '${virtualFilePrefix}/${markoRunFilePrefix}error.marko${serverEntryQuery}';
|
|
896
|
-
|
|
897
|
-
const error = new Error(\`${error.message}\`);
|
|
898
|
-
error.name = '${error.name}';`);
|
|
899
|
-
if (error.stack) {
|
|
900
|
-
writer.write(`
|
|
901
|
-
error.stack = \`${error.stack}\`;`);
|
|
902
|
-
}
|
|
903
|
-
writer.write(`
|
|
904
|
-
|
|
905
|
-
globalThis.__marko_run__ = { match, fetch, invoke };
|
|
906
|
-
|
|
907
|
-
export function match() {
|
|
908
|
-
return { handler: errorPage, params: {}, meta: {}, path: '/*' }; // /$$
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
export async function invoke(route, request, platform, url) {
|
|
912
|
-
const [context, buildInput] = createContext(route, request, platform, url);
|
|
913
|
-
if (context.request.headers.get('Accept')?.includes('text/html')) {
|
|
914
|
-
return new Response(errorPage.stream(buildInput({ error })), {
|
|
915
|
-
status: 500,
|
|
916
|
-
headers: { "content-type": "text/html;charset=UTF-8" },
|
|
917
|
-
});
|
|
918
|
-
}
|
|
919
|
-
return new Response(error, {
|
|
920
|
-
status: 500,
|
|
921
|
-
});
|
|
922
|
-
}
|
|
923
|
-
`);
|
|
924
|
-
renderFetch(writer, options);
|
|
925
|
-
return writer.end();
|
|
926
|
-
}
|
|
927
888
|
function renderRouter(routes, options = {
|
|
928
889
|
trailingSlashes: "RedirectWithout"
|
|
929
890
|
}) {
|
|
@@ -1056,15 +1017,7 @@ export async function fetch(request, platform) {
|
|
|
1056
1017
|
return await invoke(route, request, platform, url);
|
|
1057
1018
|
} catch (error) {
|
|
1058
1019
|
if (import.meta.env.DEV) {
|
|
1059
|
-
|
|
1060
|
-
if (error.cause) {
|
|
1061
|
-
body = error.cause.stack || error.cause.message || error.cause;
|
|
1062
|
-
} else {
|
|
1063
|
-
body = error.stack || error.message || "Internal Server Error";
|
|
1064
|
-
}
|
|
1065
|
-
return new Response(body, {
|
|
1066
|
-
status: 500
|
|
1067
|
-
});
|
|
1020
|
+
throw error;
|
|
1068
1021
|
}
|
|
1069
1022
|
return new Response(null, {
|
|
1070
1023
|
status: 500
|
|
@@ -1504,6 +1457,29 @@ function getExportIdentifiers(astProgramNode) {
|
|
|
1504
1457
|
}
|
|
1505
1458
|
return result;
|
|
1506
1459
|
}
|
|
1460
|
+
function getViteSSRExportIdentifiers(astProgramNode, exportObjectName = "__vite_ssr_exports__") {
|
|
1461
|
+
const result = [];
|
|
1462
|
+
if (t.isProgram(astProgramNode)) {
|
|
1463
|
+
for (const node of astProgramNode.body) {
|
|
1464
|
+
if (t.isExpressionStatement(node)) {
|
|
1465
|
+
if (t.isAssignmentExpression(node.expression) && t.isMemberExpression(node.expression.left)) {
|
|
1466
|
+
const { object, property } = node.expression.left;
|
|
1467
|
+
if (t.isIdentifier(object) && object.name === exportObjectName && t.isIdentifier(property)) {
|
|
1468
|
+
result.push(property.name);
|
|
1469
|
+
}
|
|
1470
|
+
} else if (t.isCallExpression(node.expression) && t.isMemberExpression(node.expression.callee)) {
|
|
1471
|
+
const {
|
|
1472
|
+
arguments: [arg0, arg1]
|
|
1473
|
+
} = node.expression;
|
|
1474
|
+
if (t.isIdentifier(arg0) && arg0.name === exportObjectName && (t.isStringLiteral(arg1) || "value" in arg1 && typeof arg1.value === "string")) {
|
|
1475
|
+
result.push(arg1.value);
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
return result;
|
|
1482
|
+
}
|
|
1507
1483
|
|
|
1508
1484
|
// src/vite/utils/log.ts
|
|
1509
1485
|
import zlib from "node:zlib";
|
|
@@ -1696,6 +1672,31 @@ process.once("beforeExit", (code) => {
|
|
|
1696
1672
|
}
|
|
1697
1673
|
});
|
|
1698
1674
|
|
|
1675
|
+
// src/adapter/utils.ts
|
|
1676
|
+
import supporsColor from "supports-color";
|
|
1677
|
+
import kleur2 from "kleur";
|
|
1678
|
+
function stripAnsi(string) {
|
|
1679
|
+
return string.replace(
|
|
1680
|
+
/([\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><])/g,
|
|
1681
|
+
""
|
|
1682
|
+
);
|
|
1683
|
+
}
|
|
1684
|
+
function cleanStack(stack) {
|
|
1685
|
+
return stack.split(/\n/).filter((l) => /^\s*at/.test(l)).join("\n");
|
|
1686
|
+
}
|
|
1687
|
+
function prepareError(err) {
|
|
1688
|
+
var _a;
|
|
1689
|
+
return {
|
|
1690
|
+
message: stripAnsi(err.message),
|
|
1691
|
+
stack: stripAnsi(cleanStack(err.stack || "")),
|
|
1692
|
+
id: err.id,
|
|
1693
|
+
frame: stripAnsi(err.frame || ""),
|
|
1694
|
+
plugin: err.plugin,
|
|
1695
|
+
pluginCode: (_a = err.pluginCode) == null ? void 0 : _a.toString(),
|
|
1696
|
+
loc: err.loc
|
|
1697
|
+
};
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1699
1700
|
// src/vite/plugin.ts
|
|
1700
1701
|
var debug = createDebug("@marko/run");
|
|
1701
1702
|
var __dirname = path3.dirname(fileURLToPath(import.meta.url));
|
|
@@ -1719,11 +1720,10 @@ function markoRun(opts = {}) {
|
|
|
1719
1720
|
let devServer;
|
|
1720
1721
|
let routes;
|
|
1721
1722
|
let routeData;
|
|
1722
|
-
let
|
|
1723
|
+
let getExportsFromFile;
|
|
1723
1724
|
let resolvedConfig;
|
|
1724
1725
|
let typesFile;
|
|
1725
|
-
let
|
|
1726
|
-
let isRendered = false;
|
|
1726
|
+
let seenErrors = /* @__PURE__ */ new Set();
|
|
1727
1727
|
const virtualFiles = /* @__PURE__ */ new Map();
|
|
1728
1728
|
let times = {
|
|
1729
1729
|
routesBuild: 0,
|
|
@@ -1746,97 +1746,134 @@ function markoRun(opts = {}) {
|
|
|
1746
1746
|
}
|
|
1747
1747
|
}
|
|
1748
1748
|
}
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
};
|
|
1754
|
-
try {
|
|
1755
|
-
if (isStale) {
|
|
1749
|
+
let buildVirtualFilesResult;
|
|
1750
|
+
function buildVirtualFiles() {
|
|
1751
|
+
return buildVirtualFilesResult ?? (buildVirtualFilesResult = new Promise(async (resolve, reject) => {
|
|
1752
|
+
try {
|
|
1756
1753
|
virtualFiles.clear();
|
|
1757
|
-
isRendered = false;
|
|
1758
|
-
const buildStartTime = performance.now();
|
|
1759
1754
|
routes = await buildRoutes({
|
|
1760
1755
|
walker: createFSWalker(resolvedRoutesDir),
|
|
1761
1756
|
importPrefix: routesDir
|
|
1762
1757
|
});
|
|
1763
|
-
times.routesBuild = performance.now() - buildStartTime;
|
|
1764
1758
|
if (!routes.list.length) {
|
|
1765
1759
|
throw new Error("No routes generated");
|
|
1766
1760
|
}
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
if (!route.handler.verbs.length) {
|
|
1773
|
-
throw new Error(
|
|
1774
|
-
`Did not find any valid exports in middleware entry file:'${route.handler.filePath}' - expected to find any of 'GET', 'POST', 'PUT' or 'DELETE'`
|
|
1761
|
+
for (const route of routes.list) {
|
|
1762
|
+
if (route.page) {
|
|
1763
|
+
virtualFiles.set(
|
|
1764
|
+
path3.posix.join(root, `${route.entryName}.marko`),
|
|
1765
|
+
""
|
|
1775
1766
|
);
|
|
1776
1767
|
}
|
|
1768
|
+
virtualFiles.set(path3.posix.join(root, `${route.entryName}.js`), "");
|
|
1777
1769
|
}
|
|
1778
|
-
|
|
1770
|
+
for (const route of Object.values(routes.special)) {
|
|
1779
1771
|
virtualFiles.set(
|
|
1780
1772
|
path3.posix.join(root, `${route.entryName}.marko`),
|
|
1781
|
-
|
|
1773
|
+
""
|
|
1782
1774
|
);
|
|
1783
1775
|
}
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
virtualFiles.set(
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
);
|
|
1776
|
+
if (routes.middleware.length) {
|
|
1777
|
+
virtualFiles.set(
|
|
1778
|
+
path3.posix.join(root, `${markoRunFilePrefix}middleware.js`),
|
|
1779
|
+
""
|
|
1780
|
+
);
|
|
1781
|
+
}
|
|
1782
|
+
virtualFiles.set("@marko/run/router", "");
|
|
1783
|
+
resolve(routes);
|
|
1784
|
+
} catch (err) {
|
|
1785
|
+
reject(err);
|
|
1794
1786
|
}
|
|
1795
|
-
|
|
1787
|
+
}));
|
|
1788
|
+
}
|
|
1789
|
+
let renderVirtualFilesResult;
|
|
1790
|
+
function renderVirtualFiles(context) {
|
|
1791
|
+
return renderVirtualFilesResult ?? (renderVirtualFilesResult = new Promise(async (resolve) => {
|
|
1792
|
+
var _a;
|
|
1793
|
+
const routerOptions = {
|
|
1794
|
+
trailingSlashes: opts.trailingSlashes || "RedirectWithout"
|
|
1795
|
+
};
|
|
1796
|
+
try {
|
|
1797
|
+
const routes2 = await buildVirtualFiles();
|
|
1798
|
+
for (const route of routes2.list) {
|
|
1799
|
+
if (route.handler) {
|
|
1800
|
+
const exports = await getExportsFromFile(
|
|
1801
|
+
context,
|
|
1802
|
+
route.handler.filePath
|
|
1803
|
+
);
|
|
1804
|
+
route.handler.verbs = [];
|
|
1805
|
+
for (const name of exports) {
|
|
1806
|
+
const verb = name.toLowerCase();
|
|
1807
|
+
if (name === verb.toUpperCase() && httpVerbs.includes(verb)) {
|
|
1808
|
+
route.handler.verbs.push(verb);
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
if (!route.handler.verbs.length) {
|
|
1812
|
+
context.warn(
|
|
1813
|
+
`Did not find any http verb exports in handler '${path3.relative(root, route.handler.filePath)}' - expected ${httpVerbs.map((v) => v.toUpperCase()).join(", ")}`
|
|
1814
|
+
);
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
if (route.page) {
|
|
1818
|
+
virtualFiles.set(
|
|
1819
|
+
path3.posix.join(root, `${route.entryName}.marko`),
|
|
1820
|
+
renderRouteTemplate(route)
|
|
1821
|
+
);
|
|
1822
|
+
}
|
|
1823
|
+
virtualFiles.set(
|
|
1824
|
+
path3.posix.join(root, `${route.entryName}.js`),
|
|
1825
|
+
renderRouteEntry(route)
|
|
1826
|
+
);
|
|
1827
|
+
}
|
|
1828
|
+
for (const route of Object.values(routes2.special)) {
|
|
1829
|
+
virtualFiles.set(
|
|
1830
|
+
path3.posix.join(root, `${route.entryName}.marko`),
|
|
1831
|
+
renderRouteTemplate(route)
|
|
1832
|
+
);
|
|
1833
|
+
}
|
|
1834
|
+
if (routes2.middleware.length) {
|
|
1835
|
+
for (const middleware of routes2.middleware) {
|
|
1836
|
+
if (!(await getExportsFromFile(context, middleware.filePath)).includes("default")) {
|
|
1837
|
+
context.warn(
|
|
1838
|
+
`Did not find a default export in middleware '${path3.relative(root, middleware.filePath)}'`
|
|
1839
|
+
);
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
virtualFiles.set(
|
|
1843
|
+
path3.posix.join(root, `${markoRunFilePrefix}middleware.js`),
|
|
1844
|
+
renderMiddleware(routes2.middleware)
|
|
1845
|
+
);
|
|
1846
|
+
}
|
|
1796
1847
|
virtualFiles.set(
|
|
1797
|
-
|
|
1798
|
-
|
|
1848
|
+
"@marko/run/router",
|
|
1849
|
+
renderRouter(routes2, routerOptions)
|
|
1799
1850
|
);
|
|
1800
|
-
|
|
1801
|
-
virtualFiles.set(
|
|
1802
|
-
"@marko/run/router",
|
|
1803
|
-
render ? renderRouter(routes, routerOptions) : ""
|
|
1804
|
-
);
|
|
1805
|
-
times.routesRender = performance.now() - renderStartTime;
|
|
1806
|
-
if (render) {
|
|
1807
|
-
await writeTypesFile(routes);
|
|
1851
|
+
await writeTypesFile(routes2);
|
|
1808
1852
|
if (adapter == null ? void 0 : adapter.routesGenerated) {
|
|
1809
1853
|
await adapter.routesGenerated(
|
|
1810
|
-
|
|
1854
|
+
routes2,
|
|
1811
1855
|
new Map(virtualFiles.entries()),
|
|
1812
1856
|
{
|
|
1813
1857
|
buildTime: times.routesBuild,
|
|
1814
1858
|
renderTime: times.routesRender
|
|
1815
1859
|
}
|
|
1816
1860
|
);
|
|
1861
|
+
if (!isBuild) {
|
|
1862
|
+
await ((_a = opts == null ? void 0 : opts.emitRoutes) == null ? void 0 : _a.call(opts, routes2.list));
|
|
1863
|
+
}
|
|
1817
1864
|
}
|
|
1818
|
-
|
|
1819
|
-
|
|
1865
|
+
} catch (err) {
|
|
1866
|
+
if (isBuild) {
|
|
1867
|
+
throw err;
|
|
1820
1868
|
}
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
throw err;
|
|
1869
|
+
virtualFiles.set(
|
|
1870
|
+
"@marko/run/router",
|
|
1871
|
+
`throw ${JSON.stringify(prepareError(err))}`
|
|
1872
|
+
);
|
|
1826
1873
|
}
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
renderEntryTemplate(`${markoRunFilePrefix}error`, ["<dev-error-page>"])
|
|
1831
|
-
);
|
|
1832
|
-
virtualFiles.set(
|
|
1833
|
-
"@marko/run/router",
|
|
1834
|
-
renderErrorRouter(err, routerOptions)
|
|
1835
|
-
);
|
|
1836
|
-
isRendered = true;
|
|
1837
|
-
}
|
|
1838
|
-
isStale = false;
|
|
1839
|
-
});
|
|
1874
|
+
resolve();
|
|
1875
|
+
}));
|
|
1876
|
+
}
|
|
1840
1877
|
return [
|
|
1841
1878
|
{
|
|
1842
1879
|
name: `${PLUGIN_NAME_PREFIX}:pre`,
|
|
@@ -1996,29 +2033,44 @@ function markoRun(opts = {}) {
|
|
|
1996
2033
|
} else {
|
|
1997
2034
|
ssrEntryFiles = [];
|
|
1998
2035
|
}
|
|
2036
|
+
const baseError = config2.logger.error;
|
|
2037
|
+
config2.logger.error = function(msg, options) {
|
|
2038
|
+
var _a;
|
|
2039
|
+
if (!((_a = options == null ? void 0 : options.error) == null ? void 0 : _a.message)) {
|
|
2040
|
+
baseError.call(this, msg, options);
|
|
2041
|
+
} else if (!seenErrors.has(options.error.message)) {
|
|
2042
|
+
seenErrors.add(options.error.message);
|
|
2043
|
+
console.error(buildErrorMessage(options.error));
|
|
2044
|
+
}
|
|
2045
|
+
};
|
|
1999
2046
|
},
|
|
2000
2047
|
configureServer(_server) {
|
|
2001
2048
|
devServer = _server;
|
|
2002
2049
|
devServer.watcher.on("all", async (type, filename) => {
|
|
2003
|
-
|
|
2050
|
+
seenErrors.clear();
|
|
2051
|
+
const routableFileType = matchRoutableFile(
|
|
2052
|
+
path3.parse(filename).base
|
|
2053
|
+
);
|
|
2004
2054
|
if (filename.startsWith(resolvedRoutesDir) && routableFileType) {
|
|
2005
|
-
if (type === "add") {
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
if (
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2055
|
+
if (type === "add" || type === "unlink" || type === "change" && (routableFileType === RoutableFileTypes.Handler || routableFileType === RoutableFileTypes.Middleware)) {
|
|
2056
|
+
buildVirtualFilesResult = void 0;
|
|
2057
|
+
renderVirtualFilesResult = void 0;
|
|
2058
|
+
const module = devServer.moduleGraph.getModuleById(filename);
|
|
2059
|
+
const importers = module && getImporters(module, filename);
|
|
2060
|
+
if (importers == null ? void 0 : importers.size) {
|
|
2061
|
+
for (const file of importers) {
|
|
2062
|
+
devServer.watcher.emit("change", file);
|
|
2063
|
+
}
|
|
2064
|
+
} else {
|
|
2065
|
+
for (const file of virtualFiles.keys()) {
|
|
2066
|
+
if (!file.endsWith(".marko")) {
|
|
2067
|
+
devServer.watcher.emit("change", file);
|
|
2068
|
+
}
|
|
2069
|
+
}
|
|
2018
2070
|
}
|
|
2019
2071
|
}
|
|
2020
2072
|
}
|
|
2021
|
-
});
|
|
2073
|
+
}).unwatch(typesDir + "/*");
|
|
2022
2074
|
},
|
|
2023
2075
|
async buildStart(_options) {
|
|
2024
2076
|
if (isBuild && !isSSRBuild) {
|
|
@@ -2034,10 +2086,10 @@ function markoRun(opts = {}) {
|
|
|
2034
2086
|
for (const { key, code } of routeData.files) {
|
|
2035
2087
|
virtualFiles.set(key, code);
|
|
2036
2088
|
}
|
|
2037
|
-
|
|
2038
|
-
|
|
2089
|
+
buildVirtualFilesResult = Promise.resolve(routes);
|
|
2090
|
+
renderVirtualFilesResult = Promise.resolve();
|
|
2039
2091
|
} else {
|
|
2040
|
-
|
|
2092
|
+
getExportsFromFile = isBuild ? getExportsFromFileBuild : getExportsFromFileDev.bind(null, devServer);
|
|
2041
2093
|
}
|
|
2042
2094
|
},
|
|
2043
2095
|
async resolveId(importee, importer) {
|
|
@@ -2050,8 +2102,8 @@ function markoRun(opts = {}) {
|
|
|
2050
2102
|
importee = path3.resolve(root, "." + importee);
|
|
2051
2103
|
}
|
|
2052
2104
|
importee = normalizePath(importee);
|
|
2053
|
-
if (
|
|
2054
|
-
await buildVirtualFiles(
|
|
2105
|
+
if (!buildVirtualFilesResult) {
|
|
2106
|
+
await buildVirtualFiles();
|
|
2055
2107
|
}
|
|
2056
2108
|
if (virtualFiles.has(importee)) {
|
|
2057
2109
|
resolved = importee;
|
|
@@ -2068,11 +2120,13 @@ function markoRun(opts = {}) {
|
|
|
2068
2120
|
if (id.endsWith(serverEntryQuery)) {
|
|
2069
2121
|
id = id.slice(0, -serverEntryQuery.length);
|
|
2070
2122
|
}
|
|
2123
|
+
if (!renderVirtualFilesResult) {
|
|
2124
|
+
await renderVirtualFiles(this);
|
|
2125
|
+
}
|
|
2071
2126
|
if (virtualFiles.has(id)) {
|
|
2072
|
-
if (isStale || !isRendered) {
|
|
2073
|
-
await buildVirtualFiles(true);
|
|
2074
|
-
}
|
|
2075
2127
|
return virtualFiles.get(id);
|
|
2128
|
+
} else if (path3.basename(id).startsWith(markoRunFilePrefix) && /^\.(js|marko)$/.test(path3.extname(id))) {
|
|
2129
|
+
return "";
|
|
2076
2130
|
}
|
|
2077
2131
|
}
|
|
2078
2132
|
},
|
|
@@ -2130,57 +2184,20 @@ function markoRun(opts = {}) {
|
|
|
2130
2184
|
}
|
|
2131
2185
|
];
|
|
2132
2186
|
}
|
|
2133
|
-
async function
|
|
2134
|
-
const verbs = [];
|
|
2187
|
+
async function getExportsFromFileBuild(context, filePath) {
|
|
2135
2188
|
const result = await context.load({
|
|
2136
2189
|
id: filePath,
|
|
2137
2190
|
resolveDependencies: false
|
|
2138
2191
|
});
|
|
2139
|
-
|
|
2140
|
-
const exportIds = getExportIdentifiers(result.ast);
|
|
2141
|
-
for (const id of exportIds) {
|
|
2142
|
-
const verb = id.toLowerCase();
|
|
2143
|
-
if (id === verb.toUpperCase() && httpVerbs.includes(verb)) {
|
|
2144
|
-
verbs.push(verb);
|
|
2145
|
-
}
|
|
2146
|
-
}
|
|
2147
|
-
}
|
|
2148
|
-
return verbs;
|
|
2192
|
+
return result ? getExportIdentifiers(result.ast) : [];
|
|
2149
2193
|
}
|
|
2150
|
-
async function
|
|
2151
|
-
const verbs = [];
|
|
2194
|
+
async function getExportsFromFileDev(devServer, context, filePath) {
|
|
2152
2195
|
const result = await devServer.transformRequest(filePath, { ssr: true });
|
|
2153
|
-
if (result
|
|
2154
|
-
const
|
|
2155
|
-
|
|
2156
|
-
while (match) {
|
|
2157
|
-
const id = match[1];
|
|
2158
|
-
const verb = id.toLowerCase();
|
|
2159
|
-
if (httpVerbs.includes(verb)) {
|
|
2160
|
-
if (id === verb.toUpperCase()) {
|
|
2161
|
-
verbs.push(verb);
|
|
2162
|
-
} else {
|
|
2163
|
-
console.warn(
|
|
2164
|
-
`Found export '${id}' in handler ${filePath} which is close to '${verb.toUpperCase()}'. Exported handlers need to be uppercase: GET, POST, PUT or DELETE.`
|
|
2165
|
-
);
|
|
2166
|
-
}
|
|
2167
|
-
}
|
|
2168
|
-
match = verbMatchReg.exec(result.code);
|
|
2169
|
-
}
|
|
2196
|
+
if (result) {
|
|
2197
|
+
const ast = context.parse(result.code);
|
|
2198
|
+
return getViteSSRExportIdentifiers(ast);
|
|
2170
2199
|
}
|
|
2171
|
-
return
|
|
2172
|
-
}
|
|
2173
|
-
function single(fn) {
|
|
2174
|
-
let promise;
|
|
2175
|
-
return async (...args) => {
|
|
2176
|
-
if (promise) {
|
|
2177
|
-
return promise;
|
|
2178
|
-
}
|
|
2179
|
-
promise = fn(...args);
|
|
2180
|
-
const result = await promise;
|
|
2181
|
-
promise = void 0;
|
|
2182
|
-
return result;
|
|
2183
|
-
};
|
|
2200
|
+
return [];
|
|
2184
2201
|
}
|
|
2185
2202
|
async function globFileExists(root, pattern) {
|
|
2186
2203
|
return (await glob(pattern, { root })).length > 0;
|
|
@@ -2233,6 +2250,15 @@ function getEntryFileName(file) {
|
|
|
2233
2250
|
const match = file && markoEntryFileRegex.exec(file);
|
|
2234
2251
|
return match ? match[2] || "index" : void 0;
|
|
2235
2252
|
}
|
|
2253
|
+
function getImporters(module, fileName, seen = /* @__PURE__ */ new Set()) {
|
|
2254
|
+
for (const importer of module.importers) {
|
|
2255
|
+
if (importer.id && !seen.has(importer.id)) {
|
|
2256
|
+
seen.add(importer.id);
|
|
2257
|
+
getImporters(importer, fileName, seen);
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
return seen;
|
|
2261
|
+
}
|
|
2236
2262
|
|
|
2237
2263
|
// src/vite/utils/server.ts
|
|
2238
2264
|
import net from "net";
|
package/dist/vite/utils/ast.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@marko/run",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"description": "The Marko application framework.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/marko-js/run/tree/main/packages/run",
|
|
@@ -88,51 +88,51 @@
|
|
|
88
88
|
"marko": "^5"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
|
-
"@babel/types": "^7.
|
|
91
|
+
"@babel/types": "^7.25.6",
|
|
92
92
|
"@marko/fixture-snapshots": "^2.2.1",
|
|
93
93
|
"@marko/testing-library": "^6.2.0",
|
|
94
94
|
"@types/glob": "^8.1.0",
|
|
95
95
|
"@types/human-format": "^1.0.3",
|
|
96
|
-
"@types/jsdom": "^21.1.
|
|
97
|
-
"@types/mocha": "^10.0.
|
|
98
|
-
"@types/node": "^
|
|
99
|
-
"acorn": "^8.
|
|
100
|
-
"body-parser": "^1.20.
|
|
96
|
+
"@types/jsdom": "^21.1.7",
|
|
97
|
+
"@types/mocha": "^10.0.8",
|
|
98
|
+
"@types/node": "^22.7.0",
|
|
99
|
+
"acorn": "^8.12.1",
|
|
100
|
+
"body-parser": "^1.20.3",
|
|
101
101
|
"cross-env": "^7.0.3",
|
|
102
|
-
"esbuild": "^0.
|
|
103
|
-
"express": "^4.
|
|
104
|
-
"jsdom": "^
|
|
105
|
-
"mocha": "^10.
|
|
102
|
+
"esbuild": "^0.24.0",
|
|
103
|
+
"express": "^4.21.0",
|
|
104
|
+
"jsdom": "^25.0.1",
|
|
105
|
+
"mocha": "^10.7.3",
|
|
106
106
|
"mocha-snap": "^5.0.0",
|
|
107
|
-
"playwright": "^1.
|
|
108
|
-
"prettier": "^3.
|
|
107
|
+
"playwright": "^1.47.2",
|
|
108
|
+
"prettier": "^3.3.3",
|
|
109
109
|
"ts-mocha": "^10.0.0",
|
|
110
110
|
"ts-node": "^10.9.2",
|
|
111
|
-
"tslib": "^2.
|
|
112
|
-
"tsx": "^4.
|
|
113
|
-
"typescript": "^5.
|
|
111
|
+
"tslib": "^2.7.0",
|
|
112
|
+
"tsx": "^4.19.1",
|
|
113
|
+
"typescript": "^5.6.2"
|
|
114
114
|
},
|
|
115
115
|
"dependencies": {
|
|
116
|
-
"@marko/compiler": "^5.
|
|
116
|
+
"@marko/compiler": "^5.37.13",
|
|
117
117
|
"@marko/run-explorer": "^0.1.2",
|
|
118
|
-
"@marko/vite": "^4.1.
|
|
119
|
-
"browserslist": "^4.
|
|
118
|
+
"@marko/vite": "^4.1.19",
|
|
119
|
+
"browserslist": "^4.24.0",
|
|
120
120
|
"cli-table3": "^0.6.5",
|
|
121
121
|
"compression": "^1.7.4",
|
|
122
|
-
"debug": "^4.3.
|
|
122
|
+
"debug": "^4.3.7",
|
|
123
123
|
"dotenv": "^16.4.5",
|
|
124
124
|
"draftlog": "^1.0.13",
|
|
125
|
-
"esbuild-plugin-browserslist": "^0.
|
|
126
|
-
"glob": "^
|
|
125
|
+
"esbuild-plugin-browserslist": "^0.14.0",
|
|
126
|
+
"glob": "^11.0.0",
|
|
127
127
|
"human-format": "^1.2.0",
|
|
128
128
|
"kleur": "^4.1.5",
|
|
129
129
|
"marko": "^5",
|
|
130
130
|
"parse-node-args": "^1.1.2",
|
|
131
131
|
"sade": "^1.8.1",
|
|
132
|
-
"serve-static": "^1.
|
|
132
|
+
"serve-static": "^1.16.2",
|
|
133
133
|
"supports-color": "^9.4.0",
|
|
134
|
-
"undici": "^6.
|
|
135
|
-
"vite": "^5.
|
|
134
|
+
"undici": "^6.19.8",
|
|
135
|
+
"vite": "^5.4.8",
|
|
136
136
|
"warp10": "^2.1.0"
|
|
137
137
|
}
|
|
138
138
|
}
|