@meteorjs/rspack 0.0.31 → 0.0.33
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 +28 -7
|
@@ -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';
|
|
@@ -125,6 +125,7 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
125
125
|
const isTestEager = !!Meteor.isTestEager;
|
|
126
126
|
const isTestFullApp = !!Meteor.isTestFullApp;
|
|
127
127
|
const swcExternalHelpers = !!Meteor.swcExternalHelpers;
|
|
128
|
+
const isNative = !!Meteor.isNative;
|
|
128
129
|
const mode = isProd ? 'production' : 'development';
|
|
129
130
|
|
|
130
131
|
const isTypescriptEnabled = Meteor.isTypescriptEnabled || false;
|
|
@@ -203,7 +204,7 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
203
204
|
console.log('[i] Meteor flags:', Meteor);
|
|
204
205
|
}
|
|
205
206
|
|
|
206
|
-
const isDevEnvironment = isRun && isDev && !isTest;
|
|
207
|
+
const isDevEnvironment = isRun && isDev && !isTest && !isNative;
|
|
207
208
|
const swcConfigRule = createSwcConfig({
|
|
208
209
|
isTypescriptEnabled,
|
|
209
210
|
isJsxEnabled,
|
|
@@ -325,7 +326,7 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
325
326
|
Meteor.HtmlRspackPlugin(),
|
|
326
327
|
],
|
|
327
328
|
watchOptions,
|
|
328
|
-
devtool: isDevEnvironment || isTest ? 'source-map' : 'hidden-source-map',
|
|
329
|
+
devtool: isDevEnvironment || isNative || isTest ? 'source-map' : 'hidden-source-map',
|
|
329
330
|
...(isDevEnvironment && {
|
|
330
331
|
devServer: {
|
|
331
332
|
static: { directory: clientOutputDir, publicPath: '/__rspack__/' },
|
|
@@ -406,8 +407,8 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
406
407
|
isTestModule && requireExternalsPlugin,
|
|
407
408
|
],
|
|
408
409
|
watchOptions,
|
|
409
|
-
devtool: isDevEnvironment || isTest ? 'source-map' : 'hidden-source-map',
|
|
410
|
-
...((isDevEnvironment || (isTest && !isTestEager)) &&
|
|
410
|
+
devtool: isDevEnvironment || isNative || isTest ? 'source-map' : 'hidden-source-map',
|
|
411
|
+
...((isDevEnvironment || (isTest && !isTestEager) || isNative) &&
|
|
411
412
|
createCacheStrategy(mode)),
|
|
412
413
|
};
|
|
413
414
|
|
|
@@ -425,11 +426,31 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
425
426
|
? projectConfig(Meteor, argv)
|
|
426
427
|
: projectConfig;
|
|
427
428
|
|
|
429
|
+
const omitPaths = [
|
|
430
|
+
'name',
|
|
431
|
+
'target',
|
|
432
|
+
'entry',
|
|
433
|
+
'output.path',
|
|
434
|
+
'output.filename',
|
|
435
|
+
'output.publicPath',
|
|
436
|
+
];
|
|
437
|
+
const warningFn = path => {
|
|
438
|
+
console.warn(
|
|
439
|
+
`[rspack.config.js] Ignored custom "${path}" — reserved for Meteor-Rspack integration.`,
|
|
440
|
+
);
|
|
441
|
+
};
|
|
442
|
+
|
|
428
443
|
if (Meteor.isClient) {
|
|
429
|
-
clientConfig = mergeSplitOverlap(
|
|
444
|
+
clientConfig = mergeSplitOverlap(
|
|
445
|
+
clientConfig,
|
|
446
|
+
cleanOmittedPaths(userConfig, { omitPaths, warningFn }),
|
|
447
|
+
);
|
|
430
448
|
}
|
|
431
449
|
if (Meteor.isServer) {
|
|
432
|
-
serverConfig = mergeSplitOverlap(
|
|
450
|
+
serverConfig = mergeSplitOverlap(
|
|
451
|
+
serverConfig,
|
|
452
|
+
cleanOmittedPaths(userConfig, { omitPaths, warningFn }),
|
|
453
|
+
);
|
|
433
454
|
}
|
|
434
455
|
}
|
|
435
456
|
|