@marko/run 0.2.13 → 0.2.15

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.
@@ -230,30 +230,196 @@ var bodyConsumedErrorStream = new ReadableStream({
230
230
  });
231
231
 
232
232
  // src/adapter/dev-server.ts
233
- import stripAnsi from "strip-ansi";
234
233
  import { inspect } from "util";
235
- function createViteDevMiddleware(devServer, load, factory) {
236
- let value;
237
- let middleware;
238
- return async (req, res, next) => {
239
- try {
240
- const nextValue = await load(value);
241
- if (nextValue !== value) {
242
- value = nextValue;
243
- middleware = factory(value);
244
- }
245
- await middleware(req, res, next);
246
- } catch (err) {
247
- res.statusCode = 500;
248
- if (err instanceof Error) {
249
- devServer.ssrFixStacktrace(err);
250
- res.end(err.stack && stripAnsi(err.stack));
234
+
235
+ // src/adapter/logger.ts
236
+ import kleur from "kleur";
237
+ import DraftLog from "draftlog";
238
+ import format from "human-format";
239
+ import inpspector from "inspector";
240
+ if (!inpspector.url()) {
241
+ DraftLog.into(console);
242
+ DraftLog.defaults.canReWrite = false;
243
+ }
244
+ var HttpStatusColors = [
245
+ "",
246
+ // Unused
247
+ "green",
248
+ // 1xx
249
+ "green",
250
+ // 2xx
251
+ "cyan",
252
+ // 3xx
253
+ "yellow",
254
+ // 4xx
255
+ "red"
256
+ // 5xx
257
+ ];
258
+ var IdChars = [
259
+ "",
260
+ kleur.cyan("\xB9"),
261
+ kleur.magenta("\xB2"),
262
+ kleur.green("\xB3"),
263
+ kleur.red("\u2074"),
264
+ kleur.cyan("\u2075"),
265
+ kleur.magenta("\u2076"),
266
+ kleur.green("\u2077"),
267
+ kleur.red("\u2078"),
268
+ kleur.cyan("\u2079"),
269
+ kleur.red("\u207A")
270
+ ];
271
+ var ArrowSteps = [" ", " \u25C0", " \u25C0\u2501", "\u25C0\u2501\u2501", "\u2501\u2501 ", "\u2501 ", " "];
272
+ function logger_default(_options = {}) {
273
+ let inFlight = 0;
274
+ return function logger(req, res, next) {
275
+ let startTime = Date.now();
276
+ const handleFinish = () => done("finish");
277
+ const handleClose = () => done("close");
278
+ res.on("finish", handleFinish);
279
+ res.on("close", handleClose);
280
+ const bitMask = ~inFlight & inFlight + 1;
281
+ const index = Math.log2(bitMask);
282
+ const id = IdChars[index];
283
+ if (index < IdChars.length) {
284
+ inFlight |= bitMask;
285
+ }
286
+ const finalizeLog = logRequest(id, req);
287
+ let bodyLength = 0;
288
+ const _write = res.write;
289
+ const _end = res.end;
290
+ res.write = (...args) => {
291
+ if (typeof args[1] !== "function") {
292
+ bodyLength += Buffer.byteLength(args[0], args[1]);
251
293
  } else {
252
- res.end();
294
+ bodyLength += args[0].length;
295
+ }
296
+ return _write.apply(res, args);
297
+ };
298
+ res.end = (...args) => {
299
+ if (args.length && typeof args[0] !== "function") {
300
+ if (typeof args[1] !== "function") {
301
+ bodyLength += Buffer.byteLength(args[0], args[1]);
302
+ } else {
303
+ bodyLength += args[0].length;
304
+ }
305
+ }
306
+ return _end.apply(res, args);
307
+ };
308
+ next == null ? void 0 : next();
309
+ function done(event) {
310
+ res.off("finish", handleFinish);
311
+ res.off("close", handleClose);
312
+ finalizeLog();
313
+ if (index < 10) {
314
+ inFlight ^= bitMask;
253
315
  }
316
+ const contentLength = res.getHeader("content-length") || 0;
317
+ logResponse(
318
+ id,
319
+ req,
320
+ res,
321
+ startTime,
322
+ contentLength || bodyLength,
323
+ event === "finish"
324
+ );
254
325
  }
255
326
  };
256
327
  }
328
+ var spinners;
329
+ function logRequest(id, req) {
330
+ const info = id + " " + kleur.bold(req.method) + " " + kleur.dim(req.url);
331
+ const final = kleur.dim(requestArrow(id)) + info;
332
+ if (console.draft) {
333
+ spinners ?? (spinners = createAnimationManager({ steps: ArrowSteps.length }));
334
+ const update = console.draft();
335
+ const stop = spinners.add((step) => {
336
+ update(kleur.cyan(requestArrow(id, step)) + info);
337
+ });
338
+ return () => {
339
+ stop();
340
+ update(final);
341
+ };
342
+ }
343
+ console.log(final);
344
+ return () => {
345
+ };
346
+ }
347
+ function logResponse(id, req, res, startTime, contentLength, success) {
348
+ const status = res.statusCode;
349
+ const color = HttpStatusColors[status / 100 | 0] || "red";
350
+ let length;
351
+ if (req.method === "HEAD" || [204, 205, 304].includes(status)) {
352
+ length = "";
353
+ } else if (!contentLength) {
354
+ length = kleur.dim("-");
355
+ } else {
356
+ length = formatMeasurement(bytes(contentLength));
357
+ }
358
+ let arrow = id ? "\u2501" : "\u2501\u2501";
359
+ if (success) {
360
+ arrow = kleur.dim(arrow + "\u25B6");
361
+ } else {
362
+ arrow = kleur.red(kleur.dim(arrow) + kleur.bold("x"));
363
+ }
364
+ console.log(
365
+ arrow + id + " " + kleur.bold(req.method) + " " + kleur.dim(req.url) + " " + kleur[color](status) + " " + formatMeasurement(time(startTime)) + " " + length
366
+ );
367
+ }
368
+ function requestArrow(id, step = 3) {
369
+ const arrow = ArrowSteps[step];
370
+ return id ? arrow.slice(0, -1) : arrow;
371
+ }
372
+ function time(start) {
373
+ const delta = Date.now() - start;
374
+ return delta < 5e3 ? [delta, "ms"] : [(delta / 1e3).toFixed(1), "s"];
375
+ }
376
+ function bytes(size) {
377
+ const { value, prefix } = format.raw(size, { maxDecimals: 2, unit: "b" });
378
+ return [value.toFixed(2), (prefix + "b").toLowerCase()];
379
+ }
380
+ function formatMeasurement([value, unit]) {
381
+ return kleur.dim(value + kleur.yellow(kleur.bold(unit)));
382
+ }
383
+ function createAnimationManager(options = {}) {
384
+ const { steps = 1e4, ms = 100 } = options;
385
+ const fns = /* @__PURE__ */ new Set();
386
+ let step = 0;
387
+ let isRunning = false;
388
+ let interval;
389
+ function start() {
390
+ step = 0;
391
+ isRunning = true;
392
+ interval = setInterval(() => {
393
+ if (isRunning) {
394
+ for (const fn of fns) {
395
+ fn(step);
396
+ }
397
+ step = (step + 1) % steps;
398
+ }
399
+ }, ms);
400
+ }
401
+ function stop() {
402
+ isRunning = false;
403
+ clearInterval(interval);
404
+ }
405
+ return {
406
+ add(fn) {
407
+ fns.add(fn);
408
+ if (!isRunning) {
409
+ start();
410
+ }
411
+ fn(step);
412
+ return () => {
413
+ fns.delete(fn);
414
+ if (!fns.size) {
415
+ stop();
416
+ }
417
+ };
418
+ }
419
+ };
420
+ }
421
+
422
+ // src/adapter/dev-server.ts
257
423
  async function createViteDevServer(config2) {
258
424
  const devServer = await createServer({
259
425
  ...config2,
@@ -261,6 +427,7 @@ async function createViteDevServer(config2) {
261
427
  server: { ...config2 == null ? void 0 : config2.server, middlewareMode: true }
262
428
  });
263
429
  getDevGlobal().addDevServer(devServer);
430
+ devServer.middlewares.use(logger_default());
264
431
  return devServer;
265
432
  }
266
433
  async function createDevServer(config2) {
@@ -282,7 +449,7 @@ async function createDevServer(config2) {
282
449
  }
283
450
  } else {
284
451
  res.statusCode = 500;
285
- res.end(stripAnsi(inspect(err)));
452
+ res.end(inspect(err).replace(/([\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><])/g, ""));
286
453
  }
287
454
  } else {
288
455
  next == null ? void 0 : next();
@@ -367,25 +534,25 @@ function getDevGlobal() {
367
534
 
368
535
  // src/adapter/utils.ts
369
536
  import supporsColor from "supports-color";
370
- import kleur from "kleur";
537
+ import kleur2 from "kleur";
371
538
  function logInfoBox(address, explorer) {
372
539
  const color = !!supporsColor.stdout;
373
- let message = kleur.bold("Marko Run");
540
+ let message = kleur2.bold("Marko Run");
374
541
  if (true) {
375
- message += ` v${"0.2.11"}`;
542
+ message += ` v${"0.2.15"}`;
376
543
  }
377
544
  message += "\n\n";
378
- message += kleur.dim("Server listening at");
545
+ message += kleur2.dim("Server listening at");
379
546
  message += "\n";
380
- message += kleur.cyan(kleur.underline(address));
547
+ message += kleur2.cyan(kleur2.underline(address));
381
548
  if (explorer) {
382
549
  message += "\n\n";
383
- message += kleur.dim("Explore your routes");
550
+ message += kleur2.dim("Explore your routes");
384
551
  message += "\n";
385
- message += kleur.dim(kleur.green(kleur.underline(explorer)));
552
+ message += kleur2.dim(kleur2.green(kleur2.underline(explorer)));
386
553
  }
387
554
  const lines = drawMarkoBox(message, { color, fill: color });
388
- console.log(lines.join("\n"));
555
+ console.log(lines.join("\n") + "\n");
389
556
  }
390
557
  function drawMarkoBox(message, options) {
391
558
  const textPaddingWidth = 3;
@@ -679,7 +846,7 @@ function adapter() {
679
846
  const { port = 3e3, envFile } = options;
680
847
  globalThis.__marko_run_vite_config__ = config2;
681
848
  const explorerPromise = startExplorer();
682
- if (entry) {
849
+ if (entry && entry !== defaultEntry) {
683
850
  const { nodeArgs } = parseNodeArgs(options.args);
684
851
  let worker;
685
852
  async function start() {
@@ -744,7 +911,7 @@ function adapter() {
744
911
  startExplorer(),
745
912
  spawnServer("node", args, port, envFile)
746
913
  ]);
747
- if (!options.sourceEntry) {
914
+ if (options.entry === defaultEntry) {
748
915
  logInfoBox(
749
916
  `http://localhost:${port}`,
750
917
  explorer && `http://localhost:${explorer.port}`
@@ -821,7 +988,6 @@ async function startExplorer() {
821
988
  }
822
989
  export {
823
990
  createDevServer,
824
- createViteDevMiddleware,
825
991
  createViteDevServer,
826
992
  adapter as default,
827
993
  getDevGlobal
@@ -0,0 +1,4 @@
1
+ import type { NodeMiddleware } from "./middleware";
2
+ export interface LoggerOptions {
3
+ }
4
+ export default function (_options?: LoggerOptions): NodeMiddleware;
@@ -86,7 +86,7 @@ async function getAvailablePort(port) {
86
86
  import path2 from "path";
87
87
  import crypto from "crypto";
88
88
  import fs3 from "fs";
89
- import glob from "glob";
89
+ import { glob } from "glob";
90
90
  import { fileURLToPath } from "url";
91
91
  import browserslist from "browserslist";
92
92
  import { resolveToEsbuildTarget } from "esbuild-plugin-browserslist";
@@ -191,15 +191,15 @@ var _VDir = class _VDir {
191
191
  const existing = this.files.get(file.type);
192
192
  if (existing !== file) {
193
193
  throw new Error(
194
- `Duplicate file type '${file.type}' added at path '${this.path}'. File '${file.filePath}' collides with '${existing.filePath}'.`
194
+ `Duplicate file type '${file.type}' added at path '${this.path}'. File '${file.importPath}' collides with '${existing.importPath}'.`
195
195
  );
196
196
  } else if (file.type === RoutableFileTypes.Page || file.type === RoutableFileTypes.Handler) {
197
197
  throw new Error(
198
- `Ambiguous path definition: route '${this.path}' is defined multiple times by ${file.filePath}`
198
+ `Ambiguous path definition: route '${this.path}' is defined multiple times by ${file.importPath}`
199
199
  );
200
200
  }
201
201
  throw new Error(
202
- `Ambiguous path definition: file '${this.path}' is included multiple times by ${file.filePath}`
202
+ `Ambiguous path definition: file '${this.path}' is included multiple times by ${file.importPath}`
203
203
  );
204
204
  }
205
205
  }
@@ -1823,10 +1823,14 @@ function markoRun(opts = {}) {
1823
1823
  if (render) {
1824
1824
  await writeTypesFile(routes);
1825
1825
  if (adapter == null ? void 0 : adapter.routesGenerated) {
1826
- await adapter.routesGenerated(routes, new Map(virtualFiles.entries()), {
1827
- buildTime: times.routesBuild,
1828
- renderTime: times.routesRender
1829
- });
1826
+ await adapter.routesGenerated(
1827
+ routes,
1828
+ new Map(virtualFiles.entries()),
1829
+ {
1830
+ buildTime: times.routesBuild,
1831
+ renderTime: times.routesRender
1832
+ }
1833
+ );
1830
1834
  }
1831
1835
  if (!isBuild) {
1832
1836
  await ((_a = opts == null ? void 0 : opts.emitRoutes) == null ? void 0 : _a.call(opts, routes.list));
@@ -1941,6 +1945,9 @@ function markoRun(opts = {}) {
1941
1945
  }));
1942
1946
  }
1943
1947
  }
1948
+ const browserslistTarget = isBuild && !((_g = config2.build) == null ? void 0 : _g.target) ? browserslist(void 0, {
1949
+ path: root
1950
+ }) : void 0;
1944
1951
  let pluginConfig = {
1945
1952
  logLevel: isBuild ? "warn" : void 0,
1946
1953
  define: isBuild ? {
@@ -1950,12 +1957,9 @@ function markoRun(opts = {}) {
1950
1957
  noExternal: /@marko\/run/
1951
1958
  },
1952
1959
  build: {
1953
- target: isBuild && !((_g = config2.build) == null ? void 0 : _g.target) ? resolveToEsbuildTarget(
1954
- browserslist(void 0, {
1955
- path: root
1956
- }),
1957
- { printUnknownTargets: false }
1958
- ) : void 0,
1960
+ target: (browserslistTarget == null ? void 0 : browserslistTarget.length) ? resolveToEsbuildTarget(browserslistTarget, {
1961
+ printUnknownTargets: false
1962
+ }) : void 0,
1959
1963
  emptyOutDir: isSSRBuild,
1960
1964
  // Avoid server & client deleting files from each other.
1961
1965
  rollupOptions: {
@@ -2195,14 +2199,7 @@ function single(fn) {
2195
2199
  };
2196
2200
  }
2197
2201
  async function globFileExists(root, pattern) {
2198
- return new Promise((resolve, reject) => {
2199
- glob(pattern, { root }, (err, matches) => {
2200
- if (err) {
2201
- reject(err);
2202
- }
2203
- resolve(matches.length > 0);
2204
- });
2205
- });
2202
+ return (await glob(pattern, { root })).length > 0;
2206
2203
  }
2207
2204
  async function ensureDir(dir) {
2208
2205
  if (!fs3.existsSync(dir)) {
@@ -2263,10 +2260,11 @@ var __dirname2 = path3.dirname(fileURLToPath2(import.meta.url));
2263
2260
  var defaultPort = Number(process.env.PORT || 3e3);
2264
2261
  var defaultConfigFileBases = ["serve.config", "vite.config"];
2265
2262
  var defaultConfigFileExts = [".js", ".cjs", ".mjs", ".ts", ".mts"];
2266
- async function preview(sourceEntry, entry, cwd, configFile, port, outDir, envFile, args = []) {
2263
+ async function preview(entry, distEntry, cwd, configFile, port, outDir, envFile, args = []) {
2264
+ var _a;
2267
2265
  const resolvedConfig = await resolveConfig(
2268
2266
  { root: cwd, configFile, logLevel: "silent", build: { outDir } },
2269
- "serve"
2267
+ "build"
2270
2268
  );
2271
2269
  const [availablePort, adapter] = await Promise.all([
2272
2270
  getAvailablePort(port ?? resolvedConfig.preview.port ?? resolvedConfig.server.port ?? defaultPort),
@@ -2277,8 +2275,11 @@ async function preview(sourceEntry, entry, cwd, configFile, port, outDir, envFil
2277
2275
  } else if (!adapter.startPreview) {
2278
2276
  throw new Error(`Adapter ${adapter.name} does not support 'serve' command`);
2279
2277
  }
2278
+ if (!entry) {
2279
+ entry = await ((_a = adapter.getEntryFile) == null ? void 0 : _a.call(adapter));
2280
+ }
2280
2281
  const dir = path3.resolve(cwd, resolvedConfig.build.outDir);
2281
- const entryFile = entry ? path3.join(dir, entry) : await findFileWithExt(dir, "index", [".mjs", ".js"]);
2282
+ const entryFile = distEntry ? path3.join(dir, distEntry) : await findFileWithExt(dir, "index", [".mjs", ".js"]);
2282
2283
  if (envFile) {
2283
2284
  envFile = path3.resolve(cwd, envFile);
2284
2285
  }
@@ -2288,14 +2289,15 @@ async function preview(sourceEntry, entry, cwd, configFile, port, outDir, envFil
2288
2289
  args,
2289
2290
  port: availablePort,
2290
2291
  envFile,
2291
- sourceEntry
2292
+ entry
2292
2293
  };
2293
2294
  return await adapter.startPreview(entryFile, options);
2294
2295
  }
2295
2296
  async function dev(entry, cwd, configFile, port, envFile, args = []) {
2297
+ var _a;
2296
2298
  const resolvedConfig = await resolveConfig(
2297
2299
  { root: cwd, configFile, logLevel: "silent" },
2298
- "build"
2300
+ "serve"
2299
2301
  );
2300
2302
  if (envFile) {
2301
2303
  envFile = path3.resolve(cwd, envFile);
@@ -2311,9 +2313,12 @@ async function dev(entry, cwd, configFile, port, envFile, args = []) {
2311
2313
  );
2312
2314
  } else if (!adapter.startDev) {
2313
2315
  throw new Error(
2314
- `Adapter '${adapter.name}' does not support 'serve' command`
2316
+ `Adapter '${adapter.name}' does not support 'dev' command`
2315
2317
  );
2316
2318
  }
2319
+ if (!entry) {
2320
+ entry = await ((_a = adapter.getEntryFile) == null ? void 0 : _a.call(adapter));
2321
+ }
2317
2322
  const config2 = {
2318
2323
  root: cwd,
2319
2324
  configFile,
@@ -60,7 +60,7 @@ export type DefineApp<T extends {
60
60
  export interface RouteWithHandler<Params extends ParamsObject = ParamsObject, Meta = unknown, Path extends string = string> extends Route<Params, Meta, Path> {
61
61
  handler: RouteHandler<this>;
62
62
  }
63
- export type Fetch<in TPlatform> = (request: Request, platform: TPlatform) => Promise<Response | void>;
63
+ export type Fetch<TPlatform extends Platform = Platform> = (request: Request, platform: TPlatform) => Promise<Response | void>;
64
64
  export type Match = (method: string, pathname: string) => RouteWithHandler | null;
65
65
  export type Invoke<TPlatform extends Platform = Platform> = (route: RouteWithHandler | null, request: Request, platform: TPlatform) => Promise<Response | void>;
66
66
  export interface RuntimeModule {
@@ -71,7 +71,7 @@ var __importMetaURL = (0, import_url.pathToFileURL)(__filename);
71
71
  var import_path2 = __toESM(require("path"), 1);
72
72
  var import_crypto = __toESM(require("crypto"), 1);
73
73
  var import_fs2 = __toESM(require("fs"), 1);
74
- var import_glob = __toESM(require("glob"), 1);
74
+ var import_glob = require("glob");
75
75
  var import_url2 = require("url");
76
76
  var import_browserslist = __toESM(require("browserslist"), 1);
77
77
  var import_esbuild_plugin_browserslist = require("esbuild-plugin-browserslist");
@@ -176,15 +176,15 @@ var _VDir = class _VDir {
176
176
  const existing = this.files.get(file.type);
177
177
  if (existing !== file) {
178
178
  throw new Error(
179
- `Duplicate file type '${file.type}' added at path '${this.path}'. File '${file.filePath}' collides with '${existing.filePath}'.`
179
+ `Duplicate file type '${file.type}' added at path '${this.path}'. File '${file.importPath}' collides with '${existing.importPath}'.`
180
180
  );
181
181
  } else if (file.type === RoutableFileTypes.Page || file.type === RoutableFileTypes.Handler) {
182
182
  throw new Error(
183
- `Ambiguous path definition: route '${this.path}' is defined multiple times by ${file.filePath}`
183
+ `Ambiguous path definition: route '${this.path}' is defined multiple times by ${file.importPath}`
184
184
  );
185
185
  }
186
186
  throw new Error(
187
- `Ambiguous path definition: file '${this.path}' is included multiple times by ${file.filePath}`
187
+ `Ambiguous path definition: file '${this.path}' is included multiple times by ${file.importPath}`
188
188
  );
189
189
  }
190
190
  }
@@ -1822,10 +1822,14 @@ function markoRun(opts = {}) {
1822
1822
  if (render) {
1823
1823
  await writeTypesFile(routes);
1824
1824
  if (adapter == null ? void 0 : adapter.routesGenerated) {
1825
- await adapter.routesGenerated(routes, new Map(virtualFiles.entries()), {
1826
- buildTime: times.routesBuild,
1827
- renderTime: times.routesRender
1828
- });
1825
+ await adapter.routesGenerated(
1826
+ routes,
1827
+ new Map(virtualFiles.entries()),
1828
+ {
1829
+ buildTime: times.routesBuild,
1830
+ renderTime: times.routesRender
1831
+ }
1832
+ );
1829
1833
  }
1830
1834
  if (!isBuild) {
1831
1835
  await ((_a = opts == null ? void 0 : opts.emitRoutes) == null ? void 0 : _a.call(opts, routes.list));
@@ -1940,6 +1944,9 @@ function markoRun(opts = {}) {
1940
1944
  }));
1941
1945
  }
1942
1946
  }
1947
+ const browserslistTarget = isBuild && !((_g = config2.build) == null ? void 0 : _g.target) ? (0, import_browserslist.default)(void 0, {
1948
+ path: root
1949
+ }) : void 0;
1943
1950
  let pluginConfig = {
1944
1951
  logLevel: isBuild ? "warn" : void 0,
1945
1952
  define: isBuild ? {
@@ -1949,12 +1956,9 @@ function markoRun(opts = {}) {
1949
1956
  noExternal: /@marko\/run/
1950
1957
  },
1951
1958
  build: {
1952
- target: isBuild && !((_g = config2.build) == null ? void 0 : _g.target) ? (0, import_esbuild_plugin_browserslist.resolveToEsbuildTarget)(
1953
- (0, import_browserslist.default)(void 0, {
1954
- path: root
1955
- }),
1956
- { printUnknownTargets: false }
1957
- ) : void 0,
1959
+ target: (browserslistTarget == null ? void 0 : browserslistTarget.length) ? (0, import_esbuild_plugin_browserslist.resolveToEsbuildTarget)(browserslistTarget, {
1960
+ printUnknownTargets: false
1961
+ }) : void 0,
1958
1962
  emptyOutDir: isSSRBuild,
1959
1963
  // Avoid server & client deleting files from each other.
1960
1964
  rollupOptions: {
@@ -2194,14 +2198,7 @@ function single(fn) {
2194
2198
  };
2195
2199
  }
2196
2200
  async function globFileExists(root, pattern) {
2197
- return new Promise((resolve, reject) => {
2198
- (0, import_glob.default)(pattern, { root }, (err, matches) => {
2199
- if (err) {
2200
- reject(err);
2201
- }
2202
- resolve(matches.length > 0);
2203
- });
2204
- });
2201
+ return (await (0, import_glob.glob)(pattern, { root })).length > 0;
2205
2202
  }
2206
2203
  async function ensureDir(dir) {
2207
2204
  if (!import_fs2.default.existsSync(dir)) {
@@ -27,7 +27,7 @@ var __privateSet = (obj, member, value, setter) => {
27
27
  import path2 from "path";
28
28
  import crypto from "crypto";
29
29
  import fs2 from "fs";
30
- import glob from "glob";
30
+ import { glob } from "glob";
31
31
  import { fileURLToPath } from "url";
32
32
  import browserslist from "browserslist";
33
33
  import { resolveToEsbuildTarget } from "esbuild-plugin-browserslist";
@@ -132,15 +132,15 @@ var _VDir = class _VDir {
132
132
  const existing = this.files.get(file.type);
133
133
  if (existing !== file) {
134
134
  throw new Error(
135
- `Duplicate file type '${file.type}' added at path '${this.path}'. File '${file.filePath}' collides with '${existing.filePath}'.`
135
+ `Duplicate file type '${file.type}' added at path '${this.path}'. File '${file.importPath}' collides with '${existing.importPath}'.`
136
136
  );
137
137
  } else if (file.type === RoutableFileTypes.Page || file.type === RoutableFileTypes.Handler) {
138
138
  throw new Error(
139
- `Ambiguous path definition: route '${this.path}' is defined multiple times by ${file.filePath}`
139
+ `Ambiguous path definition: route '${this.path}' is defined multiple times by ${file.importPath}`
140
140
  );
141
141
  }
142
142
  throw new Error(
143
- `Ambiguous path definition: file '${this.path}' is included multiple times by ${file.filePath}`
143
+ `Ambiguous path definition: file '${this.path}' is included multiple times by ${file.importPath}`
144
144
  );
145
145
  }
146
146
  }
@@ -1778,10 +1778,14 @@ function markoRun(opts = {}) {
1778
1778
  if (render) {
1779
1779
  await writeTypesFile(routes);
1780
1780
  if (adapter == null ? void 0 : adapter.routesGenerated) {
1781
- await adapter.routesGenerated(routes, new Map(virtualFiles.entries()), {
1782
- buildTime: times.routesBuild,
1783
- renderTime: times.routesRender
1784
- });
1781
+ await adapter.routesGenerated(
1782
+ routes,
1783
+ new Map(virtualFiles.entries()),
1784
+ {
1785
+ buildTime: times.routesBuild,
1786
+ renderTime: times.routesRender
1787
+ }
1788
+ );
1785
1789
  }
1786
1790
  if (!isBuild) {
1787
1791
  await ((_a = opts == null ? void 0 : opts.emitRoutes) == null ? void 0 : _a.call(opts, routes.list));
@@ -1896,6 +1900,9 @@ function markoRun(opts = {}) {
1896
1900
  }));
1897
1901
  }
1898
1902
  }
1903
+ const browserslistTarget = isBuild && !((_g = config2.build) == null ? void 0 : _g.target) ? browserslist(void 0, {
1904
+ path: root
1905
+ }) : void 0;
1899
1906
  let pluginConfig = {
1900
1907
  logLevel: isBuild ? "warn" : void 0,
1901
1908
  define: isBuild ? {
@@ -1905,12 +1912,9 @@ function markoRun(opts = {}) {
1905
1912
  noExternal: /@marko\/run/
1906
1913
  },
1907
1914
  build: {
1908
- target: isBuild && !((_g = config2.build) == null ? void 0 : _g.target) ? resolveToEsbuildTarget(
1909
- browserslist(void 0, {
1910
- path: root
1911
- }),
1912
- { printUnknownTargets: false }
1913
- ) : void 0,
1915
+ target: (browserslistTarget == null ? void 0 : browserslistTarget.length) ? resolveToEsbuildTarget(browserslistTarget, {
1916
+ printUnknownTargets: false
1917
+ }) : void 0,
1914
1918
  emptyOutDir: isSSRBuild,
1915
1919
  // Avoid server & client deleting files from each other.
1916
1920
  rollupOptions: {
@@ -2150,14 +2154,7 @@ function single(fn) {
2150
2154
  };
2151
2155
  }
2152
2156
  async function globFileExists(root, pattern) {
2153
- return new Promise((resolve, reject) => {
2154
- glob(pattern, { root }, (err, matches) => {
2155
- if (err) {
2156
- reject(err);
2157
- }
2158
- resolve(matches.length > 0);
2159
- });
2160
- });
2157
+ return (await glob(pattern, { root })).length > 0;
2161
2158
  }
2162
2159
  async function ensureDir(dir) {
2163
2160
  if (!fs2.existsSync(dir)) {
@@ -19,7 +19,7 @@ export interface StartDevOptions extends StartOptions {
19
19
  }
20
20
  export interface StartPreviewOptions extends StartOptions {
21
21
  dir: string;
22
- sourceEntry?: string;
22
+ entry?: string;
23
23
  }
24
24
  export interface Adapter {
25
25
  readonly name: string;