@meteorjs/rspack 0.0.31 → 0.0.32
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/mergeRulesSplitOverlap.js +79 -0
- package/package.json +1 -1
- package/rspack.config.js +23 -3
|
@@ -173,6 +173,85 @@ export function unique(key, pluginNames = [], getter = item => item.constructor
|
|
|
173
173
|
};
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Helper function to clean fields in an object based on omit paths.
|
|
178
|
+
* Supports nested path strings like 'output.filename'.
|
|
179
|
+
*
|
|
180
|
+
* @param {Object} obj - The object to clean
|
|
181
|
+
* @param {Object} options - Configuration options
|
|
182
|
+
* @param {string[]} [options.omitPaths] - Paths to omit from the object (e.g., 'output.filename')
|
|
183
|
+
* @param {Function} [options.warningFn] - Custom warning function that receives the path string
|
|
184
|
+
* @returns {Object} The cleaned object with specified paths removed
|
|
185
|
+
*/
|
|
186
|
+
export function cleanOmittedPaths(obj, options = {}) {
|
|
187
|
+
if (!obj || typeof obj !== 'object') {
|
|
188
|
+
return obj;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const { omitPaths = [], warningFn } = options;
|
|
192
|
+
|
|
193
|
+
// If no omit paths, return the original object
|
|
194
|
+
if (!omitPaths.length) {
|
|
195
|
+
return obj;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const result = { ...obj };
|
|
199
|
+
|
|
200
|
+
// Process each omit path
|
|
201
|
+
omitPaths.forEach(path => {
|
|
202
|
+
// Convert path to array of keys
|
|
203
|
+
const pathArray = Array.isArray(path) ? path : path.split('.');
|
|
204
|
+
const pathString = Array.isArray(path) ? path.join('.') : path;
|
|
205
|
+
|
|
206
|
+
// Start with the root object
|
|
207
|
+
let current = result;
|
|
208
|
+
let parent = null;
|
|
209
|
+
let lastKey = null;
|
|
210
|
+
|
|
211
|
+
// Traverse the path to find the target property
|
|
212
|
+
for (let i = 0; i < pathArray.length - 1; i++) {
|
|
213
|
+
const key = pathArray[i];
|
|
214
|
+
if (current && typeof current === 'object' && key in current) {
|
|
215
|
+
parent = current;
|
|
216
|
+
lastKey = key;
|
|
217
|
+
current = current[key];
|
|
218
|
+
} else {
|
|
219
|
+
// Path doesn't exist in the object, nothing to remove
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Get the final key in the path
|
|
225
|
+
const finalKey = pathArray[pathArray.length - 1];
|
|
226
|
+
|
|
227
|
+
// Handle single-level paths (from root)
|
|
228
|
+
if (pathArray.length === 1) {
|
|
229
|
+
const rootKey = pathArray[0];
|
|
230
|
+
if (rootKey in result) {
|
|
231
|
+
// Log warning
|
|
232
|
+
if (typeof warningFn === 'function') {
|
|
233
|
+
warningFn(pathString);
|
|
234
|
+
}
|
|
235
|
+
delete result[rootKey];
|
|
236
|
+
}
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// If we found the property for nested paths, remove it
|
|
241
|
+
if (parent && lastKey && finalKey) {
|
|
242
|
+
if (current && typeof current === 'object' && finalKey in current) {
|
|
243
|
+
// Log warning
|
|
244
|
+
if (typeof warningFn === 'function') {
|
|
245
|
+
warningFn(pathString);
|
|
246
|
+
}
|
|
247
|
+
delete current[finalKey];
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
return result;
|
|
253
|
+
}
|
|
254
|
+
|
|
176
255
|
/**
|
|
177
256
|
* Merges webpack/rspack configs with smart handling of overlapping rules.
|
|
178
257
|
*
|
package/package.json
CHANGED
package/rspack.config.js
CHANGED
|
@@ -5,7 +5,7 @@ import { inspect } from 'node:util';
|
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import { merge } from 'webpack-merge';
|
|
7
7
|
|
|
8
|
-
import { mergeSplitOverlap } from
|
|
8
|
+
import { cleanOmittedPaths, mergeSplitOverlap } from "./lib/mergeRulesSplitOverlap.js";
|
|
9
9
|
import { getMeteorAppSwcConfig } from './lib/swc.js';
|
|
10
10
|
import CleanBuildAssetsPlugin from './plugins/CleanBuildAssetsPlugin.js';
|
|
11
11
|
import HtmlRspackPlugin from './plugins/HtmlRspackPlugin.js';
|
|
@@ -425,11 +425,31 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
425
425
|
? projectConfig(Meteor, argv)
|
|
426
426
|
: projectConfig;
|
|
427
427
|
|
|
428
|
+
const omitPaths = [
|
|
429
|
+
'name',
|
|
430
|
+
'target',
|
|
431
|
+
'entry',
|
|
432
|
+
'output.path',
|
|
433
|
+
'output.filename',
|
|
434
|
+
'output.publicPath',
|
|
435
|
+
];
|
|
436
|
+
const warningFn = path => {
|
|
437
|
+
console.warn(
|
|
438
|
+
`[rspack.config.js] Ignored custom "${path}" — reserved for Meteor-Rspack integration.`,
|
|
439
|
+
);
|
|
440
|
+
};
|
|
441
|
+
|
|
428
442
|
if (Meteor.isClient) {
|
|
429
|
-
clientConfig = mergeSplitOverlap(
|
|
443
|
+
clientConfig = mergeSplitOverlap(
|
|
444
|
+
clientConfig,
|
|
445
|
+
cleanOmittedPaths(userConfig, { omitPaths, warningFn }),
|
|
446
|
+
);
|
|
430
447
|
}
|
|
431
448
|
if (Meteor.isServer) {
|
|
432
|
-
serverConfig = mergeSplitOverlap(
|
|
449
|
+
serverConfig = mergeSplitOverlap(
|
|
450
|
+
serverConfig,
|
|
451
|
+
cleanOmittedPaths(userConfig, { omitPaths, warningFn }),
|
|
452
|
+
);
|
|
433
453
|
}
|
|
434
454
|
}
|
|
435
455
|
|