@meteorjs/rspack 0.0.30 → 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 +27 -25
|
@@ -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';
|
|
@@ -82,21 +82,6 @@ function createSwcConfig({
|
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
// Coffeescript rule
|
|
86
|
-
function createCoffeescriptConfig({ swcConfig }) {
|
|
87
|
-
return {
|
|
88
|
-
test: /\.coffee$/i,
|
|
89
|
-
use: [
|
|
90
|
-
{
|
|
91
|
-
loader: 'swc-loader',
|
|
92
|
-
options: swcConfig,
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
loader: 'coffee-loader',
|
|
96
|
-
},
|
|
97
|
-
],
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
85
|
|
|
101
86
|
// Keep files outside of build folders
|
|
102
87
|
function keepOutsideBuild() {
|
|
@@ -148,7 +133,6 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
148
133
|
const isTsxEnabled =
|
|
149
134
|
Meteor.isTsxEnabled || (isTypescriptEnabled && isReactEnabled) || false;
|
|
150
135
|
|
|
151
|
-
const isCoffeescriptEnabled = Meteor.isCoffeescriptEnabled || false;
|
|
152
136
|
|
|
153
137
|
// Determine entry points
|
|
154
138
|
const entryPath = Meteor.entryPath;
|
|
@@ -227,6 +211,9 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
227
211
|
externalHelpers: swcExternalHelpers,
|
|
228
212
|
isDevEnvironment,
|
|
229
213
|
});
|
|
214
|
+
// Expose swc config to use in custom configs
|
|
215
|
+
Meteor.swcConfigOptions = swcConfigRule.options;
|
|
216
|
+
|
|
230
217
|
const externals = [
|
|
231
218
|
/^meteor.*/,
|
|
232
219
|
...(isReactEnabled ? [/^react$/, /^react-dom$/] : []),
|
|
@@ -235,7 +222,6 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
235
222
|
'/': path.resolve(process.cwd()),
|
|
236
223
|
};
|
|
237
224
|
const extensions = [
|
|
238
|
-
...(isCoffeescriptEnabled ? ['.coffee'] : []),
|
|
239
225
|
'.ts',
|
|
240
226
|
'.tsx',
|
|
241
227
|
'.mts',
|
|
@@ -247,11 +233,7 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
247
233
|
'.json',
|
|
248
234
|
'.wasm',
|
|
249
235
|
];
|
|
250
|
-
const extraRules = [
|
|
251
|
-
...(isCoffeescriptEnabled
|
|
252
|
-
? [createCoffeescriptConfig({ swcConfig: swcConfigRule?.options })]
|
|
253
|
-
: []),
|
|
254
|
-
];
|
|
236
|
+
const extraRules = [];
|
|
255
237
|
|
|
256
238
|
const reactRefreshModule = isReactEnabled
|
|
257
239
|
? safeRequire('@rspack/plugin-react-refresh')
|
|
@@ -443,11 +425,31 @@ export default function (inMeteor = {}, argv = {}) {
|
|
|
443
425
|
? projectConfig(Meteor, argv)
|
|
444
426
|
: projectConfig;
|
|
445
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
|
+
|
|
446
442
|
if (Meteor.isClient) {
|
|
447
|
-
clientConfig = mergeSplitOverlap(
|
|
443
|
+
clientConfig = mergeSplitOverlap(
|
|
444
|
+
clientConfig,
|
|
445
|
+
cleanOmittedPaths(userConfig, { omitPaths, warningFn }),
|
|
446
|
+
);
|
|
448
447
|
}
|
|
449
448
|
if (Meteor.isServer) {
|
|
450
|
-
serverConfig = mergeSplitOverlap(
|
|
449
|
+
serverConfig = mergeSplitOverlap(
|
|
450
|
+
serverConfig,
|
|
451
|
+
cleanOmittedPaths(userConfig, { omitPaths, warningFn }),
|
|
452
|
+
);
|
|
451
453
|
}
|
|
452
454
|
}
|
|
453
455
|
|