Skip to content

Commit 61b61f5

Browse files
jlengstorflindsaylevinerstavchanskyehmicky
authored
feat: merge next-on-netlify into the core plugin repo (#106)
* foundation: embed NoN into plugin under src/ * wip: updates to test paths, but things still aren’t working * fix: use next@^10.0.6 for i18n * [email protected] release * wip: start changelog entry for review * chore: update version + installation instructions * fix: edit for clarity Co-authored-by: rstavchansky <[email protected]> * fix: add link + edit for clarity Co-authored-by: rstavchansky <[email protected]> * fix: add UI-based install back in * fix: add NoN migration guide link * fix: include src in published package * [email protected] release * fix: package description * fix: next 10.0.8 changes loadConfig to be async (#105) * fix: 10.0.8 changes loadConfig to be async * wip: make literally everything async bc loadConfig * wip: fix i18n bug, got 10.0.6 tests to pass * wip: NoN tests pass on 10.0.8 but plugin test chdir fixture issue * Fix bug with Jest * fix: delete TO-DO Co-authored-by: ehmicky <[email protected]> Co-authored-by: Lindsay Levine <[email protected]> Co-authored-by: rstavchansky <[email protected]> Co-authored-by: lindsaylevine <[email protected]> Co-authored-by: ehmicky <[email protected]>
1 parent b5c9001 commit 61b61f5

File tree

221 files changed

+18386
-3235
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

221 files changed

+18386
-3235
lines changed

Diff for: .prettierignore

+2
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ __mocks__
2121
test/fixtures
2222
test/sample
2323
next.config.js
24+
src/cypress/builds/
25+
src/tests/builds/

Diff for: CHANGELOG.md

+23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
# Changelog
22

3+
## 3.0.0 (2021-03-??)
4+
5+
- feat: merge `next-on-netlify` into `@netlify/plugin-nextjs`
6+
7+
This improves our ability to maintain the plugin, reduces confusion about how to configure Next.js support for Netlify builds, and prepares the plugin for something we're pretty dang excited about: automatic installation for new Next.js projects!
8+
9+
> **NOTE: There are no breaking changes for existing plugin users.** This is a major release because we're bringing an external package into the plugin _and_ turning on automatic installation for new Next.js projects on Netlify. This doesn't break anything, but it's a big enough change that we wanted to treat it as a major release.
10+
11+
### Migrating from v2 to v3
12+
13+
If you've installed this plugin via Netlify's UI, no action is necessary. The upgrade is automatic.
14+
15+
If you've installed this plugin manually in your `netlify.toml`, you can upgrade two ways:
16+
17+
1. Manually update to the latest version using `npm i @netlify/plugin-nextjs@latest`.
18+
2. If you prefer to automatically get updates, remove this plugin from your project and `netlify.toml`, then [install the plugin using the Netlify UI](http://app.netlify.com/plugins/@netlify/plugin-nextjs/install).
19+
20+
### Migrating from the original `next-on-netlify` package
21+
22+
As part of the 3.0.0 release, `next-on-netlify` has been deprecated and merged into the Essential Next.js Build Plugin. If your site is using the `next-on-netlify` package, you'll need to switch over to the plugin to get future updates.
23+
24+
For instructions on migrating from `next-on-netlify` to the Essential Next.js Build Plugin, please see the [migration guide on the `next-on-netlify` repo](https://github.com/netlify/next-on-netlify/blob/main/MIGRATING.md).
25+
326
## 2.0.1 (2021-02-17)
427

528
- fail build if plugin cant load next.config.js ([#99](https://github.com/netlify/netlify-plugin-nextjs/pull/99))

Diff for: README.md

+31-27
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![Next.js on Netlify Build Plugin](next-on-netlify.png)
22

3-
# Next.js Build Plugin
3+
# Essential Next.js Build Plugin
44

55
<p align="center">
66
<a aria-label="npm version" href="https://www.npmjs.com/package/@netlify/plugin-nextjs">
@@ -26,46 +26,50 @@ This build plugin is a utility for supporting Next.js on Netlify. To enable serv
2626

2727
## Installation and Configuration
2828

29-
There are two ways to install the plugin in your Next.js on Netlify site: with the Netlify UI or with file-based installation.
29+
### For new Next.js sites
3030

31-
**UI-based Installation**
31+
As of v3.0.0, all new sites deployed to Netlify with Next.js will automatically install this plugin for a seamless experience deploying Next.js on Netlify!
3232

33-
You can install this plugin using this [direct in-app installation link](http://app.netlify.com/plugins/@netlify/plugin-nextjs/install) or from your team's [Plugins directory](https://app.netlify.com/plugins) in the Netlify UI.
33+
This means that you don't have to do anything — just build and deploy your site to Netlify as usual and we'll handle the rest.
3434

35-
Read more about [UI-based plugin installation](https://docs.netlify.com/configure-builds/build-plugins/#ui-installation) in our docs.
35+
You're able to [remove the plugin](https://docs.netlify.com/configure-builds/build-plugins/#remove-a-plugin) at any time by visiting the **Plugins** tab for your site in the Netlify UI.
3636

37-
**File-based Installation**
37+
### UI-based installation for existing Next.js sites
3838

39-
1. Create a `netlify.toml` in the root of your project. Your file should include the plugins section below:
39+
If your Next.js project is already deployed to Netlify, use the Netlify UI to [install the Essential Next.js Build Plugin](http://app.netlify.com/plugins/@netlify/plugin-nextjs/install) in a few clicks.
4040

41-
```toml
42-
[build]
43-
command = "npm run build"
44-
publish = "out"
41+
### Manual installation
4542

46-
[[plugins]]
47-
package = "@netlify/plugin-nextjs"
48-
```
43+
1\. Create a `netlify.toml` in the root of your project. Your file should include the plugins section below:
44+
45+
```toml
46+
[build]
47+
command = "npm run build"
48+
publish = "out"
49+
50+
[[plugins]]
51+
package = "@netlify/plugin-nextjs"
52+
```
4953

5054
You can also add context-specific properties and environment variables to your `netlify.toml`. Read more about [deploy contexts](https://docs.netlify.com/configure-builds/file-based-configuration/#deploy-contexts) in our docs. For example:
5155

52-
```toml
53-
[context.production.environment]
54-
NEXT_SERVERLESS = "true"
55-
NODE_ENV = "production"
56-
```
56+
```toml
57+
[context.production.environment]
58+
NEXT_SERVERLESS = "true"
59+
NODE_ENV = "production"
60+
```
5761

58-
2. From your project's base directory, use `npm`, `yarn`, or any other Node.js package manager to add this plugin to `devDependencies` in `package.json`.
62+
2\. From your project's base directory, use `npm`, `yarn`, or any other Node.js package manager to add this plugin to `devDependencies` in `package.json`.
5963

60-
```
61-
npm install -D @netlify/plugin-nextjs
62-
```
64+
```
65+
npm install -D @netlify/plugin-nextjs
66+
```
6367

64-
or
68+
or
6569

66-
```
67-
yarn add -D @netlify/plugin-nextjs
68-
```
70+
```
71+
yarn add -D @netlify/plugin-nextjs
72+
```
6973

7074
Read more about [file-based plugin installation](https://docs.netlify.com/configure-builds/build-plugins/#file-based-installation) in our docs.
7175

Diff for: helpers/doesNotNeedPlugin.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const doesNotNeedPlugin = async ({ netlifyConfig, packageJson, utils }) => {
1313
return (
1414
isStaticExportProject({ build, scripts }) ||
1515
doesSiteUseNextOnNetlify({ packageJson }) ||
16-
!hasCorrectNextConfig({ nextConfigPath, failBuild: utils.build.failBuild })
16+
!(await hasCorrectNextConfig({ nextConfigPath, failBuild: utils.build.failBuild }))
1717
)
1818
}
1919

Diff for: helpers/hasCorrectNextConfig.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const path = require('path')
22

33
// Checks if site has the correct next.cofig.js
4-
const hasCorrectNextConfig = ({ nextConfigPath, failBuild }) => {
4+
const hasCorrectNextConfig = async ({ nextConfigPath, failBuild }) => {
55
// In the plugin's case, no config is valid because we'll make it ourselves
66
if (nextConfigPath === undefined) return true
77

@@ -14,7 +14,7 @@ const hasCorrectNextConfig = ({ nextConfigPath, failBuild }) => {
1414
const acceptableTargets = ['serverless', 'experimental-serverless-trace']
1515
let nextConfig
1616
try {
17-
nextConfig = loadConfig(PHASE_PRODUCTION_BUILD, path.resolve('.'))
17+
nextConfig = await loadConfig(PHASE_PRODUCTION_BUILD, path.resolve('.'))
1818
} catch (error) {
1919
return failBuild('Error loading your next.config.js.', { error })
2020
}

Diff for: index.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const path = require('path')
33
const util = require('util')
44
const makeDir = require('make-dir')
55
const findUp = require('find-up')
6+
const nextOnNetlify = require('./src/index.js')
67

78
const validateNextUsage = require('./helpers/validateNextUsage')
89
const doesNotNeedPlugin = require('./helpers/doesNotNeedPlugin')
@@ -53,11 +54,7 @@ module.exports = {
5354

5455
await makeDir(PUBLISH_DIR)
5556

56-
// We cannot load `next-on-netlify` (which depends on `next`) at the
57-
// top-level because we validate whether the site is using `next`
58-
// inside `onPreBuild`.
59-
const nextOnNetlify = require('next-on-netlify')
60-
nextOnNetlify({ functionsDir: FUNCTIONS_SRC, publishDir: PUBLISH_DIR })
57+
await nextOnNetlify({ functionsDir: FUNCTIONS_SRC, publishDir: PUBLISH_DIR })
6158
},
6259
}
6360

0 commit comments

Comments
 (0)