@netlify/plugin-nextjs 4.0.0-beta.5 → 4.0.0-beta.6
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/config.js +1 -1
- package/lib/helpers/files.js +23 -20
- package/lib/index.js +0 -1
- package/package.json +3 -2
package/lib/helpers/config.js
CHANGED
|
@@ -114,7 +114,7 @@ exports.configureHandlerFunctions = ({ netlifyConfig, publish, ignore = [] }) =>
|
|
|
114
114
|
(_a = netlifyConfig.functions)[functionName] || (_a[functionName] = { included_files: [], external_node_modules: [] });
|
|
115
115
|
netlifyConfig.functions[functionName].node_bundler = 'nft';
|
|
116
116
|
(_b = netlifyConfig.functions[functionName]).included_files || (_b.included_files = []);
|
|
117
|
-
netlifyConfig.functions[functionName].included_files.push(`${publish}/server/**`, `${publish}/serverless/**`, `${publish}/*.json`, `${publish}/BUILD_ID`, `${publish}/static/chunks/webpack-middleware*.js`, ...ignore.map((path) => `!${slash(path)}`));
|
|
117
|
+
netlifyConfig.functions[functionName].included_files.push(`${publish}/server/**`, `${publish}/serverless/**`, `${publish}/*.json`, `${publish}/BUILD_ID`, `${publish}/static/chunks/webpack-middleware*.js`, `!${publish}/server/**/*.js.nft.json`, ...ignore.map((path) => `!${slash(path)}`));
|
|
118
118
|
const nextRoot = resolveModuleRoot('next');
|
|
119
119
|
if (nextRoot) {
|
|
120
120
|
netlifyConfig.functions[functionName].included_files.push(`!${nextRoot}/dist/server/lib/squoosh/**/*.wasm`, `!${nextRoot}/dist/next-server/server/lib/squoosh/**/*.wasm`, `!${nextRoot}/dist/compiled/webpack/bundle4.js`, `!${nextRoot}/dist/compiled/webpack/bundle5.js`, `!${nextRoot}/dist/compiled/terser/bundle.min.js`);
|
package/lib/helpers/files.js
CHANGED
|
@@ -1,43 +1,46 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
+
const { cpus } = require('os');
|
|
2
3
|
const { existsSync, readJson, move, cpSync, copy, writeJson } = require('fs-extra');
|
|
4
|
+
const globby = require('globby');
|
|
3
5
|
const pLimit = require('p-limit');
|
|
4
6
|
const { join } = require('pathe');
|
|
5
|
-
const
|
|
7
|
+
const slash = require('slash');
|
|
8
|
+
const TEST_ROUTE = /(|\/)\[[^/]+?](\/|\.html|$)/;
|
|
6
9
|
const isDynamicRoute = (route) => TEST_ROUTE.test(route);
|
|
7
10
|
exports.moveStaticPages = async ({ netlifyConfig, target, i18n, failBuild }) => {
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
if (!existsSync(pagesManifestPath)) {
|
|
11
|
-
failBuild(`Could not find pages manifest at ${pagesManifestPath}`);
|
|
12
|
-
}
|
|
11
|
+
console.log('Moving static page files to serve from CDN...');
|
|
12
|
+
const root = join(netlifyConfig.build.publish, target === 'server' ? 'server' : 'serverless', 'pages');
|
|
13
13
|
const files = [];
|
|
14
14
|
const moveFile = async (file) => {
|
|
15
15
|
const source = join(root, file);
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
files.push(filePath);
|
|
19
|
-
const dest = join(netlifyConfig.build.publish, filePath);
|
|
16
|
+
files.push(file);
|
|
17
|
+
const dest = join(netlifyConfig.build.publish, file);
|
|
20
18
|
await move(source, dest);
|
|
21
19
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
// Move all static files, except error documents and nft manifests
|
|
21
|
+
const pages = await globby(['**/*.{html,json}', '!**/(500|404|*.js.nft).{html,json}'], {
|
|
22
|
+
cwd: root,
|
|
23
|
+
dot: true,
|
|
24
|
+
});
|
|
25
|
+
// Limit concurrent file moves to number of cpus or 2 if there is only 1
|
|
26
|
+
const limit = pLimit(Math.max(2, cpus().length));
|
|
27
|
+
const promises = pages.map(async (rawPath) => {
|
|
28
|
+
const filePath = slash(rawPath);
|
|
29
|
+
if (isDynamicRoute(filePath)) {
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
return limit(moveFile, filePath);
|
|
33
33
|
});
|
|
34
34
|
await Promise.all(promises);
|
|
35
|
-
console.log(`Moved ${files.length}
|
|
35
|
+
console.log(`Moved ${files.length} files`);
|
|
36
36
|
// Write the manifest for use in the serverless functions
|
|
37
37
|
await writeJson(join(netlifyConfig.build.publish, 'static-manifest.json'), files);
|
|
38
38
|
if (i18n === null || i18n === void 0 ? void 0 : i18n.defaultLocale) {
|
|
39
39
|
// Copy the default locale into the root
|
|
40
|
-
|
|
40
|
+
const defaultLocaleDir = join(netlifyConfig.build.publish, i18n.defaultLocale);
|
|
41
|
+
if (existsSync(defaultLocaleDir)) {
|
|
42
|
+
await copy(defaultLocaleDir, `${netlifyConfig.build.publish}/`);
|
|
43
|
+
}
|
|
41
44
|
}
|
|
42
45
|
};
|
|
43
46
|
exports.movePublicFiles = async ({ appDir, publish }) => {
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
const { join, relative } = require('path');
|
|
3
|
-
const { copy, existsSync } = require('fs-extra');
|
|
4
3
|
const { ODB_FUNCTION_NAME } = require('./constants');
|
|
5
4
|
const { restoreCache, saveCache } = require('./helpers/cache');
|
|
6
5
|
const { getNextConfig, configureHandlerFunctions, generateRedirects } = require('./helpers/config');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/plugin-nextjs",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.6",
|
|
4
4
|
"description": "Run Next.js seamlessly on Netlify",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"files": [
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"scripts": {
|
|
11
11
|
"build:demo": "next build demo",
|
|
12
12
|
"cy:open": "cypress open --config-file cypress/config/all.json",
|
|
13
|
-
"cy:run": "cypress run --config-file cypress/config/
|
|
13
|
+
"cy:run": "cypress run --config-file ../cypress/config/ci.json",
|
|
14
14
|
"dev:demo": "next dev demo",
|
|
15
15
|
"format": "run-s format:check-fix:*",
|
|
16
16
|
"format:ci": "run-s format:check:*",
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
"@vercel/node": "^1.11.2-canary.4",
|
|
58
58
|
"chalk": "^4.1.2",
|
|
59
59
|
"fs-extra": "^10.0.0",
|
|
60
|
+
"globby": "^11.0.4",
|
|
60
61
|
"moize": "^6.1.0",
|
|
61
62
|
"node-fetch": "^2.6.6",
|
|
62
63
|
"node-stream-zip": "^1.15.0",
|