@netlify/plugin-nextjs 4.21.1 → 4.22.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 +17 -0
- package/lib/helpers/dev.js +24 -13
- package/lib/helpers/edge.js +5 -1
- package/lib/helpers/utils.js +14 -1
- package/lib/index.js +2 -5
- package/package.json +5 -3
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
# `@netlify/plugin-nextjs`
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a aria-label="npm version" href="https://www.npmjs.com/package/@netlify/plugin-nextjs">
|
|
7
|
+
<img alt="" src="https://img.shields.io/npm/v/@netlify/plugin-nextjs">
|
|
8
|
+
</a>
|
|
9
|
+
<a aria-label="MIT License" href="https://img.shields.io/npm/l/@netlify/plugin-nextjs">
|
|
10
|
+
<img alt="" src="https://img.shields.io/npm/l/@netlify/plugin-nextjs">
|
|
11
|
+
</a>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
This package handles the build process for Next.js sites on Netlify. You should not normally need to install it
|
|
15
|
+
yourself, as it is used automatically during builds of Next.js sites. See
|
|
16
|
+
[the docs for using Next.js on Netlify](https://docs.netlify.com/integrations/frameworks/next-js/overview/) for more
|
|
17
|
+
details.
|
package/lib/helpers/dev.js
CHANGED
|
@@ -5,8 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.onPreDev = void 0;
|
|
7
7
|
const path_1 = require("path");
|
|
8
|
+
const stream_1 = require("stream");
|
|
8
9
|
const execa_1 = __importDefault(require("execa"));
|
|
9
10
|
const fs_extra_1 = require("fs-extra");
|
|
11
|
+
const merge_stream_1 = __importDefault(require("merge-stream"));
|
|
10
12
|
const edge_1 = require("./edge");
|
|
11
13
|
const files_1 = require("./files");
|
|
12
14
|
// The types haven't been updated yet
|
|
@@ -20,18 +22,27 @@ const onPreDev = async ({ constants, netlifyConfig }) => {
|
|
|
20
22
|
// Ignore if it doesn't exist
|
|
21
23
|
});
|
|
22
24
|
await (0, edge_1.writeDevEdgeFunction)(constants);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
25
|
+
// Eventually we might want to do this via esbuild's API, but for now the CLI works fine
|
|
26
|
+
const common = [`--bundle`, `--outdir=${(0, path_1.resolve)('.netlify')}`, `--format=esm`, `--target=esnext`, '--watch'];
|
|
27
|
+
const opts = {
|
|
28
|
+
all: true,
|
|
29
|
+
env: { ...process.env, FORCE_COLOR: '1' },
|
|
30
|
+
};
|
|
31
|
+
// TypeScript
|
|
32
|
+
const tsout = (0, execa_1.default)(`esbuild`, [...common, (0, path_1.resolve)(base, 'middleware.ts')], opts).all;
|
|
33
|
+
// JavaScript
|
|
34
|
+
const jsout = (0, execa_1.default)(`esbuild`, [...common, (0, path_1.resolve)(base, 'middleware.js')], opts).all;
|
|
35
|
+
const filter = new stream_1.Transform({
|
|
36
|
+
transform(chunk, encoding, callback) {
|
|
37
|
+
const str = chunk.toString(encoding);
|
|
38
|
+
// Skip if message includes this, because we run even when the files are missing
|
|
39
|
+
if (!str.includes('[ERROR] Could not resolve')) {
|
|
40
|
+
this.push(chunk);
|
|
41
|
+
}
|
|
42
|
+
callback();
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
(0, merge_stream_1.default)(tsout, jsout).pipe(filter).pipe(process.stdout);
|
|
46
|
+
// Don't return the promise because we don't want to wait for the child process to finish
|
|
36
47
|
};
|
|
37
48
|
exports.onPreDev = onPreDev;
|
package/lib/helpers/edge.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.enableEdgeInNextConfig = exports.writeEdgeFunctions = exports.writeDevEdgeFunction = exports.loadMiddlewareManifest = void 0;
|
|
3
|
+
exports.enableEdgeInNextConfig = exports.writeEdgeFunctions = exports.writeDevEdgeFunction = exports.cleanupEdgeFunctions = exports.loadMiddlewareManifest = void 0;
|
|
4
4
|
/* eslint-disable max-lines */
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const path_1 = require("path");
|
|
@@ -67,6 +67,10 @@ const writeEdgeFunction = async ({ edgeFunctionDefinition, edgeFunctionRoot, net
|
|
|
67
67
|
pattern: stripLookahead(edgeFunctionDefinition.regexp),
|
|
68
68
|
};
|
|
69
69
|
};
|
|
70
|
+
const cleanupEdgeFunctions = async ({ INTERNAL_EDGE_FUNCTIONS_SRC = '.netlify/edge-functions', }) => {
|
|
71
|
+
await (0, fs_extra_1.emptyDir)(INTERNAL_EDGE_FUNCTIONS_SRC);
|
|
72
|
+
};
|
|
73
|
+
exports.cleanupEdgeFunctions = cleanupEdgeFunctions;
|
|
70
74
|
const writeDevEdgeFunction = async ({ INTERNAL_EDGE_FUNCTIONS_SRC = '.netlify/edge-functions', }) => {
|
|
71
75
|
const manifest = {
|
|
72
76
|
functions: [
|
package/lib/helpers/utils.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isBundleSizeCheckDisabled = exports.getCustomImageResponseHeaders = exports.isNextAuthInstalled = exports.findModuleFromBase = exports.shouldSkip = exports.getPreviewRewrites = exports.getApiRewrites = exports.redirectsForNextRouteWithData = exports.redirectsForNextRoute = exports.isApiRoute = exports.routeToDataRoute = exports.netlifyRoutesForNextRouteWithData = exports.toNetlifyRoute = void 0;
|
|
6
|
+
exports.getRemotePatterns = exports.isBundleSizeCheckDisabled = exports.getCustomImageResponseHeaders = exports.isNextAuthInstalled = exports.findModuleFromBase = exports.shouldSkip = exports.getPreviewRewrites = exports.getApiRewrites = exports.redirectsForNextRouteWithData = exports.redirectsForNextRoute = exports.isApiRoute = exports.routeToDataRoute = exports.netlifyRoutesForNextRouteWithData = exports.toNetlifyRoute = void 0;
|
|
7
7
|
const globby_1 = __importDefault(require("globby"));
|
|
8
8
|
const pathe_1 = require("pathe");
|
|
9
9
|
const constants_1 = require("../constants");
|
|
@@ -156,4 +156,17 @@ const getCustomImageResponseHeaders = (headers) => {
|
|
|
156
156
|
exports.getCustomImageResponseHeaders = getCustomImageResponseHeaders;
|
|
157
157
|
const isBundleSizeCheckDisabled = () => process.env.DISABLE_BUNDLE_ZIP_SIZE_CHECK === '1' || process.env.DISABLE_BUNDLE_ZIP_SIZE_CHECK === 'true';
|
|
158
158
|
exports.isBundleSizeCheckDisabled = isBundleSizeCheckDisabled;
|
|
159
|
+
const getRemotePatterns = (experimental, images) => {
|
|
160
|
+
var _a;
|
|
161
|
+
// Where remote patterns is configured pre-v12.2.5
|
|
162
|
+
if ((_a = experimental.images) === null || _a === void 0 ? void 0 : _a.remotePatterns) {
|
|
163
|
+
return experimental.images.remotePatterns;
|
|
164
|
+
}
|
|
165
|
+
// Where remote patterns is configured after v12.2.5
|
|
166
|
+
if (images.remotePatterns) {
|
|
167
|
+
return images.remotePatterns || [];
|
|
168
|
+
}
|
|
169
|
+
return [];
|
|
170
|
+
};
|
|
171
|
+
exports.getRemotePatterns = getRemotePatterns;
|
|
159
172
|
/* eslint-enable max-lines */
|
package/lib/index.js
CHANGED
|
@@ -40,11 +40,11 @@ const plugin = {
|
|
|
40
40
|
}
|
|
41
41
|
const { publish } = netlifyConfig.build;
|
|
42
42
|
(0, verification_1.checkNextSiteHasBuilt)({ publish, failBuild });
|
|
43
|
-
let experimentalRemotePatterns = [];
|
|
44
43
|
const { appDir, basePath, i18n, images, target, ignore, trailingSlash, outdir, experimental } = await (0, config_1.getNextConfig)({
|
|
45
44
|
publish,
|
|
46
45
|
failBuild,
|
|
47
46
|
});
|
|
47
|
+
await (0, edge_1.cleanupEdgeFunctions)(constants);
|
|
48
48
|
const middlewareManifest = await (0, edge_1.loadMiddlewareManifest)(netlifyConfig);
|
|
49
49
|
let usingEdge = false;
|
|
50
50
|
if ((middlewareManifest === null || middlewareManifest === void 0 ? void 0 : middlewareManifest.functions) && Object.keys(middlewareManifest.functions).length !== 0) {
|
|
@@ -67,9 +67,6 @@ const plugin = {
|
|
|
67
67
|
`));
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
if (experimental.images) {
|
|
71
|
-
experimentalRemotePatterns = experimental.images.remotePatterns || [];
|
|
72
|
-
}
|
|
73
70
|
if ((0, utils_1.isNextAuthInstalled)()) {
|
|
74
71
|
const config = await (0, config_1.getRequiredServerFiles)(publish);
|
|
75
72
|
const userDefinedNextAuthUrl = config.config.env.NEXTAUTH_URL;
|
|
@@ -101,7 +98,7 @@ const plugin = {
|
|
|
101
98
|
imageconfig: images,
|
|
102
99
|
netlifyConfig,
|
|
103
100
|
basePath,
|
|
104
|
-
remotePatterns:
|
|
101
|
+
remotePatterns: (0, utils_1.getRemotePatterns)(experimental, images),
|
|
105
102
|
responseHeaders: (0, utils_1.getCustomImageResponseHeaders)(netlifyConfig.headers),
|
|
106
103
|
});
|
|
107
104
|
await (0, redirects_1.generateRedirects)({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/plugin-nextjs",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.22.0",
|
|
4
4
|
"description": "Run Next.js seamlessly on Netlify",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -11,12 +11,13 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@netlify/esbuild": "0.14.25",
|
|
13
13
|
"@netlify/functions": "^1.2.0",
|
|
14
|
-
"@netlify/ipx": "^1.2.
|
|
14
|
+
"@netlify/ipx": "^1.2.4",
|
|
15
15
|
"@vercel/node-bridge": "^2.1.0",
|
|
16
16
|
"chalk": "^4.1.2",
|
|
17
17
|
"execa": "^5.1.1",
|
|
18
18
|
"fs-extra": "^10.0.0",
|
|
19
19
|
"globby": "^11.0.4",
|
|
20
|
+
"merge-stream": "^2.0.0",
|
|
20
21
|
"moize": "^6.1.0",
|
|
21
22
|
"node-fetch": "^2.6.6",
|
|
22
23
|
"node-stream-zip": "^1.15.0",
|
|
@@ -30,9 +31,10 @@
|
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
33
|
"@delucis/if-env": "^1.1.2",
|
|
33
|
-
"@netlify/build": "^27.
|
|
34
|
+
"@netlify/build": "^27.17.1",
|
|
34
35
|
"@types/fs-extra": "^9.0.13",
|
|
35
36
|
"@types/jest": "^27.4.1",
|
|
37
|
+
"@types/merge-stream": "^1.1.2",
|
|
36
38
|
"@types/node": "^17.0.25",
|
|
37
39
|
"next": "^12.2.0",
|
|
38
40
|
"npm-run-all": "^4.1.5",
|