@netlify/plugin-nextjs 5.0.0-rc.1 → 5.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@ import {
8
8
  copyNextDependencies,
9
9
  copyNextServerCode,
10
10
  writeTagsManifest
11
- } from "../../esm-chunks/chunk-4J4A5OE2.js";
11
+ } from "../../esm-chunks/chunk-52WMBYKL.js";
12
12
  import "../../esm-chunks/chunk-VZNKO4OO.js";
13
13
  import "../../esm-chunks/chunk-UYKENJEU.js";
14
14
  import "../../esm-chunks/chunk-5JVNISGM.js";
@@ -9,7 +9,7 @@ import {
9
9
  copyStaticContent,
10
10
  publishStaticDir,
11
11
  unpublishStaticDir
12
- } from "../../esm-chunks/chunk-WQIG4U66.js";
12
+ } from "../../esm-chunks/chunk-MPZEWLBG.js";
13
13
  import "../../esm-chunks/chunk-VZNKO4OO.js";
14
14
  import "../../esm-chunks/chunk-TYCYFZ22.js";
15
15
  import "../../esm-chunks/chunk-5JVNISGM.js";
@@ -6,8 +6,8 @@
6
6
 
7
7
  import {
8
8
  createServerHandler
9
- } from "../../esm-chunks/chunk-GAZUUVZW.js";
10
- import "../../esm-chunks/chunk-4J4A5OE2.js";
9
+ } from "../../esm-chunks/chunk-E3NFUTWC.js";
10
+ import "../../esm-chunks/chunk-52WMBYKL.js";
11
11
  import "../../esm-chunks/chunk-VZNKO4OO.js";
12
12
  import "../../esm-chunks/chunk-655Y7ISI.js";
13
13
  import "../../esm-chunks/chunk-UYKENJEU.js";
@@ -19,7 +19,9 @@ var import_fast_glob = __toESM(require_out(), 1);
19
19
  import { existsSync } from "node:fs";
20
20
  import { cp, mkdir, readFile, readdir, readlink, symlink, writeFile } from "node:fs/promises";
21
21
  import { createRequire } from "node:module";
