next-build-filter 0.2.1 → 0.2.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.
|
@@ -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
|
-
|
|
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
|
}
|
package/lib/with-page-filter.js
CHANGED
|
@@ -32,14 +32,14 @@ function withPageFilter(options = {}) {
|
|
|
32
32
|
return {
|
|
33
33
|
...nextConfig,
|
|
34
34
|
|
|
35
|
-
webpack: (config,
|
|
35
|
+
webpack: (config, options) => {
|
|
36
36
|
// Apply the existing webpack config if it exists
|
|
37
37
|
if (nextConfig.webpack) {
|
|
38
|
-
config = nextConfig.webpack(config,
|
|
38
|
+
config = nextConfig.webpack(config, options);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
// Don't apply filtering in development mode unless explicitly enabled
|
|
42
|
-
if (dev && !filterOptions.enableInDev) {
|
|
42
|
+
if (options.dev && !filterOptions.enableInDev) {
|
|
43
43
|
return config;
|
|
44
44
|
}
|
|
45
45
|
|
|
@@ -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.
|
|
3
|
+
"version": "0.2.3",
|
|
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",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"test:e2e": "node tests/e2e/run-e2e-tests.js",
|
|
18
18
|
"test:all": "npm run test && npm run test:e2e",
|
|
19
19
|
"prepublishOnly": "npm run build",
|
|
20
|
-
"postversion": "npm publish",
|
|
20
|
+
"postversion": "npm run test:all && npm publish && git push --follow-tags",
|
|
21
21
|
"build": "echo \"No build process needed for now\""
|
|
22
22
|
},
|
|
23
23
|
"keywords": [
|