-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for "_middleware.{js,ts}" to vercel dev
#6880
Add support for "_middleware.{js,ts}" to vercel dev
#6880
Conversation
25711b1
to
7c81a16
Compare
7c81a16
to
2859cb1
Compare
2859cb1
to
df1a48e
Compare
d678e55
to
e19bd58
Compare
e19bd58
to
8f8b8fc
Compare
8f8b8fc
to
cf0e9b6
Compare
cf0e9b6
to
336ead9
Compare
336ead9
to
c156146
Compare
7c48ca9
to
fac1e24
Compare
46b0ed5
to
4aebe94
Compare
c4fd8db
to
90f15c3
Compare
packages/middleware/src/index.ts
Outdated
@@ -37,25 +49,26 @@ async function getMiddlewareFile() { | |||
return middlewareFiles[0]; | |||
} | |||
|
|||
export async function build() { | |||
const middlewareFile = await getMiddlewareFile(); | |||
export async function build({ workPath }: BuildOptions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to avoid having to specify workPath
explicitly since it should be able to be inferred from cwd. But let's leave it since it'll make writing tests easier (makes the function more "pure").
Using BuildOptions
interface though isn't quite correct, since that's the interface for the Runtimes' build()
function, not the Plugins' build()
function. So far, this workPath
is the only prop that needs to be passed in to the Plugin build fn.
* [cli] Fix tracing for `vc build` * Ignore object when there are no changes * Make Next < 12 work with FS API w/ nft * Update packages/cli/src/commands/build.ts Co-authored-by: Nathan Rajlich <n@n8.io> * Document how Next.js processing works in build * [cli] Fix static assets (#6906) * Make sure output path is .next * Fix up require-server-files for processing * Fix typo * Move static * Update static rename Co-authored-by: Andy Bitz <artzbitz@gmail.com> Co-authored-by: Nathan Rajlich <n@n8.io> Co-authored-by: Andy <AndyBitz@users.noreply.github.com>
- vercel@23.1.3-canary.17 - @vercel/client@10.2.3-canary.15 - @vercel/static-config@0.0.1-canary.0
- vercel@23.1.3-canary.18
The new plugin architecture doesn't pass a full BuildOptions object, previous to this commit it wasn't passing any options at all. I've added workingPath to support running dev/build from directories other than the project root.
This allows vercel build to continue working for projects that are not using frameworks, but use package.json to manage dependencies.
Next js PR w/ the header fix: vercel/next.js#30560
…into edge-function-exploration
result = true; | ||
} | ||
|
||
if (!result) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We removed this error message because it's possible you have a package.json
and no build script defined (i.e. I want to have deps in my middleware or API file).
vercel dev
* Add initial `vercel-plugin-middleware` * Ignore `entries.js` from ESLint * Add `runDevMiddleware()` stub * Add test * Add support for "_middleware.{js,ts}" to `vercel dev` (#6880) * Add websandbox from next.js codebase. * Use node-fetch instead of next's polyfilled fetch. * Handle middleware rewrites. * Add response, headers, and request to websandbox context. * Move websandbox dependency to middleware plugin. * Add integration tests, update websandbox to support ts files and json imports. * commit yarn.lock changes after rebasing * Clean up left over console.logs, fix some tsc issues, and rebase issue. * Fix failing test and eslint. * Fix middleware test on windows. * [examples] Update Vercel Next.js example template to 12.0.1 (#6905) * Mark the Plugins as external to CLI's ncc build * [cli] Improve tracing in vc build (#6898) * [cli] Fix tracing for `vc build` * Ignore object when there are no changes * Make Next < 12 work with FS API w/ nft * Update packages/cli/src/commands/build.ts Co-authored-by: Nathan Rajlich <n@n8.io> * Document how Next.js processing works in build * [cli] Fix static assets (#6906) * Make sure output path is .next * Fix up require-server-files for processing * Fix typo * Move static * Update static rename Co-authored-by: Andy Bitz <artzbitz@gmail.com> Co-authored-by: Nathan Rajlich <n@n8.io> Co-authored-by: Andy <AndyBitz@users.noreply.github.com> * Publish Canary - vercel@23.1.3-canary.17 - @vercel/client@10.2.3-canary.15 - @vercel/static-config@0.0.1-canary.0 * [cli] Ignore `.env` and `.gitignore` in "vc build" (#6910) * Publish Canary - vercel@23.1.3-canary.18 * Pass workPath to plugins. The new plugin architecture doesn't pass a full BuildOptions object, previous to this commit it wasn't passing any options at all. I've added workingPath to support running dev/build from directories other than the project root. * Remove error state when package.json exists, but no build script This allows vercel build to continue working for projects that are not using frameworks, but use package.json to manage dependencies. * Fix types, pull in middleware header fix from next.js Next js PR w/ the header fix: vercel/next.js#30560 * Fix missing entries file for vc build. * Update call signature of middleware when using vc build. Co-authored-by: Drew Bredvick <dbredvick@gmail.com> Co-authored-by: Nathan Rajlich <n@n8.io> Co-authored-by: Jared Palmer <jared@jaredpalmer.com> Co-authored-by: Andy Bitz <artzbitz@gmail.com> Co-authored-by: Andy <AndyBitz@users.noreply.github.com> Co-authored-by: Gary Borton <gdborton@gmail.com> Co-authored-by: Drew Bredvick <dbredvick@gmail.com> Co-authored-by: Jared Palmer <jared@jaredpalmer.com> Co-authored-by: Andy Bitz <artzbitz@gmail.com> Co-authored-by: Andy <AndyBitz@users.noreply.github.com>
Related Issues
This adds support for running _middleware.{js,ts} in the
vc dev
command.📋 Checklist
Tests
yarn test-unit
Code Review