Skip to content

chore: move middleware support into separate package #1520

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

Merged
merged 4 commits into from
Aug 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ jobs:
if: ${{ steps.release.outputs.releases_created }}
- name: Install dependencies
run: CI=1 npm ci
working-directory: plugin
if: ${{ steps.release.outputs.releases_created }}
- run: npm publish
working-directory: plugin
if: ${{ steps.release.outputs.releases_created }}
- run: npm publish packages/runtime/
if: ${{ steps.release.outputs['packages/runtime--version'] }}
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- run: npm publish packages/next/
if: ${{ steps.release.outputs['packages/next--version'] }}
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- uses: netlify/submit-build-plugin-action@v1
if: ${{ steps.release.outputs.releases_created }}
if: ${{ steps.release.outputs['packages/runtime--version'] }}
with:
github-token: ${{ steps.get-token.outputs.token }}
package-json-dir: plugin
package-json-dir: packages/runtime
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,7 @@ Temporary Items
.netlify
demos/default/.next
.parcel-cache
packages/runtime/lib
packages/runtime/dist-types
packages/*/lib

# Cypress
cypress/screenshots
2 changes: 1 addition & 1 deletion demos/middleware/middleware.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'

import { MiddlewareRequest } from '@netlify/plugin-nextjs/middleware'
import { MiddlewareRequest } from '@netlify/next'

export async function middleware(req: NextRequest) {
let response
Expand Down
1 change: 1 addition & 0 deletions demos/middleware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"dependencies": {
"@netlify/plugin-nextjs": "*",
"@netlify/next": "*",
"next": "^12.2.0",
"react": "18.0.0",
"react-dom": "18.0.0"
Expand Down
23 changes: 19 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"format:check-fix:prettier": "run-e format:check:prettier format:fix:prettier",
"format:check:prettier": "cross-env-shell prettier --check $npm_package_config_prettier",
"format:fix:prettier": "cross-env-shell prettier --write $npm_package_config_prettier",
"build": "npm run -w @netlify/plugin-nextjs build",
"build": "npm run build -w packages/next -w packages/runtime",
"postinstall": "run-s build install-husky",
"install-husky": "if-env CI=1 || husky install node_modules/@netlify/eslint-config-node/.husky",
"test": "run-s build:demo test:jest",
Expand Down
38 changes: 38 additions & 0 deletions packages/next/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "@netlify/next",
"version": "0.0.1",
"description": "Enhanced Next.js features on Netlify",
"main": "lib/index.js",
"files": [
"lib/**/*"
],
"devDependencies": {
"@types/node": "^17.0.25",
"next": "^12.2.0",
"npm-run-all": "^4.1.5",
"typescript": "^4.6.3"
},
"scripts": {
"prepublishOnly": "run-s clean build",
"clean": "rimraf lib",
"build": "tsc",
"watch": "tsc --watch",
"prepare": "npm run build"
},
"peerDependencies": {
"next": ">=12.2.0"
},
"repository": {
"type": "git",
"url": "git+https://github.com/netlify/netlify-plugin-nextjs.git"
},
"author": "",
"license": "MIT",
"bugs": {
"url": "https://github.com/netlify/netlify-plugin-nextjs/issues"
},
"homepage": "https://github.com/netlify/netlify-plugin-nextjs#readme",
"engines": {
"node": ">=12.0.0"
}
}
1 change: 1 addition & 0 deletions packages/next/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './middleware'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NextURL } from 'next/dist/server/web/next-url'
import type { NextURL } from 'next/dist/server/web/next-url'
import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'

Expand Down
12 changes: 12 additions & 0 deletions packages/next/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"declaration": true /* Generates corresponding '.d.ts' file. */,
"outDir": "./lib" /* Redirect output structure to the directory. */,
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
},
"include": [
"src/**/*.ts",
"src/**/*.js"
]
}
16 changes: 2 additions & 14 deletions packages/runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,8 @@
"files": [
"lib/**/*",
"src/templates/edge/*",
"manifest.yml",
"middleware.js"
"manifest.yml"
],
"typesVersions": {
"*": {
"middleware": [
"dist-types/middleware"
]
}
},
"exports": {
".": "./lib/index.js",
"./middleware": "./lib/middleware/index.js"
},
"dependencies": {
"@netlify/functions": "^1.0.0",
"@netlify/ipx": "^1.2.0",
Expand Down Expand Up @@ -66,7 +54,7 @@
"url": "git+https://github.com/netlify/netlify-plugin-nextjs.git"
},
"author": "",
"license": "ISC",
"license": "MIT",
"bugs": {
"url": "https://github.com/netlify/netlify-plugin-nextjs/issues"
},
Expand Down
2 changes: 0 additions & 2 deletions packages/runtime/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "./lib" /* Redirect output structure to the directory. */,
"declaration": true /* Generates corresponding '.d.ts' file. */,
"declarationDir": "./dist-types",
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
},
"include": [
Expand Down
3 changes: 2 additions & 1 deletion release-please-config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"bootstrap-sha": "62a4ce414f5b02f539902f88dd4b548df5cfa8ef",
"packages": {
"packages/runtime": {}
"packages/runtime": {},
"packages/next": {}
}
}