diff --git a/.changeset/tiny-apes-shave.md b/.changeset/tiny-apes-shave.md new file mode 100644 index 000000000..979650a6b --- /dev/null +++ b/.changeset/tiny-apes-shave.md @@ -0,0 +1,20 @@ +--- +'@astrojs/vercel': minor +--- + + +**[BREAKING]** Now with Build Output API (v3)! [See the README to get started](https://github.com/withastro/astro/tree/main/packages/integrations/vercel#readme). + +- `trailingSlash` redirects works without a `vercel.json` file: just configure them inside your `astro.config.mjs` +- Multiple deploy targets: `edge`, `serverless` and `static`! +- When building to `serverless`, your code isn't transpiled to CJS anymore. + +**Migrate from v0.1** + +1. Change the import inside `astro.config.mjs`: + ```diff + - import vercel from '@astrojs/vercel'; + + import vercel from '@astrojs/vercel/serverless'; + ``` +2. Rename the `ENABLE_FILE_SYSTEM_API` environment variable to `ENABLE_VC_BUILD`, as Vercel changed it. +3. The output folder changed from `.output` to `.vercel/output` — you may need to update your `.gitignore`. diff --git a/.gitignore b/.gitignore index 30c24d1e9..fa9abb6d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ node_modules/ dist/ -.output/ *.tsbuildinfo .DS_Store .vercel diff --git a/.prettierignore b/.prettierignore index 7c89fbaf5..7b6398b3e 100644 --- a/.prettierignore +++ b/.prettierignore @@ -4,7 +4,6 @@ # Deep Directories **/dist -**/.output **/smoke **/node_modules **/fixtures diff --git a/examples/blog-multiple-authors/.gitignore b/examples/blog-multiple-authors/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/blog-multiple-authors/.gitignore +++ b/examples/blog-multiple-authors/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/blog/.gitignore b/examples/blog/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/blog/.gitignore +++ b/examples/blog/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/component/.gitignore b/examples/component/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/component/.gitignore +++ b/examples/component/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/docs/.gitignore b/examples/docs/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/docs/.gitignore +++ b/examples/docs/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/env-vars/.gitignore b/examples/env-vars/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/env-vars/.gitignore +++ b/examples/env-vars/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/framework-alpine/.gitignore b/examples/framework-alpine/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/framework-alpine/.gitignore +++ b/examples/framework-alpine/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/framework-lit/.gitignore b/examples/framework-lit/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/framework-lit/.gitignore +++ b/examples/framework-lit/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/framework-multiple/.gitignore b/examples/framework-multiple/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/framework-multiple/.gitignore +++ b/examples/framework-multiple/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/framework-preact/.gitignore b/examples/framework-preact/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/framework-preact/.gitignore +++ b/examples/framework-preact/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/framework-react/.gitignore b/examples/framework-react/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/framework-react/.gitignore +++ b/examples/framework-react/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/framework-solid/.gitignore b/examples/framework-solid/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/framework-solid/.gitignore +++ b/examples/framework-solid/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/framework-svelte/.gitignore b/examples/framework-svelte/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/framework-svelte/.gitignore +++ b/examples/framework-svelte/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/framework-vue/.gitignore b/examples/framework-vue/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/framework-vue/.gitignore +++ b/examples/framework-vue/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/integrations-playground/.gitignore b/examples/integrations-playground/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/integrations-playground/.gitignore +++ b/examples/integrations-playground/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/minimal/.gitignore b/examples/minimal/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/minimal/.gitignore +++ b/examples/minimal/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/non-html-pages/.gitignore b/examples/non-html-pages/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/non-html-pages/.gitignore +++ b/examples/non-html-pages/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/portfolio/.gitignore b/examples/portfolio/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/portfolio/.gitignore +++ b/examples/portfolio/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/starter/.gitignore b/examples/starter/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/starter/.gitignore +++ b/examples/starter/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/subpath/.gitignore b/examples/subpath/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/subpath/.gitignore +++ b/examples/subpath/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/with-markdown-plugins/.gitignore b/examples/with-markdown-plugins/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/with-markdown-plugins/.gitignore +++ b/examples/with-markdown-plugins/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/with-markdown-shiki/.gitignore b/examples/with-markdown-shiki/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/with-markdown-shiki/.gitignore +++ b/examples/with-markdown-shiki/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/with-markdown/.gitignore b/examples/with-markdown/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/with-markdown/.gitignore +++ b/examples/with-markdown/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/with-nanostores/.gitignore b/examples/with-nanostores/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/with-nanostores/.gitignore +++ b/examples/with-nanostores/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/with-tailwindcss/.gitignore b/examples/with-tailwindcss/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/with-tailwindcss/.gitignore +++ b/examples/with-tailwindcss/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/examples/with-vite-plugin-pwa/.gitignore b/examples/with-vite-plugin-pwa/.gitignore index 7329a851d..02f6e50b4 100644 --- a/examples/with-vite-plugin-pwa/.gitignore +++ b/examples/with-vite-plugin-pwa/.gitignore @@ -1,6 +1,5 @@ # build output dist/ -.output/ # dependencies node_modules/ diff --git a/packages/integrations/vercel/README.md b/packages/integrations/vercel/README.md index 0536fa49f..a30617b67 100644 --- a/packages/integrations/vercel/README.md +++ b/packages/integrations/vercel/README.md @@ -6,31 +6,34 @@ Use this integration in your Astro configuration file: ```js import { defineConfig } from 'astro/config'; -import vercel from '@astrojs/vercel'; +import vercel from '@astrojs/vercel/serverless'; export default defineConfig({ adapter: vercel() }); ``` -When you build your project, Astro will know to use the `.output` folder format that Vercel expects. +When you build your project, Astro will know to use the `.vercel/output` folder format that Vercel expects. -``` -astro build -``` +## Deploying -That's it! You can deploy by CLI (`vercel deploy`) or by connecting your new repo in the [Vercel Dashboard](https://vercel.com/). +You can deploy by CLI (`vercel deploy`) or by connecting your new repo in the [Vercel Dashboard](https://vercel.com/). Alternatively, you can create a production build locally: + +```sh +ENABLE_VC_BUILD=1 astro build +vercel deploy --prebuilt +``` ## Requirements -**Vercel's [File System API](https://vercel.com/docs/file-system-api/v2) must be enabled.** You must enable it yourself by setting the environment variable: `ENABLE_FILE_SYSTEM_API=1`. +**Vercel's [Build Output API](https://vercel.com/docs/build-output-api/v3) must be enabled.** You must enable it yourself by setting the environment variable: `ENABLE_VC_BUILD=1`. ```js // vercel.json { "build": { "env": { - "ENABLE_FILE_SYSTEM_API": "1" + "ENABLE_VC_BUILD": "1" } } } @@ -38,6 +41,36 @@ That's it! You can deploy by CLI (`vercel deploy`) or by connecting your new rep [Learn more about setting enviroment variables in Vercel](https://vercel.com/docs/concepts/projects/environment-variables). +## Targets + +You can deploy to different targes: + +- `edge`: SSR inside a [Edge function](https://vercel.com/docs/concepts/functions/edge-functions). +- `serverless`: SSR inside a [Node.js function](https://vercel.com/docs/concepts/functions/serverless-functions). +- `static`: generates a static website following Vercel's output formats, redirects, etc. + +> **Note**: deploying to the Edge has [its limitations](https://vercel.com/docs/concepts/functions/edge-functions#known-limitations) — they can't be more than 1 MB in size and they don't support native Node.js APIs, among others. + +You can change where to target by changing the import: + +```js +import vercel from '@astrojs/vercel/edge'; +import vercel from '@astrojs/vercel/serverless'; +import vercel from '@astrojs/vercel/static'; +``` + +### Node.js version + +When deploying to `serverless` you can choose what version of Node.js you want to target: `12.x`, `14.x` or `16.x` (default). + +```js +import { defineConfig } from 'astro/config'; +import vercel from '@astrojs/vercel/serverless'; + +export default defineConfig({ + adapter: vercel({ nodeVersion: '14.x' }) +}); +``` ## Limitations diff --git a/packages/integrations/vercel/package.json b/packages/integrations/vercel/package.json index 963d6e419..e7f98b77e 100644 --- a/packages/integrations/vercel/package.json +++ b/packages/integrations/vercel/package.json @@ -14,8 +14,11 @@ "bugs": "https://github.com/withastro/astro/issues", "homepage": "https://astro.build", "exports": { - ".": "./dist/index.js", - "./server-entrypoint": "./dist/server-entrypoint.js", + "./edge": "./dist/edge/adapter.js", + "./edge/entrypoint": "./dist/edge/entrypoint.js", + "./serverless": "./dist/serverless/adapter.js", + "./serverless/entrypoint": "./dist/serverless/entrypoint.js", + "./static": "./dist/serverless/adapter.js", "./package.json": "./package.json" }, "scripts": { @@ -25,7 +28,7 @@ }, "dependencies": { "@astrojs/webapi": "^0.11.1", - "esbuild": "^0.14.38" + "@vercel/nft": "^0.18.2" }, "devDependencies": { "astro": "workspace:*", diff --git a/packages/integrations/vercel/src/edge/adapter.ts b/packages/integrations/vercel/src/edge/adapter.ts new file mode 100644 index 000000000..664eb2c43 --- /dev/null +++ b/packages/integrations/vercel/src/edge/adapter.ts @@ -0,0 +1,74 @@ +import type { AstroAdapter, AstroConfig, AstroIntegration } from 'astro'; + +import { writeJson, getVercelOutput } from '../lib/fs.js'; +import { getRedirects } from '../lib/redirects.js'; + +const PACKAGE_NAME = '@astrojs/vercel/edge'; + +function getAdapter(): AstroAdapter { + return { + name: PACKAGE_NAME, + serverEntrypoint: `${PACKAGE_NAME}/entrypoint`, + exports: ['default'], + }; +} + +export default function vercelEdge(): AstroIntegration { + let _config: AstroConfig; + let functionFolder: URL; + let serverEntry: string; + + return { + name: PACKAGE_NAME, + hooks: { + 'astro:config:setup': ({ config }) => { + config.outDir = getVercelOutput(config.root); + }, + 'astro:config:done': ({ setAdapter, config }) => { + setAdapter(getAdapter()); + _config = config; + }, + 'astro:build:setup': ({ vite, target }) => { + if (target === 'server') { + vite.resolve ||= {}; + vite.resolve.alias ||= {}; + const alias = vite.resolve.alias as Record; + alias['react-dom/server'] = 'react-dom/server.browser'; + vite.ssr = { + noExternal: true, + }; + } + }, + 'astro:build:start': async ({ buildConfig }) => { + if (String(process.env.ENABLE_VC_BUILD) !== '1') { + throw new Error( + `The enviroment variable "ENABLE_VC_BUILD" was not found. Make sure you have it set to "1" in your Vercel project.\nLearn how to set enviroment variables here: https://vercel.com/docs/concepts/projects/environment-variables` + ); + } + + buildConfig.serverEntry = serverEntry = 'entry.mjs'; + buildConfig.client = new URL('./static/', _config.outDir); + buildConfig.server = functionFolder = new URL('./functions/render.func/', _config.outDir); + }, + 'astro:build:done': async ({ routes }) => { + // Edge function config + // https://vercel.com/docs/build-output-api/v3#vercel-primitives/edge-functions/configuration + await writeJson(new URL(`./.vc-config.json`, functionFolder), { + runtime: 'edge', + entrypoint: serverEntry, + }); + + // Output configuration + // https://vercel.com/docs/build-output-api/v3#build-output-configuration + await writeJson(new URL(`./config.json`, _config.outDir), { + version: 3, + routes: [ + ...getRedirects(routes, _config), + { handle: 'filesystem' }, + { src: '/.*', middlewarePath: 'render' }, + ], + }); + }, + }, + }; +} diff --git a/packages/integrations/vercel/src/edge/entrypoint.ts b/packages/integrations/vercel/src/edge/entrypoint.ts new file mode 100644 index 000000000..af1496f60 --- /dev/null +++ b/packages/integrations/vercel/src/edge/entrypoint.ts @@ -0,0 +1,21 @@ +import './shim.js'; + +import type { SSRManifest } from 'astro'; +import { App } from 'astro/app'; + +export function createExports(manifest: SSRManifest) { + const app = new App(manifest); + + const handler = async (request: Request): Promise => { + if (app.match(request)) { + return await app.render(request); + } + + return new Response(null, { + status: 404, + statusText: 'Not found', + }); + }; + + return { default: handler }; +} diff --git a/packages/integrations/vercel/src/edge/shim.ts b/packages/integrations/vercel/src/edge/shim.ts new file mode 100644 index 000000000..1a73feb39 --- /dev/null +++ b/packages/integrations/vercel/src/edge/shim.ts @@ -0,0 +1 @@ +process.argv = []; diff --git a/packages/integrations/vercel/src/index.ts b/packages/integrations/vercel/src/index.ts deleted file mode 100644 index 838844a08..000000000 --- a/packages/integrations/vercel/src/index.ts +++ /dev/null @@ -1,149 +0,0 @@ -import type { AstroAdapter, AstroConfig, AstroIntegration, RouteData } from 'astro'; -import type { PathLike } from 'fs'; -import fs from 'fs/promises'; -import { fileURLToPath } from 'url'; -import esbuild from 'esbuild'; - -const writeJson = (path: PathLike, data: any) => - fs.writeFile(path, JSON.stringify(data), { encoding: 'utf-8' }); - -const ENTRYFILE = '__astro_entry'; - -export function getAdapter(): AstroAdapter { - return { - name: '@astrojs/vercel', - serverEntrypoint: '@astrojs/vercel/server-entrypoint', - exports: ['default'], - }; -} - -export default function vercel(): AstroIntegration { - let _config: AstroConfig; - let _serverEntry: URL; - - return { - name: '@astrojs/vercel', - hooks: { - 'astro:config:setup': ({ config }) => { - config.outDir = new URL('./.output/', config.root); - config.build.format = 'directory'; - }, - 'astro:config:done': ({ setAdapter, config }) => { - setAdapter(getAdapter()); - _config = config; - _serverEntry = new URL(`./server/pages/${ENTRYFILE}.js`, config.outDir); - }, - 'astro:build:setup': ({ vite, target }) => { - if (target === 'server') { - vite.build!.rollupOptions = { - input: [], - output: { - format: 'cjs', - file: fileURLToPath(_serverEntry), - dir: undefined, - entryFileNames: undefined, - chunkFileNames: undefined, - assetFileNames: undefined, - inlineDynamicImports: true, - }, - }; - } - }, - 'astro:build:start': async ({ buildConfig }) => { - buildConfig.serverEntry = `${ENTRYFILE}.js`; - buildConfig.client = new URL('./static/', _config.outDir); - buildConfig.server = new URL('./server/pages/', _config.outDir); - - if (String(process.env.ENABLE_FILE_SYSTEM_API) !== '1') { - console.warn( - `The enviroment variable "ENABLE_FILE_SYSTEM_API" was not found. Make sure you have it set to "1" in your Vercel project.\nLearn how to set enviroment variables here: https://vercel.com/docs/concepts/projects/environment-variables` - ); - } - }, - 'astro:build:done': async ({ routes }) => { - // Bundle dependecies - await esbuild.build({ - entryPoints: [fileURLToPath(_serverEntry)], - outfile: fileURLToPath(_serverEntry), - bundle: true, - format: 'cjs', - platform: 'node', - target: 'node14', - allowOverwrite: true, - minifyWhitespace: true, - }); - - let staticRoutes: RouteData[] = []; - let dynamicRoutes: RouteData[] = []; - - for (const route of routes) { - if (route.params.length === 0) staticRoutes.push(route); - else dynamicRoutes.push(route); - } - - // Routes Manifest - // https://vercel.com/docs/file-system-api#configuration/routes - await writeJson(new URL(`./routes-manifest.json`, _config.outDir), { - version: 3, - basePath: '/', - pages404: false, - redirects: - _config.trailingSlash !== 'ignore' - ? routes - .filter((route) => route.type === 'page' && !route.pathname?.endsWith('/')) - .map((route) => { - const path = - '/' + - route.segments - .map((segments) => - segments - .map((part) => - part.spread - ? `:${part.content}*` - : part.dynamic - ? `:${part.content}` - : part.content - ) - .join('') - ) - .join('/'); - - let source, destination; - - if (_config.trailingSlash === 'always') { - source = path; - destination = path + '/'; - } else { - source = path + '/'; - destination = path; - } - - return { source, destination, statusCode: 308 }; - }) - : undefined, - rewrites: staticRoutes.map((route) => { - let source = route.pathname as string; - - if ( - route.type === 'page' && - _config.trailingSlash === 'always' && - !source.endsWith('/') - ) { - source += '/'; - } - - return { - source, - regex: route.pattern.toString(), - destination: `/${ENTRYFILE}`, - }; - }), - dynamicRoutes: dynamicRoutes.map((route) => ({ - page: `/${ENTRYFILE}`, - regex: route.pattern.toString(), - })), - }); - }, - }, - }; -} diff --git a/packages/integrations/vercel/src/lib/fs.ts b/packages/integrations/vercel/src/lib/fs.ts new file mode 100644 index 000000000..e192ba554 --- /dev/null +++ b/packages/integrations/vercel/src/lib/fs.ts @@ -0,0 +1,13 @@ +import type { PathLike } from 'node:fs'; +import * as fs from 'node:fs/promises'; + +export async function writeJson(path: PathLike, data: T) { + await fs.writeFile(path, JSON.stringify(data), { encoding: 'utf-8' }); +} + +export async function emptyDir(dir: PathLike): Promise { + await fs.rm(dir, { recursive: true, force: true, maxRetries: 3 }); + await fs.mkdir(dir, { recursive: true }); +} + +export const getVercelOutput = (root: URL) => new URL('./.vercel/output/', root); diff --git a/packages/integrations/vercel/src/lib/nft.ts b/packages/integrations/vercel/src/lib/nft.ts new file mode 100644 index 000000000..d88429714 --- /dev/null +++ b/packages/integrations/vercel/src/lib/nft.ts @@ -0,0 +1,38 @@ +import * as fs from 'node:fs/promises'; +import { fileURLToPath } from 'node:url'; +import { nodeFileTrace } from '@vercel/nft'; + +export async function copyDependenciesToFunction( + root: URL, + functionFolder: URL, + serverEntry: string +) { + const entryPath = fileURLToPath(new URL(`./${serverEntry}`, functionFolder)); + + const result = await nodeFileTrace([entryPath], { + base: fileURLToPath(root), + }); + + for (const file of result.fileList) { + if (file.startsWith('.vercel/')) continue; + const origin = new URL(file, root); + const dest = new URL(file, functionFolder); + + const meta = await fs.stat(origin); + const isSymlink = (await fs.lstat(origin)).isSymbolicLink(); + + // Create directories recursively + if (meta.isDirectory() && !isSymlink) { + await fs.mkdir(new URL('..', dest), { recursive: true }); + } else { + await fs.mkdir(new URL('.', dest), { recursive: true }); + } + + if (isSymlink) { + const link = await fs.readlink(origin); + await fs.symlink(link, dest, meta.isDirectory() ? 'dir' : 'file'); + } else { + await fs.copyFile(origin, dest); + } + } +} diff --git a/packages/integrations/vercel/src/lib/redirects.ts b/packages/integrations/vercel/src/lib/redirects.ts new file mode 100644 index 000000000..b52ce8725 --- /dev/null +++ b/packages/integrations/vercel/src/lib/redirects.ts @@ -0,0 +1,83 @@ +import type { AstroConfig, RoutePart, RouteData } from 'astro'; + +// https://vercel.com/docs/project-configuration#legacy/routes +interface VercelRoute { + src: string; + methods?: string[]; + dest?: string; + headers?: Record; + status?: number; + continue?: boolean; +} + +// Copied from /home/juanm04/dev/misc/astro/packages/astro/src/core/routing/manifest/create.ts +// 2022-04-26 +function getMatchPattern(segments: RoutePart[][]) { + return segments + .map((segment) => { + return segment[0].spread + ? '(?:\\/(.*?))?' + : '\\/' + + segment + .map((part) => { + if (part) + return part.dynamic + ? '([^/]+?)' + : part.content + .normalize() + .replace(/\?/g, '%3F') + .replace(/#/g, '%23') + .replace(/%5B/g, '[') + .replace(/%5D/g, ']') + .replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + }) + .join(''); + }) + .join(''); +} + +function getReplacePattern(segments: RoutePart[][]) { + let n = 0; + let result = ''; + + for (const segment of segments) { + for (const part of segment) { + if (part.dynamic) result += '$' + ++n; + else result += part.content; + } + result += '/'; + } + + // Remove trailing slash + result = result.slice(0, -1); + + return result; +} + +export function getRedirects(routes: RouteData[], config: AstroConfig): VercelRoute[] { + let redirects: VercelRoute[] = []; + + if (config.trailingSlash === 'always') { + for (const route of routes) { + if (route.type !== 'page' || route.segments.length === 0) continue; + + redirects.push({ + src: config.base + getMatchPattern(route.segments), + headers: { Location: config.base + getReplacePattern(route.segments) + '/' }, + status: 308, + }); + } + } else if (config.trailingSlash === 'never') { + for (const route of routes) { + if (route.type !== 'page' || route.segments.length === 0) continue; + + redirects.push({ + src: config.base + getMatchPattern(route.segments) + '/', + headers: { Location: config.base + getReplacePattern(route.segments) }, + status: 308, + }); + } + } + + return redirects; +} diff --git a/packages/integrations/vercel/src/serverless/adapter.ts b/packages/integrations/vercel/src/serverless/adapter.ts new file mode 100644 index 000000000..babda1f84 --- /dev/null +++ b/packages/integrations/vercel/src/serverless/adapter.ts @@ -0,0 +1,78 @@ +import type { AstroAdapter, AstroConfig, AstroIntegration } from 'astro'; + +import { writeJson, getVercelOutput } from '../lib/fs.js'; +import { copyDependenciesToFunction } from '../lib/nft.js'; +import { getRedirects } from '../lib/redirects.js'; + +const PACKAGE_NAME = '@astrojs/vercel/serverless'; + +function getAdapter(): AstroAdapter { + return { + name: PACKAGE_NAME, + serverEntrypoint: `${PACKAGE_NAME}/entrypoint`, + exports: ['default'], + }; +} + +export interface Options { + nodeVersion?: '12.x' | '14.x' | '16.x'; +} + +export default function vercelEdge({ nodeVersion = '16.x' }: Options = {}): AstroIntegration { + let _config: AstroConfig; + let functionFolder: URL; + let serverEntry: string; + + return { + name: PACKAGE_NAME, + hooks: { + 'astro:config:setup': ({ config }) => { + config.outDir = getVercelOutput(config.root); + }, + 'astro:config:done': ({ setAdapter, config }) => { + setAdapter(getAdapter()); + _config = config; + }, + 'astro:build:start': async ({ buildConfig }) => { + if (String(process.env.ENABLE_VC_BUILD) !== '1') { + throw new Error( + `The enviroment variable "ENABLE_VC_BUILD" was not found. Make sure you have it set to "1" in your Vercel project.\nLearn how to set enviroment variables here: https://vercel.com/docs/concepts/projects/environment-variables` + ); + } + + buildConfig.serverEntry = serverEntry = 'entry.js'; + buildConfig.client = new URL('./static/', _config.outDir); + buildConfig.server = functionFolder = new URL('./functions/render.func/', _config.outDir); + }, + 'astro:build:done': async ({ routes }) => { + // Copy necessary files (e.g. node_modules/) + await copyDependenciesToFunction(_config.root, functionFolder, serverEntry); + + // Enable ESM + // https://aws.amazon.com/blogs/compute/using-node-js-es-modules-and-top-level-await-in-aws-lambda/ + await writeJson(new URL(`./package.json`, functionFolder), { + type: 'module', + }); + + // Serverless function config + // https://vercel.com/docs/build-output-api/v3#vercel-primitives/serverless-functions/configuration + await writeJson(new URL(`./.vc-config.json`, functionFolder), { + runtime: `nodejs${nodeVersion}`, + handler: serverEntry, + launcherType: 'Nodejs', + }); + + // Output configuration + // https://vercel.com/docs/build-output-api/v3#build-output-configuration + await writeJson(new URL(`./config.json`, _config.outDir), { + version: 3, + routes: [ + ...getRedirects(routes, _config), + { handle: 'filesystem' }, + { src: '/.*', dest: 'render' }, + ], + }); + }, + }, + }; +} diff --git a/packages/integrations/vercel/src/server-entrypoint.ts b/packages/integrations/vercel/src/serverless/entrypoint.ts similarity index 92% rename from packages/integrations/vercel/src/server-entrypoint.ts rename to packages/integrations/vercel/src/serverless/entrypoint.ts index e32dbdd86..6ef7ccef9 100644 --- a/packages/integrations/vercel/src/server-entrypoint.ts +++ b/packages/integrations/vercel/src/serverless/entrypoint.ts @@ -1,7 +1,7 @@ import type { SSRManifest } from 'astro'; import { App } from 'astro/app'; import { polyfill } from '@astrojs/webapi'; -import type { IncomingMessage, ServerResponse } from 'http'; +import type { IncomingMessage, ServerResponse } from 'node:http'; import { getRequest, setResponse } from './request-transform.js'; diff --git a/packages/integrations/vercel/src/request-transform.ts b/packages/integrations/vercel/src/serverless/request-transform.ts similarity index 95% rename from packages/integrations/vercel/src/request-transform.ts rename to packages/integrations/vercel/src/serverless/request-transform.ts index 0a87ca642..7cdb2550a 100644 --- a/packages/integrations/vercel/src/request-transform.ts +++ b/packages/integrations/vercel/src/serverless/request-transform.ts @@ -1,5 +1,5 @@ -import { Readable } from 'stream'; -import type { IncomingMessage, ServerResponse } from 'http'; +import { Readable } from 'node:stream'; +import type { IncomingMessage, ServerResponse } from 'node:http'; /* Credits to the SvelteKit team diff --git a/packages/integrations/vercel/src/static/adapter.ts b/packages/integrations/vercel/src/static/adapter.ts new file mode 100644 index 000000000..489ab356b --- /dev/null +++ b/packages/integrations/vercel/src/static/adapter.ts @@ -0,0 +1,50 @@ +import type { AstroAdapter, AstroConfig, AstroIntegration } from 'astro'; + +import { getVercelOutput, writeJson, emptyDir } from '../lib/fs.js'; +import { getRedirects } from '../lib/redirects.js'; + +const PACKAGE_NAME = '@astrojs/vercel/static'; + +function getAdapter(): AstroAdapter { + return { name: PACKAGE_NAME }; +} + +export default function vercelStatic(): AstroIntegration { + let _config: AstroConfig; + + return { + name: '@astrojs/vercel', + hooks: { + 'astro:config:setup': ({ config }) => { + config.outDir = new URL('./static/', getVercelOutput(config.root)); + config.build.format = 'directory'; + }, + 'astro:config:done': ({ setAdapter, config }) => { + setAdapter(getAdapter()); + _config = config; + }, + 'astro:build:start': async ({ buildConfig }) => { + if (String(process.env.ENABLE_VC_BUILD) !== '1') { + throw new Error( + `The enviroment variable "ENABLE_VC_BUILD" was not found. Make sure you have it set to "1" in your Vercel project.\nLearn how to set enviroment variables here: https://vercel.com/docs/concepts/projects/environment-variables` + ); + } + + buildConfig.staticMode = true; + + // Ensure to have `.vercel/output` empty. + // This is because, when building to static, outDir = .vercel/output/static/, + // so .vercel/output itself won't get cleaned. + await emptyDir(getVercelOutput(_config.root)); + }, + 'astro:build:done': async ({ routes }) => { + // Output configuration + // https://vercel.com/docs/build-output-api/v3#build-output-configuration + await writeJson(new URL(`./config.json`, getVercelOutput(_config.root)), { + version: 3, + routes: [...getRedirects(routes, _config), { handle: 'filesystem' }], + }); + }, + }, + }; +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index be8f0175e..ae04af1c5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1480,12 +1480,12 @@ importers: packages/integrations/vercel: specifiers: '@astrojs/webapi': ^0.11.1 + '@vercel/nft': ^0.18.2 astro: workspace:* astro-scripts: workspace:* - esbuild: ^0.14.38 dependencies: '@astrojs/webapi': link:../../webapi - esbuild: 0.14.38 + '@vercel/nft': 0.18.2 devDependencies: astro: link:../../astro astro-scripts: link:../../../scripts @@ -3538,6 +3538,24 @@ packages: read-yaml-file: 1.1.0 dev: true + /@mapbox/node-pre-gyp/1.0.9: + resolution: {integrity: sha512-aDF3S3rK9Q2gey/WAttUlISduDItz5BU3306M9Eyv6/oS40aMprnopshtlKTykxRNIBEZuRMaZAnbrQ4QtKGyw==} + hasBin: true + dependencies: + detect-libc: 2.0.1 + https-proxy-agent: 5.0.1 + make-dir: 3.1.0 + node-fetch: 2.6.7 + nopt: 5.0.0 + npmlog: 5.0.1 + rimraf: 3.0.2 + semver: 7.3.7 + tar: 6.1.11 + transitivePeerDependencies: + - encoding + - supports-color + dev: false + /@nanostores/preact/0.1.3_szcmxo7i5hx4oviopihqnbgbg4: resolution: {integrity: sha512-uiX1ned0LrzASot+sPUjyJzr8Js3pX075omazgsSdLf0zPp4ss8xwTiuNh5FSKigTSQEVqZFiS+W8CnHIrX62A==} engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} @@ -4403,6 +4421,26 @@ packages: '@unocss/scope': 0.15.6 dev: true + /@vercel/nft/0.18.2: + resolution: {integrity: sha512-Oxy4y5JDh7CMbaxEGjKKzHcnQ1gRQqtfp+x3xvOmZYixXHwaD2RMJDTzaPz0b2B3pgVbbPOHY87wffJPFDaoFg==} + hasBin: true + dependencies: + '@mapbox/node-pre-gyp': 1.0.9 + acorn: 8.7.0 + bindings: 1.5.0 + estree-walker: 2.0.2 + glob: 7.2.0 + graceful-fs: 4.2.10 + micromatch: 4.0.5 + node-gyp-build: 4.4.0 + node-pre-gyp: 0.13.0 + resolve-from: 5.0.0 + rollup-pluginutils: 2.8.2 + transitivePeerDependencies: + - encoding + - supports-color + dev: false + /@vitejs/plugin-vue/2.3.1_vite@2.9.5+vue@3.2.33: resolution: {integrity: sha512-YNzBt8+jt6bSwpt7LP890U1UcTOIZZxfpE5WOJ638PNxSEKOqAi0+FSKS0nVeukfdZ0Ai/H7AFd6k3hayfGZqQ==} engines: {node: '>=12.0.0'} @@ -4519,6 +4557,10 @@ packages: resolution: {integrity: sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ==} dev: true + /abbrev/1.1.1: + resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==} + dev: false + /abort-controller/3.0.0: resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==} engines: {node: '>=6.5'} @@ -4559,7 +4601,6 @@ packages: resolution: {integrity: sha512-V/LGr1APy+PXIwKebEWrkZPwoeoF+w1jiOBUmuxuiUIaOHtob8Qc9BTrYo7VuI5fR8tqsy+buA2WFooR5olqvQ==} engines: {node: '>=0.4.0'} hasBin: true - dev: true /adm-zip/0.5.9: resolution: {integrity: sha512-s+3fXLkeeLjZ2kLjCBwQufpI5fuN+kIGBxu6530nVQZGVol0d7Y/M88/xw9HGGUcJjKf8LutN3VPRUBq6N7Ajg==} @@ -4573,7 +4614,6 @@ packages: debug: 4.3.4 transitivePeerDependencies: - supports-color - dev: true /aggregate-error/3.1.0: resolution: {integrity: sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==} @@ -4640,7 +4680,6 @@ packages: /ansi-regex/2.1.1: resolution: {integrity: sha1-w7M6te42DYbg5ijwRorn7yfWVN8=} engines: {node: '>=0.10.0'} - dev: true /ansi-regex/5.0.1: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} @@ -4677,14 +4716,20 @@ packages: /aproba/1.2.0: resolution: {integrity: sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==} - dev: true /are-we-there-yet/1.1.7: resolution: {integrity: sha512-nxwy40TuMiUGqMyRHgCSWZ9FM4VAoRP4xUYSTv5ImRog+h9yISPbVH7H8fASCIzYn9wlEv4zvFL7uKDMCFQm3g==} dependencies: delegates: 1.0.0 readable-stream: 2.3.7 - dev: true + + /are-we-there-yet/2.0.0: + resolution: {integrity: sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw==} + engines: {node: '>=10'} + dependencies: + delegates: 1.0.0 + readable-stream: 3.6.0 + dev: false /arg/5.0.1: resolution: {integrity: sha512-e0hDa9H2Z9AwFkk2qDlwhoMYE4eToKarchkQHovNdLTCYMHZHeRjI71crOh+dio4K6u1IcwubQqo79Ga4CyAQA==} @@ -4870,6 +4915,12 @@ packages: resolution: {integrity: sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==} engines: {node: '>=8'} + /bindings/1.5.0: + resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==} + dependencies: + file-uri-to-path: 1.0.0 + dev: false + /bl/4.1.0: resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==} dependencies: @@ -5136,7 +5187,6 @@ packages: /chownr/1.1.4: resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==} - dev: true /chownr/2.0.0: resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==} @@ -5195,7 +5245,6 @@ packages: /code-point-at/1.1.0: resolution: {integrity: sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=} engines: {node: '>=0.10.0'} - dev: true /color-convert/1.9.3: resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==} @@ -5221,6 +5270,11 @@ packages: simple-swizzle: 0.2.2 dev: true + /color-support/1.1.3: + resolution: {integrity: sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==} + hasBin: true + dev: false + /color/4.2.3: resolution: {integrity: sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==} engines: {node: '>=12.5.0'} @@ -5273,7 +5327,6 @@ packages: /console-control-strings/1.1.0: resolution: {integrity: sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=} - dev: true /convert-source-map/1.8.0: resolution: {integrity: sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA==} @@ -5289,7 +5342,6 @@ packages: /core-util-is/1.0.3: resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} - dev: true /cross-spawn/5.1.0: resolution: {integrity: sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=} @@ -5392,6 +5444,12 @@ packages: engines: {node: '>=0.11'} dev: true + /debug/3.2.7: + resolution: {integrity: sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==} + dependencies: + ms: 2.1.3 + dev: false + /debug/4.3.3_supports-color@8.1.1: resolution: {integrity: sha512-/zxw5+vh1Tfv+4Qn7a5nsbcJKPaSvCDhojn6FEl9vupwK2VCSDtEiEtqr8DFtzYFOdz63LBkxec7DYuc2jon6Q==} engines: {node: '>=6.0'} @@ -5461,7 +5519,6 @@ packages: /deep-extend/0.6.0: resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==} engines: {node: '>=4.0.0'} - dev: true /deep-is/0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} @@ -5522,7 +5579,6 @@ packages: /delegates/1.0.0: resolution: {integrity: sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=} - dev: true /depd/2.0.0: resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==} @@ -5545,12 +5601,10 @@ packages: resolution: {integrity: sha1-+hN8S9aY7fVc1c0CrFWfkaTEups=} engines: {node: '>=0.10'} hasBin: true - dev: true /detect-libc/2.0.1: resolution: {integrity: sha512-463v3ZeIrcWtdgIg6vI6XUncguvr2TnGl4SzDXinkt9mSLpBJKXT3mW6xT3VQdDN11+WVs29pgvivTc4Lp8v+w==} engines: {node: '>=8'} - dev: true /detective/5.2.0: resolution: {integrity: sha512-6SsIx+nUUbuK0EthKjv0zrdnajCCXVYGmbYYiYjFVpzcjwEs/JMDZ8tPRG29J/HhN56t3GJp2cGSWDRjjot8Pg==} @@ -6103,6 +6157,10 @@ packages: '@types/unist': 2.0.6 dev: false + /estree-walker/0.6.1: + resolution: {integrity: sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==} + dev: false + /estree-walker/1.0.1: resolution: {integrity: sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==} dev: true @@ -6238,6 +6296,10 @@ packages: flat-cache: 3.0.4 dev: true + /file-uri-to-path/1.0.0: + resolution: {integrity: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==} + dev: false + /file-uri-to-path/2.0.0: resolution: {integrity: sha512-hjPFI8oE/2iQPVe4gbrJ73Pp+Xfub2+WI2LlXDbsaJBwT5wuMh35WNWVYYTpnz895shtwfyutMFLFywpQAFdLg==} engines: {node: '>= 6'} @@ -6343,6 +6405,12 @@ packages: universalify: 2.0.0 dev: true + /fs-minipass/1.2.7: + resolution: {integrity: sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA==} + dependencies: + minipass: 2.9.0 + dev: false + /fs-minipass/2.1.0: resolution: {integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==} engines: {node: '>= 8'} @@ -6390,7 +6458,21 @@ packages: string-width: 1.0.2 strip-ansi: 3.0.1 wide-align: 1.1.5 - dev: true + + /gauge/3.0.2: + resolution: {integrity: sha512-+5J6MS/5XksCuXq++uFRsnUd7Ovu1XenbeuIuNRJxYWjgQbPuFhT14lAvsWfqfAmnwluf1OwMjz39HjfLPci0Q==} + engines: {node: '>=10'} + dependencies: + aproba: 1.2.0 + color-support: 1.1.3 + console-control-strings: 1.1.0 + has-unicode: 2.0.1 + object-assign: 4.1.1 + signal-exit: 3.0.7 + string-width: 4.2.3 + strip-ansi: 6.0.1 + wide-align: 1.1.5 + dev: false /gensync/1.0.0-beta.2: resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} @@ -6581,7 +6663,6 @@ packages: /has-unicode/2.0.1: resolution: {integrity: sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk=} - dev: true /has/1.0.3: resolution: {integrity: sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==} @@ -6787,7 +6868,6 @@ packages: debug: 4.3.4 transitivePeerDependencies: - supports-color - dev: true /human-id/1.0.2: resolution: {integrity: sha512-UNopramDEhHJD+VR+ehk8rOslwSfByxPIZyJRfV739NDhN5LF1fa1MqnzKm2lGTQRjNrjK19Q5fhkgIfjlVUKw==} @@ -6807,7 +6887,6 @@ packages: engines: {node: '>=0.10.0'} dependencies: safer-buffer: 2.1.2 - dev: true /idb/6.1.5: resolution: {integrity: sha512-IJtugpKkiVXQn5Y+LteyBCNk1N8xpGV3wWZk9EVtZWH8DYkjBn0bX1XnGP9RkyZF0sAcywa6unHqSWKe7q4LGw==} @@ -6816,6 +6895,12 @@ packages: /ieee754/1.2.1: resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} + /ignore-walk/3.0.4: + resolution: {integrity: sha512-PY6Ii8o1jMRA1z4F2hRkH/xN59ox43DavKvD3oDpfurRlOJyAHpifIwpbdv1n4jt4ov0jSpw3kQ4GhJnpBL6WQ==} + dependencies: + minimatch: 3.1.2 + dev: false + /ignore/5.2.0: resolution: {integrity: sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ==} engines: {node: '>= 4'} @@ -6859,7 +6944,6 @@ packages: /ini/1.3.8: resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==} - dev: true /inline-style-parser/0.1.1: resolution: {integrity: sha512-7NXolsK4CAS5+xvdj5OMMbI962hU/wvwoxk+LWR9Ek9bVtyuuYScDN6eS0rUm6TxApFpw7CX1o4uJzcd4AyD3Q==} @@ -6984,7 +7068,6 @@ packages: engines: {node: '>=0.10.0'} dependencies: number-is-nan: 1.0.1 - dev: true /is-fullwidth-code-point/3.0.0: resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} @@ -7164,7 +7247,6 @@ packages: /isarray/1.0.0: resolution: {integrity: sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=} - dev: true /isexe/2.0.0: resolution: {integrity: sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=} @@ -7464,6 +7546,13 @@ packages: sourcemap-codec: 1.4.8 dev: false + /make-dir/3.1.0: + resolution: {integrity: sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==} + engines: {node: '>=8'} + dependencies: + semver: 6.3.0 + dev: false + /map-obj/1.0.1: resolution: {integrity: sha1-2TPOuSBdgr3PSIb2dCvcK03qFG0=} engines: {node: '>=0.10.0'} @@ -8005,6 +8094,13 @@ packages: /minimist/1.2.6: resolution: {integrity: sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==} + /minipass/2.9.0: + resolution: {integrity: sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg==} + dependencies: + safe-buffer: 5.2.1 + yallist: 3.1.1 + dev: false + /minipass/3.1.6: resolution: {integrity: sha512-rty5kpw9/z8SX9dmxblFA6edItUmwJgMeYDZRrwlIVN27i8gysGbznJwUggw2V/FVqFSDdWy040ZPS811DYAqQ==} engines: {node: '>=8'} @@ -8012,6 +8108,12 @@ packages: yallist: 4.0.0 dev: false + /minizlib/1.3.3: + resolution: {integrity: sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q==} + dependencies: + minipass: 2.9.0 + dev: false + /minizlib/2.1.2: resolution: {integrity: sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==} engines: {node: '>= 8'} @@ -8086,7 +8188,6 @@ packages: /ms/2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} - dev: true /nanoid/3.3.1: resolution: {integrity: sha512-n6Vs/3KGyxPQd6uO0eH4Bv0ojGSUvuLlIHtC3Y0kEO23YRge8H9x1GCzLn28YX0H66pMkxuaeESFq4tKISKwdw==} @@ -8112,6 +8213,16 @@ packages: resolution: {integrity: sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=} dev: true + /needle/2.9.1: + resolution: {integrity: sha512-6R9fqJ5Zcmf+uYaFgdIHmLwNldn5HbK8L5ybn7Uz+ylX/rnOsSp1AHcvQSrCaFN+qNM1wpymHqD7mVasEOlHGQ==} + engines: {node: '>= 4.4.x'} + hasBin: true + dependencies: + debug: 3.2.7 + iconv-lite: 0.4.24 + sax: 1.2.4 + dev: false + /netmask/2.0.2: resolution: {integrity: sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg==} engines: {node: '>= 0.4.0'} @@ -8172,9 +8283,47 @@ packages: fetch-blob: 3.1.5 formdata-polyfill: 4.0.10 + /node-gyp-build/4.4.0: + resolution: {integrity: sha512-amJnQCcgtRVw9SvoebO3BKGESClrfXGCUTX9hSn1OuGQTQBOZmVd0Z0OlecpuRksKvbsUqALE8jls/ErClAPuQ==} + hasBin: true + dev: false + + /node-pre-gyp/0.13.0: + resolution: {integrity: sha512-Md1D3xnEne8b/HGVQkZZwV27WUi1ZRuZBij24TNaZwUPU3ZAFtvT6xxJGaUVillfmMKnn5oD1HoGsp2Ftik7SQ==} + deprecated: 'Please upgrade to @mapbox/node-pre-gyp: the non-scoped node-pre-gyp package is deprecated and only the @mapbox scoped package will recieve updates in the future' + hasBin: true + dependencies: + detect-libc: 1.0.3 + mkdirp: 0.5.6 + needle: 2.9.1 + nopt: 4.0.3 + npm-packlist: 1.4.8 + npmlog: 4.1.2 + rc: 1.2.8 + rimraf: 2.7.1 + semver: 5.7.1 + tar: 4.4.19 + dev: false + /node-releases/2.0.3: resolution: {integrity: sha512-maHFz6OLqYxz+VQyCAtA3PTX4UP/53pa05fyDNc9CwjvJ0yEh6+xBwKsgCxMNhS8taUKBFYxfuiaD9U/55iFaw==} + /nopt/4.0.3: + resolution: {integrity: sha512-CvaGwVMztSMJLOeXPrez7fyfObdZqNUK1cPAEzLHrTybIua9pMdmmPR5YwtfNftIOMv3DPUhFaxsZMNTQO20Kg==} + hasBin: true + dependencies: + abbrev: 1.1.1 + osenv: 0.1.5 + dev: false + + /nopt/5.0.0: + resolution: {integrity: sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==} + engines: {node: '>=6'} + hasBin: true + dependencies: + abbrev: 1.1.1 + dev: false + /normalize-package-data/2.5.0: resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==} dependencies: @@ -8195,6 +8344,24 @@ packages: /not/0.1.0: resolution: {integrity: sha1-yWkcF0bFXc++VMvYvU/wQbwrUZ0=} + /npm-bundled/1.1.2: + resolution: {integrity: sha512-x5DHup0SuyQcmL3s7Rx/YQ8sbw/Hzg0rj48eN0dV7hf5cmQq5PXIeioroH3raV1QC1yh3uTYuMThvEQF3iKgGQ==} + dependencies: + npm-normalize-package-bin: 1.0.1 + dev: false + + /npm-normalize-package-bin/1.0.1: + resolution: {integrity: sha512-EPfafl6JL5/rU+ot6P3gRSCpPDW5VmIzX959Ob1+ySFUuuYHWHekXpwdUZcKP5C+DS4GEtdJluwBjnsNDl+fSA==} + dev: false + + /npm-packlist/1.4.8: + resolution: {integrity: sha512-5+AZgwru5IevF5ZdnFglB5wNlHG1AOOuw28WhUq8/8emhBmLv6jX5by4WJCh7lW0uSYZYS6DXqIsyZVIXRZU9A==} + dependencies: + ignore-walk: 3.0.4 + npm-bundled: 1.1.2 + npm-normalize-package-bin: 1.0.1 + dev: false + /npm-run-path/4.0.1: resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==} engines: {node: '>=8'} @@ -8215,7 +8382,15 @@ packages: console-control-strings: 1.1.0 gauge: 2.7.4 set-blocking: 2.0.0 - dev: true + + /npmlog/5.0.1: + resolution: {integrity: sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw==} + dependencies: + are-we-there-yet: 2.0.0 + console-control-strings: 1.1.0 + gauge: 3.0.2 + set-blocking: 2.0.0 + dev: false /nth-check/2.0.1: resolution: {integrity: sha512-it1vE95zF6dTT9lBsYbxvqh0Soy4SPowchj0UBGj/V6cTPnXXtQOPUbhZ6CmGzAD/rW22LQK6E96pcdJXk4A4w==} @@ -8225,7 +8400,6 @@ packages: /number-is-nan/1.0.1: resolution: {integrity: sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=} engines: {node: '>=0.10.0'} - dev: true /object-assign/4.1.1: resolution: {integrity: sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=} @@ -8323,10 +8497,21 @@ packages: wcwidth: 1.0.1 dev: false + /os-homedir/1.0.2: + resolution: {integrity: sha1-/7xJiDNuDoM94MFox+8VISGqf7M=} + engines: {node: '>=0.10.0'} + dev: false + /os-tmpdir/1.0.2: resolution: {integrity: sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=} engines: {node: '>=0.10.0'} - dev: true + + /osenv/0.1.5: + resolution: {integrity: sha512-0CWcCECdMVc2Rw3U5w9ZjqX6ga6ubk1xDVKxtBQPK7wis/0F2r9T6k4ydGYhecl7YUBxBVxhL5oisPsNxAPe2g==} + dependencies: + os-homedir: 1.0.2 + os-tmpdir: 1.0.2 + dev: false /outdent/0.5.0: resolution: {integrity: sha512-/jHxFIzoMXdqPzTaCpFzAAWhpkSjZPF4Vsn6jAfNpmbH/ymsmd7Qc6VE9BGn0L6YMj6uwpQLxCECpus4ukKS9Q==} @@ -8702,7 +8887,6 @@ packages: /process-nextick-args/2.0.1: resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} - dev: true /prompts/2.4.2: resolution: {integrity: sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==} @@ -8786,7 +8970,6 @@ packages: ini: 1.3.8 minimist: 1.2.6 strip-json-comments: 2.0.1 - dev: true /react-dom/17.0.2_react@17.0.2: resolution: {integrity: sha512-s4h96KtLDUQlsENhMn1ar8t2bEa+q/YAtj8pPPdIjPDGBDIVNsrD9aXNWqspUe6AzKCIG0C1HZZLqLV7qpOBGA==} @@ -8870,7 +9053,6 @@ packages: safe-buffer: 5.1.2 string_decoder: 1.1.1 util-deprecate: 1.0.2 - dev: true /readable-stream/3.6.0: resolution: {integrity: sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==} @@ -9075,7 +9257,6 @@ packages: /resolve-from/5.0.0: resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==} engines: {node: '>=8'} - dev: true /resolve/1.22.0: resolution: {integrity: sha512-Hhtrw0nLeSrFQ7phPp4OOcVjLPIeMnRlr5mcnVuMe7M/7eBn98A3hmFRLoFo3DLZkivSYwhRUJTyPyWAk56WLw==} @@ -9143,7 +9324,6 @@ packages: hasBin: true dependencies: glob: 7.2.0 - dev: true /rollup-plugin-terser/7.0.2_rollup@2.70.2: resolution: {integrity: sha512-w3iIaU4OxcF52UUXiZNsNeuXIMDvFrr+ZXK6bFZ0Q60qyVfq4uLptoS4bbq3paG3x216eQllFZX7zt6TIImguQ==} @@ -9157,6 +9337,12 @@ packages: terser: 5.12.1 dev: true + /rollup-pluginutils/2.8.2: + resolution: {integrity: sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==} + dependencies: + estree-walker: 0.6.1 + dev: false + /rollup/2.70.2: resolution: {integrity: sha512-EitogNZnfku65I1DD5Mxe8JYRUCy0hkK5X84IlDtUs+O6JRMpRciXTzyCUuX11b5L5pvjH+OmFXiQ3XjabcXgg==} engines: {node: '>=10.0.0'} @@ -9190,7 +9376,6 @@ packages: /safer-buffer/2.1.2: resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} - dev: true /sander/0.5.1: resolution: {integrity: sha1-dB4kXiMfB8r7b98PEzrfohalAq0=} @@ -9237,7 +9422,6 @@ packages: /semver/5.7.1: resolution: {integrity: sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==} hasBin: true - dev: true /semver/6.3.0: resolution: {integrity: sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==} @@ -9268,7 +9452,6 @@ packages: /set-blocking/2.0.0: resolution: {integrity: sha1-BF+XgtARrppoA93TgrJDkrPYkPc=} - dev: true /setprototypeof/1.2.0: resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==} @@ -9546,7 +9729,6 @@ packages: code-point-at: 1.1.0 is-fullwidth-code-point: 1.0.0 strip-ansi: 3.0.1 - dev: true /string-width/4.2.3: resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==} @@ -9598,7 +9780,6 @@ packages: resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==} dependencies: safe-buffer: 5.1.2 - dev: true /string_decoder/1.3.0: resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} @@ -9626,7 +9807,6 @@ packages: engines: {node: '>=0.10.0'} dependencies: ansi-regex: 2.1.1 - dev: true /strip-ansi/6.0.1: resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==} @@ -9678,7 +9858,6 @@ packages: /strip-json-comments/2.0.1: resolution: {integrity: sha1-PFMZQukIwml8DsNEhYwobHygpgo=} engines: {node: '>=0.10.0'} - dev: true /strip-json-comments/3.1.1: resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} @@ -9849,6 +10028,19 @@ packages: readable-stream: 3.6.0 dev: true + /tar/4.4.19: + resolution: {integrity: sha512-a20gEsvHnWe0ygBY8JbxoM4w3SJdhc7ZAuxkLqh+nvNQN2IOt0B5lLgM490X5Hl8FF0dl0tOf2ewFYAlIFgzVA==} + engines: {node: '>=4.5'} + dependencies: + chownr: 1.1.4 + fs-minipass: 1.2.7 + minipass: 2.9.0 + minizlib: 1.3.3 + mkdirp: 0.5.6 + safe-buffer: 5.2.1 + yallist: 3.1.1 + dev: false + /tar/6.1.11: resolution: {integrity: sha512-an/KZQzQUkZCkuoAA64hM92X0Urb6VpRhAFllDzz44U2mcD5scmT3zBc4VgVpkugF580+DQn8eAFSyoQt0tznA==} engines: {node: '>= 10'} @@ -10690,8 +10882,7 @@ packages: /wide-align/1.1.5: resolution: {integrity: sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==} dependencies: - string-width: 1.0.2 - dev: true + string-width: 4.2.3 /widest-line/4.0.1: resolution: {integrity: sha512-o0cyEG0e8GPzT4iGHphIOh0cJOV8fivsXxddQasHPHfoZf1ZexrfeA21w2NaEN1RHE+fXlfISmOE8R9N3u3Qig==} @@ -10908,7 +11099,6 @@ packages: /yallist/3.1.1: resolution: {integrity: sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==} - dev: true /yallist/4.0.0: resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==}