@netlify/plugin-nextjs 4.20.0 → 4.21.3
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/index.js +1 -0
- package/package.json +5 -6
- package/src/templates/edge/next-dev.js +4 -5
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/index.js
CHANGED
|
@@ -45,6 +45,7 @@ const plugin = {
|
|
|
45
45
|
publish,
|
|
46
46
|
failBuild,
|
|
47
47
|
});
|
|
48
|
+
await (0, edge_1.cleanupEdgeFunctions)(constants);
|
|
48
49
|
const middlewareManifest = await (0, edge_1.loadMiddlewareManifest)(netlifyConfig);
|
|
49
50
|
let usingEdge = false;
|
|
50
51
|
if ((middlewareManifest === null || middlewareManifest === void 0 ? void 0 : middlewareManifest.functions) && Object.keys(middlewareManifest.functions).length !== 0) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/plugin-nextjs",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.21.3",
|
|
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",
|
|
@@ -48,9 +50,6 @@
|
|
|
48
50
|
"watch": "tsc --watch",
|
|
49
51
|
"prepare": "npm run build"
|
|
50
52
|
},
|
|
51
|
-
"peerDependencies": {
|
|
52
|
-
"next": "*"
|
|
53
|
-
},
|
|
54
53
|
"repository": {
|
|
55
54
|
"type": "git",
|
|
56
55
|
"url": "git+https://github.com/netlify/next-runtime.git"
|
|
@@ -22,11 +22,10 @@ const exists = async (relativePath) => {
|
|
|
22
22
|
let idx = 0
|
|
23
23
|
|
|
24
24
|
const handler = async (req, context) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// }
|
|
25
|
+
if (!Deno.env.get('NETLIFY_DEV')) {
|
|
26
|
+
// Only run in dev
|
|
27
|
+
return
|
|
28
|
+
}
|
|
30
29
|
|
|
31
30
|
let middleware
|
|
32
31
|
// Dynamic imports and FS operations aren't allowed when deployed,
|