@vercel/express 0.0.26 → 0.1.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.
Files changed (2) hide show
  1. package/dist/index.js +7 -647
  2. package/package.json +4 -3
package/dist/index.js CHANGED
@@ -32,14 +32,12 @@ var src_exports = {};
32
32
  __export(src_exports, {
33
33
  build: () => build,
34
34
  entrypointCallback: () => entrypointCallback,
35
- experimentalBuild: () => build2,
36
- experimentalVersion: () => version,
37
35
  findEntrypoint: () => findEntrypoint,
38
36
  name: () => name,
39
37
  require_: () => require_,
40
38
  shouldServe: () => shouldServe,
41
39
  startDevServer: () => startDevServer,
42
- version: () => version2
40
+ version: () => version
43
41
  });
44
42
  module.exports = __toCommonJS(src_exports);
45
43
 
@@ -83,20 +81,20 @@ var build = async (args) => {
83
81
  return entrypointCallback(args);
84
82
  }
85
83
  });
86
- let version3 = void 0;
84
+ let version2 = void 0;
87
85
  try {
88
86
  const resolved = require_.resolve(`${frameworkName}/package.json`, {
89
87
  paths: [args.workPath]
90
88
  });
91
89
  const expressVersion = require_(resolved).version;
92
90
  if (expressVersion) {
93
- version3 = expressVersion;
91
+ version2 = expressVersion;
94
92
  }
95
93
  } catch (e) {
96
94
  }
97
95
  res.output.framework = {
98
96
  slug: frameworkName,
99
- version: version3
97
+ version: version2
100
98
  };
101
99
  return res;
102
100
  };
@@ -205,645 +203,9 @@ var findMainPackageEntrypoint = (files) => {
205
203
  return null;
206
204
  };
207
205
 
