@netlify/plugin-nextjs 4.2.7 → 4.3.1

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.
package/lib/constants.js CHANGED
@@ -9,6 +9,7 @@ exports.HIDDEN_PATHS = [
9
9
  '/cache/*',
10
10
  '/server/*',
11
11
  '/serverless/*',
12
+ '/trace',
12
13
  '/traces',
13
14
  '/routes-manifest.json',
14
15
  '/build-manifest.json',
@@ -54,6 +54,9 @@ const matchesRewrite = (file, rewrites) => {
54
54
  exports.matchesRewrite = matchesRewrite;
55
55
  const getMiddleware = async (publish) => {
56
56
  var _a;
57
+ if (process.env.NEXT_SKIP_MIDDLEWARE) {
58
+ return [];
59
+ }
57
60
  const manifestPath = (0, pathe_1.join)(publish, 'server', 'middleware-manifest.json');
58
61
  if ((0, fs_extra_1.existsSync)(manifestPath)) {
59
62
  const manifest = await (0, fs_extra_1.readJson)(manifestPath, { throws: false });
@@ -13,7 +13,7 @@ const getPageResolver_1 = require("../templates/getPageResolver");
13
13
  const generateFunctions = async ({ FUNCTIONS_SRC = constants_1.DEFAULT_FUNCTIONS_SRC, INTERNAL_FUNCTIONS_SRC, PUBLISH_DIR }, appDir) => {
14
14
  const functionsDir = INTERNAL_FUNCTIONS_SRC || FUNCTIONS_SRC;
15
15
  const functionDir = (0, pathe_1.join)(process.cwd(), functionsDir, constants_1.HANDLER_FUNCTION_NAME);
16
- const publishDir = (0, pathe_1.relative)(functionDir, (0, pathe_1.join)(process.cwd(), PUBLISH_DIR));
16
+ const publishDir = (0, pathe_1.relative)(functionDir, (0, pathe_1.resolve)(PUBLISH_DIR));
17
17
  const writeHandler = async (func, isODB) => {
18
18
  const handlerSource = await (0, getHandler_1.getHandler)({ isODB, publishDir, appDir: (0, pathe_1.relative)(functionDir, appDir) });
19
19
  await (0, fs_extra_1.ensureDir)((0, pathe_1.join)(functionsDir, func));
@@ -66,7 +66,7 @@ const checkNextSiteHasBuilt = ({ publish, failBuild, }) => {
66
66
  ? `Your publish directory is set to "out", but in most cases it should be ".next".`
67
67
  : `In most cases it should be set to ".next", unless you have chosen a custom "distDir" in your Next config.`;
68
68
  return failBuild((0, outdent_1.outdent) `
69
- The directory "${path_1.default.relative(process.cwd(), publish)}" does not contain a Next.js production build. Perhaps the build command was not run, or you specified the wrong publish directory.
69
+ The directory "${publish}" does not contain a Next.js production build. Perhaps the build command was not run, or you specified the wrong publish directory.
70
70
  ${outWarning}
71
71
  If you are using "next export" then you should set the environment variable NETLIFY_NEXT_PLUGIN_SKIP to "true".
72
72
  `);
@@ -82,7 +82,7 @@ exports.checkNextSiteHasBuilt = checkNextSiteHasBuilt;
82
82
  const checkForRootPublish = ({ publish, failBuild, }) => {
83
83
  if (path_1.default.resolve(publish) === path_1.default.resolve('.')) {
84
84
  failBuild((0, outdent_1.outdent) `
85
- Your publish directory is pointing to the base directory of your site. This is not supported for Next.js sites, and is probably a mistake.
85
+ Your publish directory is pointing to the base directory of your site. This is not supported for Next.js sites, and is probably a mistake.
86
86
  In most cases it should be set to ".next", unless you have chosen a custom "distDir" in your Next config, or the Next site is in a subdirectory.
87
87
  `);
88
88
  }
@@ -14,6 +14,12 @@ const { augmentFsModule, getMaxAge, getMultiValueHeaders, getNextServer } = requ
14
14
  // eslint-disable-next-line max-params
15
15
  const makeHandler = (conf, app, pageRoot, staticManifest = [], mode = 'ssr') => {
16
16
  var _a;
17
+ // Change working directory into the site root, unless using Nx, which moves the
18
+ // dist directory and handles this itself
19
+ const dir = path.resolve(__dirname, app);
20
+ if (pageRoot.startsWith(dir)) {
21
+ process.chdir(dir);
22
+ }
17
23
  // This is just so nft knows about the page entrypoints. It's not actually used
18
24
  try {
19
25
  // eslint-disable-next-line node/no-missing-require
@@ -27,6 +33,9 @@ const makeHandler = (conf, app, pageRoot, staticManifest = [], mode = 'ssr') =>
27
33
  // This is our flag that we use when patching the source
28
34
  // eslint-disable-next-line no-underscore-dangle
29
35
  process.env._BYPASS_SSG = 'true';
36
+ for (const [key, value] of Object.entries(conf.env)) {
37
+ process.env[key] = String(value);
38
+ }
30
39
  // Set during the request as it needs the host header. Hoisted so we can define the function once
31
40
  let base;
32
41
  augmentFsModule({ promises, staticManifest, pageRoot, getBase: () => base });
@@ -45,7 +54,7 @@ const makeHandler = (conf, app, pageRoot, staticManifest = [], mode = 'ssr') =>
45
54
  const NextServer = getNextServer();
46
55
  const nextServer = new NextServer({
47
56
  conf,
48
- dir: path.resolve(__dirname, app),
57
+ dir,
49
58
  customServer: false,
50
59
  hostname: url.hostname,
51
60
  port,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/plugin-nextjs",
3
- "version": "4.2.7",
3
+ "version": "4.3.1",
4
4
  "description": "Run Next.js seamlessly on Netlify",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -54,7 +54,7 @@
54
54
  "homepage": "https://github.com/netlify/netlify-plugin-nextjs#readme",
55
55
  "dependencies": {
56
56
  "@netlify/functions": "^1.0.0",
57
- "@netlify/ipx": "^0.0.9",
57
+ "@netlify/ipx": "^0.0.10",
58
58
  "@vercel/node-bridge": "^2.1.0",
59
59
  "chalk": "^4.1.2",
60
60
  "fs-extra": "^10.0.0",
@@ -75,8 +75,8 @@
75
75
  "@babel/core": "^7.15.8",
76
76
  "@babel/preset-env": "^7.15.8",
77
77
  "@babel/preset-typescript": "^7.16.0",
78
- "@netlify/build": "^26.3.3",
79
- "@netlify/eslint-config-node": "^5.1.4",
78
+ "@netlify/build": "^26.5.1",
79
+ "@netlify/eslint-config-node": "^5.1.8",
80
80
  "@reach/dialog": "^0.16.2",
81
81
  "@reach/visually-hidden": "^0.16.0",
82
82
  "@testing-library/cypress": "^8.0.1",