@netlify/plugin-nextjs 4.0.0-rc.2 → 4.0.0

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/README.md CHANGED
@@ -1,9 +1,6 @@
1
- ![Next.js on Netlify Build Plugin](next-on-netlify.png)
1
+ ![Essential Next.js Build Plugin](next-on-netlify.png)
2
2
 
3
- # Essential Next.js Build Plugin (beta)
4
-
5
- :warning: This is the beta version of the Essential Next.js plugin. For the stable version, refer to
6
- [Essential Next.js plugin v3](https://github.com/netlify/netlify-plugin-nextjs/tree/v3#readme) :warning:
3
+ # Essential Next.js Build Plugin
7
4
 
8
5
  <p align="center">
9
6
  <a aria-label="npm version" href="https://www.npmjs.com/package/@netlify/plugin-nextjs">
@@ -19,36 +16,46 @@
19
16
  Version 4 is a complete rewrite of the Essential Next.js plugin. For full details of everything that's new, check out
20
17
  [the v4 release notes](https://github.com/netlify/netlify-plugin-nextjs/blob/main/docs/release-notes/v4.md)
21
18
 
22
- ## Installing the beta
19
+ ## Installing the plugin
23
20
 
24
- - Install the module:
21
+ The plugin installs automatically for new Next.js sites on Netlify. You can also install it manually like this:
25
22
 
26
23
  ```shell
27
- npm install -D @netlify/plugin-nextjs@beta
24
+ npm install -D @netlify/plugin-nextjs
28
25
  ```
29
26
 
30
- - Change the `publish` directory to `.next` and add the plugin to `netlify.toml` if not already installed:
27
+ ...then add the plugin to your `netlify.toml` file:
31
28
 
32
29
  ```toml
33
- [build]
34
- publish = ".next"
35
-
36
30
  [[plugins]]
37
31
  package = "@netlify/plugin-nextjs"
38
32
  ```
39
33
 
40
- If you previously set a custom `distDir` in your `next.config.js`, or set `node_bundler` or `external_node_modules` in
41
- your `netlify.toml` these are no longer needed and can be removed.
34
+ ## Migrating from an older version of the plugin
35
+
36
+ You can manually upgrade from the previous version of the plugin by running the following command:
37
+
38
+ ```shell
39
+ npm install -D @netlify/plugin-nextjs@latest
40
+ ```
41
+
42
+ Change the `publish` directory to `.next`:
43
+
44
+ ```toml
45
+ [build]
46
+ publish = ".next"
47
+ ```
48
+
49
+ If you previously set these values, they're no longer needed and can be removed:
50
+
51
+ - `distDir` in your `next.config.js`
52
+ - `node_bundler = "esbuild"` in `netlify.toml`
53
+ - `external_node_modules` in `netlify.toml`
42
54
 
43
55
  The `serverless` and `experimental-serverless-trace` targets are deprecated in Next 12, and all builds with this plugin
44
56
  will now use the default `server` target. If you previously set the target in your `next.config.js`, you should remove
45
57
  it.
46
58
 
47
- If you are using a monorepo you will need to change `publish` to point to the full path to the built `.next` directory,
48
- which may be in a subdirectory. If you have changed your `distDir` then it will need to match that.
49
-
50
- If you are using Nx, then you will need to point `publish` to the folder inside `dist`, e.g. `dist/apps/myapp/.next`.
51
-
52
59
  If you currently use redirects or rewrites on your site, see
53
60
  [the Rewrites and Redirects guide](https://github.com/netlify/netlify-plugin-nextjs/blob/main/docs/redirects-rewrites.md)
54
61
  for information on changes to how they are handled in this version.
@@ -57,7 +64,20 @@ If you want to use Next 12's beta Middleware feature, this will mostly work as e
57
64
  [read the docs on some caveats and workarounds](https://github.com/netlify/netlify-plugin-nextjs/blob/main/docs/middleware.md)
58
65
  that are currently needed.
59
66
 
60
- ## Beta feedback
67
+ ## Monorepos
68
+
69
+ If you are using a monorepo you will need to change `publish` to point to the full path to the built `.next` directory,
70
+ which may be in a subdirectory. If you have changed your `distDir` then it will need to match that.
71
+
72
+ If you are using Nx, then you will need to point `publish` to the folder inside `dist`, e.g. `dist/apps/myapp/.next`.
73
+
74
+ ## Incremental Static Regeneration (ISR)
75
+
76
+ The Essential Next.js plugin now fully supports ISR on Netlify. For more details see
77
+ [the ISR docs](https://github.com/netlify/netlify-plugin-nextjs/blob/main/docs/isr.md).
78
+
79
+ ## Feedback
61
80
 
62
- Please share any thoughts, feedback or questions about the beta
63
- [in our discussion](https://github.com/netlify/netlify-plugin-nextjs/discussions/706).
81
+ If you think you have found a bug in the plugin,
82
+ [please open an issue](https://github.com/netlify/netlify-plugin-nextjs/issues). If you have comments or feature
83
+ requests, [see the dicussion board](https://github.com/netlify/netlify-plugin-nextjs/discussions)
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
22
22
  return (mod && mod.__esModule) ? mod : { "default": mod };
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.logBetaMessage = exports.checkZipSize = exports.checkForRootPublish = exports.checkNextSiteHasBuilt = exports.checkForOldFunctions = exports.verifyNetlifyBuildVersion = void 0;
25
+ exports.checkZipSize = exports.checkForRootPublish = exports.checkNextSiteHasBuilt = exports.checkForOldFunctions = exports.verifyNetlifyBuildVersion = void 0;
26
26
  const fs_1 = require("fs");
27
27
  const path_1 = __importStar(require("path"));
28
28
  const chalk_1 = require("chalk");
@@ -61,9 +61,12 @@ const checkForOldFunctions = async ({ functions }) => {
61
61
  exports.checkForOldFunctions = checkForOldFunctions;
62
62
  const checkNextSiteHasBuilt = ({ publish, failBuild, }) => {
63
63
  if (!fs_1.existsSync(path_1.default.join(publish, 'BUILD_ID'))) {
64
+ const outWarning = path_1.default.basename(publish) === 'out'
65
+ ? `Your publish directory is set to "out", but in most cases it should be ".next".`
66
+ : `In most cases it should be set to ".next", unless you have chosen a custom "distDir" in your Next config.`;
64
67
  return failBuild(outdent_1.outdent `
65
- 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.
66
- In most cases it should be set to the site's ".next" directory path, unless you have chosen a custom "distDir" in your Next config.
68
+ 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
+ ${outWarning}
67
70
  If you are using "next export" then the Essential Next.js plugin should be removed. See https://ntl.fyi/remove-plugin for details.
68
71
  `);
69
72
  }
@@ -116,8 +119,3 @@ const checkZipSize = async (file, maxSize = constants_1.LAMBDA_MAX_SIZE) => {
116
119
  console.log(chalk_1.greenBright `\n\nFor more information on fixing this, see ${chalk_1.blueBright `https://ntl.fyi/large-next-functions`}`);
117
120
  };
118
121
  exports.checkZipSize = checkZipSize;
119
- const logBetaMessage = () => console.log(chalk_1.greenBright(outdent_1.outdent `
120
- Thank you for trying the Essential Next.js beta plugin.
121
- Please share feedback (both good and bad) at ${chalk_1.blueBright `https://ntl.fyi/next-beta-feedback`}
122
- `));
123
- exports.logBetaMessage = logBetaMessage;
package/lib/index.js CHANGED
@@ -11,7 +11,6 @@ const verification_1 = require("./helpers/verification");
11
11
  const plugin = {
12
12
  async onPreBuild({ constants, netlifyConfig, utils: { build: { failBuild }, cache, }, }) {
13
13
  var _a;
14
- verification_1.logBetaMessage();
15
14
  const { publish } = netlifyConfig.build;
16
15
  verification_1.checkForRootPublish({ publish, failBuild });
17
16
  verification_1.verifyNetlifyBuildVersion({ failBuild, ...constants });
@@ -53,8 +52,5 @@ const plugin = {
53
52
  const { basePath } = await config_1.getNextConfig({ publish: netlifyConfig.build.publish, failBuild });
54
53
  await files_1.unpatchNextFiles(basePath);
55
54
  },
56
- onEnd() {
57
- verification_1.logBetaMessage();
58
- },
59
55
  };
60
56
  module.exports = plugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/plugin-nextjs",
3
- "version": "4.0.0-rc.2",
3
+ "version": "4.0.0",
4
4
  "description": "Run Next.js seamlessly on Netlify",
5
5
  "main": "lib/index.js",
6
6
  "files": [
@@ -74,7 +74,7 @@
74
74
  "@babel/core": "^7.15.8",
75
75
  "@babel/preset-env": "^7.15.8",
76
76
  "@babel/preset-typescript": "^7.16.0",
77
- "@netlify/build": "^20.2.0",
77
+ "@netlify/build": "^20.3.0",
78
78
  "@netlify/eslint-config-node": "^4.0.0",
79
79
  "@testing-library/cypress": "^8.0.1",
80
80
  "@types/fs-extra": "^9.0.13",