next-build-filter 0.2.0 → 0.2.2

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.
@@ -60,13 +60,19 @@ class AdvancedNextBuildFilterPlugin {
60
60
  const request = resolveData.request;
61
61
  const context = resolveData.context;
62
62
 
63
+ // Additional safety check for webpack 4 compatibility
64
+ if (!request || typeof request !== 'string') {
65
+ return resolveData;
66
+ }
67
+
63
68
  if (this.isPageModule(request, context) && this.shouldFilterPage(request)) {
64
69
  if (this.options.verbose) {
65
70
  console.log(`📄 Intercepting page request: ${request}`);
66
71
  }
67
72
 
68
73
  // Replace with empty module
69
- resolveData.request = path.resolve(__dirname, 'empty-module.js');
74
+ // Use require.resolve instead of path.resolve to ensure compatibility with webpack 4
75
+ resolveData.request = require.resolve('./empty-module.js');
70
76
  this.filteredPages.add(request);
71
77
  }
72
78
 
@@ -197,6 +203,9 @@ class AdvancedNextBuildFilterPlugin {
197
203
  }
198
204
 
199
205
  normalizePath(filePath) {
206
+ if (!filePath || typeof filePath !== 'string') {
207
+ return '';
208
+ }
200
209
  return filePath.replace(/\\/g, '/').toLowerCase();
201
210
  }
202
211
  }
@@ -64,6 +64,11 @@ class NextBuildFilterPlugin {
64
64
 
65
65
  const request = resolveData.request;
66
66
 
67
+ // Additional safety check for webpack 4 compatibility
68
+ if (typeof request !== 'string') {
69
+ return;
70
+ }
71
+
67
72
  // Check if this is a page file
68
73
  if (this.isPageFile(request, resolveData.context)) {
69
74
  const normalizedRequest = this.normalizePath(request);
@@ -280,6 +285,9 @@ class NextBuildFilterPlugin {
280
285
  * Normalize file paths for consistent comparison
281
286
  */
282
287
  normalizePath(filePath) {
288
+ if (!filePath || typeof filePath !== 'string') {
289
+ return '';
290
+ }
283
291
  return filePath.replace(/\\/g, '/').toLowerCase();
284
292
  }
285
293
  }
@@ -175,6 +175,9 @@ function extractRoutePath(normalizedRequest, options) {
175
175
  }
176
176
 
177
177
  function normalizePath(filePath) {
178
+ if (!filePath || typeof filePath !== 'string') {
179
+ return '';
180
+ }
178
181
  return filePath.replace(/\\/g, '/').toLowerCase();
179
182
  }
180
183
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-build-filter",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "A Next.js plugin to exclude pages/routes during build without removing files. Supports both Pages Router and App Router (Next.js 13+).",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -59,6 +59,6 @@
59
59
  },
60
60
  "homepage": "https://github.com/banyudu/next-build-filter#readme",
61
61
  "engines": {
62
- "node": ">=16.0.0"
62
+ "node": ">=18.0.0"
63
63
  }
64
64
  }