@sveltejs/adapter-vercel 6.3.0 → 6.3.2

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/index.js +48 -0
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -379,6 +379,31 @@ const plugin = function (defaults = {}) {
379
379
  );
380
380
  }
381
381
 
382
+ if (builder.config.kit.experimental.remoteFunctions) {
383
+ // Ensure remote functions are always handled by the catchall route, which will be symlinked to /_app/remote.
384
+ // This stops them from being affected by ISR config from other routes that match /[...rest] (ref: #15085)
385
+ // and also makes them show as handled by `/_app/remote` in Vercel's observability.
386
+
387
+ const app_path = builder.getAppPath();
388
+ const remote_dir = path.join(dirs.functions, app_path, 'remote'); // Usually .vercel/output/functions/_app/remote
389
+ const remote_symlink_path = `${remote_dir}.func`;
390
+
391
+ // Handle remote functions with the catchall route as it won't have any ISR settings
392
+ const target = path.join(dirs.functions, INTERNAL, 'catchall.func');
393
+
394
+ // Ensure the parent directory exists before symlinking
395
+ builder.mkdirp(path.join(dirs.functions, app_path));
396
+
397
+ const relative = path.relative(path.dirname(remote_symlink_path), target);
398
+
399
+ fs.symlinkSync(relative, remote_symlink_path);
400
+
401
+ static_config.routes.push({
402
+ src: `/${app_path}/remote/.+`,
403
+ dest: `/${app_path}/remote` // Maps to /![-]/catchall via the symlink
404
+ });
405
+ }
406
+
382
407
  for (const route of builder.routes) {
383
408
  if (is_prerendered(route)) continue;
384
409
 
@@ -591,6 +616,19 @@ function static_vercel_config(builder, config, dir) {
591
616
  }
592
617
 
593
618
  const routes = [
619
+ // Strip any user-supplied __pathname query parameter; SvelteKit reserves
620
+ // this for ISR handlers
621
+ {
622
+ src: '.*',
623
+ continue: true,
624
+ transforms: [
625
+ {
626
+ type: 'request.query',
627
+ op: 'delete',
628
+ target: { key: '__pathname' }
629
+ }
630
+ ]
631
+ },
594
632
  ...prerendered_redirects,
595
633
  {
596
634
  src: `/${builder.getAppPath()}/immutable/.+`,
@@ -641,6 +679,16 @@ function static_vercel_config(builder, config, dir) {
641
679
  handle: 'filesystem'
642
680
  });
643
681
 
682
+ // Prevent incorrect caching: if a request to /_app/immutable/* doesn't match
683
+ // a static file, return 404 instead of falling through to dynamic routes.
684
+ // Otherwise, we could accidentally immutably cache dynamic content served
685
+ // by the fallback function.
686
+ routes.push({
687
+ src: `/${builder.getAppPath()}/immutable/.+`,
688
+ status: 404,
689
+ continue: false
690
+ });
691
+
644
692
  return {
645
693
  version: 3,
646
694
  routes,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/adapter-vercel",
3
- "version": "6.3.0",
3
+ "version": "6.3.2",
4
4
  "description": "A SvelteKit adapter that creates a Vercel app",
5
5
  "keywords": [
6
6
  "adapter",
@@ -42,7 +42,7 @@
42
42
  "@types/node": "^18.19.119",
43
43
  "typescript": "^5.3.3",
44
44
  "vitest": "^4.0.0",
45
- "@sveltejs/kit": "^2.49.3"
45
+ "@sveltejs/kit": "^2.52.2"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "@sveltejs/kit": "^2.4.0"