@netlify/plugin-nextjs 4.15.0 → 4.16.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/lib/helpers/files.js +7 -2
- package/lib/index.js +0 -1
- package/lib/templates/getHandler.js +7 -0
- package/package.json +7 -8
package/lib/helpers/files.js
CHANGED
|
@@ -229,6 +229,7 @@ const moveStaticPages = async ({ netlifyConfig, target, i18n, basePath, }) => {
|
|
|
229
229
|
}
|
|
230
230
|
};
|
|
231
231
|
exports.moveStaticPages = moveStaticPages;
|
|
232
|
+
const PATCH_WARNING = `/* File patched by Netlify */`;
|
|
232
233
|
/**
|
|
233
234
|
* Attempt to patch a source file, preserving a backup
|
|
234
235
|
*/
|
|
@@ -237,7 +238,11 @@ const patchFile = async ({ file, replacements, }) => {
|
|
|
237
238
|
console.warn('File was not found');
|
|
238
239
|
return false;
|
|
239
240
|
}
|
|
240
|
-
|
|
241
|
+
let content = await (0, fs_extra_1.readFile)(file, 'utf8');
|
|
242
|
+
// If the file has already been patched, patch the backed-up original instead
|
|
243
|
+
if (content.includes(PATCH_WARNING) && (0, fs_extra_1.existsSync)(`${file}.orig`)) {
|
|
244
|
+
content = await (0, fs_extra_1.readFile)(`${file}.orig`, 'utf8');
|
|
245
|
+
}
|
|
241
246
|
const newContent = replacements.reduce((acc, [from, to]) => {
|
|
242
247
|
if (acc.includes(to)) {
|
|
243
248
|
console.log('Already patched. Skipping.');
|
|
@@ -250,7 +255,7 @@ const patchFile = async ({ file, replacements, }) => {
|
|
|
250
255
|
return false;
|
|
251
256
|
}
|
|
252
257
|
await (0, fs_extra_1.writeFile)(`${file}.orig`, content);
|
|
253
|
-
await (0, fs_extra_1.writeFile)(file, newContent);
|
|
258
|
+
await (0, fs_extra_1.writeFile)(file, `${newContent}\n${PATCH_WARNING}`);
|
|
254
259
|
console.log('Done');
|
|
255
260
|
return true;
|
|
256
261
|
};
|
package/lib/index.js
CHANGED
|
@@ -123,7 +123,6 @@ const plugin = {
|
|
|
123
123
|
(0, config_1.generateCustomHeaders)(nextConfig, headers);
|
|
124
124
|
(0, verification_1.warnForProblematicUserRewrites)({ basePath, redirects });
|
|
125
125
|
(0, verification_1.warnForRootRedirects)({ appDir });
|
|
126
|
-
await (0, files_1.unpatchNextFiles)(basePath);
|
|
127
126
|
},
|
|
128
127
|
};
|
|
129
128
|
module.exports = plugin;
|
|
@@ -81,6 +81,13 @@ const makeHandler = (conf, app, pageRoot, staticManifest = [], mode = 'ssr') =>
|
|
|
81
81
|
// Next expects to be able to parse the query from the URL
|
|
82
82
|
const query = new URLSearchParams(event.queryStringParameters).toString();
|
|
83
83
|
event.path = query ? `${event.path}?${query}` : event.path;
|
|
84
|
+
const graphToken = event.netlifyGraphToken;
|
|
85
|
+
if (graphToken && requestMode !== 'ssr') {
|
|
86
|
+
// Prefix with underscore to help us determine the origin of the token
|
|
87
|
+
// allows us to write better error messages
|
|
88
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
89
|
+
process.env._NETLIFY_GRAPH_TOKEN = graphToken;
|
|
90
|
+
}
|
|
84
91
|
const { headers, ...result } = await getBridge(event).launcher(event, context);
|
|
85
92
|
// Convert all headers to multiValueHeaders
|
|
86
93
|
const multiValueHeaders = getMultiValueHeaders(headers);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/plugin-nextjs",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.16.0",
|
|
4
4
|
"description": "Run Next.js seamlessly on Netlify",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"manifest.yml"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@netlify/functions": "^1.
|
|
13
|
-
"@netlify/ipx": "^1.2.
|
|
12
|
+
"@netlify/functions": "^1.1.0",
|
|
13
|
+
"@netlify/ipx": "^1.2.1",
|
|
14
14
|
"@vercel/node-bridge": "^2.1.0",
|
|
15
15
|
"chalk": "^4.1.2",
|
|
16
16
|
"fs-extra": "^10.0.0",
|
|
@@ -51,15 +51,14 @@
|
|
|
51
51
|
},
|
|
52
52
|
"repository": {
|
|
53
53
|
"type": "git",
|
|
54
|
-
"url": "git+https://github.com/netlify/
|
|
54
|
+
"url": "git+https://github.com/netlify/next-runtime.git"
|
|
55
55
|
},
|
|
56
|
-
"author": "",
|
|
57
56
|
"license": "MIT",
|
|
58
57
|
"bugs": {
|
|
59
|
-
"url": "https://github.com/netlify/
|
|
58
|
+
"url": "https://github.com/netlify/next-runtime/issues"
|
|
60
59
|
},
|
|
61
|
-
"homepage": "https://github.com/netlify/
|
|
60
|
+
"homepage": "https://github.com/netlify/next-runtime#readme",
|
|
62
61
|
"engines": {
|
|
63
62
|
"node": ">=12.0.0"
|
|
64
63
|
}
|
|
65
|
-
}
|
|
64
|
+
}
|