208
- // src/experimental/build.ts
209
- var import_build_utils6 = require("@vercel/build-utils");
210
-
211
- // src/experimental/utils.ts
212
- var import_path2 = require("path");
213
- var import_build_utils2 = require("@vercel/build-utils");
214
- async function downloadInstallAndBundle(args) {
215
- const { entrypoint, files, workPath, meta, config } = args;
216
- await (0, import_build_utils2.download)(files, workPath, meta);
217
- const entrypointFsDirname = (0, import_path2.join)(workPath, (0, import_path2.dirname)(entrypoint));
218
- const nodeVersion = await (0, import_build_utils2.getNodeVersion)(
219
- entrypointFsDirname,
220
- void 0,
221
- config,
222
- meta
223
- );
224
- const spawnOpts = (0, import_build_utils2.getSpawnOptions)(meta || {}, nodeVersion);
225
- const {
226
- cliType,
227
- lockfileVersion,
228
- packageJsonPackageManager,
229
- turboSupportsCorepackHome
230
- } = await (0, import_build_utils2.scanParentDirs)(entrypointFsDirname, true);
231
- spawnOpts.env = (0, import_build_utils2.getEnvForPackageManager)({
232
- cliType,
233
- lockfileVersion,
234
- packageJsonPackageManager,
235
- nodeVersion,
236
- env: spawnOpts.env || {},
237
- turboSupportsCorepackHome,
238
- projectCreatedAt: config.projectSettings?.createdAt
239
- });
240
- const installCommand = config.projectSettings?.installCommand;
241
- if (typeof installCommand === "string") {
242
- if (installCommand.trim()) {
243
- console.log(`Running "install" command: \`${installCommand}\`...`);
244
- await (0, import_build_utils2.execCommand)(installCommand, {
245
- ...spawnOpts,
246
- cwd: entrypointFsDirname
247
- });
248
- } else {
249
- console.log(`Skipping "install" command...`);
250
- }
251
- } else {
252
- await (0, import_build_utils2.runNpmInstall)(
253
- entrypointFsDirname,
254
- [],
255
- spawnOpts,
256
- meta,
257
- nodeVersion,
258
- config.projectSettings?.createdAt
259
- );
260
- }
261
- return { entrypointFsDirname, nodeVersion, spawnOpts };
262
- }
263
- async function maybeExecBuildCommand(args, options) {
264
- const projectBuildCommand = args.config.projectSettings?.buildCommand;
265
- if (projectBuildCommand) {
266
- await (0, import_build_utils2.execCommand)(projectBuildCommand, {
267
- ...options.spawnOpts,
268
- cwd: args.workPath
269
- });
270
- } else {
271
- const possibleScripts = ["build"];
272
- await (0, import_build_utils2.runPackageJsonScript)(
273
- options.entrypointFsDirname,
274
- possibleScripts,
275
- options.spawnOpts,
276
- args.config.projectSettings?.createdAt
277
- );
278
- }
279
- }
280
-
281
- // src/experimental/rolldown.ts
282
- var import_build_utils3 = require("@vercel/build-utils");
283
- var import_nft = require("@vercel/nft");
284
- var import_fs2 = require("fs");
285
- var import_path3 = require("path");
286
- var import_rolldown = require("rolldown");
287
- var rolldown = async (args) => {
288
- const baseDir = args.repoRootPath || args.workPath;
289
- const entrypointPath = (0, import_path3.join)(args.workPath, args.entrypoint);
290
- const files = {};
291
- const shouldAddSourcemapSupport = false;
292
- const extension = (0, import_path3.extname)(args.entrypoint);
293
- const extensionMap = {
294
- ".ts": { format: "auto", extension: "js" },
295
- ".mts": { format: "esm", extension: "mjs" },
296
- ".cts": { format: "cjs", extension: "cjs" },
297
- ".cjs": { format: "cjs", extension: "cjs" },
298
- ".js": { format: "auto", extension: "js" },
299
- ".mjs": { format: "esm", extension: "mjs" }
300
- };
301
- const extensionInfo = extensionMap[extension] || extensionMap[".js"];
302
- let format = extensionInfo.format;
303
- const packageJsonPath = (0, import_path3.join)(args.workPath, "package.json");
304
- const external = [];
305
- if ((0, import_fs2.existsSync)(packageJsonPath)) {
306
- const { mode } = (0, import_fs2.lstatSync)(packageJsonPath);
307
- const source = (0, import_fs2.readFileSync)(packageJsonPath);
308
- const relPath = (0, import_path3.relative)(baseDir, packageJsonPath);
309
- let pkg;
310
- try {
311
- pkg = JSON.parse(source.toString());
312
- } catch (_e) {
313
- pkg = {};
314
- }
315
- if (format === "auto") {
316
- if (pkg.type === "module") {
317
- format = "esm";
318
- } else {
319
- format = "cjs";
320
- }
321
- }
322
- for (const dependency of Object.keys(pkg.dependencies || {})) {
323
- external.push(dependency);
324
- }
325
- for (const dependency of Object.keys(pkg.devDependencies || {})) {
326
- external.push(dependency);
327
- }
328
- for (const dependency of Object.keys(pkg.peerDependencies || {})) {
329
- external.push(dependency);
330
- }
331
- for (const dependency of Object.keys(pkg.optionalDependencies || {})) {
332
- external.push(dependency);
333
- }
334
- files[relPath] = new import_build_utils3.FileBlob({ data: source, mode });
335
- }
336
- const absoluteImportPlugin = {
337
- name: "absolute-import-resolver",
338
- resolveId(source) {
339
- if (external.includes(source)) {
340
- return { id: source, external: true };
341
- }
342
- return null;
343
- }
344
- };
345
- let tsconfigPath = (0, import_path3.join)(baseDir, "tsconfig.json");
346
- if (!(0, import_fs2.existsSync)(tsconfigPath)) {
347
- tsconfigPath = await (0, import_build_utils3.walkParentDirs)({
348
- base: baseDir,
349
- start: args.workPath,
350
- filename: "tsconfig.json"
351
- });
352
- }
353
- const relativeOutputDir = (0, import_path3.join)(
354
- ".vercel",
355
- "output",
356
- "functions",
357
- "index.func"
358
- );
359
- const outputDir = (0, import_path3.join)(baseDir, relativeOutputDir);
360
- let handler = null;
361
- await (0, import_rolldown.build)({
362
- input: entrypointPath,
363
- cwd: baseDir,
364
- platform: "node",
365
- external: /node_modules/,
366
- plugins: [absoluteImportPlugin],
367
- tsconfig: tsconfigPath || void 0,
368
- output: {
369
- dir: outputDir,
370
- // FIXME: This is a bit messy, not sure what facadeModuleId even is and the only reason for renaming here
371
- // is to preserve the proper extension for mjs/cjs scenario.
372
- // There doesn't seem to be another way to do only specify the entrypoint extension.
373
- entryFileNames: (info) => {
374
- if (info.name === "rolldown_runtime") {
375
- return "rolldown_runtime.js";
376
- }
377
- const facadeModuleId = info.facadeModuleId;
378
- if (!facadeModuleId) {
379
- throw new Error(`Unable to resolve module for ${info.name}`);
380
- }
381
- const relPath = (0, import_path3.relative)(baseDir, facadeModuleId);
382
- const extension2 = (0, import_path3.extname)(relPath);
383
- const extensionMap2 = {
384
- ".ts": ".js",
385
- ".mts": ".mjs",
386
- ".mjs": ".mjs",
387
- ".cts": ".cjs",
388
- ".cjs": ".cjs",
389
- ".js": ".js"
390
- };
391
- const ext = extensionMap2[extension2] || ".js";
392
- const nameWithJS = relPath.slice(0, -extension2.length) + ext;
393
- if (info.isEntry) {
394
- handler = nameWithJS;
395
- }
396
- return nameWithJS;
397
- },
398
- format,
399
- preserveModules: true,
400
- sourcemap: false
401
- }
402
- });
403
- if (typeof handler !== "string") {
404
- throw new Error(`Unable to resolve module for ${args.entrypoint}`);
405
- }
406
- const nftResult = await (0, import_nft.nodeFileTrace)([(0, import_path3.join)(outputDir, handler)], {
407
- // This didn't work as I expected it to, didn't find node_modules
408
- // base: outputDir,
409
- // processCwd: outputDir,
410
- ignore: args.config.excludeFiles
411
- });
412
- for (const file of nftResult.fileList) {
413
- if (file.startsWith(relativeOutputDir)) {
414
- const stats = (0, import_fs2.lstatSync)(file);
415
- const relPath = (0, import_path3.relative)(outputDir, file);
416
- files[relPath] = new import_build_utils3.FileFsRef({
417
- fsPath: file,
418
- mode: stats.mode
419
- });
420
- } else {
421
- const stats = (0, import_fs2.lstatSync)(file);
422
- files[file] = new import_build_utils3.FileFsRef({ fsPath: file, mode: stats.mode });
423
- }
424
- }
425
- return {
426
- files,
427
- shouldAddSourcemapSupport,
428
- handler,
429
- outputDir
430
- };
431
- };
432
-
433
- // src/experimental/find-entrypoint.ts
434
- var import_build_utils4 = require("@vercel/build-utils");
435
- var import_node2 = require("@vercel/node");
436
- var import_module2 = require("module");
437
- var import_path4 = require("path");
438
- var import_fs3 = __toESM(require("fs"));
439
- var REGEX2 = /(?:from|require|import)\s*(?:\(\s*)?["']express["']\s*(?:\))?/g;
440
- var validFilenames2 = [
441
- "app",
442
- "index",
443
- "server",
444
- "src/app",
445
- "src/index",
446
- "src/server"
447
- ];
448
- var require_2 = (0, import_module2.createRequire)(__filename);
449
- var validExtensions2 = ["js", "cjs", "mjs", "ts", "cts", "mts"];
450
- var entrypointsForMessage2 = validFilenames2.map((filename) => `- ${filename}.{${validExtensions2.join(",")}}`).join("\n");
451
- var entrypointCallback2 = async (args) => {
452
- const mainPackageEntrypoint = findMainPackageEntrypoint2(args.files);
453
- const entrypointGlob = `{${validFilenames2.map((entrypoint) => `${entrypoint}`).join(",")}}.{${validExtensions2.join(",")}}`;
454
- const dir = args.config.projectSettings?.outputDirectory?.replace(
455
- /^\/+|\/+$/g,
456
- ""
457
- );
458
- if (dir) {
459
- const { entrypoint: entrypointFromOutputDir, entrypointsNotMatchingRegex: entrypointsNotMatchingRegex2 } = findEntrypoint2(await (0, import_build_utils4.glob)(entrypointGlob, (0, import_path4.join)(args.workPath, dir)));
460
- if (entrypointFromOutputDir) {
461
- return (0, import_path4.join)(dir, entrypointFromOutputDir);
462
- }
463
- if (entrypointsNotMatchingRegex2.length > 0) {
464
- throw new Error(
465
- `No entrypoint found which imports express. Found possible ${pluralize2("entrypoint", entrypointsNotMatchingRegex2.length)}: ${entrypointsNotMatchingRegex2.join(", ")}`
466
- );
467
- }
468
- throw new Error(
469
- `No entrypoint found in output directory: "${dir}". Searched for:
470
- ${entrypointsForMessage2}`
471
- );
472
- }
473
- const files = await (0, import_build_utils4.glob)(entrypointGlob, args.workPath);
474
- const { entrypoint: entrypointFromRoot, entrypointsNotMatchingRegex } = findEntrypoint2(files);
475
- if (entrypointFromRoot) {
476
- return entrypointFromRoot;
477
- }
478
- if (mainPackageEntrypoint) {
479
- const entrypointFromPackageJson = await (0, import_build_utils4.glob)(
480
- mainPackageEntrypoint,
481
- args.workPath
482
- );
483
- if (entrypointFromPackageJson[mainPackageEntrypoint]) {
484
- if (checkMatchesRegex2(entrypointFromPackageJson[mainPackageEntrypoint])) {
485
- return mainPackageEntrypoint;
486
- }
487
- }
488
- }
489
- if (entrypointsNotMatchingRegex.length > 0) {
490
- throw new Error(
491
- `No entrypoint found which imports express. Found possible ${pluralize2("entrypoint", entrypointsNotMatchingRegex.length)}: ${entrypointsNotMatchingRegex.join(", ")}`
492
- );
493
- }
494
- throw new Error(
495
- `No entrypoint found. Searched for:
496
- ${entrypointsForMessage2}`
497
- );
498
- };
499
- function pluralize2(word, count) {
500
- return count === 1 ? word : `${word}s`;
501
- }
502
- var findEntrypoint2 = (files) => {
503
- const allEntrypoints = validFilenames2.flatMap(
504
- (filename) => validExtensions2.map((extension) => `${filename}.${extension}`)
505
- );
506
- const possibleEntrypointsInFiles = allEntrypoints.filter((entrypoint2) => {
507
- return files[entrypoint2] !== void 0;
508
- });
509
- const entrypointsMatchingRegex = possibleEntrypointsInFiles.filter(
510
- (entrypoint2) => {
511
- const file = files[entrypoint2];
512
- return checkMatchesRegex2(file);
513
- }
514
- );
515
- const entrypointsNotMatchingRegex = possibleEntrypointsInFiles.filter(
516
- (entrypoint2) => {
517
- const file = files[entrypoint2];
518
- return !checkMatchesRegex2(file);
519
- }
520
- );
521
- const entrypoint = entrypointsMatchingRegex[0];
522
- if (entrypointsMatchingRegex.length > 1) {
523
- console.warn(
524
- `Multiple entrypoints found: ${entrypointsMatchingRegex.join(", ")}. Using ${entrypoint}.`
525
- );
526
- }
527
- return {
528
- entrypoint,
529
- entrypointsNotMatchingRegex
530
- };
531
- };
532
- var checkMatchesRegex2 = (file) => {
533
- const content = import_fs3.default.readFileSync(file.fsPath, "utf-8");
534
- const matchesContent = content.match(REGEX2);
535
- return matchesContent !== null;
536
- };
537
- var findMainPackageEntrypoint2 = (files) => {
538
- const packageJson = files["package.json"];
539
- if (packageJson) {
540
- if (packageJson.type === "FileFsRef") {
541
- const packageJsonContent = import_fs3.default.readFileSync(packageJson.fsPath, "utf-8");
542
- let packageJsonJson;
543
- try {
544
- packageJsonJson = JSON.parse(packageJsonContent);
545
- } catch (_e) {
546
- packageJsonJson = {};
547
- }
548
- if ("main" in packageJsonJson && typeof packageJsonJson.main === "string") {
549
- return packageJsonJson.main;
550
- }
551
- }
552
- }
553
- return null;
554
- };
555
-
556
- // src/experimental/introspection.ts
557
- var import_build_utils5 = require("@vercel/build-utils");
558
- var import_path5 = require("path");
559
- var import_fs_extra = require("fs-extra");
560
- var import_child_process = require("child_process");
561
- var import_fs4 = require("fs");
562
- var import_promises = require("fs/promises");
563
- var import_module3 = require("module");
564
- var import_path_to_regexp = require("path-to-regexp");
565
- var import_zod = require("zod");
566
- var require_3 = (0, import_module3.createRequire)(__filename);
567
- var introspectApp = async (args, options) => {
568
- const source = expressShimSource(options);
569
- await (0, import_fs_extra.outputFile)(
570
- (0, import_path5.join)(options.outputDir, "node_modules", "express", "index.js"),
571
- source
572
- );
573
- await invokeFunction(args, options);
574
- const {
575
- routes: routesFromIntrospection,
576
- views,
577
- staticPaths
578
- } = await processIntrospection(options);
579
- await cleanup(options);
580
- if (views) {
581
- try {
582
- const validatedViews = validatePath(views, args.workPath);
583
- const viewFiles = await (0, import_build_utils5.glob)((0, import_path5.join)(validatedViews, "**/*"), args.workPath);
584
- for (const [p, f] of Object.entries(viewFiles)) {
585
- options.files[p] = f;
586
- }
587
- } catch (error) {
588
- console.log(`Skipping invalid views path: ${views}`);
589
- }
590
- }
591
- if (staticPaths) {
592
- try {
593
- const validatedStaticPaths = staticPaths.map(
594
- (path) => validatePath(path, args.workPath)
595
- );
596
- for (const staticPath of validatedStaticPaths) {
597
- const staticFiles = await (0, import_build_utils5.glob)((0, import_path5.join)(staticPath, "**/*"), args.workPath);
598
- for (const [p, f] of Object.entries(staticFiles)) {
599
- options.files[p] = f;
600
- }
601
- }
602
- } catch (error) {
603
- console.log(`Skipping invalid static paths: ${staticPaths}`);
604
- }
605
- }
606
- const routes = [
607
- {
608
- handle: "filesystem"
609
- },
610
- ...routesFromIntrospection,
611
- {
612
- src: "/(.*)",
613
- dest: "/"
614
- }
615
- ];
616
- return { routes };
617
- };
618
- var cleanup = async (options) => {
619
- await (0, import_promises.rm)((0, import_path5.join)(options.outputDir, "node_modules"), {
620
- recursive: true,
621
- force: true
622
- });
623
- await (0, import_promises.rm)(getIntrospectionPath(options), { force: true });
624
- };
625
- var processIntrospection = async (options) => {
626
- const schema = import_zod.z.object({
627
- routes: import_zod.z.record(
628
- import_zod.z.string(),
629
- import_zod.z.object({
630
- methods: import_zod.z.array(import_zod.z.string())
631
- })
632
- ).transform(
633
- (value) => Object.entries(value).map(([path, route]) => convertExpressRoute(path, route)).filter(Boolean)
634
- ),
635
- views: import_zod.z.string().optional(),
636
- staticPaths: import_zod.z.array(import_zod.z.string()).optional(),
637
- viewEngine: import_zod.z.string().optional()
638
- });
639
- try {
640
- const introspectionPath = (0, import_path5.join)(options.outputDir, "introspection.json");
641
- const introspection = (0, import_fs4.readFileSync)(introspectionPath, "utf8");
642
- return schema.parse(JSON.parse(introspection));
643
- } catch (error) {
644
- console.log(
645
- `Unable to extract routes from express, route level observability will not be available`
646
- );
647
- return {
648
- routes: [],
649
- views: void 0,
650
- staticPaths: void 0,
651
- viewEngine: void 0
652
- };
653
- }
654
- };
655
- var getIntrospectionPath = (options) => {
656
- return (0, import_path5.join)(options.outputDir, "introspection.json");
657
- };
658
- var invokeFunction = async (args, options) => {
659
- await new Promise((resolve2) => {
660
- try {
661
- const child = (0, import_child_process.spawn)("node", [(0, import_path5.join)(options.outputDir, options.handler)], {
662
- stdio: ["pipe", "pipe", "pipe"],
663
- cwd: options.outputDir,
664
- env: {
665
- ...process.env,
666
- ...args.meta?.env || {},
667
- ...args.meta?.buildEnv || {}
668
- }
669
- });
670
- setTimeout(() => {
671
- child.kill("SIGTERM");
672
- }, 5e3);
673
- child.on("error", () => {
674
- console.log(
675
- `Unable to extract routes from express, route level observability will not be available`
676
- );
677
- resolve2(void 0);
678
- });
679
- child.on("close", () => {
680
- resolve2(void 0);
681
- });
682
- } catch (error) {
683
- console.log(
684
- `Unable to extract routes from express, route level observability will not be available`
685
- );
686
- resolve2(void 0);
687
- }
688
- });
689
- };
690
- var expressShimSource = (args) => {
691
- const pathToExpress = require_3.resolve("express", {
692
- paths: [args.outputDir]
693
- });
694
- const introspectionPath = getIntrospectionPath(args);
695
- return `
696
- const fs = require('fs');
697
- const path = require('path');
698
- const originalExpress = require(${JSON.stringify(pathToExpress)});
699
-
700
- let app = null
701
- let staticPaths = [];
702
- let views = ''
703
- let viewEngine = ''
704
- const routes = {};
705
- const originalStatic = originalExpress.static
706
- originalExpress.static = (...args) => {
707
- staticPaths.push(args[0]);
708
- return originalStatic(...args);
709
- }
710
- function expressWrapper() {
711
- app = originalExpress.apply(this, arguments);
712
- return app;
713
- }
714
-
715
- // Copy all properties from the original express to the wrapper
716
- Object.setPrototypeOf(expressWrapper, originalExpress);
717
- Object.assign(expressWrapper, originalExpress);
718
-
719
- // Preserve the original prototype
720
- expressWrapper.prototype = originalExpress.prototype;
721
-
722
- module.exports = expressWrapper;
723
-
724
- let routesExtracted = false;
725
-
726
- const extractRoutes = () => {
727
- if (routesExtracted) {
728
- return;
729
- }
730
- routesExtracted = true;
731
-
732
- const methods = ["all", "get", "post", "put", "delete", "patch", "options", "head"]
733
- if (!app) {
734
- return;
735
- }
736
- const router = app._router || app.router
737
- for (const route of router.stack) {
738
- if(route.route) {
739
- const m = [];
740
- for (const method of methods) {
741
- if(route.route.methods[method]) {
742
- m.push(method.toUpperCase());
743
- }
744
- }
745
- routes[route.route.path] = { methods: m };
746
- }
747
- }
748
-
749
- views = app.settings.views
750
- viewEngine = app.settings['view engine']
751
-
752
- // Ensure directory exists
753
- const dir = path.dirname(${JSON.stringify(introspectionPath)});
754
- if (!fs.existsSync(dir)) {
755
- fs.mkdirSync(dir, { recursive: true });
756
- }
757
-
758
- fs.writeFileSync(${JSON.stringify(introspectionPath)}, JSON.stringify({routes, views, staticPaths, viewEngine}, null, 2));
759
- }
760
-
761
- process.on('exit', () => {
762
- extractRoutes()
763
- });
764
-
765
- process.on('SIGINT', () => {
766
- extractRoutes()
767
- process.exit(0);
768
- });
769
- // Write routes to file on SIGTERM
770
- process.on('SIGTERM', () => {
771
- extractRoutes()
772
- process.exit(0);
773
- });
774
- `;
775
- };
776
- var convertExpressRoute = (route, routeData) => {
777
- const { regexp } = (0, import_path_to_regexp.pathToRegexp)(route);
778
- const dest = route;
779
- if (dest === "/") {
780
- return;
781
- }
782
- const src = regexp.source;
783
- return {
784
- src,
785
- dest,
786
- methods: routeData.methods
787
- };
788
- };
789
- var validatePath = (inputPath, workPath) => {
790
- if (inputPath.indexOf("\0") !== -1) {
791
- throw new Error(`Path contains null bytes: ${inputPath}`);
792
- }
793
- const normalizedPath = (0, import_path5.normalize)(inputPath);
794
- if (normalizedPath.includes("..")) {
795
- throw new Error(
796
- `Path contains directory traversal sequences: ${inputPath}`
797
- );
798
- }
799
- if ((0, import_path5.isAbsolute)(normalizedPath)) {
800
- throw new Error(`Absolute paths are not allowed: ${inputPath}`);
801
- }
802
- const resolvedPath = (0, import_path5.resolve)(workPath, normalizedPath);
803
- const resolvedWorkPath = (0, import_path5.resolve)(workPath);
804
- if (!resolvedPath.startsWith(resolvedWorkPath + import_path5.sep) && resolvedPath !== resolvedWorkPath) {
805
- throw new Error(`Path escapes the intended directory: ${inputPath}`);
806
- }
807
- return normalizedPath;
808
- };
809
-
810
- // src/experimental/build.ts
811
- var version = 2;
812
- var build2 = async (args) => {
813
- console.log(`Using experimental express build`);
814
- const downloadResult = await downloadInstallAndBundle(args);
815
- await maybeExecBuildCommand(args, downloadResult);
816
- args.entrypoint = await entrypointCallback2(args);
817
- const rolldownResult = await rolldown(args);
818
- const { routes } = await introspectApp(args, rolldownResult);
819
- const lambda = new import_build_utils6.NodejsLambda({
820
- runtime: downloadResult.nodeVersion.runtime,
821
- ...rolldownResult,
822
- shouldAddHelpers: false,
823
- shouldAddSourcemapSupport: true,
824
- framework: {
825
- slug: "express"
826
- },
827
- awsLambdaHandler: ""
828
- });
829
- const output = { index: lambda };
830
- for (const route of routes) {
831
- if (route.dest) {
832
- if (route.dest === "/") {
833
- continue;
834
- }
835
- output[route.dest] = lambda;
836
- }
837
- }
838
- return {
839
- routes,
840
- output
841
- };
842
- };
843
-
844
206
  // src/index.ts
845
- var import_node3 = require("@vercel/node");
846
- var version2 = 3;
207
+ var import_node2 = require("@vercel/node");
208
+ var version = 3;
847
209
  var name = "express";
848
210
  var shouldServe = async (opts) => {
849
211
  const requestPath = opts.requestPath.replace(/\/$/, "");
@@ -855,7 +217,7 @@ var shouldServe = async (opts) => {
855
217
  var startDevServer = async (opts) => {
856
218
  const entrypoint = await entrypointCallback(opts);
857
219
  process.env.EXPERIMENTAL_NODE_TYPESCRIPT_ERRORS = "1";
858
- return (0, import_node3.startDevServer)({
220
+ return (0, import_node2.startDevServer)({
859
221
  ...opts,
860
222
  entrypoint,
861
223
  publicDir: "public"
@@ -865,8 +227,6 @@ var startDevServer = async (opts) => {
865
227
  0 && (module.exports = {
866
228
  build,
867
229
  entrypointCallback,
868
- experimentalBuild,
869
- experimentalVersion,
870
230
  findEntrypoint,
871
231
  name,
872
232
  require_,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/express",
3
- "version": "0.0.26",
3
+ "version": "0.1.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.js",
6
6
  "homepage": "https://vercel.com/docs",
@@ -24,13 +24,14 @@
24
24
  "rolldown": "1.0.0-beta.35",
25
25
  "ts-morph": "12.0.0",
26
26
  "zod": "3.22.4",
27
- "@vercel/node": "5.4.1"
27
+ "@vercel/node": "5.5.0",
28
+ "@vercel/cervel": "0.0.2"
28
29
  },
29
30
  "devDependencies": {
30
31
  "@types/fs-extra": "11",
31
32
  "@types/jest": "27.5.1",
32
33
  "@types/node": "14.18.33",
33
- "@vercel/build-utils": "12.1.3",
34
+ "@vercel/build-utils": "12.2.0",
34
35
  "execa": "3.2.0",
35
36
  "jest-junit": "16.0.0",
36
37
  "vite": "^5.1.6",