mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
add normalization for externals configuration in webpack merge
This commit is contained in:
@@ -252,6 +252,25 @@ export function cleanOmittedPaths(obj, options = {}) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes externals configuration to ensure consistent handling.
|
||||
* @param {Object} config - The configuration object
|
||||
* @returns {Object} - The normalized configuration
|
||||
*/
|
||||
function normalizeExternals(config) {
|
||||
if (!config || !config.externals) return config;
|
||||
|
||||
// Create a deep clone of the config to avoid modifying the original
|
||||
const result = { ...config };
|
||||
|
||||
// If externals is not an array, convert it to an array
|
||||
if (!Array.isArray(result.externals)) {
|
||||
result.externals = [result.externals];
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges webpack/rspack configs with smart handling of overlapping rules.
|
||||
*
|
||||
@@ -259,6 +278,9 @@ export function cleanOmittedPaths(obj, options = {}) {
|
||||
* @returns {Object} Merged config
|
||||
*/
|
||||
export function mergeSplitOverlap(...configs) {
|
||||
// Normalize externals in all configs before merging
|
||||
const normalizedConfigs = configs.map(normalizeExternals);
|
||||
|
||||
return mergeWithCustomize({
|
||||
customizeArray(a, b, key) {
|
||||
if (key === 'module.rules') {
|
||||
@@ -287,5 +309,5 @@ export function mergeSplitOverlap(...configs) {
|
||||
// fall through to default merging
|
||||
return undefined;
|
||||
}
|
||||
})(...configs);
|
||||
})(...normalizedConfigs);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user