22
- import { dirname, join, resolve } from "node:path";
22
+ import { dirname, join, resolve, sep } from "node:path";
23
+ import { sep as posixSep } from "node:path/posix";
24
+ var toPosixPath = (path) => path.split(sep).join(posixSep);
23
25
  var copyNextServerCode = async (ctx) => {
24
26
  const reqServerFilesPath = join(
25
27
  ctx.standaloneRootDir,
@@ -27,7 +29,7 @@ var copyNextServerCode = async (ctx) => {
27
29
  "required-server-files.json"
28
30
  );
29
31
  const reqServerFiles = JSON.parse(await readFile(reqServerFilesPath, "utf-8"));
30
- if (ctx.distDir.replace(new RegExp(`^${ctx.packagePath}/?`), "") !== reqServerFiles.config.distDir) {
32
+ if (toPosixPath(ctx.distDir).replace(new RegExp(`^${ctx.packagePath}/?`), "") !== reqServerFiles.config.distDir) {
31
33
  reqServerFiles.config.distDir = ctx.nextDistDir;
32
34
  await writeFile(reqServerFilesPath, JSON.stringify(reqServerFiles));
33
35
  }
@@ -38,7 +40,7 @@ var copyNextServerCode = async (ctx) => {
38
40
  "utf-8"
39
41
  );
40
42
  const srcDir = join(ctx.standaloneDir, ctx.nextDistDir);
41
- const nextFolder = ctx.distDir === ctx.buildConfig.distDir ? ctx.distDir : ctx.nextDistDir;
43
+ const nextFolder = toPosixPath(ctx.distDir) === toPosixPath(ctx.buildConfig.distDir) ? ctx.distDir : ctx.nextDistDir;
42
44
  const destDir = join(ctx.serverHandlerDir, nextFolder);
43
45
  const paths = await (0, import_fast_glob.default)(
44
46
  [`*`, `server/*`, `server/chunks/*`, `server/edge-chunks/*`, `server/+(app|pages)/**/*.js`],
@@ -109,8 +111,9 @@ var copyNextDependencies = async (ctx) => {
109
111
  await Promise.all(promises);
110
112
  const require2 = createRequire(ctx.serverHandlerDir);
111
113
  try {
112
- require2.resolve("styled-jsx");
113
- require2.resolve("next");
114
+ const nextEntryAbsolutePath = require2.resolve("next");
115
+ const nextRequire = createRequire(nextEntryAbsolutePath);
116
+ nextRequire.resolve("styled-jsx");
114
117
  } catch {
115
118
  throw new Error(
116
119
  "node_modules are not installed correctly, if you are using pnpm please set the public hoist pattern to: `public-hoist-pattern[]=*`.\nRefer to your docs for more details: https://docs.netlify.com/integrations/frameworks/next-js/overview/#pnpm-support"
@@ -8,7 +8,7 @@ import {
8
8
  copyNextDependencies,
9
9
  copyNextServerCode,
10
10
  writeTagsManifest
11
- } from "./chunk-4J4A5OE2.js";
11
+ } from "./chunk-52WMBYKL.js";
12
12
  import {
13
13
  require_out
14
14
  } from "./chunk-VZNKO4OO.js";
@@ -22,17 +22,42 @@ import {
22
22
  // src/build/functions/server.ts
23
23
  var import_fast_glob = __toESM(require_out(), 1);
24
24
  import { cp, mkdir, readFile, rm, writeFile } from "fs/promises";
25
- import { join } from "node:path";
25
+ import { join, relative } from "node:path";
26
+ import { join as posixJoin } from "node:path/posix";
26
27
  var copyHandlerDependencies = async (ctx) => {
28
+ const promises = [];
29
+ const { included_files: includedFiles = [] } = ctx.netlifyConfig.functions?.["*"] || {};
30
+ if (includedFiles.length !== 0) {
31
+ const resolvedFiles = await Promise.all(
32
+ includedFiles.map((globPattern) => (0, import_fast_glob.glob)(globPattern, { cwd: process.cwd() }))
33
+ );
34
+ for (const filePath of resolvedFiles.flat()) {
35
+ promises.push(
36
+ cp(
37
+ join(process.cwd(), filePath),
38
+ // the serverHandlerDir is aware of the dist dir.
39
+ // The distDir must not be the package path therefore we need to rely on the
40
+ // serverHandlerDir instead of the serverHandlerRootDir
41
+ // therefore we need to remove the package path from the filePath
42
+ join(ctx.serverHandlerDir, relative(ctx.packagePath, filePath)),
43
+ {
44
+ recursive: true,
45
+ force: true
46
+ }
47
+ )
48
+ );
49
+ }
50
+ }
27
51
  const fileList = await (0, import_fast_glob.glob)("dist/**/*", { cwd: ctx.pluginDir });
28
- await Promise.all(
29
- [...fileList].map(
30
- (path) => cp(join(ctx.pluginDir, path), join(ctx.serverHandlerDir, ".netlify", path), {
52
+ for (const filePath of fileList) {
53
+ promises.push(
54
+ cp(join(ctx.pluginDir, filePath), join(ctx.serverHandlerDir, ".netlify", filePath), {
31
55
  recursive: true,
32
56
  force: true
33
57
  })
34
- )
35
- );
58
+ );
59
+ }
60
+ await Promise.all(promises);
36
61
  };
37
62
  var writeHandlerManifest = async (ctx) => {
38
63
  await writeFile(
@@ -61,7 +86,7 @@ var getHandlerFile = async (ctx) => {
61
86
  const templatesDir = join(ctx.pluginDir, "dist/build/templates");
62
87
  if (ctx.packagePath.length !== 0) {
63
88
  const template = await readFile(join(templatesDir, "handler-monorepo.tmpl.js"), "utf-8");
64
- return template.replaceAll("{{cwd}}", ctx.lambdaWorkingDirectory).replace("{{nextServerHandler}}", ctx.nextServerHandler);
89
+ return template.replaceAll("{{cwd}}", posixJoin(ctx.lambdaWorkingDirectory)).replace("{{nextServerHandler}}", posixJoin(ctx.nextServerHandler));
65
90
  }
66
91
  return await readFile(join(templatesDir, "handler.tmpl.js"), "utf-8");
67
92
  };
@@ -18,7 +18,7 @@ import {
18
18
  var import_fast_glob = __toESM(require_out(), 1);
19
19
  import { existsSync } from "node:fs";
20
20
  import { cp, mkdir, rename, rm } from "node:fs/promises";
21
- import { join } from "node:path";
21
+ import { basename, join } from "node:path";
22
22
  var copyStaticContent = async (ctx) => {
23
23
  const srcDir = join(ctx.publishDir, "server/pages");
24
24
  const destDir = ctx.blobDir;
@@ -58,7 +58,7 @@ var copyStaticAssets = async (ctx) => {
58
58
  var publishStaticDir = async (ctx) => {
59
59
  try {
60
60
  await rm(ctx.tempPublishDir, { recursive: true, force: true });
61
- await mkdir(ctx.tempPublishDir, { recursive: true });
61
+ await mkdir(basename(ctx.tempPublishDir), { recursive: true });
62
62
  await rename(ctx.publishDir, ctx.tempPublishDir);
63
63
  await rename(ctx.staticDir, ctx.publishDir);
64
64
  } catch (error) {
@@ -8,7 +8,7 @@ import "./chunk-5JVNISGM.js";
8
8
 
9
9
  // package.json
10
10
  var name = "@netlify/plugin-nextjs";
11
- var version = "5.0.0-rc.1";
11
+ var version = "5.0.0-rc.2";
12
12
  var description = "Run Next.js seamlessly on Netlify";
13
13
  var main = "./dist/index.js";
14
14
  var type = "module";
@@ -57,7 +57,7 @@ var devDependencies = {
57
57
  "@netlify/eslint-config-node": "^7.0.1",
58
58
  "@netlify/functions": "^2.5.1",
59
59
  "@netlify/serverless-functions-api": "^1.10.1",
60
- "@netlify/zip-it-and-ship-it": "^9.29.2",
60
+ "@netlify/zip-it-and-ship-it": "^9.30.0",
61
61
  "@opentelemetry/api": "^1.7.0",
62
62
  "@opentelemetry/exporter-trace-otlp-http": "^0.48.0",
63
63
  "@opentelemetry/resources": "^1.21.0",
package/dist/index.js CHANGED
@@ -12,14 +12,14 @@ import {
12
12
  copyStaticContent,
13
13
  publishStaticDir,
14
14
  unpublishStaticDir
15
- } from "./esm-chunks/chunk-WQIG4U66.js";
15
+ } from "./esm-chunks/chunk-MPZEWLBG.js";
16
16
  import {
17
17
  createEdgeHandlers
18
18
  } from "./esm-chunks/chunk-ZZOGIP2V.js";
19
19
  import {
20
20
  createServerHandler
21
- } from "./esm-chunks/chunk-GAZUUVZW.js";
22
- import "./esm-chunks/chunk-4J4A5OE2.js";
21
+ } from "./esm-chunks/chunk-E3NFUTWC.js";
22
+ import "./esm-chunks/chunk-52WMBYKL.js";
23
23
  import "./esm-chunks/chunk-VZNKO4OO.js";
24
24
  import {
25
25
  restoreBuildCache,
@@ -52794,7 +52794,7 @@ var import_semantic_conventions = __toESM(require_src2(), 1);
52794
52794
  var import_api = __toESM(require_src(), 1);
52795
52795
  var {
52796
52796
  default: { version, name }
52797
- } = await import("../../esm-chunks/package-QW5XSFQ4.js");
52797
+ } = await import("../../esm-chunks/package-V53S3A76.js");
52798
52798
  var sdk = new import_sdk_node.NodeSDK({
52799
52799
  resource: new import_resources.Resource({
52800
52800
  [import_semantic_conventions.SemanticResourceAttributes.SERVICE_NAME]: name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/plugin-nextjs",
3
- "version": "5.0.0-rc.1",
3
+ "version": "5.0.0-rc.2",
4
4
  "description": "Run Next.js seamlessly on Netlify",
5
5
  "main": "./dist/index.js",
6
6
  "type": "module",