@netlify/plugin-nextjs 4.28.3 → 4.28.4

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.
@@ -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.warnOnApiRoutes = exports.getApiRouteConfigs = exports.setupImageFunction = exports.generatePagesResolver = exports.generateFunctions = void 0;
6
+ exports.warnOnApiRoutes = exports.getExtendedApiRouteConfigs = exports.getApiRouteConfigs = exports.setupImageFunction = exports.generatePagesResolver = exports.generateFunctions = void 0;
7
7
  const node_bridge_1 = __importDefault(require("@vercel/node-bridge"));
8
8
  const chalk_1 = __importDefault(require("chalk"));
9
9
  const destr_1 = __importDefault(require("destr"));
@@ -125,12 +125,21 @@ const getApiRouteConfigs = async (publish, baseDir) => {
125
125
  const pages = await (0, fs_extra_1.readJSON)((0, pathe_1.join)(publish, 'server', 'pages-manifest.json'));
126
126
  const apiRoutes = Object.keys(pages).filter((page) => page.startsWith('/api/'));
127
127
  const pagesDir = (0, pathe_1.join)(baseDir, 'pages');
128
- return Promise.all(apiRoutes.map(async (apiRoute) => {
128
+ return await Promise.all(apiRoutes.map(async (apiRoute) => {
129
129
  const filePath = (0, files_1.getSourceFileForPage)(apiRoute, pagesDir);
130
130
  return { route: apiRoute, config: await (0, analysis_1.extractConfigFromFile)(filePath), compiled: pages[apiRoute] };
131
131
  }));
132
132
  };
133
133
  exports.getApiRouteConfigs = getApiRouteConfigs;
134
+ /**
135
+ * Looks for extended API routes (background and scheduled functions) and extract the config from the source file.
136
+ */
137
+ const getExtendedApiRouteConfigs = async (publish, baseDir) => {
138
+ const settledApiRoutes = await (0, exports.getApiRouteConfigs)(publish, baseDir);
139
+ // We only want to return the API routes that are background or scheduled functions
140
+ return settledApiRoutes.filter((apiRoute) => apiRoute.config.type !== undefined);
141
+ };
142
+ exports.getExtendedApiRouteConfigs = getExtendedApiRouteConfigs;
134
143
  /**
135
144
  * Warn the user of the caveats if they're using background or scheduled API routes
136
145
  */
@@ -149,7 +158,7 @@ const warnOnApiRoutes = async ({ FUNCTIONS_DIST, }) => {
149
158
  }
150
159
  if (functions.some((func) => func.schedule)) {
151
160
  console.warn((0, outdent_1.outdent) `
152
- ${chalk_1.default.yellowBright `Using scheduled API routes`}
161
+ ${chalk_1.default.yellowBright `Using scheduled API routes`}
153
162
  These are run on a schedule when deployed to production.
154
163
  You can test them locally by loading them in your browser but this will not be available when deployed, and any returned value is ignored.
155
164
  `);
package/lib/index.js CHANGED
@@ -92,7 +92,7 @@ const plugin = {
92
92
  }
93
93
  const buildId = (0, fs_extra_1.readFileSync)((0, path_1.join)(publish, 'BUILD_ID'), 'utf8').trim();
94
94
  await (0, config_1.configureHandlerFunctions)({ netlifyConfig, ignore, publish: (0, path_1.relative)(process.cwd(), publish) });
95
- const apiRoutes = await (0, functions_1.getApiRouteConfigs)(publish, appDir);
95
+ const apiRoutes = await (0, functions_1.getExtendedApiRouteConfigs)(publish, appDir);
96
96
  await (0, functions_1.generateFunctions)(constants, appDir, apiRoutes);
97
97
  await (0, functions_1.generatePagesResolver)({ target, constants });
98
98
  await (0, files_1.movePublicFiles)({ appDir, outdir, publish });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/plugin-nextjs",
3
- "version": "4.28.3",
3
+ "version": "4.28.4",
4
4
  "description": "Run Next.js seamlessly on Netlify",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "devDependencies": {
38
38
  "@delucis/if-env": "^1.1.2",
39
- "@netlify/build": "^28.1.4",
39
+ "@netlify/build": "^28.1.7",
40
40
  "@types/fs-extra": "^9.0.13",
41
41
  "@types/jest": "^27.4.1",
42
42
  "@types/merge-stream": "^1.1.2",