mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-11 12:57:46 +00:00
Compare commits
9 Commits
@vercel/py
...
@vercel/py
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d5537500d8 | ||
|
|
4b1736b2f2 | ||
|
|
9da1c6fa66 | ||
|
|
a6c320846e | ||
|
|
4973814978 | ||
|
|
f1289ff263 | ||
|
|
3ff93279cd | ||
|
|
58f9d649a8 | ||
|
|
cadc082ad1 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/build-utils",
|
||||
"version": "5.4.1",
|
||||
"version": "5.4.2",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.js",
|
||||
|
||||
@@ -41,6 +41,7 @@ export interface Config {
|
||||
devCommand?: string;
|
||||
framework?: string | null;
|
||||
nodeVersion?: string;
|
||||
middleware?: boolean;
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vercel",
|
||||
"version": "28.2.1",
|
||||
"version": "28.2.3",
|
||||
"preferGlobal": true,
|
||||
"license": "Apache-2.0",
|
||||
"description": "The command-line interface for Vercel",
|
||||
@@ -41,16 +41,16 @@
|
||||
"node": ">= 14"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vercel/build-utils": "5.4.1",
|
||||
"@vercel/go": "2.2.4",
|
||||
"@vercel/hydrogen": "0.0.17",
|
||||
"@vercel/next": "3.1.23",
|
||||
"@vercel/node": "2.5.12",
|
||||
"@vercel/python": "3.1.13",
|
||||
"@vercel/redwood": "1.0.21",
|
||||
"@vercel/remix": "1.0.22",
|
||||
"@vercel/ruby": "1.3.30",
|
||||
"@vercel/static-build": "1.0.21",
|
||||
"@vercel/build-utils": "5.4.2",
|
||||
"@vercel/go": "2.2.5",
|
||||
"@vercel/hydrogen": "0.0.18",
|
||||
"@vercel/next": "3.1.25",
|
||||
"@vercel/node": "2.5.14",
|
||||
"@vercel/python": "3.1.14",
|
||||
"@vercel/redwood": "1.0.23",
|
||||
"@vercel/remix": "1.0.24",
|
||||
"@vercel/ruby": "1.3.31",
|
||||
"@vercel/static-build": "1.0.22",
|
||||
"update-notifier": "5.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -95,9 +95,9 @@
|
||||
"@types/which": "1.3.2",
|
||||
"@types/write-json-file": "2.2.1",
|
||||
"@types/yauzl-promise": "2.1.0",
|
||||
"@vercel/client": "12.2.3",
|
||||
"@vercel/frameworks": "1.1.3",
|
||||
"@vercel/fs-detectors": "2.1.0",
|
||||
"@vercel/client": "12.2.4",
|
||||
"@vercel/frameworks": "1.1.4",
|
||||
"@vercel/fs-detectors": "3.0.0",
|
||||
"@vercel/fun": "1.0.4",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"@zeit/source-map-support": "0.6.2",
|
||||
|
||||
@@ -445,11 +445,7 @@ test(
|
||||
test(
|
||||
'[vercel dev] Middleware that has no response',
|
||||
testFixtureStdio('middleware-no-response', async (testPath: any) => {
|
||||
await testPath(
|
||||
500,
|
||||
'/api/hello',
|
||||
'A server error has occurred\n\nEDGE_FUNCTION_INVOCATION_FAILED'
|
||||
);
|
||||
await testPath(200, '/api/hello', 'hello from a serverless function');
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ const {
|
||||
|
||||
jest.setTimeout(6 * 60 * 1000);
|
||||
|
||||
const isCI = !!process.env.CI;
|
||||
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
|
||||
const isCanary = () => getDistTag(cliVersion) === 'canary';
|
||||
|
||||
@@ -52,7 +53,7 @@ function fetchWithRetry(url, opts = {}) {
|
||||
return res;
|
||||
},
|
||||
{
|
||||
retries: opts.retries || 3,
|
||||
retries: opts.retries ?? 3,
|
||||
factor: 1,
|
||||
}
|
||||
);
|
||||
@@ -150,9 +151,9 @@ async function testPath(
|
||||
fetchOpts = {}
|
||||
) {
|
||||
const opts = {
|
||||
retries: isCI ? 5 : 0,
|
||||
...fetchOpts,
|
||||
redirect: 'manual-dont-change',
|
||||
retries: 5,
|
||||
status,
|
||||
};
|
||||
const url = `${origin}${path}`;
|
||||
@@ -330,7 +331,7 @@ function testFixtureStdio(
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
body: JSON.stringify(projectSettings),
|
||||
retries: 3,
|
||||
retries: isCI ? 3 : 0,
|
||||
status: 200,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/client",
|
||||
"version": "12.2.3",
|
||||
"version": "12.2.4",
|
||||
"main": "dist/index.js",
|
||||
"typings": "dist/index.d.ts",
|
||||
"homepage": "https://vercel.com",
|
||||
@@ -43,7 +43,7 @@
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@vercel/build-utils": "5.4.1",
|
||||
"@vercel/build-utils": "5.4.2",
|
||||
"@vercel/routing-utils": "2.0.2",
|
||||
"@zeit/fetch": "5.2.0",
|
||||
"async-retry": "1.2.3",
|
||||
|
||||
@@ -1 +1 @@
|
||||
<svg width="48" height="48" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M22.428.013c-.103.01-.431.042-.727.066C14.883.693 8.497 4.37 4.453 10.024A23.754 23.754 0 0 0 .216 20.51C.023 21.828 0 22.217 0 24.005c0 1.787.023 2.177.216 3.495 1.304 9.012 7.718 16.584 16.417 19.39 1.558.501 3.2.844 5.068 1.05.727.08 3.87.08 4.598 0 3.224-.356 5.954-1.154 8.648-2.529.412-.21.492-.267.436-.314-.038-.028-1.797-2.388-3.909-5.24l-3.838-5.184-4.809-7.117c-2.646-3.913-4.824-7.112-4.842-7.112-.019-.005-.038 3.157-.047 7.018-.014 6.76-.019 7.033-.103 7.192-.122.23-.216.324-.413.427-.15.075-.282.09-.99.09h-.812l-.216-.137a.878.878 0 0 1-.314-.342l-.099-.211.01-9.407.014-9.41.145-.184c.075-.098.235-.225.347-.286.193-.094.268-.103 1.08-.103.957 0 1.116.038 1.365.31.07.075 2.674 3.997 5.79 8.721s7.376 11.175 9.469 14.342l3.8 5.756.192-.127c1.704-1.107 3.505-2.683 4.932-4.325a23.888 23.888 0 0 0 5.65-12.268c.192-1.319.215-1.708.215-3.495 0-1.788-.023-2.177-.216-3.495-1.304-9.013-7.718-16.584-16.417-19.39C29.832.623 28.199.28 26.369.074c-.45-.047-3.551-.099-3.94-.061zm9.825 14.515a.947.947 0 0 1 .474.554c.038.122.047 2.73.038 8.608l-.014 8.436-1.488-2.28-1.492-2.28v-6.132c0-3.964.019-6.193.047-6.3a.957.957 0 0 1 .465-.592c.192-.098.262-.108 1-.108.694 0 .816.01.97.094z" fill="#fff"/></svg>
|
||||
<svg width="48" height="48" fill="none" xmlns="http://www.w3.org/2000/svg"><mask id="mask" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="48" height="48"><circle cx="24" cy="24" r="24" fill="#000"/></mask><g mask="url(#mask)"><circle cx="24" cy="24" r="23.2" fill="#000" stroke="#fff" stroke-width="1.6"/><path d="M39.8687 42.0055L18.4378 14.4H14.3999V33.592H17.6302V18.5023L37.333 43.9587C38.222 43.3637 39.069 42.7108 39.8687 42.0055Z" fill="url(#gradient0)"/><rect x="30.6667" y="14.4" width="3.2" height="19.2" fill="url(#gradient1)"/></g><defs><linearGradient id="gradient0" x1="29.0666" y1="31.0667" x2="38.5332" y2="42.8" gradientUnits="userSpaceOnUse"><stop stop-color="#fff"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></linearGradient><linearGradient id="gradient1" x1="32.2667" y1="14.4" x2="32.2132" y2="28.5001" gradientUnits="userSpaceOnUse"><stop stop-color="#fff"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></linearGradient></defs></svg>
|
||||
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 997 B |
@@ -1 +1 @@
|
||||
<svg width="48" height="48" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M22.428.013c-.103.01-.431.042-.727.066C14.883.693 8.497 4.37 4.453 10.024A23.754 23.754 0 0 0 .216 20.51C.023 21.828 0 22.217 0 24.005c0 1.787.023 2.177.216 3.495 1.304 9.012 7.718 16.584 16.417 19.39 1.558.501 3.2.844 5.068 1.05.727.08 3.87.08 4.598 0 3.224-.356 5.954-1.154 8.648-2.529.412-.21.492-.267.436-.314-.038-.028-1.797-2.388-3.909-5.24l-3.838-5.184-4.809-7.117c-2.646-3.913-4.824-7.112-4.842-7.112-.019-.005-.038 3.157-.047 7.018-.014 6.76-.019 7.033-.103 7.192-.122.23-.216.324-.413.427-.15.075-.282.09-.99.09h-.812l-.216-.137a.878.878 0 0 1-.314-.342l-.099-.211.01-9.407.014-9.41.145-.184c.075-.098.235-.225.347-.286.193-.094.268-.103 1.08-.103.957 0 1.116.038 1.365.31.07.075 2.674 3.997 5.79 8.721s7.376 11.175 9.469 14.342l3.8 5.756.192-.127c1.704-1.107 3.505-2.683 4.932-4.325a23.888 23.888 0 0 0 5.65-12.268c.192-1.319.215-1.708.215-3.495 0-1.788-.023-2.177-.216-3.495-1.304-9.013-7.718-16.584-16.417-19.39C29.832.623 28.199.28 26.369.074c-.45-.047-3.551-.099-3.94-.061zm9.825 14.515a.947.947 0 0 1 .474.554c.038.122.047 2.73.038 8.608l-.014 8.436-1.488-2.28-1.492-2.28v-6.132c0-3.964.019-6.193.047-6.3a.957.957 0 0 1 .465-.592c.192-.098.262-.108 1-.108.694 0 .816.01.97.094z" fill="#000"/></svg>
|
||||
<svg width="48" height="48" fill="none" xmlns="http://www.w3.org/2000/svg"><mask id="mask" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="48" height="48"><circle cx="24" cy="24" r="24" fill="#000"/></mask><g mask="url(#mask)"><circle cx="24" cy="24" r="23.2" fill="#000" stroke="#000" stroke-width="1.6"/><path d="M39.8687 42.0055L18.4378 14.4H14.3999V33.592H17.6302V18.5023L37.333 43.9587C38.222 43.3637 39.069 42.7108 39.8687 42.0055Z" fill="url(#gradient0)"/><rect x="30.6667" y="14.4" width="3.2" height="19.2" fill="url(#gradient1)"/></g><defs><linearGradient id="gradient0" x1="29.0666" y1="31.0667" x2="38.5332" y2="42.8" gradientUnits="userSpaceOnUse"><stop stop-color="#fff"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></linearGradient><linearGradient id="gradient1" x1="32.2667" y1="14.4" x2="32.2132" y2="28.5001" gradientUnits="userSpaceOnUse"><stop stop-color="#fff"/><stop offset="1" stop-color="#fff" stop-opacity="0"/></linearGradient></defs></svg>
|
||||
|
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 997 B |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/frameworks",
|
||||
"version": "1.1.3",
|
||||
"version": "1.1.4",
|
||||
"main": "./dist/frameworks.js",
|
||||
"types": "./dist/frameworks.d.ts",
|
||||
"files": [
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/fs-detectors",
|
||||
"version": "2.1.0",
|
||||
"version": "3.0.0",
|
||||
"description": "Vercel filesystem detectors",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
@@ -19,7 +19,7 @@
|
||||
"test-unit": "yarn test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vercel/frameworks": "1.1.3",
|
||||
"@vercel/frameworks": "1.1.4",
|
||||
"@vercel/routing-utils": "2.0.2",
|
||||
"glob": "8.0.3",
|
||||
"js-yaml": "4.1.0",
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { posix as posixPath } from 'path';
|
||||
|
||||
export interface Stat {
|
||||
name: string;
|
||||
path: string;
|
||||
@@ -76,12 +78,43 @@ export abstract class DetectorFilesystem {
|
||||
|
||||
/**
|
||||
* Returns a list of Stat objects from the current working directory.
|
||||
* @param dirPath The path of the directory to read.
|
||||
* @param options.potentialFiles optional. Array of potential file names (relative to the path). If provided, these will be used to mark the filesystem caches as existing or not existing.
|
||||
*/
|
||||
public readdir = async (name: string): Promise<Stat[]> => {
|
||||
let p = this.readdirCache.get(name);
|
||||
public readdir = async (
|
||||
dirPath: string,
|
||||
options?: { potentialFiles?: string[] }
|
||||
): Promise<Stat[]> => {
|
||||
let p = this.readdirCache.get(dirPath);
|
||||
if (!p) {
|
||||
p = this._readdir(name);
|
||||
this.readdirCache.set(name, p);
|
||||
p = this._readdir(dirPath);
|
||||
this.readdirCache.set(dirPath, p);
|
||||
|
||||
const directoryContent = await p;
|
||||
const directoryFiles = new Set<string>();
|
||||
|
||||
for (const file of directoryContent) {
|
||||
if (file.type === 'file') {
|
||||
// we know this file exists, mark it as so on the filesystem
|
||||
this.fileCache.set(file.path, Promise.resolve(true));
|
||||
this.pathCache.set(file.path, Promise.resolve(true));
|
||||
directoryFiles.add(file.name);
|
||||
}
|
||||
}
|
||||
|
||||
if (options?.potentialFiles) {
|
||||
// calculate the set of paths that truly do not exist
|
||||
const filesThatDoNotExist = options.potentialFiles.filter(
|
||||
path => !directoryFiles.has(path)
|
||||
);
|
||||
for (const filePath of filesThatDoNotExist) {
|
||||
const fullFilePath =
|
||||
dirPath === '/' ? filePath : posixPath.join(dirPath, filePath);
|
||||
// we know this file does not exist, mark it as so on the filesystem
|
||||
this.fileCache.set(fullFilePath, Promise.resolve(false));
|
||||
this.pathCache.set(fullFilePath, Promise.resolve(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
return p;
|
||||
};
|
||||
@@ -92,16 +125,4 @@ export abstract class DetectorFilesystem {
|
||||
public chdir = (name: string): DetectorFilesystem => {
|
||||
return this._chdir(name);
|
||||
};
|
||||
|
||||
/**
|
||||
* Writes a file to the filesystem cache.
|
||||
* @param name the name of the file to write
|
||||
* @param content The content of the file
|
||||
*/
|
||||
public writeFile(name: string, content?: string): void {
|
||||
if (content)
|
||||
this.readFileCache.set(name, Promise.resolve(Buffer.from(content)));
|
||||
this.fileCache.set(name, Promise.resolve(true));
|
||||
this.pathCache.set(name, Promise.resolve(true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,11 +135,18 @@ describe('DetectorFilesystem', () => {
|
||||
};
|
||||
|
||||
const fs = new VirtualFilesystem(files);
|
||||
const hasPathSpy = jest.spyOn(fs, '_hasPath');
|
||||
|
||||
expect(await fs.readdir('/')).toEqual([
|
||||
expect(await fs.readdir('/', { potentialFiles: ['config.rb'] })).toEqual([
|
||||
{ name: 'package.json', path: 'package.json', type: 'file' },
|
||||
{ name: 'packages', path: 'packages', type: 'dir' },
|
||||
]);
|
||||
expect(await fs.hasPath('package.json')).toBe(true);
|
||||
expect(hasPathSpy).not.toHaveBeenCalled();
|
||||
expect(await fs.hasPath('config.rb')).toBe(false);
|
||||
expect(hasPathSpy).not.toHaveBeenCalled();
|
||||
expect(await fs.hasPath('tsconfig.json')).toBe(false);
|
||||
expect(hasPathSpy).toHaveBeenCalled();
|
||||
|
||||
expect(await fs.readdir('packages')).toEqual([
|
||||
{ name: 'app1', path: 'packages/app1', type: 'dir' },
|
||||
@@ -151,24 +158,19 @@ describe('DetectorFilesystem', () => {
|
||||
{ name: 'app2', path: 'packages/app2', type: 'dir' },
|
||||
]);
|
||||
|
||||
expect(await fs.readdir('packages/app1')).toEqual([
|
||||
expect(
|
||||
await fs.readdir('packages/app1', { potentialFiles: ['package.json'] })
|
||||
).toEqual([
|
||||
{
|
||||
name: 'package.json',
|
||||
path: 'packages/app1/package.json',
|
||||
type: 'file',
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it('should be able to write files', async () => {
|
||||
const files = {};
|
||||
const fs = new VirtualFilesystem(files);
|
||||
|
||||
fs.writeFile('file.txt', 'Hello World');
|
||||
|
||||
expect(await fs.readFile('file.txt')).toEqual(Buffer.from('Hello World'));
|
||||
expect(await fs.hasPath('file.txt')).toBe(true);
|
||||
expect(await fs.isFile('file.txt')).toBe(true);
|
||||
hasPathSpy.mock.calls.length = 0;
|
||||
expect(await fs.hasPath('packages/app1/package.json')).toBe(true);
|
||||
expect(hasPathSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should be able to change directories', async () => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/go",
|
||||
"version": "2.2.4",
|
||||
"version": "2.2.5",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/go",
|
||||
@@ -35,7 +35,7 @@
|
||||
"@types/jest": "28.1.6",
|
||||
"@types/node-fetch": "^2.3.0",
|
||||
"@types/tar": "^4.0.0",
|
||||
"@vercel/build-utils": "5.4.1",
|
||||
"@vercel/build-utils": "5.4.2",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"async-retry": "1.3.1",
|
||||
"execa": "^1.0.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/hydrogen",
|
||||
"version": "0.0.17",
|
||||
"version": "0.0.18",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
"homepage": "https://vercel.com/docs",
|
||||
@@ -21,7 +21,7 @@
|
||||
"devDependencies": {
|
||||
"@types/jest": "27.5.1",
|
||||
"@types/node": "*",
|
||||
"@vercel/build-utils": "5.4.1",
|
||||
"@vercel/build-utils": "5.4.2",
|
||||
"typescript": "4.6.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/next",
|
||||
"version": "3.1.23",
|
||||
"version": "3.1.25",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/next-js",
|
||||
@@ -44,8 +44,8 @@
|
||||
"@types/semver": "6.0.0",
|
||||
"@types/text-table": "0.2.1",
|
||||
"@types/webpack-sources": "3.2.0",
|
||||
"@vercel/build-utils": "5.4.1",
|
||||
"@vercel/nft": "0.21.0",
|
||||
"@vercel/build-utils": "5.4.2",
|
||||
"@vercel/nft": "0.22.1",
|
||||
"@vercel/routing-utils": "2.0.2",
|
||||
"async-sema": "3.0.1",
|
||||
"buffer-crc32": "0.2.13",
|
||||
|
||||
@@ -2636,7 +2636,10 @@ async function getServerlessPages(params: {
|
||||
for (const [entry, normalizedEntry] of Object.entries(
|
||||
params.appPathRoutesManifest
|
||||
)) {
|
||||
const normalizedPath = `${path.join('.', normalizedEntry)}.js`;
|
||||
const normalizedPath = `${path.join(
|
||||
'.',
|
||||
normalizedEntry === '/' ? '/index' : normalizedEntry
|
||||
)}.js`;
|
||||
const globPath = `${path.join('.', entry)}.js`;
|
||||
|
||||
if (appPaths[globPath]) {
|
||||
|
||||
@@ -2352,7 +2352,22 @@ export async function getMiddlewareBundle({
|
||||
|
||||
for (const worker of workerConfigs.values()) {
|
||||
const edgeFile = worker.edgeFunction.name;
|
||||
const shortPath = edgeFile.replace(/^pages\//, '');
|
||||
let shortPath = edgeFile;
|
||||
|
||||
// Replacing the folder prefix for the page
|
||||
//
|
||||
// For `pages/`, use file base name directly:
|
||||
// pages/index -> index
|
||||
// For `app/`, use folder name, handle the root page as index:
|
||||
// app/route/page -> route
|
||||
// app/page -> index
|
||||
// app/index/page -> index/index
|
||||
if (shortPath.startsWith('pages/')) {
|
||||
shortPath = shortPath.replace(/^pages\//, '');
|
||||
} else if (shortPath.startsWith('app/') && shortPath.endsWith('/page')) {
|
||||
shortPath =
|
||||
shortPath.replace(/^app\//, '').replace(/(^|\/)page$/, '') || 'index';
|
||||
}
|
||||
|
||||
worker.edgeFunction.name = shortPath;
|
||||
source.edgeFunctions[shortPath] = worker.edgeFunction;
|
||||
|
||||
7
packages/next/test/fixtures/00-app-dir-edge/app/edge/page.server.js
vendored
Normal file
7
packages/next/test/fixtures/00-app-dir-edge/app/edge/page.server.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default function Page() {
|
||||
return <p>edge</p>;
|
||||
}
|
||||
|
||||
export const config = {
|
||||
runtime: 'experimental-edge',
|
||||
};
|
||||
7
packages/next/test/fixtures/00-app-dir-edge/app/index/page.server.js
vendored
Normal file
7
packages/next/test/fixtures/00-app-dir-edge/app/index/page.server.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default function page() {
|
||||
return 'index/page';
|
||||
}
|
||||
|
||||
export const config = {
|
||||
runtime: 'experimental-edge',
|
||||
};
|
||||
7
packages/next/test/fixtures/00-app-dir-edge/app/page.server.js
vendored
Normal file
7
packages/next/test/fixtures/00-app-dir-edge/app/page.server.js
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export default function page() {
|
||||
return 'page';
|
||||
}
|
||||
|
||||
export const config = {
|
||||
runtime: 'experimental-edge',
|
||||
};
|
||||
9
packages/next/test/fixtures/00-app-dir-edge/next.config.js
vendored
Normal file
9
packages/next/test/fixtures/00-app-dir-edge/next.config.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
module.exports = {
|
||||
experimental: {
|
||||
appDir: true,
|
||||
runtime: 'experimental-edge',
|
||||
serverComponents: true,
|
||||
legacyBrowsers: false,
|
||||
browsersListForSwc: true,
|
||||
},
|
||||
};
|
||||
7
packages/next/test/fixtures/00-app-dir-edge/package.json
vendored
Normal file
7
packages/next/test/fixtures/00-app-dir-edge/package.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"next": "canary",
|
||||
"react": "experimental",
|
||||
"react-dom": "experimental"
|
||||
}
|
||||
}
|
||||
15
packages/next/test/fixtures/00-app-dir-edge/vercel.json
vendored
Normal file
15
packages/next/test/fixtures/00-app-dir-edge/vercel.json
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"builds": [
|
||||
{
|
||||
"src": "package.json",
|
||||
"use": "@vercel/next"
|
||||
}
|
||||
],
|
||||
"probes": [
|
||||
{
|
||||
"path": "/edge",
|
||||
"status": 200,
|
||||
"mustContain": "edge"
|
||||
}
|
||||
]
|
||||
}
|
||||
3
packages/next/test/fixtures/00-app-dir/app/page.server.js
vendored
Normal file
3
packages/next/test/fixtures/00-app-dir/app/page.server.js
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export default function Page() {
|
||||
return <p>index app page</p>;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"next": "https://files-26yo0dy1b-ijjk-testing.vercel.app",
|
||||
"next": "canary",
|
||||
"react": "experimental",
|
||||
"react-dom": "experimental"
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import Link from 'next/link';
|
||||
export default function Page(props) {
|
||||
return (
|
||||
<>
|
||||
<p>hello from pages/index</p>
|
||||
<Link href="/dashboard">Dashboard</Link>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
{
|
||||
"path": "/",
|
||||
"status": 200,
|
||||
"mustContain": "hello from pages/index"
|
||||
"mustContain": "index app page"
|
||||
},
|
||||
{
|
||||
"path": "/blog/123",
|
||||
|
||||
@@ -17,7 +17,6 @@ it('should build with app-dir correctly', async () => {
|
||||
for (const key of Object.keys(buildResult.output)) {
|
||||
if (buildResult.output[key].type === 'Lambda') {
|
||||
lambdas.add(buildResult.output[key]);
|
||||
console.log('found lambda', key);
|
||||
}
|
||||
}
|
||||
expect(lambdas.size).toBe(1);
|
||||
@@ -27,6 +26,26 @@ it('should build with app-dir correctly', async () => {
|
||||
expect(buildResult.output['dashboard/deployments/[id]']).toBeDefined();
|
||||
});
|
||||
|
||||
it('should build with app-dir in edg runtime correctly', async () => {
|
||||
const { buildResult } = await runBuildLambda(
|
||||
path.join(__dirname, '../fixtures/00-app-dir-edge')
|
||||
);
|
||||
|
||||
console.log('buildResult', buildResult);
|
||||
const edgeFunctions = new Set();
|
||||
|
||||
for (const key of Object.keys(buildResult.output)) {
|
||||
if (buildResult.output[key].type === 'EdgeFunction') {
|
||||
edgeFunctions.add(buildResult.output[key]);
|
||||
}
|
||||
}
|
||||
|
||||
expect(edgeFunctions.size).toBe(3);
|
||||
expect(buildResult.output['edge']).toBeDefined();
|
||||
expect(buildResult.output['index']).toBeDefined();
|
||||
expect(buildResult.output['index/index']).toBeDefined();
|
||||
});
|
||||
|
||||
it('should show error from basePath with legacy monorepo build', async () => {
|
||||
let error;
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/node",
|
||||
"version": "2.5.12",
|
||||
"version": "2.5.14",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/node-js",
|
||||
@@ -29,12 +29,12 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@edge-runtime/vm": "1.1.0-beta.23",
|
||||
"@edge-runtime/vm": "1.1.0-beta.32",
|
||||
"@types/node": "*",
|
||||
"@vercel/build-utils": "5.4.1",
|
||||
"@vercel/build-utils": "5.4.2",
|
||||
"@vercel/node-bridge": "3.0.0",
|
||||
"@vercel/static-config": "2.0.3",
|
||||
"edge-runtime": "1.1.0-beta.23",
|
||||
"edge-runtime": "1.1.0-beta.32",
|
||||
"esbuild": "0.14.47",
|
||||
"exit-hook": "2.2.1",
|
||||
"node-fetch": "2.6.7",
|
||||
@@ -53,7 +53,7 @@
|
||||
"@types/node-fetch": "^2.6.1",
|
||||
"@types/test-listen": "1.1.0",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"@vercel/nft": "0.22.0",
|
||||
"@vercel/nft": "0.22.1",
|
||||
"content-type": "1.0.4",
|
||||
"cookie": "0.4.0",
|
||||
"etag": "1.8.1",
|
||||
|
||||
@@ -151,7 +151,8 @@ async function serializeRequest(message: IncomingMessage) {
|
||||
|
||||
async function compileUserCode(
|
||||
entrypointPath: string,
|
||||
entrypointLabel: string
|
||||
entrypointLabel: string,
|
||||
isMiddleware: boolean
|
||||
): Promise<undefined | { userCode: string; wasmAssets: WasmAssets }> {
|
||||
const { wasmAssets, plugin: edgeWasmPlugin } = createEdgeWasmPlugin();
|
||||
try {
|
||||
@@ -176,6 +177,8 @@ async function compileUserCode(
|
||||
const userCode = `
|
||||
${compiledFile.text};
|
||||
|
||||
const isMiddleware = ${isMiddleware};
|
||||
|
||||
addEventListener('fetch', async (event) => {
|
||||
try {
|
||||
let serializedRequest = await event.request.text();
|
||||
@@ -205,7 +208,16 @@ async function compileUserCode(
|
||||
let response = await edgeHandler(event.request, event);
|
||||
|
||||
if (!response) {
|
||||
throw new Error('Edge Function "${entrypointLabel}" did not return a response.');
|
||||
if (isMiddleware) {
|
||||
// allow empty responses to pass through
|
||||
response = new Response(null, {
|
||||
headers: {
|
||||
'x-middleware-next': '1',
|
||||
},
|
||||
});
|
||||
} else {
|
||||
throw new Error('Edge Function "${entrypointLabel}" did not return a response.');
|
||||
}
|
||||
}
|
||||
|
||||
return event.respondWith(response);
|
||||
@@ -280,9 +292,14 @@ async function createEdgeRuntime(params?: {
|
||||
|
||||
async function createEdgeEventHandler(
|
||||
entrypointPath: string,
|
||||
entrypointLabel: string
|
||||
entrypointLabel: string,
|
||||
isMiddleware: boolean
|
||||
): Promise<(request: IncomingMessage) => Promise<VercelProxyResponse>> {
|
||||
const userCode = await compileUserCode(entrypointPath, entrypointLabel);
|
||||
const userCode = await compileUserCode(
|
||||
entrypointPath,
|
||||
entrypointLabel,
|
||||
isMiddleware
|
||||
);
|
||||
const server = await createEdgeRuntime(userCode);
|
||||
|
||||
return async function (request: IncomingMessage) {
|
||||
@@ -352,7 +369,11 @@ async function createEventHandler(
|
||||
// an Edge Function, otherwise needs to be opted-in via
|
||||
// `export const config = { runtime: 'experimental-edge' }`
|
||||
if (config.middleware === true || runtime === 'experimental-edge') {
|
||||
return createEdgeEventHandler(entrypointPath, entrypoint);
|
||||
return createEdgeEventHandler(
|
||||
entrypointPath,
|
||||
entrypoint,
|
||||
config.middleware || false
|
||||
);
|
||||
}
|
||||
|
||||
return createServerlessEventHandler(entrypointPath, options);
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
import { readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
export default function handler(_req, res) {
|
||||
// This build.js asset should be included but not the dep.js asset
|
||||
// because this is readFile(), not require(). It also shouldn't transpile
|
||||
// with babel because it should be considered an asset.
|
||||
const file = join(process.cwd(), 'assets', 'build.js');
|
||||
const content = readFileSync(file, 'utf8');
|
||||
res.setHeader('Content-Type', 'application/javascript');
|
||||
return res.end(content);
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
import dep from './dep.js';
|
||||
@@ -1,3 +0,0 @@
|
||||
// This file should not be included because the
|
||||
// api/index.js is performing a readFile(), not require().
|
||||
export const dep = 'dep1';
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"probes": [
|
||||
{
|
||||
"path": "/api",
|
||||
"mustContain": "import dep from './dep.js';"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/python",
|
||||
"version": "3.1.13",
|
||||
"version": "3.1.14",
|
||||
"main": "./dist/index.js",
|
||||
"license": "MIT",
|
||||
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/python",
|
||||
@@ -22,7 +22,7 @@
|
||||
"devDependencies": {
|
||||
"@types/execa": "^0.9.0",
|
||||
"@types/jest": "27.4.1",
|
||||
"@vercel/build-utils": "5.4.1",
|
||||
"@vercel/build-utils": "5.4.2",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"execa": "^1.0.0",
|
||||
"typescript": "4.3.4"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/redwood",
|
||||
"version": "1.0.21",
|
||||
"version": "1.0.23",
|
||||
"main": "./dist/index.js",
|
||||
"license": "MIT",
|
||||
"homepage": "https://vercel.com/docs",
|
||||
@@ -19,7 +19,7 @@
|
||||
"test-unit": "yarn test test/prepare-cache.test.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vercel/nft": "0.22.0",
|
||||
"@vercel/nft": "0.22.1",
|
||||
"@vercel/routing-utils": "2.0.2",
|
||||
"semver": "6.1.1"
|
||||
},
|
||||
@@ -27,6 +27,6 @@
|
||||
"@types/aws-lambda": "8.10.19",
|
||||
"@types/node": "*",
|
||||
"@types/semver": "6.0.0",
|
||||
"@vercel/build-utils": "5.4.1"
|
||||
"@vercel/build-utils": "5.4.2"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/remix",
|
||||
"version": "1.0.22",
|
||||
"version": "1.0.24",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
"homepage": "https://vercel.com/docs",
|
||||
@@ -20,12 +20,12 @@
|
||||
"default-server.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"@vercel/nft": "0.22.0"
|
||||
"@vercel/nft": "0.22.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "27.5.1",
|
||||
"@types/node": "*",
|
||||
"@vercel/build-utils": "5.4.1",
|
||||
"@vercel/build-utils": "5.4.2",
|
||||
"typescript": "4.6.4"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@vercel/ruby",
|
||||
"author": "Nathan Cahill <nathan@nathancahill.com>",
|
||||
"version": "1.3.30",
|
||||
"version": "1.3.31",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://vercel.com/docs/runtimes#official-runtimes/ruby",
|
||||
@@ -22,7 +22,7 @@
|
||||
"devDependencies": {
|
||||
"@types/fs-extra": "8.0.0",
|
||||
"@types/semver": "6.0.0",
|
||||
"@vercel/build-utils": "5.4.1",
|
||||
"@vercel/build-utils": "5.4.2",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"execa": "2.0.4",
|
||||
"fs-extra": "^7.0.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vercel/static-build",
|
||||
"version": "1.0.21",
|
||||
"version": "1.0.22",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index",
|
||||
"homepage": "https://vercel.com/docs/build-step",
|
||||
@@ -36,8 +36,8 @@
|
||||
"@types/ms": "0.7.31",
|
||||
"@types/node-fetch": "2.5.4",
|
||||
"@types/promise-timeout": "1.3.0",
|
||||
"@vercel/build-utils": "5.4.1",
|
||||
"@vercel/frameworks": "1.1.3",
|
||||
"@vercel/build-utils": "5.4.2",
|
||||
"@vercel/frameworks": "1.1.4",
|
||||
"@vercel/ncc": "0.24.0",
|
||||
"@vercel/routing-utils": "2.0.2",
|
||||
"fs-extra": "10.0.0",
|
||||
|
||||
63
yarn.lock
63
yarn.lock
@@ -719,10 +719,10 @@
|
||||
dependencies:
|
||||
"@jridgewell/trace-mapping" "0.3.9"
|
||||
|
||||
"@edge-runtime/format@^1.1.0-beta.23":
|
||||
version "1.1.0-beta.23"
|
||||
resolved "https://registry.yarnpkg.com/@edge-runtime/format/-/format-1.1.0-beta.23.tgz#c28fddee0c45a62be63f691a01306c611c99e739"
|
||||
integrity sha512-TuY7ywLzp2XQQZpM8cX1dzm2QMK2juvtpMVR8K61utL2qvokzJ4gBYLcPSKhH0EWAt4WwgymNVRX0cpdSLAqAg==
|
||||
"@edge-runtime/format@^1.1.0-beta.32":
|
||||
version "1.1.0-beta.32"
|
||||
resolved "https://registry.yarnpkg.com/@edge-runtime/format/-/format-1.1.0-beta.32.tgz#6f0d5a8726cc54ebb2b1dcb86fe25c0ff093731d"
|
||||
integrity sha512-wpQtbgHJuSF1fvDV6Gxg2L7uNpzhQnRl91DREgOdRfa3S8y9AANjPi1/g3GPBGPiGZoX2Fv+MKV6RgY5/jLfJA==
|
||||
|
||||
"@edge-runtime/jest-environment@1.1.0-beta.7":
|
||||
version "1.1.0-beta.7"
|
||||
@@ -736,22 +736,22 @@
|
||||
jest-mock "28.1.1"
|
||||
jest-util "28.1.1"
|
||||
|
||||
"@edge-runtime/primitives@^1.1.0-beta.23":
|
||||
version "1.1.0-beta.23"
|
||||
resolved "https://registry.yarnpkg.com/@edge-runtime/primitives/-/primitives-1.1.0-beta.23.tgz#b9b8d83e3dce63286cf80b8d5ece43f32420c4ab"
|
||||
integrity sha512-0vHcZZwyxjmw/so9irYtA82/+nAlJRs+1WpRYBx7iae1FOGCPM4BIKEmboWmwTuj7c6avz9kIbptokdMUPgV9A==
|
||||
"@edge-runtime/primitives@^1.1.0-beta.32":
|
||||
version "1.1.0-beta.33"
|
||||
resolved "https://registry.yarnpkg.com/@edge-runtime/primitives/-/primitives-1.1.0-beta.33.tgz#9bd0d866addfdc98ec32ff3ca0f6d24f412a5c03"
|
||||
integrity sha512-mAZw/YRhwkaPVYwSwOTJTMMzZxfuLze6VEepsrVO/4yjnxriOf2GREgLal6OBtTcEEC44q4lqS+OSd0QaSFZEQ==
|
||||
|
||||
"@edge-runtime/primitives@^1.1.0-beta.7":
|
||||
version "1.1.0-beta.7"
|
||||
resolved "https://registry.yarnpkg.com/@edge-runtime/primitives/-/primitives-1.1.0-beta.7.tgz#0450ee3e5e03a8898ee072c0d0ee01fd2c1ed8f1"
|
||||
integrity sha512-ZwuSMpmrf2mAj/O7EWxKOXrC03YMkU64N+CgvVFOtJGfhydk4Db/392Zama3BjNYAMOr/oY9L7HxfPutAFesKw==
|
||||
|
||||
"@edge-runtime/vm@1.1.0-beta.23", "@edge-runtime/vm@^1.1.0-beta.23":
|
||||
version "1.1.0-beta.23"
|
||||
resolved "https://registry.yarnpkg.com/@edge-runtime/vm/-/vm-1.1.0-beta.23.tgz#b55d9add18cb7bb57acf184f6cd7b6edec782a25"
|
||||
integrity sha512-XBp3rCuX4scJVOo2KconAotL5XGX3zdd8IkfDNr5VVSQ/B6HkiTNuf+EvzSQTpplF+fiyLTpfcP9EbNLibwLTA==
|
||||
"@edge-runtime/vm@1.1.0-beta.32", "@edge-runtime/vm@^1.1.0-beta.32":
|
||||
version "1.1.0-beta.32"
|
||||
resolved "https://registry.yarnpkg.com/@edge-runtime/vm/-/vm-1.1.0-beta.32.tgz#1bc9c77a88343478d50009f30813b9fbf8a0f4ad"
|
||||
integrity sha512-G0SH80am2XjlK6oFI3RoKlg1SBS5ZAeqakYasfNhJEXqM7g7tsoh5jURMQcNxpLvo48XBTgHgAVEMzhAGgDPZg==
|
||||
dependencies:
|
||||
"@edge-runtime/primitives" "^1.1.0-beta.23"
|
||||
"@edge-runtime/primitives" "^1.1.0-beta.32"
|
||||
|
||||
"@edge-runtime/vm@^1.1.0-beta.7":
|
||||
version "1.1.0-beta.7"
|
||||
@@ -3212,27 +3212,10 @@
|
||||
resolved "https://registry.yarnpkg.com/@vercel/ncc/-/ncc-0.24.0.tgz#a2e8783a185caa99b5d8961a57dfc9665de16296"
|
||||
integrity sha512-crqItMcIwCkvdXY/V3/TzrHJQx6nbIaRqE1cOopJhgGX6izvNov40SmD//nS5flfEvdK54YGjwVVq+zG6crjOg==
|
||||
|
||||
"@vercel/nft@0.21.0":
|
||||
version "0.21.0"
|
||||
resolved "https://registry.yarnpkg.com/@vercel/nft/-/nft-0.21.0.tgz#e0715b1997cd7021a7c7c48b584ef2295fd4b810"
|
||||
integrity sha512-hFCAETfI5cG8l5iAiLhMC2bReC5K7SIybzrxGorv+eGspIbIFsVw7Vg85GovXm/LxA08pIDrAlrhR6GN36XB/Q==
|
||||
dependencies:
|
||||
"@mapbox/node-pre-gyp" "^1.0.5"
|
||||
acorn "^8.6.0"
|
||||
async-sema "^3.1.1"
|
||||
bindings "^1.4.0"
|
||||
estree-walker "2.0.2"
|
||||
glob "^7.1.3"
|
||||
graceful-fs "^4.2.9"
|
||||
micromatch "^4.0.2"
|
||||
node-gyp-build "^4.2.2"
|
||||
resolve-from "^5.0.0"
|
||||
rollup-pluginutils "^2.8.2"
|
||||
|
||||
"@vercel/nft@0.22.0":
|
||||
version "0.22.0"
|
||||
resolved "https://registry.yarnpkg.com/@vercel/nft/-/nft-0.22.0.tgz#586ed4edfd0dabc9bf07525044782198a0b31199"
|
||||
integrity sha512-hB80/093PPiCefN2gVbqv6J93MH+63Zr7uDCwkiS/U4W07DXkLoftbnkBmZoS0Q84LiTSl9DRVSHU4XYCX+sJA==
|
||||
"@vercel/nft@0.22.1":
|
||||
version "0.22.1"
|
||||
resolved "https://registry.yarnpkg.com/@vercel/nft/-/nft-0.22.1.tgz#0d91d2a21e3a7f0b23ce1550da9870eac4942828"
|
||||
integrity sha512-lYYZIoxRurqDOSoVIdBicGnpUIpfyaS5qVjdPq+EfI285WqtZK3NK/dyCkiyBul+X2U2OEhRyeMdXPCHGJbohw==
|
||||
dependencies:
|
||||
"@mapbox/node-pre-gyp" "^1.0.5"
|
||||
acorn "^8.6.0"
|
||||
@@ -5490,13 +5473,13 @@ ecc-jsbn@~0.1.1:
|
||||
jsbn "~0.1.0"
|
||||
safer-buffer "^2.1.0"
|
||||
|
||||
edge-runtime@1.1.0-beta.23:
|
||||
version "1.1.0-beta.23"
|
||||
resolved "https://registry.yarnpkg.com/edge-runtime/-/edge-runtime-1.1.0-beta.23.tgz#fd4d93f021c622e9b188399fa83e6bd5e445cb5e"
|
||||
integrity sha512-A7dO/Y+4UJnaxFcdz6pepL+0GcvvViWvf201oFQXepgdSxPDKiqxaayCag0eiirQ6OfF+cSTmPD3xrfEoAIjiQ==
|
||||
edge-runtime@1.1.0-beta.32:
|
||||
version "1.1.0-beta.32"
|
||||
resolved "https://registry.yarnpkg.com/edge-runtime/-/edge-runtime-1.1.0-beta.32.tgz#e43fd53c57fdba3c567b3fef50743cba00ff5e49"
|
||||
integrity sha512-fbqqUF3OKynqtWgExhjyxXX2SwbkWuwmjUYhml3Sv8Y/vkrTxyTKrxS0MoxUy5sGPB3BBEtpopn36cQgwlOpAg==
|
||||
dependencies:
|
||||
"@edge-runtime/format" "^1.1.0-beta.23"
|
||||
"@edge-runtime/vm" "^1.1.0-beta.23"
|
||||
"@edge-runtime/format" "^1.1.0-beta.32"
|
||||
"@edge-runtime/vm" "^1.1.0-beta.32"
|
||||
exit-hook "2.2.1"
|
||||
http-status "1.5.2"
|
||||
mri "1.2.0"
|
||||
|
||||
Reference in New Issue
Block a user