@sveltejs/adapter-vercel 1.0.0-next.51 → 1.0.0-next.52

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 (3) hide show
  1. package/README.md +1 -1
  2. package/index.js +15 -6
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -6,7 +6,7 @@ If you're using [adapter-auto](../adapter-auto), you don't need to install this
6
6
 
7
7
  ## Usage
8
8
 
9
- > The `edge` and `split` options depend on the Vercel Build Output API which is currently in beta. For now, you must opt in by visiting `https://vercel.com/svelte/[YOUR_PROJECT]/settings/environment-variables` and adding `ENABLE_VC_BUILD` with the value `1`.
9
+ > The `edge` and `split` options depend on the Vercel Build Output API which is currently in beta. For now, you must opt in by visiting `https://vercel.com/[YOUR_USERNAME]/[YOUR_PROJECT]/settings/environment-variables` and adding `ENABLE_VC_BUILD` with the value `1`.
10
10
 
11
11
  Add `"@sveltejs/adapter-vercel": "next"` to the `devDependencies` in your `package.json` and run `npm install`.
12
12
 
package/index.js CHANGED
@@ -329,7 +329,7 @@ async function v3(builder, external, edge, split) {
329
329
  })
330
330
  );
331
331
 
332
- routes.push({ src: pattern, middlewarePath: name });
332
+ routes.push({ src: pattern, dest: `/${name}` });
333
333
  }
334
334
 
335
335
  const generate_function = edge ? generate_edge_function : generate_serverless_function;
@@ -340,10 +340,19 @@ async function v3(builder, external, edge, split) {
340
340
  id: route.pattern.toString(), // TODO is `id` necessary?
341
341
  filter: (other) => route.pattern.toString() === other.pattern.toString(),
342
342
  complete: async (entry) => {
343
- const src = `${route.pattern
343
+ let sliced_pattern = route.pattern
344
344
  .toString()
345
- .slice(1, -2) // remove leading / and trailing $/
346
- .replace(/\\\//g, '/')}(?:/__data.json)?$`; // TODO adding /__data.json is a temporary workaround — those endpoints should be treated as distinct routes
345
+ // remove leading / and trailing $/
346
+ .slice(1, -2)
347
+ // replace escaped \/ with /
348
+ .replace(/\\\//g, '/');
349
+
350
+ // replace the root route "^/" with "^/?"
351
+ if (sliced_pattern === '^/') {
352
+ sliced_pattern = '^/?';
353
+ }
354
+
355
+ const src = `${sliced_pattern}(?:/__data.json)?$`; // TODO adding /__data.json is a temporary workaround — those endpoints should be treated as distinct routes
347
356
 
348
357
  await generate_function(route.id || 'index', src, entry.generateManifest);
349
358
  }
@@ -395,8 +404,8 @@ function get_node_version() {
395
404
  const full = process.version.slice(1); // 'v16.5.0' --> '16.5.0'
396
405
  const major = parseInt(full.split('.')[0]); // '16.5.0' --> 16
397
406
 
398
- if (major < 14) {
399
- throw new Error(`SvelteKit only support Node.js version 14 or greater (currently using v${full}). Consult the documentation: https://vercel.com/docs/runtimes#official-runtimes/node-js/node-js-version`)
407
+ if (major < 16) {
408
+ throw new Error(`SvelteKit only supports Node.js version 16 or greater (currently using v${full}). Consult the documentation: https://vercel.com/docs/runtimes#official-runtimes/node-js/node-js-version`)
400
409
  }
401
410
 
402
411
  return { major, full };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sveltejs/adapter-vercel",
3
- "version": "1.0.0-next.51",
3
+ "version": "1.0.0-next.52",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/sveltejs/kit",
@@ -25,7 +25,7 @@
25
25
  "esbuild": "^0.14.21"
26
26
  },
27
27
  "devDependencies": {
28
- "@sveltejs/kit": "1.0.0-next.330",
28
+ "@sveltejs/kit": "1.0.0-next.331",
29
29
  "@types/node": "^14.14.20",
30
30
  "typescript": "^4.6.2"
31
31
  },