Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@netlify/plugin-nextjs

Package Overview
Dependencies
Maintainers
23
Versions
261
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@netlify/plugin-nextjs - npm Package Compare versions

Comparing version 5.5.1 to 5.6.0

dist/esm-chunks/package-OHGYB5OD.js

2

dist/build/content/server.js

@@ -172,3 +172,3 @@

const promises = entries.map(async (entry) => {
if (entry === "package.json" || entry === ctx.nextDistDir) {
if (entry === ctx.nextDistDir) {
return;

@@ -175,0 +175,0 @@ }

@@ -434,6 +434,3 @@

await copyRuntime(ctx, handlerDirectory);
await writeFile(
join(handlerRuntimeDirectory, "matchers.json"),
JSON.stringify(augmentMatchers(matchers, ctx))
);
await writeFile(join(handlerRuntimeDirectory, "matchers.json"), JSON.stringify(matchers));
const minimalNextConfig = {

@@ -440,0 +437,0 @@ basePath: nextConfig.basePath,

@@ -64,6 +64,12 @@

}
promises.push(
writeFile(
join(ctx.serverHandlerRuntimeModulesDir, "package.json"),
JSON.stringify({ type: "module" })
)
);
const fileList = await (0, import_fast_glob.glob)("dist/**/*", { cwd: ctx.pluginDir });
for (const filePath of fileList) {
promises.push(
cp(join(ctx.pluginDir, filePath), join(ctx.serverHandlerDir, ".netlify", filePath), {
cp(join(ctx.pluginDir, filePath), join(ctx.serverHandlerRuntimeModulesDir, filePath), {
recursive: true,

@@ -94,8 +100,2 @@ force: true

};
var writePackageMetadata = async (ctx) => {
await writeFile(
join(ctx.serverHandlerRootDir, "package.json"),
JSON.stringify({ type: "module" })
);
};
var applyTemplateVariables = (template, variables) => {

@@ -131,3 +131,3 @@ return Object.entries(variables).reduce((acc, [key, value]) => {

await tracer.withActiveSpan("createServerHandler", async () => {
await mkdir(join(ctx.serverHandlerDir, ".netlify"), { recursive: true });
await mkdir(join(ctx.serverHandlerRuntimeModulesDir), { recursive: true });
await copyNextServerCode(ctx);

@@ -137,3 +137,2 @@ await copyNextDependencies(ctx);

await writeHandlerManifest(ctx);
await writePackageMetadata(ctx);
await writeHandlerFile(ctx);

@@ -140,0 +139,0 @@ await verifyHandlerDirStructure(ctx);

@@ -136,2 +136,5 @@

}
get serverHandlerRuntimeModulesDir() {
return join(this.serverHandlerDir, ".netlify");
}
get nextServerHandler() {

@@ -138,0 +141,0 @@ if (this.relativeAppDir.length !== 0) {

@@ -106,7 +106,6 @@

function verifyNetlifyForms(ctx, html) {
if (!verifications.has("netlifyForms") && !verifications.has("netlifyFormsWorkaround") && formDetectionRegex.test(html)) {
console.warn(
if (process.env.NETLIFY_NEXT_VERIFY_FORMS !== "0" && process.env.NETLIFY_NEXT_VERIFY_FORMS?.toUpperCase() !== "FALSE" && !verifications.has("netlifyFormsWorkaround") && formDetectionRegex.test(html)) {
ctx.failBuild(
"@netlify/plugin-nextjs@5 requires migration steps to support Netlify Forms. Refer to https://ntl.fyi/next-runtime-forms-migration for migration example."
);
verifications.add("netlifyForms");
}

@@ -113,0 +112,0 @@ }

@@ -5,2 +5,3 @@ import type { Context } from '@netlify/edge-functions'

addBasePath,
addLocale,
addTrailingSlash,

@@ -77,2 +78,29 @@ normalizeDataUrl,

export const localizeRequest = (
url: URL,
nextConfig?: {
basePath?: string
i18n?: I18NConfig | null
},
): { localizedUrl: URL; locale?: string } => {
const localizedUrl = new URL(url)
localizedUrl.pathname = removeBasePath(localizedUrl.pathname, nextConfig?.basePath)
// Detect the locale from the URL
const { detectedLocale } = normalizeLocalePath(localizedUrl.pathname, nextConfig?.i18n?.locales)
// Add the locale to the URL if not already present
localizedUrl.pathname = addLocale(
localizedUrl.pathname,
detectedLocale ?? nextConfig?.i18n?.defaultLocale,
)
localizedUrl.pathname = addBasePath(localizedUrl.pathname, nextConfig?.basePath)
return {
localizedUrl,
locale: detectedLocale,
}
}
export const buildNextRequest = (

@@ -79,0 +107,0 @@ request: Request,

@@ -32,2 +32,16 @@ /**

// add locale prefix if not present, allowing for locale fallbacks
export const addLocale = (path: string, locale?: string) => {
if (
locale &&
path.toLowerCase() !== `/${locale.toLowerCase()}` &&
!path.toLowerCase().startsWith(`/${locale.toLowerCase()}/`) &&
!path.startsWith(`/api/`) &&
!path.startsWith(`/_next/`)
) {
return `/${locale}${path}`
}
return path
}
// https://github.com/vercel/next.js/blob/canary/packages/next/src/shared/lib/i18n/normalize-locale-path.ts

@@ -34,0 +48,0 @@

@@ -8,3 +8,3 @@ import type { Context } from '@netlify/edge-functions'

import { logger, LogLevel } from './lib/logging.ts'
import { buildNextRequest, RequestData } from './lib/next-request.ts'
import { buildNextRequest, localizeRequest, RequestData } from './lib/next-request.ts'
import { buildResponse, FetchEventResult } from './lib/response.ts'

@@ -35,4 +35,4 @@ import {

) {
const nextRequest = buildNextRequest(request, context, nextConfig)
const url = new URL(request.url)
const reqLogger = logger

@@ -45,2 +45,3 @@ .withLogLevel(

const { localizedUrl } = localizeRequest(url, nextConfig)
// While we have already checked the path when mapping to the edge function,

@@ -50,3 +51,5 @@ // Next.js supports extra rules that we need to check here too, because we

// that's the case, short-circuit the execution.
if (!matchesMiddleware(url.pathname, request, searchParamsToUrlQuery(url.searchParams))) {
if (
!matchesMiddleware(localizedUrl.pathname, request, searchParamsToUrlQuery(url.searchParams))
) {
reqLogger.debug('Aborting middleware due to runtime rules')

@@ -57,2 +60,3 @@

const nextRequest = buildNextRequest(request, context, nextConfig)
try {

@@ -59,0 +63,0 @@ const result = await nextHandler({ request: nextRequest })

{
"name": "@netlify/plugin-nextjs",
"version": "5.5.1",
"version": "5.6.0",
"description": "Run Next.js seamlessly on Netlify",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc